From 1a8535c30d7ccb039dc61253d9f89424a1a523be Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Tue, 11 Jul 2023 16:56:45 +0100 Subject: [PATCH 001/205] Anchor prototype of solana tbtc --- .gitignore | 1 + .yarnrc.yml | 1 + .../solana/solana-tbtc-anchor/.gitignore | 8 + .../solana/solana-tbtc-anchor/.prettierignore | 8 + .../solana/solana-tbtc-anchor/Anchor.toml | 15 + .../solana/solana-tbtc-anchor/Cargo.lock | 2408 +++++++++++++++ .../solana/solana-tbtc-anchor/Cargo.toml | 13 + .../solana-tbtc-anchor/migrations/deploy.ts | 12 + .../solana/solana-tbtc-anchor/package.json | 21 + .../programs/solana-tbtc-anchor/Cargo.toml | 20 + .../programs/solana-tbtc-anchor/Xargo.toml | 2 + .../programs/solana-tbtc-anchor/src/lib.rs | 338 ++ .../tests/solana-tbtc-anchor.ts | 444 +++ .../solana/solana-tbtc-anchor/tsconfig.json | 11 + package.json | 5 +- yarn.lock | 2713 ++++++++++++++++- 16 files changed, 5909 insertions(+), 111 deletions(-) create mode 100644 .yarnrc.yml create mode 100644 cross-chain/solana/solana-tbtc-anchor/.gitignore create mode 100644 cross-chain/solana/solana-tbtc-anchor/.prettierignore create mode 100644 cross-chain/solana/solana-tbtc-anchor/Anchor.toml create mode 100644 cross-chain/solana/solana-tbtc-anchor/Cargo.lock create mode 100644 cross-chain/solana/solana-tbtc-anchor/Cargo.toml create mode 100644 cross-chain/solana/solana-tbtc-anchor/migrations/deploy.ts create mode 100644 cross-chain/solana/solana-tbtc-anchor/package.json create mode 100644 cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Cargo.toml create mode 100644 cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Xargo.toml create mode 100644 cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs create mode 100644 cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts create mode 100644 cross-chain/solana/solana-tbtc-anchor/tsconfig.json diff --git a/.gitignore b/.gitignore index 842aea9ee..78b53c1e3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist/ .envrc yarn-error.log +.yarn/ diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 000000000..3186f3f07 --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/cross-chain/solana/solana-tbtc-anchor/.gitignore b/cross-chain/solana/solana-tbtc-anchor/.gitignore new file mode 100644 index 000000000..8d401163f --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/.gitignore @@ -0,0 +1,8 @@ + +.anchor +.DS_Store +target +**/*.rs.bk +node_modules +test-ledger +.yarn diff --git a/cross-chain/solana/solana-tbtc-anchor/.prettierignore b/cross-chain/solana/solana-tbtc-anchor/.prettierignore new file mode 100644 index 000000000..c1a0b75f0 --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/.prettierignore @@ -0,0 +1,8 @@ + +.anchor +.DS_Store +target +node_modules +dist +build +test-ledger diff --git a/cross-chain/solana/solana-tbtc-anchor/Anchor.toml b/cross-chain/solana/solana-tbtc-anchor/Anchor.toml new file mode 100644 index 000000000..6fab30aa2 --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/Anchor.toml @@ -0,0 +1,15 @@ +[features] +seeds = false +skip-lint = false +[programs.localnet] +solana_tbtc_anchor = "HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG" + +[registry] +url = "https://api.apr.dev" + +[provider] +cluster = "Localnet" +wallet = "/home/eth/.config/solana/id.json" + +[scripts] +test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" diff --git a/cross-chain/solana/solana-tbtc-anchor/Cargo.lock b/cross-chain/solana/solana-tbtc-anchor/Cargo.lock new file mode 100644 index 000000000..2ec9ed067 --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/Cargo.lock @@ -0,0 +1,2408 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aead" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +dependencies = [ + "generic-array", +] + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "opaque-debug", +] + +[[package]] +name = "aes-gcm-siv" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589c637f0e68c877bbd59a4599bbe849cac8e5f3e4b5a3ebae8f528cd218dcdc" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "polyval", + "subtle", + "zeroize", +] + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.10", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "getrandom 0.2.10", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +dependencies = [ + "memchr", +] + +[[package]] +name = "anchor-attribute-access-control" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faa5be5b72abea167f87c868379ba3c2be356bfca9e6f474fd055fa0f7eeb4f2" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2", + "quote", + "regex", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-account" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f468970344c7c9f9d03b4da854fd7c54f21305059f53789d0045c1dd803f0018" +dependencies = [ + "anchor-syn", + "anyhow", + "bs58 0.5.0", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-constant" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59948e7f9ef8144c2aefb3f32a40c5fce2798baeec765ba038389e82301017ef" +dependencies = [ + "anchor-syn", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-error" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc753c9d1c7981cb8948cf7e162fb0f64558999c0413058e2d43df1df5448086" +dependencies = [ + "anchor-syn", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-event" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38b4e172ba1b52078f53fdc9f11e3dc0668ad27997838a0aad2d148afac8c97" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-attribute-program" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eebd21543606ab61e2d83d9da37d24d3886a49f390f9c43a1964735e8c0f0d5" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-derive-accounts" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec4720d899b3686396cced9508f23dab420f1308344456ec78ef76f98fda42af" +dependencies = [ + "anchor-syn", + "anyhow", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-derive-space" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f495e85480bd96ddeb77b71d499247c7d4e8b501e75ecb234e9ef7ae7bd6552a" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "anchor-lang" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d2d4b20100f1310a774aba3471ef268e5c4ba4d5c28c0bbe663c2658acbc414" +dependencies = [ + "anchor-attribute-access-control", + "anchor-attribute-account", + "anchor-attribute-constant", + "anchor-attribute-error", + "anchor-attribute-event", + "anchor-attribute-program", + "anchor-derive-accounts", + "anchor-derive-space", + "arrayref", + "base64 0.13.1", + "bincode", + "borsh 0.10.3", + "bytemuck", + "getrandom 0.2.10", + "solana-program", + "thiserror", +] + +[[package]] +name = "anchor-spl" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78f860599da1c2354e7234c768783049eb42e2f54509ecfc942d2e0076a2da7b" +dependencies = [ + "anchor-lang", + "solana-program", + "spl-associated-token-account", + "spl-token", + "spl-token-2022", +] + +[[package]] +name = "anchor-syn" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a125e4b0cc046cfec58f5aa25038e34cf440151d58f0db3afc55308251fe936d" +dependencies = [ + "anyhow", + "bs58 0.5.0", + "heck", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2 0.10.7", + "syn 1.0.109", + "thiserror", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "anyhow" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" + +[[package]] +name = "ark-bn254" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" +dependencies = [ + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", + "itertools", + "num-traits", + "zeroize", +] + +[[package]] +name = "ark-ff" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "digest 0.10.7", + "itertools", + "num-bigint", + "num-traits", + "paste", + "rustc_version", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-ff-macros" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" +dependencies = [ + "num-bigint", + "num-traits", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-poly" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.13.2", +] + +[[package]] +name = "ark-serialize" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest 0.10.7", + "num-bigint", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ark-std" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" +dependencies = [ + "num-traits", + "rand 0.8.5", +] + +[[package]] +name = "array-bytes" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ad284aeb45c13f2fb4f084de4a420ebf447423bdf9386c0540ce33cb3ef4b8c" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitmaps" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +dependencies = [ + "typenum", +] + +[[package]] +name = "blake3" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", + "digest 0.10.7", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "block-padding", + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "borsh" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" +dependencies = [ + "borsh-derive 0.9.3", + "hashbrown 0.11.2", +] + +[[package]] +name = "borsh" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" +dependencies = [ + "borsh-derive 0.10.3", + "hashbrown 0.13.2", +] + +[[package]] +name = "borsh-derive" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" +dependencies = [ + "borsh-derive-internal 0.9.3", + "borsh-schema-derive-internal 0.9.3", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" +dependencies = [ + "borsh-derive-internal 0.10.3", + "borsh-schema-derive-internal 0.10.3", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "bumpalo" +version = "3.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" + +[[package]] +name = "bv" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8834bb1d8ee5dc048ee3124f2c7c1afcc6bc9aed03f11e9dfd8c69470a5db340" +dependencies = [ + "feature-probe", + "serde", +] + +[[package]] +name = "bytemuck" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.25", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +dependencies = [ + "android-tzdata", + "num-traits", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[package]] +name = "console_log" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89f72f65e8501878b8a004d5a1afb780987e2ce2b4532c562e367a72c57499f" +dependencies = [ + "log", + "web-sys", +] + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "cpufeatures" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +dependencies = [ + "libc", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "ctr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +dependencies = [ + "cipher", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "serde", + "subtle", + "zeroize", +] + +[[package]] +name = "darling" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.25", +] + +[[package]] +name = "darling_macro" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.25", +] + +[[package]] +name = "derivation-path" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e5c37193a1db1d8ed868c03ec7b152175f26160a5b740e5e484143877e0adf0" + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", + "subtle", +] + +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-dalek-bip32" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d2be62a4061b872c8c0873ee4fc6f101ce7b889d039f019c5fa2af471a59908" +dependencies = [ + "derivation-path", + "ed25519-dalek", + "hmac 0.12.1", + "sha2 0.10.7", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[package]] +name = "env_logger" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "feature-probe" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "serde", + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash 0.7.6", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.3", +] + +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array", + "hmac 0.8.1", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "im" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" +dependencies = [ + "bitmaps", + "rand_core 0.6.4", + "rand_xoshiro", + "rayon", + "serde", + "sized-chunks", + "typenum", + "version_check", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" + +[[package]] +name = "jobserver" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "keccak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "libsecp256k1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" +dependencies = [ + "arrayref", + "base64 0.12.3", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.7.3", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "lock_api" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "merlin" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.6.4", + "zeroize", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.2", + "libc", +] + +[[package]] +name = "num_enum" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +dependencies = [ + "num_enum_derive 0.5.11", +] + +[[package]] +name = "num_enum" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" +dependencies = [ + "num_enum_derive 0.6.1", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "num_enum_derive" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.25", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "paste" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" + +[[package]] +name = "pbkdf2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +dependencies = [ + "crypto-mac", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "polyval" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "qstring" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d464fae65fff2680baf48019211ce37aaec0c78e9264c84a3e484717f965104e" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "quote" +version = "1.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.10", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_xoshiro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "rayon" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustversion" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" + +[[package]] +name = "ryu" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" + +[[package]] +name = "serde" +version = "1.0.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a16be4fe5320ade08736447e3198294a5ea9a6d44dde6f35f0a5e06859c427a" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.25", +] + +[[package]] +name = "serde_json" +version = "1.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" +dependencies = [ + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.25", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha3" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +dependencies = [ + "block-buffer 0.9.0", + "digest 0.9.0", + "keccak", + "opaque-debug", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" + +[[package]] +name = "sized-chunks" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" +dependencies = [ + "bitmaps", + "typenum", +] + +[[package]] +name = "smallvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" + +[[package]] +name = "solana-frozen-abi" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c272bd949536a92f0fc4d9572bf72b35b3545fc1f6ee031e44f9d075809055d" +dependencies = [ + "ahash 0.8.3", + "blake3", + "block-buffer 0.10.4", + "bs58 0.4.0", + "bv", + "byteorder", + "cc", + "either", + "generic-array", + "getrandom 0.1.16", + "im", + "lazy_static", + "log", + "memmap2", + "once_cell", + "rand_core 0.6.4", + "rustc_version", + "serde", + "serde_bytes", + "serde_derive", + "serde_json", + "sha2 0.10.7", + "solana-frozen-abi-macro", + "subtle", + "thiserror", +] + +[[package]] +name = "solana-frozen-abi-macro" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f84be4b6dd2cc4e8ad5baa54a23018c8936ec32322ebcffd88355631700292a" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.25", +] + +[[package]] +name = "solana-logger" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3cb934e8c9015e86cd9c7382ea3083578d1c0813a351644cfdabe3009591b03" +dependencies = [ + "env_logger", + "lazy_static", + "log", +] + +[[package]] +name = "solana-program" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "476510cb86b9602a793582788f5e23a9cca11929d3880b7427a67142b1e4a430" +dependencies = [ + "ark-bn254", + "ark-ec", + "ark-ff", + "ark-serialize", + "array-bytes", + "base64 0.21.2", + "bincode", + "bitflags", + "blake3", + "borsh 0.10.3", + "bs58 0.4.0", + "bv", + "bytemuck", + "cc", + "console_error_panic_hook", + "console_log", + "curve25519-dalek", + "getrandom 0.2.10", + "itertools", + "js-sys", + "lazy_static", + "libc", + "libsecp256k1", + "log", + "memoffset", + "num-bigint", + "num-derive", + "num-traits", + "parking_lot", + "rand 0.7.3", + "rand_chacha 0.2.2", + "rustc_version", + "rustversion", + "serde", + "serde_bytes", + "serde_derive", + "serde_json", + "sha2 0.10.7", + "sha3 0.10.8", + "solana-frozen-abi", + "solana-frozen-abi-macro", + "solana-sdk-macro", + "thiserror", + "tiny-bip39", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "solana-sdk" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "352b70bb14d8968d5484aa73a1aede3acc816f10a0b264c6599108c5dd6b647b" +dependencies = [ + "assert_matches", + "base64 0.21.2", + "bincode", + "bitflags", + "borsh 0.10.3", + "bs58 0.4.0", + "bytemuck", + "byteorder", + "chrono", + "derivation-path", + "digest 0.10.7", + "ed25519-dalek", + "ed25519-dalek-bip32", + "generic-array", + "hmac 0.12.1", + "itertools", + "js-sys", + "lazy_static", + "libsecp256k1", + "log", + "memmap2", + "num-derive", + "num-traits", + "num_enum 0.6.1", + "pbkdf2 0.11.0", + "qstring", + "rand 0.7.3", + "rand_chacha 0.2.2", + "rustc_version", + "rustversion", + "serde", + "serde_bytes", + "serde_derive", + "serde_json", + "serde_with", + "sha2 0.10.7", + "sha3 0.10.8", + "solana-frozen-abi", + "solana-frozen-abi-macro", + "solana-logger", + "solana-program", + "solana-sdk-macro", + "thiserror", + "uriparse", + "wasm-bindgen", +] + +[[package]] +name = "solana-sdk-macro" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e38a884c027b0759d0969efc1253f3b8798f9d5fbef2eb158cdb70763619d2f3" +dependencies = [ + "bs58 0.4.0", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.25", +] + +[[package]] +name = "solana-tbtc-anchor" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-spl", +] + +[[package]] +name = "solana-zk-token-sdk" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02a4c38e1cf77cc046a48d0e515ec3fe654d9c3ba49790523f2d8fd28a5e51d3" +dependencies = [ + "aes-gcm-siv", + "base64 0.21.2", + "bincode", + "bytemuck", + "byteorder", + "curve25519-dalek", + "getrandom 0.1.16", + "itertools", + "lazy_static", + "merlin", + "num-derive", + "num-traits", + "rand 0.7.3", + "serde", + "serde_json", + "sha3 0.9.1", + "solana-program", + "solana-sdk", + "subtle", + "thiserror", + "zeroize", +] + +[[package]] +name = "spl-associated-token-account" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978dba3bcbe88d0c2c58366c254d9ea41c5f73357e72fc0bdee4d6b5fc99c8f4" +dependencies = [ + "assert_matches", + "borsh 0.9.3", + "num-derive", + "num-traits", + "solana-program", + "spl-token", + "spl-token-2022", + "thiserror", +] + +[[package]] +name = "spl-memo" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0dc6f70db6bacea7ff25870b016a65ba1d1b6013536f08e4fd79a8f9005325" +dependencies = [ + "solana-program", +] + +[[package]] +name = "spl-token" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e85e168a785e82564160dcb87b2a8e04cee9bfd1f4d488c729d53d6a4bd300d" +dependencies = [ + "arrayref", + "bytemuck", + "num-derive", + "num-traits", + "num_enum 0.5.11", + "solana-program", + "thiserror", +] + +[[package]] +name = "spl-token-2022" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0043b590232c400bad5ee9eb983ced003d15163c4c5d56b090ac6d9a57457b47" +dependencies = [ + "arrayref", + "bytemuck", + "num-derive", + "num-traits", + "num_enum 0.5.11", + "solana-program", + "solana-zk-token-sdk", + "spl-memo", + "spl-token", + "thiserror", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.25", +] + +[[package]] +name = "tiny-bip39" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +dependencies = [ + "anyhow", + "hmac 0.8.1", + "once_cell", + "pbkdf2 0.4.0", + "rand 0.7.3", + "rustc-hash", + "sha2 0.9.9", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-ident" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "universal-hash" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "uriparse" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0200d0fc04d809396c2ad43f3c95da3582a2556eba8d453c1087f4120ee352ff" +dependencies = [ + "fnv", + "lazy_static", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.25", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.25", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" + +[[package]] +name = "web-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-targets" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winnow" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529" +dependencies = [ + "memchr", +] + +[[package]] +name = "zeroize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.25", +] diff --git a/cross-chain/solana/solana-tbtc-anchor/Cargo.toml b/cross-chain/solana/solana-tbtc-anchor/Cargo.toml new file mode 100644 index 000000000..ef17a63c0 --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/Cargo.toml @@ -0,0 +1,13 @@ +[workspace] +members = [ + "programs/*" +] + +[profile.release] +overflow-checks = true +lto = "fat" +codegen-units = 1 +[profile.release.build-override] +opt-level = 3 +incremental = false +codegen-units = 1 diff --git a/cross-chain/solana/solana-tbtc-anchor/migrations/deploy.ts b/cross-chain/solana/solana-tbtc-anchor/migrations/deploy.ts new file mode 100644 index 000000000..82fb175fa --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/migrations/deploy.ts @@ -0,0 +1,12 @@ +// Migrations are an early feature. Currently, they're nothing more than this +// single deploy script that's invoked from the CLI, injecting a provider +// configured from the workspace's Anchor.toml. + +const anchor = require("@coral-xyz/anchor"); + +module.exports = async function (provider) { + // Configure client to use the provider. + anchor.setProvider(provider); + + // Add your deploy script here. +}; diff --git a/cross-chain/solana/solana-tbtc-anchor/package.json b/cross-chain/solana/solana-tbtc-anchor/package.json new file mode 100644 index 000000000..4a866202d --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/package.json @@ -0,0 +1,21 @@ +{ + "scripts": { + "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + }, + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@solana/spl-token": "^0.3.8", + "@solana/web3.js": "^1.77.3", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "prettier": "^2.6.2", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } +} diff --git a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Cargo.toml b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Cargo.toml new file mode 100644 index 000000000..4f6c212af --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "solana-tbtc-anchor" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "solana_tbtc_anchor" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] +default = [] + +[dependencies] +anchor-lang = "0.28.0" +anchor-spl = "0.28.0" \ No newline at end of file diff --git a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Xargo.toml b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Xargo.toml new file mode 100644 index 000000000..475fb71ed --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs new file mode 100644 index 000000000..8e5f50536 --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs @@ -0,0 +1,338 @@ +use anchor_lang::prelude::*; +use anchor_spl::{ + associated_token::AssociatedToken, + // mint, + token::{mint_to, TokenAccount, Mint as SplMint, MintTo as SplMintTo, Token as SplToken}, +}; + +declare_id!("HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG"); + +#[program] +pub mod solana_tbtc_anchor { + use super::*; + + pub fn initialize(ctx: Context) -> Result<()> { + let tbtc = &mut ctx.accounts.tbtc; + tbtc.creator = ctx.accounts.creator.key(); + tbtc.token_mint = ctx.accounts.tbtc_mint.key(); + tbtc.token_bump = *ctx.bumps.get("tbtc_mint").unwrap(); + tbtc.minters = 0; + tbtc.guardians = 0; + tbtc.paused = false; + Ok(()) + } + + pub fn add_minter(ctx: Context) -> Result<()> { + let minter_info = &mut ctx.accounts.minter_info; + minter_info.minter = ctx.accounts.minter.key(); + minter_info.bump = *ctx.bumps.get("minter_info").unwrap(); + + ctx.accounts.tbtc.minters += 1; + Ok(()) + } + + pub fn remove_minter(ctx: Context, _minter: Pubkey) -> Result<()> { + require!(ctx.accounts.tbtc.minters > 0, TbtcError::NoMinters); + ctx.accounts.tbtc.minters -= 1; + Ok(()) + } + + pub fn add_guardian(ctx: Context) -> Result<()> { + let guardian_info = &mut ctx.accounts.guardian_info; + guardian_info.guardian = ctx.accounts.guardian.key(); + guardian_info.bump = *ctx.bumps.get("guardian_info").unwrap(); + + ctx.accounts.tbtc.guardians += 1; + Ok(()) + } + + pub fn remove_guardian(ctx: Context, _minter: Pubkey) -> Result<()> { + require!(ctx.accounts.tbtc.guardians > 0, TbtcError::NoGuardians); + ctx.accounts.tbtc.guardians -= 1; + Ok(()) + } + + pub fn setup_mint(_ctx: Context) -> Result<()> { + msg!("setup mint complete\n\n\n"); + Ok(()) + } + + pub fn mint(ctx: Context, amount: u64) -> Result<()> { + msg!("start mint\n\n\n"); + let seed = b"tbtc-mint"; + let key_seed = ctx.accounts.tbtc.key(); + let mint_bump = ctx.accounts.tbtc.token_bump; + let signer: &[&[&[u8]]] = &[&[seed, key_seed.as_ref(), &[mint_bump]]]; + + let cpi_ctx = CpiContext::new_with_signer( + ctx.accounts.token_program.to_account_info(), + SplMintTo { + mint: ctx.accounts.tbtc_mint.to_account_info(), + to: ctx.accounts.recipient_account.to_account_info(), + authority: ctx.accounts.tbtc_mint.to_account_info(), + }, + signer, + ); + mint_to(cpi_ctx, amount)?; + + Ok(()) + } + + pub fn pause(ctx: Context) -> Result<()> { + ctx.accounts.tbtc.paused = true; + Ok(()) + } + + pub fn unpause(ctx: Context) -> Result<()> { + ctx.accounts.tbtc.paused = false; + Ok(()) + } +} + +#[account] +#[derive(Default)] +pub struct Tbtc { + creator: Pubkey, + token_mint: Pubkey, + token_bump: u8, + minters: u8, + guardians: u8, + paused: bool, +} + +#[account] +#[derive(Default)] +pub struct MinterInfo { + minter: Pubkey, + bump: u8, +} + +#[account] +#[derive(Default)] +pub struct GuardianInfo { + guardian: Pubkey, + bump: u8, +} + +#[derive(Accounts)] +pub struct Initialize<'info> { + // Use PDA for the mint address + // so we can sign for it from the program + #[account( + init, + seeds = [b"tbtc-mint", tbtc.key().as_ref()], + bump, + payer = creator, + mint::decimals = 8, + mint::authority = tbtc_mint, + )] + pub tbtc_mint: Account<'info, SplMint>, + + #[account(init, payer = creator, space = 8 + Tbtc::MAXIMUM_SIZE)] + pub tbtc: Account<'info, Tbtc>, + + #[account(mut)] + pub creator: Signer<'info>, + + pub token_program: Program<'info, SplToken>, + pub system_program: Program<'info, System> +} + +#[derive(Accounts)] +pub struct AddMinter<'info> { + #[account( + mut, + has_one = creator @ TbtcError::IsNotCreator + )] + pub tbtc: Account<'info, Tbtc>, + pub creator: Signer<'info>, + pub minter: Signer<'info>, + #[account(mut)] + pub payer: Signer<'info>, + #[account( + init, + payer = payer, + space = 8 + 32 + 1, + seeds = [b"minter-info", tbtc.key().as_ref(), minter.key().as_ref()], bump + )] + pub minter_info: Account<'info, MinterInfo>, + pub system_program: Program<'info, System>, +} + +#[derive(Accounts)] +#[instruction(minter: Pubkey)] +pub struct RemoveMinter<'info> { + #[account( + mut, + has_one = creator @ TbtcError::IsNotCreator + )] + pub tbtc: Account<'info, Tbtc>, + pub creator: Signer<'info>, + #[account( + mut, + constraint = minter_info.minter == minter, + close = creator, + seeds = [b"minter-info", tbtc.key().as_ref(), minter.as_ref()], + bump = minter_info.bump, + )] + pub minter_info: Account<'info, MinterInfo>, +} + +#[derive(Accounts)] +pub struct AddGuardian<'info> { + #[account( + mut, + has_one = creator @ TbtcError::IsNotCreator + )] + pub tbtc: Account<'info, Tbtc>, + pub creator: Signer<'info>, + pub guardian: Signer<'info>, + #[account(mut)] + pub payer: Signer<'info>, + #[account( + init, + payer = payer, + space = 8 + 32 + 1, + seeds = [b"guardian-info", tbtc.key().as_ref(), guardian.key().as_ref()], bump + )] + pub guardian_info: Account<'info, GuardianInfo>, + pub system_program: Program<'info, System>, +} + +#[derive(Accounts)] +#[instruction(guardian: Pubkey)] +pub struct RemoveGuardian<'info> { + #[account( + mut, + has_one = creator @ TbtcError::IsNotCreator + )] + pub tbtc: Account<'info, Tbtc>, + pub creator: Signer<'info>, + #[account( + mut, + constraint = guardian_info.guardian == guardian, + close = creator, + seeds = [b"guardian-info", tbtc.key().as_ref(), guardian.as_ref()], + bump = guardian_info.bump, + )] + pub guardian_info: Account<'info, GuardianInfo>, +} + +#[derive(Accounts)] +pub struct Pause<'info> { + #[account( + mut, + constraint = !tbtc.paused @ TbtcError::IsPaused + )] + pub tbtc: Account<'info, Tbtc>, + #[account( + has_one = guardian, + seeds = [b"guardian-info", tbtc.key().as_ref(), guardian.key().as_ref()], + bump = guardian_info.bump + )] + pub guardian_info: Account<'info, GuardianInfo>, + pub guardian: Signer<'info>, +} + +#[derive(Accounts)] +pub struct Unpause<'info> { + #[account( + mut, + constraint = tbtc.paused @ TbtcError::IsNotPaused, + has_one = creator @ TbtcError::IsNotCreator + )] + pub tbtc: Account<'info, Tbtc>, + pub creator: Signer<'info>, +} + +#[derive(Accounts)] +pub struct SetupMint<'info> { + // Use the correct token mint for the program. + #[account( + mut, + seeds = [b"tbtc-mint", tbtc.key().as_ref()], + bump = tbtc.token_bump, + mint::decimals = 8, + mint::authority = tbtc_mint, + )] + pub tbtc_mint: Account<'info, SplMint>, + pub tbtc: Account<'info, Tbtc>, + + // Set up the recipient's token account. + #[account( + init, + payer = payer, + associated_token::mint = tbtc_mint, + associated_token::authority = recipient, + )] + pub recipient_account: Account<'info, TokenAccount>, + /// CHECK: the recipient doesn't need to sign the mint, + /// and it doesn't conform to any specific rules. + /// Validating the recipient is the minter's responsibility. + pub recipient: UncheckedAccount<'info>, + #[account(mut)] + pub payer: Signer<'info>, + + pub token_program: Program<'info, SplToken>, + pub associated_token_program: Program<'info, AssociatedToken>, + pub system_program: Program<'info, System> +} + +#[derive(Accounts)] +pub struct Mint<'info> { + // Use the correct token mint for the program. + #[account( + mut, + seeds = [b"tbtc-mint", tbtc.key().as_ref()], + bump = tbtc.token_bump, + mint::decimals = 8, + mint::authority = tbtc_mint, + )] + pub tbtc_mint: Account<'info, SplMint>, + + // Can not mint when paused. + #[account( + constraint = !tbtc.paused @ TbtcError::IsPaused + )] + pub tbtc: Account<'info, Tbtc>, + + // Require the signing minter to match a valid minter info. + #[account( + has_one = minter, + seeds = [b"minter-info", tbtc.key().as_ref(), minter.key().as_ref()], + bump = minter_info.bump, + )] + pub minter_info: Account<'info, MinterInfo>, + pub minter: Signer<'info>, + + // Use the associated token account for the recipient. + // This account needs to be initialised first. + #[account( + mut, + associated_token::mint = tbtc_mint, + associated_token::authority = recipient, + )] + pub recipient_account: Account<'info, TokenAccount>, + /// CHECK: the recipient doesn't need to sign the mint, + /// and it doesn't conform to any specific rules. + /// Validating the recipient is the minter's responsibility. + pub recipient: UncheckedAccount<'info>, + + pub token_program: Program<'info, SplToken>, +} + +impl Tbtc { + pub const MAXIMUM_SIZE: usize = 32 + 32 + 1 + 1 + 1 + 1; +} + +#[error_code] +pub enum TbtcError { + AlreadyCreated, + IsPaused, + IsNotPaused, + IsNotMinter, + IsNotGuardian, + IsNotCreator, + NoMinters, + NoGuardians, +} \ No newline at end of file diff --git a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts new file mode 100644 index 000000000..dd276109c --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts @@ -0,0 +1,444 @@ +import * as anchor from "@coral-xyz/anchor"; +import { Program, AnchorError } from "@coral-xyz/anchor"; +import * as spl from "@solana/spl-token"; +import * as web3 from '@solana/web3.js'; +import { SolanaTbtcAnchor } from "../target/types/solana_tbtc_anchor"; +import { expect } from 'chai'; + +async function setup( + program: Program, + tbtc, + creator +) { + const [tbtcMintPDA, _] = getTokenPDA(program, tbtc); + + await program.methods + .initialize() + .accounts({ + tbtcMint: tbtcMintPDA, + tbtc: tbtc.publicKey, + creator: creator.publicKey + }) + .signers([tbtc]) + .rpc(); +} + +async function checkState( + program: Program, + tbtc, + expectedCreator, + expectedMinters, + expectedGuardians, + expectedTokens +) { + let tbtcState = await program.account.tbtc.fetch(tbtc.publicKey); + + expect(tbtcState.creator).to.eql(expectedCreator.publicKey); + expect(tbtcState.minters).to.equal(expectedMinters); + expect(tbtcState.guardians).to.equal(expectedGuardians); + + let tbtcMint = tbtcState.tokenMint; + + let mintState = await spl.getMint(program.provider.connection, tbtcMint); + + expect(mintState.supply == expectedTokens).to.be.true; +} + +async function checkPaused( + program: Program, + tbtc, + paused: boolean +) { + let tbtcState = await program.account.tbtc.fetch(tbtc.publicKey); + expect(tbtcState.paused).to.equal(paused); +} + +function getTokenPDA( + program: Program, + tbtc, +): [anchor.web3.PublicKey, number] { + return web3.PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode('tbtc-mint'), + tbtc.publicKey.toBuffer(), + ], + program.programId + ); +} + +function getMinterPDA( + program: Program, + tbtc, + minter +): [anchor.web3.PublicKey, number] { + return web3.PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode('minter-info'), + tbtc.publicKey.toBuffer(), + minter.publicKey.toBuffer(), + ], + program.programId + ); +} + +async function addMinter( + program: Program, + tbtc, + creator, + minter, + payer +): Promise { + const [minterInfoPDA, _] = getMinterPDA(program, tbtc, minter); + await program.methods + .addMinter() + .accounts({ + tbtc: tbtc.publicKey, + creator: creator.publicKey, + minter: minter.publicKey, + payer: payer.publicKey, + minterInfo: minterInfoPDA, + }) + .signers([minter]) + .rpc(); + return minterInfoPDA; +} + +async function checkMinter( + program: Program, + tbtc, + minter +) { + const [minterInfoPDA, bump] = getMinterPDA(program, tbtc, minter); + let minterInfo = await program.account.minterInfo.fetch(minterInfoPDA); + + expect(minterInfo.minter).to.eql(minter.publicKey); + expect(minterInfo.bump).to.equal(bump); +} + +async function removeMinter( + program: Program, + tbtc, + creator, + minter, + minterInfo +) { + await program.methods + .removeMinter(minter.publicKey) + .accounts({ + tbtc: tbtc.publicKey, + creator: creator.publicKey, + minterInfo: minterInfo, + }) + .signers([]) + .rpc(); +} + +function getGuardianPDA( + program: Program, + tbtc, + guardian +): [anchor.web3.PublicKey, number] { + return web3.PublicKey.findProgramAddressSync( + [ + anchor.utils.bytes.utf8.encode('guardian-info'), + tbtc.publicKey.toBuffer(), + guardian.publicKey.toBuffer(), + ], + program.programId + ); +} + +async function addGuardian( + program: Program, + tbtc, + creator, + guardian, + payer +): Promise { + const [guardianInfoPDA, _] = getGuardianPDA(program, tbtc, guardian); + await program.methods + .addGuardian() + .accounts({ + tbtc: tbtc.publicKey, + creator: creator.publicKey, + guardian: guardian.publicKey, + payer: payer.publicKey, + guardianInfo: guardianInfoPDA, + }) + .signers([guardian]) + .rpc(); + return guardianInfoPDA; +} + +async function checkGuardian( + program: Program, + tbtc, + guardian +) { + const [guardianInfoPDA, bump] = getGuardianPDA(program, tbtc, guardian); + let guardianInfo = await program.account.guardianInfo.fetch(guardianInfoPDA); + + expect(guardianInfo.guardian).to.eql(guardian.publicKey); + expect(guardianInfo.bump).to.equal(bump); +} + +async function removeGuardian( + program: Program, + tbtc, + creator, + guardian, + guardianInfo +) { + await program.methods + .removeGuardian(guardian.publicKey) + .accounts({ + tbtc: tbtc.publicKey, + creator: creator.publicKey, + guardianInfo: guardianInfo, + }) + .signers([]) + .rpc(); +} + +async function pause( + program: Program, + tbtc, + guardian +) { + const [guardianInfoPDA, _] = getGuardianPDA(program, tbtc, guardian); + await program.methods + .pause() + .accounts({ + tbtc: tbtc.publicKey, + guardianInfo: guardianInfoPDA, + guardian: guardian.publicKey + }) + .signers([guardian]) + .rpc(); +} + +async function unpause( + program: Program, + tbtc, + creator +) { + await program.methods + .unpause() + .accounts({ + tbtc: tbtc.publicKey, + creator: creator.publicKey + }) + .signers([]) + .rpc(); +} + +async function setupMint( + program: Program, + tbtc, + creator, + recipient, +) { + const [tbtcMintPDA, _] = getTokenPDA(program, tbtc); + const associatedTokenAccount = spl.getAssociatedTokenAddressSync( + tbtcMintPDA, + recipient.publicKey, + ); + + await program.methods + .setupMint() + .accounts({ + tbtcMint: tbtcMintPDA, + tbtc: tbtc.publicKey, + payer: creator.publicKey, + recipientAccount: associatedTokenAccount, + recipient: recipient.publicKey, + }) + .signers([]) + .rpc() +} + +async function mint( + program: Program, + tbtc, + minter, + minterInfoPDA, + recipient, + amount, +) { + const [tbtcMintPDA, _] = getTokenPDA(program, tbtc); + const associatedTokenAccount = spl.getAssociatedTokenAddressSync( + tbtcMintPDA, + recipient.publicKey, + ); + + await program.methods + .mint(new anchor.BN(amount)) + .accounts({ + tbtcMint: tbtcMintPDA, + tbtc: tbtc.publicKey, + minterInfo: minterInfoPDA, + minter: minter.publicKey, + recipientAccount: associatedTokenAccount, + recipient: recipient.publicKey, + }) + .signers([minter]) + .rpc(); +} + +describe("solana-tbtc-anchor", () => { + // Configure the client to use the local cluster. + anchor.setProvider(anchor.AnchorProvider.env()); + + const program = anchor.workspace.SolanaTbtcAnchor as Program; + + + const creator = (program.provider as anchor.AnchorProvider).wallet; + const minterKeys = anchor.web3.Keypair.generate(); + const minter2Keys = anchor.web3.Keypair.generate(); + const impostorKeys = anchor.web3.Keypair.generate(); + const guardianKeys = anchor.web3.Keypair.generate(); + const guardian2Keys = anchor.web3.Keypair.generate(); + + const recipientKeys = anchor.web3.Keypair.generate(); + + it('setup', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + }); + + it('add minter', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await checkMinter(program, tbtcKeys, minterKeys); + await checkState(program, tbtcKeys, creator, 1, 0, 0); + }); + + it('mint', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await checkMinter(program, tbtcKeys, minterKeys); + await checkState(program, tbtcKeys, creator, 1, 0, 0); + + await setupMint(program, tbtcKeys, creator, recipientKeys); + await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000); + + await checkState(program, tbtcKeys, creator, 1, 0, 1000); + }); + + it('won\'t mint', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await checkMinter(program, tbtcKeys, minterKeys); + await checkState(program, tbtcKeys, creator, 1, 0, 0); + + await setupMint(program, tbtcKeys, creator, recipientKeys); + + try { + await mint(program, tbtcKeys, impostorKeys, minterInfoPDA, recipientKeys, 1000); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('ConstraintSeeds'); + expect(err.program.equals(program.programId)).is.true; + } + }); + + it('remove minter', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await checkMinter(program, tbtcKeys, minterKeys); + await checkState(program, tbtcKeys, creator, 1, 0, 0); + await removeMinter(program, tbtcKeys, creator, minterKeys, minterInfoPDA); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + }); + + it('won\'t remove minter', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await checkMinter(program, tbtcKeys, minterKeys); + await checkState(program, tbtcKeys, creator, 1, 0, 0); + await removeMinter(program, tbtcKeys, creator, minterKeys, minterInfoPDA); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + + try { + await removeMinter(program, tbtcKeys, creator, minterKeys, minterInfoPDA); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('AccountNotInitialized'); + expect(err.program.equals(program.programId)).is.true; + } + }); + + it('add guardian', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await checkGuardian(program, tbtcKeys, guardianKeys); + await checkState(program, tbtcKeys, creator, 0, 1, 0); + }); + + it('remove guardian', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + const guardianInfoPDA = await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await checkGuardian(program, tbtcKeys, guardianKeys); + await checkState(program, tbtcKeys, creator, 0, 1, 0); + await removeGuardian(program, tbtcKeys, creator, guardianKeys, guardianInfoPDA); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + }); + + it('pause', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await checkPaused(program, tbtcKeys, false); + await pause(program, tbtcKeys, guardianKeys); + await checkPaused(program, tbtcKeys, true); + }); + + it('unpause', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await checkPaused(program, tbtcKeys, false); + await pause(program, tbtcKeys, guardianKeys); + await checkPaused(program, tbtcKeys, true); + await unpause(program, tbtcKeys, creator); + await checkPaused(program, tbtcKeys, false); + }); + + it('won\'t mint when paused', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await pause(program, tbtcKeys, guardianKeys); + await setupMint(program, tbtcKeys, creator, recipientKeys); + + try { + await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000); + + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsPaused'); + expect(err.program.equals(program.programId)).is.true; + } + }) +}); diff --git a/cross-chain/solana/solana-tbtc-anchor/tsconfig.json b/cross-chain/solana/solana-tbtc-anchor/tsconfig.json new file mode 100644 index 000000000..558b83e5e --- /dev/null +++ b/cross-chain/solana/solana-tbtc-anchor/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "types": ["mocha", "chai"], + "typeRoots": ["./node_modules/@types"], + "lib": ["es2015"], + "module": "commonjs", + "target": "es6", + "esModuleInterop": true + } + } + \ No newline at end of file diff --git a/package.json b/package.json index ecc60378d..69cf8e6d2 100644 --- a/package.json +++ b/package.json @@ -8,5 +8,8 @@ "prettier": "^2.3.2", "prettier-plugin-sh": "^0.7.1", "prettier-plugin-solidity": "^1.0.0-beta.14" - } + }, + "workspaces": [ + "./cross-chain/solana/*" + ] } diff --git a/yarn.lock b/yarn.lock index 3f3c6dba3..cd01785e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1,113 +1,2606 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! +__metadata: + version: 6 + cacheKey: 8 + +"@babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.22.3": + version: 7.22.6 + resolution: "@babel/runtime@npm:7.22.6" + dependencies: + regenerator-runtime: ^0.13.11 + checksum: e585338287c4514a713babf4fdb8fc2a67adcebab3e7723a739fc62c79cfda875b314c90fd25f827afb150d781af97bc16c85bfdbfa2889f06053879a1ddb597 + languageName: node + linkType: hard + +"@coral-xyz/anchor@npm:^0.28.0": + version: 0.28.0 + resolution: "@coral-xyz/anchor@npm:0.28.0" + dependencies: + "@coral-xyz/borsh": ^0.28.0 + "@solana/web3.js": ^1.68.0 + base64-js: ^1.5.1 + bn.js: ^5.1.2 + bs58: ^4.0.1 + buffer-layout: ^1.2.2 + camelcase: ^6.3.0 + cross-fetch: ^3.1.5 + crypto-hash: ^1.3.0 + eventemitter3: ^4.0.7 + js-sha256: ^0.9.0 + pako: ^2.0.3 + snake-case: ^3.0.4 + superstruct: ^0.15.4 + toml: ^3.0.0 + checksum: 58b3677b5b2ce2c779045184ce4a0ef696966a6a58f41c1c56f6f178db0491acecb6ec677ce0502f0b382a2c724f9c2860d82cc88601784d556d95fbeda415e5 + languageName: node + linkType: hard + +"@coral-xyz/borsh@npm:^0.28.0": + version: 0.28.0 + resolution: "@coral-xyz/borsh@npm:0.28.0" + dependencies: + bn.js: ^5.1.2 + buffer-layout: ^1.2.0 + peerDependencies: + "@solana/web3.js": ^1.68.0 + checksum: bc2b06b777f9ed43d3b886d2350826bd44d5b932c4fd4471af5956e8755236f5854938c890ee4986d88f61d1439e1d84e715c43dcb6dca4e76198c1ce8dc7a58 + languageName: node + linkType: hard + +"@isaacs/cliui@npm:^8.0.2": + version: 8.0.2 + resolution: "@isaacs/cliui@npm:8.0.2" + dependencies: + string-width: ^5.1.2 + string-width-cjs: "npm:string-width@^4.2.0" + strip-ansi: ^7.0.1 + strip-ansi-cjs: "npm:strip-ansi@^6.0.1" + wrap-ansi: ^8.1.0 + wrap-ansi-cjs: "npm:wrap-ansi@^7.0.0" + checksum: 4a473b9b32a7d4d3cfb7a614226e555091ff0c5a29a1734c28c72a182c2f6699b26fc6b5c2131dfd841e86b185aea714c72201d7c98c2fba5f17709333a67aeb + languageName: node + linkType: hard "@keep-network/prettier-config-keep@github:keep-network/prettier-config-keep": - version "0.0.1" - resolved "https://codeload.github.com/keep-network/prettier-config-keep/tar.gz/d6ec02e80dd76edfba073ca58ef99aee39002c2c" - -"@solidity-parser/parser@^0.13.2": - version "0.13.2" - resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.13.2.tgz#b6c71d8ca0b382d90a7bbed241f9bc110af65cbe" - integrity sha512-RwHnpRnfrnD2MSPveYoPh8nhofEvX7fgjHk1Oq+NNvCcLx4r1js91CO9o+F/F3fBzOCyvm8kKRTriFICX/odWw== - dependencies: - antlr4ts "^0.5.0-alpha.4" - -ansi-regex@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" - integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== - -antlr4ts@^0.5.0-alpha.4: - version "0.5.0-alpha.4" - resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a" - integrity sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ== - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -emoji-regex@^9.2.2: - version "9.2.2" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" - integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== - -escape-string-regexp@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" - integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -mvdan-sh@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/mvdan-sh/-/mvdan-sh-0.5.0.tgz#fa76f611a103595ad0f04f5d18e582892c46e87c" - integrity sha512-UWbdl4LHd2fUnaEcOUFVWRdWGLkNoV12cKVIPiirYd8qM5VkCoCTXErlDubevrkEG7kGohvjRxAlTQmOqG80tw== - -prettier-plugin-sh@^0.7.1: - version "0.7.1" - resolved "https://registry.yarnpkg.com/prettier-plugin-sh/-/prettier-plugin-sh-0.7.1.tgz#a2d38de10e55919ea945a6e72c4815b16d6614ad" - integrity sha512-2MWRdGOSz0yf/z2kTKF1AqxDuH9MZD8faoDAz5ySGphxssi9oyM3Ys+jp7AfqsCXvGUDbRA4EJOlKS0yZKAW6w== - dependencies: - mvdan-sh "^0.5.0" - -prettier-plugin-solidity@^1.0.0-beta.14: - version "1.0.0-beta.15" - resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.15.tgz#ca7388e17e2620dc6251746e405150479abdc0a3" - integrity sha512-5+pM/Z1BgQN6xMCe/AfXmiVhoteaVgruVoGT8aa0zJMRiNOiK+SeaW2kOyzTI6sgg3QsUW58+ahf1hxlc/Adbw== - dependencies: - "@solidity-parser/parser" "^0.13.2" - emoji-regex "^9.2.2" - escape-string-regexp "^4.0.0" - semver "^7.3.5" - solidity-comments-extractor "^0.0.7" - string-width "^4.2.2" - -prettier@^2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d" - integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ== - -semver@^7.3.5: - version "7.3.5" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" - integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== - dependencies: - lru-cache "^6.0.0" - -solidity-comments-extractor@^0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19" - integrity sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw== - -string-width@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" - integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.0" - -strip-ansi@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" - integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== - dependencies: - ansi-regex "^5.0.0" - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + version: 0.0.1 + resolution: "@keep-network/prettier-config-keep@https://github.com/keep-network/prettier-config-keep.git#commit=d6ec02e80dd76edfba073ca58ef99aee39002c2c" + peerDependencies: + prettier: ^2.3.0 + checksum: d6825c49952c53ab044b67fb7607eb6cbdc7181b918711818c015396990bd6d594ad6a71029594a12c2ad8ac8e827ff26b5e58fd15eb88c25b7e086069bb99dc + languageName: node + linkType: hard + +"@noble/curves@npm:^1.0.0": + version: 1.1.0 + resolution: "@noble/curves@npm:1.1.0" + dependencies: + "@noble/hashes": 1.3.1 + checksum: 2658cdd3f84f71079b4e3516c47559d22cf4b55c23ac8ee9d2b1f8e5b72916d9689e59820e0f9d9cb4a46a8423af5b56dc6bb7782405c88be06a015180508db5 + languageName: node + linkType: hard + +"@noble/hashes@npm:1.3.1, @noble/hashes@npm:^1.3.0": + version: 1.3.1 + resolution: "@noble/hashes@npm:1.3.1" + checksum: 7fdefc0f7a0c1ec27acc6ff88841793e3f93ec4ce6b8a6a12bfc0dd70ae6b7c4c82fe305fdfeda1735d5ad4a9eebe761e6693b3d355689c559e91242f4bc95b1 + languageName: node + linkType: hard + +"@npmcli/fs@npm:^3.1.0": + version: 3.1.0 + resolution: "@npmcli/fs@npm:3.1.0" + dependencies: + semver: ^7.3.5 + checksum: a50a6818de5fc557d0b0e6f50ec780a7a02ab8ad07e5ac8b16bf519e0ad60a144ac64f97d05c443c3367235d337182e1d012bbac0eb8dbae8dc7b40b193efd0e + languageName: node + linkType: hard + +"@pkgjs/parseargs@npm:^0.11.0": + version: 0.11.0 + resolution: "@pkgjs/parseargs@npm:0.11.0" + checksum: 6ad6a00fc4f2f2cfc6bff76fb1d88b8ee20bc0601e18ebb01b6d4be583733a860239a521a7fbca73b612e66705078809483549d2b18f370eb346c5155c8e4a0f + languageName: node + linkType: hard + +"@solana/buffer-layout-utils@npm:^0.2.0": + version: 0.2.0 + resolution: "@solana/buffer-layout-utils@npm:0.2.0" + dependencies: + "@solana/buffer-layout": ^4.0.0 + "@solana/web3.js": ^1.32.0 + bigint-buffer: ^1.1.5 + bignumber.js: ^9.0.1 + checksum: 9284242245b18b49577195ba7548263850be865a4a2d183944fa01bb76382039db589aab8473698e9bb734b515ada9b4d70db0a72e341c5d567c59b83d6d0840 + languageName: node + linkType: hard + +"@solana/buffer-layout@npm:^4.0.0": + version: 4.0.1 + resolution: "@solana/buffer-layout@npm:4.0.1" + dependencies: + buffer: ~6.0.3 + checksum: bf846888e813187243d4008a7a9f58b49d16cbd995b9d7f1b72898aa510ed77b1ce5e8468e7b2fd26dd81e557a4e74a666e21fccb95f123c1f740d41138bbacd + languageName: node + linkType: hard + +"@solana/spl-token@npm:^0.3.8": + version: 0.3.8 + resolution: "@solana/spl-token@npm:0.3.8" + dependencies: + "@solana/buffer-layout": ^4.0.0 + "@solana/buffer-layout-utils": ^0.2.0 + buffer: ^6.0.3 + peerDependencies: + "@solana/web3.js": ^1.47.4 + checksum: 01f4f87112b0ad277701a3bcb8e03069b69449b92724b17959107686731082bfd3475b5f105e1e8f04badd2e810a43d5ef811744ced5178eea1232de8fd75147 + languageName: node + linkType: hard + +"@solana/web3.js@npm:^1.32.0, @solana/web3.js@npm:^1.68.0, @solana/web3.js@npm:^1.77.3": + version: 1.78.0 + resolution: "@solana/web3.js@npm:1.78.0" + dependencies: + "@babel/runtime": ^7.22.3 + "@noble/curves": ^1.0.0 + "@noble/hashes": ^1.3.0 + "@solana/buffer-layout": ^4.0.0 + agentkeepalive: ^4.2.1 + bigint-buffer: ^1.1.5 + bn.js: ^5.0.0 + borsh: ^0.7.0 + bs58: ^4.0.1 + buffer: 6.0.3 + fast-stable-stringify: ^1.0.0 + jayson: ^4.1.0 + node-fetch: ^2.6.11 + rpc-websockets: ^7.5.1 + superstruct: ^0.14.2 + checksum: 9f0aae54fa8f2d9285ae525b4f962a17160fd98ac588fbf528742630fb2cf0208ec7b6c0c307d6bba82a92a0e8cbb5411b965d553cc4c62488e24b57c2211d84 + languageName: node + linkType: hard + +"@solidity-parser/parser@npm:^0.13.2": + version: 0.13.2 + resolution: "@solidity-parser/parser@npm:0.13.2" + dependencies: + antlr4ts: ^0.5.0-alpha.4 + checksum: bfdd8ec7f7b88f3cc75e333e03202cde5e5dacbec7f00612f22dec5e22b0995713637872ce202064d182bae56a274fcb2ca8715ad5482af5e8b38728a0216cf7 + languageName: node + linkType: hard + +"@tootallnate/once@npm:2": + version: 2.0.0 + resolution: "@tootallnate/once@npm:2.0.0" + checksum: ad87447820dd3f24825d2d947ebc03072b20a42bfc96cbafec16bff8bbda6c1a81fcb0be56d5b21968560c5359a0af4038a68ba150c3e1694fe4c109a063bed8 + languageName: node + linkType: hard + +"@types/bn.js@npm:^5.1.0": + version: 5.1.1 + resolution: "@types/bn.js@npm:5.1.1" + dependencies: + "@types/node": "*" + checksum: e50ed2dd3abe997e047caf90e0352c71e54fc388679735217978b4ceb7e336e51477791b715f49fd77195ac26dd296c7bad08a3be9750e235f9b2e1edb1b51c2 + languageName: node + linkType: hard + +"@types/chai@npm:^4.3.0": + version: 4.3.5 + resolution: "@types/chai@npm:4.3.5" + checksum: c8f26a88c6b5b53a3275c7f5ff8f107028e3cbb9ff26795fff5f3d9dea07106a54ce9e2dce5e40347f7c4cc35657900aaf0c83934a25a1ae12e61e0f5516e431 + languageName: node + linkType: hard + +"@types/connect@npm:^3.4.33": + version: 3.4.35 + resolution: "@types/connect@npm:3.4.35" + dependencies: + "@types/node": "*" + checksum: fe81351470f2d3165e8b12ce33542eef89ea893e36dd62e8f7d72566dfb7e448376ae962f9f3ea888547ce8b55a40020ca0e01d637fab5d99567673084542641 + languageName: node + linkType: hard + +"@types/json5@npm:^0.0.29": + version: 0.0.29 + resolution: "@types/json5@npm:0.0.29" + checksum: e60b153664572116dfea673c5bda7778dbff150498f44f998e34b5886d8afc47f16799280e4b6e241c0472aef1bc36add771c569c68fc5125fc2ae519a3eb9ac + languageName: node + linkType: hard + +"@types/mocha@npm:^9.0.0": + version: 9.1.1 + resolution: "@types/mocha@npm:9.1.1" + checksum: 516077c0acd9806dc78317f88aaac0df5aaf0bdc2f63dfdadeabdf0b0137953b6ca65472e6ff7c30bc93ce4e0ae76eae70e8d46764b9a8eae4877a928b6ef49a + languageName: node + linkType: hard + +"@types/node@npm:*": + version: 20.4.1 + resolution: "@types/node@npm:20.4.1" + checksum: 22cbcc792f2eb636fe4188778ed0f32658ab872aa7fcb9847b3fa289a42b14b9f5e30c6faec50ef3c7adbc6c2a246926e5858136bb8b10c035a3fcaa6afbeed2 + languageName: node + linkType: hard + +"@types/node@npm:^12.12.54": + version: 12.20.55 + resolution: "@types/node@npm:12.20.55" + checksum: e4f86785f4092706e0d3b0edff8dca5a13b45627e4b36700acd8dfe6ad53db71928c8dee914d4276c7fd3b6ccd829aa919811c9eb708a2c8e4c6eb3701178c37 + languageName: node + linkType: hard + +"@types/ws@npm:^7.4.4": + version: 7.4.7 + resolution: "@types/ws@npm:7.4.7" + dependencies: + "@types/node": "*" + checksum: b4c9b8ad209620c9b21e78314ce4ff07515c0cadab9af101c1651e7bfb992d7fd933bd8b9c99d110738fd6db523ed15f82f29f50b45510288da72e964dedb1a3 + languageName: node + linkType: hard + +"@ungap/promise-all-settled@npm:1.1.2": + version: 1.1.2 + resolution: "@ungap/promise-all-settled@npm:1.1.2" + checksum: 08d37fdfa23a6fe8139f1305313562ebad973f3fac01bcce2773b2bda5bcb0146dfdcf3cb6a722cf0a5f2ca0bc56a827eac8f1e7b3beddc548f654addf1fc34c + languageName: node + linkType: hard + +"JSONStream@npm:^1.3.5": + version: 1.3.5 + resolution: "JSONStream@npm:1.3.5" + dependencies: + jsonparse: ^1.2.0 + through: ">=2.2.7 <3" + bin: + JSONStream: ./bin.js + checksum: 2605fa124260c61bad38bb65eba30d2f72216a78e94d0ab19b11b4e0327d572b8d530c0c9cc3b0764f727ad26d39e00bf7ebad57781ca6368394d73169c59e46 + languageName: node + linkType: hard + +"abbrev@npm:^1.0.0": + version: 1.1.1 + resolution: "abbrev@npm:1.1.1" + checksum: a4a97ec07d7ea112c517036882b2ac22f3109b7b19077dc656316d07d308438aac28e4d9746dc4d84bf6b1e75b4a7b0a5f3cb30592419f128ca9a8cee3bcfa17 + languageName: node + linkType: hard + +"agent-base@npm:6, agent-base@npm:^6.0.2": + version: 6.0.2 + resolution: "agent-base@npm:6.0.2" + dependencies: + debug: 4 + checksum: f52b6872cc96fd5f622071b71ef200e01c7c4c454ee68bc9accca90c98cfb39f2810e3e9aa330435835eedc8c23f4f8a15267f67c6e245d2b33757575bdac49d + languageName: node + linkType: hard + +"agentkeepalive@npm:^4.2.1": + version: 4.3.0 + resolution: "agentkeepalive@npm:4.3.0" + dependencies: + debug: ^4.1.0 + depd: ^2.0.0 + humanize-ms: ^1.2.1 + checksum: 982453aa44c11a06826c836025e5162c846e1200adb56f2d075400da7d32d87021b3b0a58768d949d824811f5654223d5a8a3dad120921a2439625eb847c6260 + languageName: node + linkType: hard + +"aggregate-error@npm:^3.0.0": + version: 3.1.0 + resolution: "aggregate-error@npm:3.1.0" + dependencies: + clean-stack: ^2.0.0 + indent-string: ^4.0.0 + checksum: 1101a33f21baa27a2fa8e04b698271e64616b886795fd43c31068c07533c7b3facfcaf4e9e0cab3624bd88f729a592f1c901a1a229c9e490eafce411a8644b79 + languageName: node + linkType: hard + +"ansi-colors@npm:4.1.1": + version: 4.1.1 + resolution: "ansi-colors@npm:4.1.1" + checksum: 138d04a51076cb085da0a7e2d000c5c0bb09f6e772ed5c65c53cb118d37f6c5f1637506d7155fb5f330f0abcf6f12fa2e489ac3f8cdab9da393bf1bb4f9a32b0 + languageName: node + linkType: hard + +"ansi-regex@npm:^5.0.0": + version: 5.0.0 + resolution: "ansi-regex@npm:5.0.0" + checksum: b1bb4e992a5d96327bb4f72eaba9f8047f1d808d273ad19d399e266bfcc7fb19a4d1a127a32f7bc61fe46f1a94a4d04ec4c424e3fbe184929aa866323d8ed4ce + languageName: node + linkType: hard + +"ansi-regex@npm:^5.0.1": + version: 5.0.1 + resolution: "ansi-regex@npm:5.0.1" + checksum: 2aa4bb54caf2d622f1afdad09441695af2a83aa3fe8b8afa581d205e57ed4261c183c4d3877cee25794443fde5876417d859c108078ab788d6af7e4fe52eb66b + languageName: node + linkType: hard + +"ansi-regex@npm:^6.0.1": + version: 6.0.1 + resolution: "ansi-regex@npm:6.0.1" + checksum: 1ff8b7667cded1de4fa2c9ae283e979fc87036864317da86a2e546725f96406746411d0d85e87a2d12fa5abd715d90006de7fa4fa0477c92321ad3b4c7d4e169 + languageName: node + linkType: hard + +"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0": + version: 4.3.0 + resolution: "ansi-styles@npm:4.3.0" + dependencies: + color-convert: ^2.0.1 + checksum: 513b44c3b2105dd14cc42a19271e80f386466c4be574bccf60b627432f9198571ebf4ab1e4c3ba17347658f4ee1711c163d574248c0c1cdc2d5917a0ad582ec4 + languageName: node + linkType: hard + +"ansi-styles@npm:^6.1.0": + version: 6.2.1 + resolution: "ansi-styles@npm:6.2.1" + checksum: ef940f2f0ced1a6347398da88a91da7930c33ecac3c77b72c5905f8b8fe402c52e6fde304ff5347f616e27a742da3f1dc76de98f6866c69251ad0b07a66776d9 + languageName: node + linkType: hard + +"antlr4ts@npm:^0.5.0-alpha.4": + version: 0.5.0-alpha.4 + resolution: "antlr4ts@npm:0.5.0-alpha.4" + checksum: 37948499d59477f5b5a8ea71dfb8b5330e71d5a7cee60f57351dd744219b8619fa6aac1a5b6ec1a9991846e8ddc9ca47680eb166c59b44333369b3115e7aa358 + languageName: node + linkType: hard + +"anymatch@npm:~3.1.2": + version: 3.1.3 + resolution: "anymatch@npm:3.1.3" + dependencies: + normalize-path: ^3.0.0 + picomatch: ^2.0.4 + checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 + languageName: node + linkType: hard + +"aproba@npm:^1.0.3 || ^2.0.0": + version: 2.0.0 + resolution: "aproba@npm:2.0.0" + checksum: 5615cadcfb45289eea63f8afd064ab656006361020e1735112e346593856f87435e02d8dcc7ff0d11928bc7d425f27bc7c2a84f6c0b35ab0ff659c814c138a24 + languageName: node + linkType: hard + +"are-we-there-yet@npm:^3.0.0": + version: 3.0.1 + resolution: "are-we-there-yet@npm:3.0.1" + dependencies: + delegates: ^1.0.0 + readable-stream: ^3.6.0 + checksum: 52590c24860fa7173bedeb69a4c05fb573473e860197f618b9a28432ee4379049336727ae3a1f9c4cb083114601c1140cee578376164d0e651217a9843f9fe83 + languageName: node + linkType: hard + +"argparse@npm:^2.0.1": + version: 2.0.1 + resolution: "argparse@npm:2.0.1" + checksum: 83644b56493e89a254bae05702abf3a1101b4fa4d0ca31df1c9985275a5a5bd47b3c27b7fa0b71098d41114d8ca000e6ed90cad764b306f8a503665e4d517ced + languageName: node + linkType: hard + +"arrify@npm:^1.0.0": + version: 1.0.1 + resolution: "arrify@npm:1.0.1" + checksum: 745075dd4a4624ff0225c331dacb99be501a515d39bcb7c84d24660314a6ec28e68131b137e6f7e16318170842ce97538cd298fc4cd6b2cc798e0b957f2747e7 + languageName: node + linkType: hard + +"assertion-error@npm:^1.1.0": + version: 1.1.0 + resolution: "assertion-error@npm:1.1.0" + checksum: fd9429d3a3d4fd61782eb3962ae76b6d08aa7383123fca0596020013b3ebd6647891a85b05ce821c47d1471ed1271f00b0545cf6a4326cf2fc91efcc3b0fbecf + languageName: node + linkType: hard + +"balanced-match@npm:^1.0.0": + version: 1.0.2 + resolution: "balanced-match@npm:1.0.2" + checksum: 9706c088a283058a8a99e0bf91b0a2f75497f185980d9ffa8b304de1d9e58ebda7c72c07ebf01dadedaac5b2907b2c6f566f660d62bd336c3468e960403b9d65 + languageName: node + linkType: hard + +"base-x@npm:^3.0.2": + version: 3.0.9 + resolution: "base-x@npm:3.0.9" + dependencies: + safe-buffer: ^5.0.1 + checksum: 957101d6fd09e1903e846fd8f69fd7e5e3e50254383e61ab667c725866bec54e5ece5ba49ce385128ae48f9ec93a26567d1d5ebb91f4d56ef4a9cc0d5a5481e8 + languageName: node + linkType: hard + +"base64-js@npm:^1.3.1, base64-js@npm:^1.5.1": + version: 1.5.1 + resolution: "base64-js@npm:1.5.1" + checksum: 669632eb3745404c2f822a18fc3a0122d2f9a7a13f7fb8b5823ee19d1d2ff9ee5b52c53367176ea4ad093c332fd5ab4bd0ebae5a8e27917a4105a4cfc86b1005 + languageName: node + linkType: hard + +"bigint-buffer@npm:^1.1.5": + version: 1.1.5 + resolution: "bigint-buffer@npm:1.1.5" + dependencies: + bindings: ^1.3.0 + node-gyp: latest + checksum: d010c9f57758bcdaccb435d88b483ffcc95fe8bbc6e7fb3a44fb5221f29c894ffaf4a3c5a4a530e0e7d6608203c2cde9b79ee4f2386cd6d4462d1070bc8c9f4e + languageName: node + linkType: hard + +"bignumber.js@npm:^9.0.1": + version: 9.1.1 + resolution: "bignumber.js@npm:9.1.1" + checksum: ad243b7e2f9120b112d670bb3d674128f0bd2ca1745b0a6c9df0433bd2c0252c43e6315d944c2ac07b4c639e7496b425e46842773cf89c6a2dcd4f31e5c4b11e + languageName: node + linkType: hard + +"binary-extensions@npm:^2.0.0": + version: 2.2.0 + resolution: "binary-extensions@npm:2.2.0" + checksum: ccd267956c58d2315f5d3ea6757cf09863c5fc703e50fbeb13a7dc849b812ef76e3cf9ca8f35a0c48498776a7478d7b4a0418e1e2b8cb9cb9731f2922aaad7f8 + languageName: node + linkType: hard + +"bindings@npm:^1.3.0": + version: 1.5.0 + resolution: "bindings@npm:1.5.0" + dependencies: + file-uri-to-path: 1.0.0 + checksum: 65b6b48095717c2e6105a021a7da4ea435aa8d3d3cd085cb9e85bcb6e5773cf318c4745c3f7c504412855940b585bdf9b918236612a1c7a7942491de176f1ae7 + languageName: node + linkType: hard + +"bn.js@npm:^5.0.0, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0": + version: 5.2.1 + resolution: "bn.js@npm:5.2.1" + checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3 + languageName: node + linkType: hard + +"borsh@npm:^0.7.0": + version: 0.7.0 + resolution: "borsh@npm:0.7.0" + dependencies: + bn.js: ^5.2.0 + bs58: ^4.0.0 + text-encoding-utf-8: ^1.0.2 + checksum: e98bfb5f7cfb820819c2870b884dac58dd4b4ce6a86c286c8fbf5c9ca582e73a8c6094df67e81a28c418ff07a309c6b118b2e27fdfea83fd92b8100c741da0b5 + languageName: node + linkType: hard + +"brace-expansion@npm:^1.1.7": + version: 1.1.11 + resolution: "brace-expansion@npm:1.1.11" + dependencies: + balanced-match: ^1.0.0 + concat-map: 0.0.1 + checksum: faf34a7bb0c3fcf4b59c7808bc5d2a96a40988addf2e7e09dfbb67a2251800e0d14cd2bfc1aa79174f2f5095c54ff27f46fb1289fe2d77dac755b5eb3434cc07 + languageName: node + linkType: hard + +"brace-expansion@npm:^2.0.1": + version: 2.0.1 + resolution: "brace-expansion@npm:2.0.1" + dependencies: + balanced-match: ^1.0.0 + checksum: a61e7cd2e8a8505e9f0036b3b6108ba5e926b4b55089eeb5550cd04a471fe216c96d4fe7e4c7f995c728c554ae20ddfc4244cad10aef255e72b62930afd233d1 + languageName: node + linkType: hard + +"braces@npm:~3.0.2": + version: 3.0.2 + resolution: "braces@npm:3.0.2" + dependencies: + fill-range: ^7.0.1 + checksum: e2a8e769a863f3d4ee887b5fe21f63193a891c68b612ddb4b68d82d1b5f3ff9073af066c343e9867a393fe4c2555dcb33e89b937195feb9c1613d259edfcd459 + languageName: node + linkType: hard + +"browser-stdout@npm:1.3.1": + version: 1.3.1 + resolution: "browser-stdout@npm:1.3.1" + checksum: b717b19b25952dd6af483e368f9bcd6b14b87740c3d226c2977a65e84666ffd67000bddea7d911f111a9b6ddc822b234de42d52ab6507bce4119a4cc003ef7b3 + languageName: node + linkType: hard + +"bs58@npm:^4.0.0, bs58@npm:^4.0.1": + version: 4.0.1 + resolution: "bs58@npm:4.0.1" + dependencies: + base-x: ^3.0.2 + checksum: b3c5365bb9e0c561e1a82f1a2d809a1a692059fae016be233a6127ad2f50a6b986467c3a50669ce4c18929dcccb297c5909314dd347a25a68c21b68eb3e95ac2 + languageName: node + linkType: hard + +"buffer-from@npm:^1.0.0, buffer-from@npm:^1.1.0": + version: 1.1.2 + resolution: "buffer-from@npm:1.1.2" + checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb + languageName: node + linkType: hard + +"buffer-layout@npm:^1.2.0, buffer-layout@npm:^1.2.2": + version: 1.2.2 + resolution: "buffer-layout@npm:1.2.2" + checksum: e5809ba275530bf4e52fd09558b7c2111fbda5b405124f581acf364261d9c154e271800271898cd40473f9bcbb42c31584efb04219bde549d3460ca4bafeaa07 + languageName: node + linkType: hard + +"buffer@npm:6.0.3, buffer@npm:^6.0.3, buffer@npm:~6.0.3": + version: 6.0.3 + resolution: "buffer@npm:6.0.3" + dependencies: + base64-js: ^1.3.1 + ieee754: ^1.2.1 + checksum: 5ad23293d9a731e4318e420025800b42bf0d264004c0286c8cc010af7a270c7a0f6522e84f54b9ad65cbd6db20b8badbfd8d2ebf4f80fa03dab093b89e68c3f9 + languageName: node + linkType: hard + +"bufferutil@npm:^4.0.1": + version: 4.0.7 + resolution: "bufferutil@npm:4.0.7" + dependencies: + node-gyp: latest + node-gyp-build: ^4.3.0 + checksum: f75aa87e3d1b99b87a95f60a855e63f70af07b57fb8443e75a2ddfef2e47788d130fdd46e3a78fd7e0c10176082b26dfbed970c5b8632e1cc299cafa0e93ce45 + languageName: node + linkType: hard + +"cacache@npm:^17.0.0": + version: 17.1.3 + resolution: "cacache@npm:17.1.3" + dependencies: + "@npmcli/fs": ^3.1.0 + fs-minipass: ^3.0.0 + glob: ^10.2.2 + lru-cache: ^7.7.1 + minipass: ^5.0.0 + minipass-collect: ^1.0.2 + minipass-flush: ^1.0.5 + minipass-pipeline: ^1.2.4 + p-map: ^4.0.0 + ssri: ^10.0.0 + tar: ^6.1.11 + unique-filename: ^3.0.0 + checksum: 385756781e1e21af089160d89d7462b7ed9883c978e848c7075b90b73cb823680e66092d61513050164588387d2ca87dd6d910e28d64bc13a9ac82cd8580c796 + languageName: node + linkType: hard + +"camelcase@npm:^6.0.0, camelcase@npm:^6.3.0": + version: 6.3.0 + resolution: "camelcase@npm:6.3.0" + checksum: 8c96818a9076434998511251dcb2761a94817ea17dbdc37f47ac080bd088fc62c7369429a19e2178b993497132c8cbcf5cc1f44ba963e76782ba469c0474938d + languageName: node + linkType: hard + +"chai@npm:^4.3.4": + version: 4.3.7 + resolution: "chai@npm:4.3.7" + dependencies: + assertion-error: ^1.1.0 + check-error: ^1.0.2 + deep-eql: ^4.1.2 + get-func-name: ^2.0.0 + loupe: ^2.3.1 + pathval: ^1.1.1 + type-detect: ^4.0.5 + checksum: 0bba7d267848015246a66995f044ce3f0ebc35e530da3cbdf171db744e14cbe301ab913a8d07caf7952b430257ccbb1a4a983c570a7c5748dc537897e5131f7c + languageName: node + linkType: hard + +"chalk@npm:^4.1.0": + version: 4.1.2 + resolution: "chalk@npm:4.1.2" + dependencies: + ansi-styles: ^4.1.0 + supports-color: ^7.1.0 + checksum: fe75c9d5c76a7a98d45495b91b2172fa3b7a09e0cc9370e5c8feb1c567b85c4288e2b3fded7cfdd7359ac28d6b3844feb8b82b8686842e93d23c827c417e83fc + languageName: node + linkType: hard + +"check-error@npm:^1.0.2": + version: 1.0.2 + resolution: "check-error@npm:1.0.2" + checksum: d9d106504404b8addd1ee3f63f8c0eaa7cd962a1a28eb9c519b1c4a1dc7098be38007fc0060f045ee00f075fbb7a2a4f42abcf61d68323677e11ab98dc16042e + languageName: node + linkType: hard + +"chokidar@npm:3.5.3": + version: 3.5.3 + resolution: "chokidar@npm:3.5.3" + dependencies: + anymatch: ~3.1.2 + braces: ~3.0.2 + fsevents: ~2.3.2 + glob-parent: ~5.1.2 + is-binary-path: ~2.1.0 + is-glob: ~4.0.1 + normalize-path: ~3.0.0 + readdirp: ~3.6.0 + dependenciesMeta: + fsevents: + optional: true + checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c + languageName: node + linkType: hard + +"chownr@npm:^2.0.0": + version: 2.0.0 + resolution: "chownr@npm:2.0.0" + checksum: c57cf9dd0791e2f18a5ee9c1a299ae6e801ff58fee96dc8bfd0dcb4738a6ce58dd252a3605b1c93c6418fe4f9d5093b28ffbf4d66648cb2a9c67eaef9679be2f + languageName: node + linkType: hard + +"clean-stack@npm:^2.0.0": + version: 2.2.0 + resolution: "clean-stack@npm:2.2.0" + checksum: 2ac8cd2b2f5ec986a3c743935ec85b07bc174d5421a5efc8017e1f146a1cf5f781ae962618f416352103b32c9cd7e203276e8c28241bbe946160cab16149fb68 + languageName: node + linkType: hard + +"cliui@npm:^7.0.2": + version: 7.0.4 + resolution: "cliui@npm:7.0.4" + dependencies: + string-width: ^4.2.0 + strip-ansi: ^6.0.0 + wrap-ansi: ^7.0.0 + checksum: ce2e8f578a4813806788ac399b9e866297740eecd4ad1823c27fd344d78b22c5f8597d548adbcc46f0573e43e21e751f39446c5a5e804a12aace402b7a315d7f + languageName: node + linkType: hard + +"color-convert@npm:^2.0.1": + version: 2.0.1 + resolution: "color-convert@npm:2.0.1" + dependencies: + color-name: ~1.1.4 + checksum: 79e6bdb9fd479a205c71d89574fccfb22bd9053bd98c6c4d870d65c132e5e904e6034978e55b43d69fcaa7433af2016ee203ce76eeba9cfa554b373e7f7db336 + languageName: node + linkType: hard + +"color-name@npm:~1.1.4": + version: 1.1.4 + resolution: "color-name@npm:1.1.4" + checksum: b0445859521eb4021cd0fb0cc1a75cecf67fceecae89b63f62b201cca8d345baf8b952c966862a9d9a2632987d4f6581f0ec8d957dfacece86f0a7919316f610 + languageName: node + linkType: hard + +"color-support@npm:^1.1.3": + version: 1.1.3 + resolution: "color-support@npm:1.1.3" + bin: + color-support: bin.js + checksum: 9b7356817670b9a13a26ca5af1c21615463b500783b739b7634a0c2047c16cef4b2865d7576875c31c3cddf9dd621fa19285e628f20198b233a5cfdda6d0793b + languageName: node + linkType: hard + +"commander@npm:^2.20.3": + version: 2.20.3 + resolution: "commander@npm:2.20.3" + checksum: ab8c07884e42c3a8dbc5dd9592c606176c7eb5c1ca5ff274bcf907039b2c41de3626f684ea75ccf4d361ba004bbaff1f577d5384c155f3871e456bdf27becf9e + languageName: node + linkType: hard + +"concat-map@npm:0.0.1": + version: 0.0.1 + resolution: "concat-map@npm:0.0.1" + checksum: 902a9f5d8967a3e2faf138d5cb784b9979bad2e6db5357c5b21c568df4ebe62bcb15108af1b2253744844eb964fc023fbd9afbbbb6ddd0bcc204c6fb5b7bf3af + languageName: node + linkType: hard + +"console-control-strings@npm:^1.1.0": + version: 1.1.0 + resolution: "console-control-strings@npm:1.1.0" + checksum: 8755d76787f94e6cf79ce4666f0c5519906d7f5b02d4b884cf41e11dcd759ed69c57da0670afd9236d229a46e0f9cf519db0cd829c6dca820bb5a5c3def584ed + languageName: node + linkType: hard + +"cross-fetch@npm:^3.1.5": + version: 3.1.8 + resolution: "cross-fetch@npm:3.1.8" + dependencies: + node-fetch: ^2.6.12 + checksum: 78f993fa099eaaa041122ab037fe9503ecbbcb9daef234d1d2e0b9230a983f64d645d088c464e21a247b825a08dc444a6e7064adfa93536d3a9454b4745b3632 + languageName: node + linkType: hard + +"cross-spawn@npm:^7.0.0": + version: 7.0.3 + resolution: "cross-spawn@npm:7.0.3" + dependencies: + path-key: ^3.1.0 + shebang-command: ^2.0.0 + which: ^2.0.1 + checksum: 671cc7c7288c3a8406f3c69a3ae2fc85555c04169e9d611def9a675635472614f1c0ed0ef80955d5b6d4e724f6ced67f0ad1bb006c2ea643488fcfef994d7f52 + languageName: node + linkType: hard + +"crypto-hash@npm:^1.3.0": + version: 1.3.0 + resolution: "crypto-hash@npm:1.3.0" + checksum: a3a507e0d2b18fbd2da8088a1c62d0c53c009a99bbfa6d851cac069734ffa546922fa51bdd776d006459701cdda873463e5059ece3431aca048fd99e7573d138 + languageName: node + linkType: hard + +"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.3.3": + version: 4.3.4 + resolution: "debug@npm:4.3.4" + dependencies: + ms: 2.1.2 + peerDependenciesMeta: + supports-color: + optional: true + checksum: 3dbad3f94ea64f34431a9cbf0bafb61853eda57bff2880036153438f50fb5a84f27683ba0d8e5426bf41a8c6ff03879488120cf5b3a761e77953169c0600a708 + languageName: node + linkType: hard + +"debug@npm:4.3.3": + version: 4.3.3 + resolution: "debug@npm:4.3.3" + dependencies: + ms: 2.1.2 + peerDependenciesMeta: + supports-color: + optional: true + checksum: 14472d56fe4a94dbcfaa6dbed2dd3849f1d72ba78104a1a328047bb564643ca49df0224c3a17fa63533fd11dd3d4c8636cd861191232a2c6735af00cc2d4de16 + languageName: node + linkType: hard + +"decamelize@npm:^4.0.0": + version: 4.0.0 + resolution: "decamelize@npm:4.0.0" + checksum: b7d09b82652c39eead4d6678bb578e3bebd848add894b76d0f6b395bc45b2d692fb88d977e7cfb93c4ed6c119b05a1347cef261174916c2e75c0a8ca57da1809 + languageName: node + linkType: hard + +"deep-eql@npm:^4.1.2": + version: 4.1.3 + resolution: "deep-eql@npm:4.1.3" + dependencies: + type-detect: ^4.0.0 + checksum: 7f6d30cb41c713973dc07eaadded848b2ab0b835e518a88b91bea72f34e08c4c71d167a722a6f302d3a6108f05afd8e6d7650689a84d5d29ec7fe6220420397f + languageName: node + linkType: hard + +"delay@npm:^5.0.0": + version: 5.0.0 + resolution: "delay@npm:5.0.0" + checksum: 62f151151ecfde0d9afbb8a6be37a6d103c4cb24f35a20ef3fe56f920b0d0d0bb02bc9c0a3084d0179ef669ca332b91155f2ee4d9854622cd2cdba5fc95285f9 + languageName: node + linkType: hard + +"delegates@npm:^1.0.0": + version: 1.0.0 + resolution: "delegates@npm:1.0.0" + checksum: a51744d9b53c164ba9c0492471a1a2ffa0b6727451bdc89e31627fdf4adda9d51277cfcbfb20f0a6f08ccb3c436f341df3e92631a3440226d93a8971724771fd + languageName: node + linkType: hard + +"depd@npm:^2.0.0": + version: 2.0.0 + resolution: "depd@npm:2.0.0" + checksum: abbe19c768c97ee2eed6282d8ce3031126662252c58d711f646921c9623f9052e3e1906443066beec1095832f534e57c523b7333f8e7e0d93051ab6baef5ab3a + languageName: node + linkType: hard + +"diff@npm:5.0.0": + version: 5.0.0 + resolution: "diff@npm:5.0.0" + checksum: f19fe29284b633afdb2725c2a8bb7d25761ea54d321d8e67987ac851c5294be4afeab532bd84531e02583a3fe7f4014aa314a3eda84f5590e7a9e6b371ef3b46 + languageName: node + linkType: hard + +"diff@npm:^3.1.0": + version: 3.5.0 + resolution: "diff@npm:3.5.0" + checksum: 00842950a6551e26ce495bdbce11047e31667deea546527902661f25cc2e73358967ebc78cf86b1a9736ec3e14286433225f9970678155753a6291c3bca5227b + languageName: node + linkType: hard + +"dot-case@npm:^3.0.4": + version: 3.0.4 + resolution: "dot-case@npm:3.0.4" + dependencies: + no-case: ^3.0.4 + tslib: ^2.0.3 + checksum: a65e3519414856df0228b9f645332f974f2bf5433370f544a681122eab59e66038fc3349b4be1cdc47152779dac71a5864f1ccda2f745e767c46e9c6543b1169 + languageName: node + linkType: hard + +"eastasianwidth@npm:^0.2.0": + version: 0.2.0 + resolution: "eastasianwidth@npm:0.2.0" + checksum: 7d00d7cd8e49b9afa762a813faac332dee781932d6f2c848dc348939c4253f1d4564341b7af1d041853bc3f32c2ef141b58e0a4d9862c17a7f08f68df1e0f1ed + languageName: node + linkType: hard + +"emoji-regex@npm:^8.0.0": + version: 8.0.0 + resolution: "emoji-regex@npm:8.0.0" + checksum: d4c5c39d5a9868b5fa152f00cada8a936868fd3367f33f71be515ecee4c803132d11b31a6222b2571b1e5f7e13890156a94880345594d0ce7e3c9895f560f192 + languageName: node + linkType: hard + +"emoji-regex@npm:^9.2.2": + version: 9.2.2 + resolution: "emoji-regex@npm:9.2.2" + checksum: 8487182da74aabd810ac6d6f1994111dfc0e331b01271ae01ec1eb0ad7b5ecc2bbbbd2f053c05cb55a1ac30449527d819bbfbf0e3de1023db308cbcb47f86601 + languageName: node + linkType: hard + +"encoding@npm:^0.1.13": + version: 0.1.13 + resolution: "encoding@npm:0.1.13" + dependencies: + iconv-lite: ^0.6.2 + checksum: bb98632f8ffa823996e508ce6a58ffcf5856330fde839ae42c9e1f436cc3b5cc651d4aeae72222916545428e54fd0f6aa8862fd8d25bdbcc4589f1e3f3715e7f + languageName: node + linkType: hard + +"env-paths@npm:^2.2.0": + version: 2.2.1 + resolution: "env-paths@npm:2.2.1" + checksum: 65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e + languageName: node + linkType: hard + +"err-code@npm:^2.0.2": + version: 2.0.3 + resolution: "err-code@npm:2.0.3" + checksum: 8b7b1be20d2de12d2255c0bc2ca638b7af5171142693299416e6a9339bd7d88fc8d7707d913d78e0993176005405a236b066b45666b27b797252c771156ace54 + languageName: node + linkType: hard + +"es6-promise@npm:^4.0.3": + version: 4.2.8 + resolution: "es6-promise@npm:4.2.8" + checksum: 95614a88873611cb9165a85d36afa7268af5c03a378b35ca7bda9508e1d4f1f6f19a788d4bc755b3fd37c8ebba40782018e02034564ff24c9d6fa37e959ad57d + languageName: node + linkType: hard + +"es6-promisify@npm:^5.0.0": + version: 5.0.0 + resolution: "es6-promisify@npm:5.0.0" + dependencies: + es6-promise: ^4.0.3 + checksum: fbed9d791598831413be84a5374eca8c24800ec71a16c1c528c43a98e2dadfb99331483d83ae6094ddb9b87e6f799a15d1553cebf756047e0865c753bc346b92 + languageName: node + linkType: hard + +"escalade@npm:^3.1.1": + version: 3.1.1 + resolution: "escalade@npm:3.1.1" + checksum: a3e2a99f07acb74b3ad4989c48ca0c3140f69f923e56d0cba0526240ee470b91010f9d39001f2a4a313841d237ede70a729e92125191ba5d21e74b106800b133 + languageName: node + linkType: hard + +"escape-string-regexp@npm:4.0.0, escape-string-regexp@npm:^4.0.0": + version: 4.0.0 + resolution: "escape-string-regexp@npm:4.0.0" + checksum: 98b48897d93060f2322108bf29db0feba7dd774be96cd069458d1453347b25ce8682ecc39859d4bca2203cc0ab19c237bcc71755eff49a0f8d90beadeeba5cc5 + languageName: node + linkType: hard + +"eventemitter3@npm:^4.0.7": + version: 4.0.7 + resolution: "eventemitter3@npm:4.0.7" + checksum: 1875311c42fcfe9c707b2712c32664a245629b42bb0a5a84439762dd0fd637fc54d078155ea83c2af9e0323c9ac13687e03cfba79b03af9f40c89b4960099374 + languageName: node + linkType: hard + +"exponential-backoff@npm:^3.1.1": + version: 3.1.1 + resolution: "exponential-backoff@npm:3.1.1" + checksum: 3d21519a4f8207c99f7457287291316306255a328770d320b401114ec8481986e4e467e854cb9914dd965e0a1ca810a23ccb559c642c88f4c7f55c55778a9b48 + languageName: node + linkType: hard + +"eyes@npm:^0.1.8": + version: 0.1.8 + resolution: "eyes@npm:0.1.8" + checksum: c31703a92bf36ba75ee8d379ee7985c24ee6149f3a6175f44cec7a05b178c38bce9836d3ca48c9acb0329a960ac2c4b2ead4e60cdd4fe6e8c92cad7cd6913687 + languageName: node + linkType: hard + +"fast-stable-stringify@npm:^1.0.0": + version: 1.0.0 + resolution: "fast-stable-stringify@npm:1.0.0" + checksum: ef1203d246a7e8ac15e2bfbda0a89fa375947bccf9f7910be0ea759856dbe8ea5024a0d8cc2cceabe18a9cb67e95927b78bb6173a3ae37ec55a518cf36e5244b + languageName: node + linkType: hard + +"file-uri-to-path@npm:1.0.0": + version: 1.0.0 + resolution: "file-uri-to-path@npm:1.0.0" + checksum: b648580bdd893a008c92c7ecc96c3ee57a5e7b6c4c18a9a09b44fb5d36d79146f8e442578bc0e173dc027adf3987e254ba1dfd6e3ec998b7c282873010502144 + languageName: node + linkType: hard + +"fill-range@npm:^7.0.1": + version: 7.0.1 + resolution: "fill-range@npm:7.0.1" + dependencies: + to-regex-range: ^5.0.1 + checksum: cc283f4e65b504259e64fd969bcf4def4eb08d85565e906b7d36516e87819db52029a76b6363d0f02d0d532f0033c9603b9e2d943d56ee3b0d4f7ad3328ff917 + languageName: node + linkType: hard + +"find-up@npm:5.0.0": + version: 5.0.0 + resolution: "find-up@npm:5.0.0" + dependencies: + locate-path: ^6.0.0 + path-exists: ^4.0.0 + checksum: 07955e357348f34660bde7920783204ff5a26ac2cafcaa28bace494027158a97b9f56faaf2d89a6106211a8174db650dd9f503f9c0d526b1202d5554a00b9095 + languageName: node + linkType: hard + +"flat@npm:^5.0.2": + version: 5.0.2 + resolution: "flat@npm:5.0.2" + bin: + flat: cli.js + checksum: 12a1536ac746db74881316a181499a78ef953632ddd28050b7a3a43c62ef5462e3357c8c29d76072bb635f147f7a9a1f0c02efef6b4be28f8db62ceb3d5c7f5d + languageName: node + linkType: hard + +"foreground-child@npm:^3.1.0": + version: 3.1.1 + resolution: "foreground-child@npm:3.1.1" + dependencies: + cross-spawn: ^7.0.0 + signal-exit: ^4.0.1 + checksum: 139d270bc82dc9e6f8bc045fe2aae4001dc2472157044fdfad376d0a3457f77857fa883c1c8b21b491c6caade9a926a4bed3d3d2e8d3c9202b151a4cbbd0bcd5 + languageName: node + linkType: hard + +"fs-minipass@npm:^2.0.0": + version: 2.1.0 + resolution: "fs-minipass@npm:2.1.0" + dependencies: + minipass: ^3.0.0 + checksum: 1b8d128dae2ac6cc94230cc5ead341ba3e0efaef82dab46a33d171c044caaa6ca001364178d42069b2809c35a1c3c35079a32107c770e9ffab3901b59af8c8b1 + languageName: node + linkType: hard + +"fs-minipass@npm:^3.0.0": + version: 3.0.2 + resolution: "fs-minipass@npm:3.0.2" + dependencies: + minipass: ^5.0.0 + checksum: e9cc0e1f2d01c6f6f62f567aee59530aba65c6c7b2ae88c5027bc34c711ebcfcfaefd0caf254afa6adfe7d1fba16bc2537508a6235196bac7276747d078aef0a + languageName: node + linkType: hard + +"fs.realpath@npm:^1.0.0": + version: 1.0.0 + resolution: "fs.realpath@npm:1.0.0" + checksum: 99ddea01a7e75aa276c250a04eedeffe5662bce66c65c07164ad6264f9de18fb21be9433ead460e54cff20e31721c811f4fb5d70591799df5f85dce6d6746fd0 + languageName: node + linkType: hard + +"fsevents@npm:~2.3.2": + version: 2.3.2 + resolution: "fsevents@npm:2.3.2" + dependencies: + node-gyp: latest + checksum: 97ade64e75091afee5265e6956cb72ba34db7819b4c3e94c431d4be2b19b8bb7a2d4116da417950c3425f17c8fe693d25e20212cac583ac1521ad066b77ae31f + conditions: os=darwin + languageName: node + linkType: hard + +"fsevents@patch:fsevents@~2.3.2#~builtin": + version: 2.3.2 + resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" + dependencies: + node-gyp: latest + conditions: os=darwin + languageName: node + linkType: hard + +"gauge@npm:^4.0.3": + version: 4.0.4 + resolution: "gauge@npm:4.0.4" + dependencies: + aproba: ^1.0.3 || ^2.0.0 + color-support: ^1.1.3 + console-control-strings: ^1.1.0 + has-unicode: ^2.0.1 + signal-exit: ^3.0.7 + string-width: ^4.2.3 + strip-ansi: ^6.0.1 + wide-align: ^1.1.5 + checksum: 788b6bfe52f1dd8e263cda800c26ac0ca2ff6de0b6eee2fe0d9e3abf15e149b651bd27bf5226be10e6e3edb5c4e5d5985a5a1a98137e7a892f75eff76467ad2d + languageName: node + linkType: hard + +"get-caller-file@npm:^2.0.5": + version: 2.0.5 + resolution: "get-caller-file@npm:2.0.5" + checksum: b9769a836d2a98c3ee734a88ba712e62703f1df31b94b784762c433c27a386dd6029ff55c2a920c392e33657d80191edbf18c61487e198844844516f843496b9 + languageName: node + linkType: hard + +"get-func-name@npm:^2.0.0": + version: 2.0.0 + resolution: "get-func-name@npm:2.0.0" + checksum: 8d82e69f3e7fab9e27c547945dfe5cc0c57fc0adf08ce135dddb01081d75684a03e7a0487466f478872b341d52ac763ae49e660d01ab83741f74932085f693c3 + languageName: node + linkType: hard + +"glob-parent@npm:~5.1.2": + version: 5.1.2 + resolution: "glob-parent@npm:5.1.2" + dependencies: + is-glob: ^4.0.1 + checksum: f4f2bfe2425296e8a47e36864e4f42be38a996db40420fe434565e4480e3322f18eb37589617a98640c5dc8fdec1a387007ee18dbb1f3f5553409c34d17f425e + languageName: node + linkType: hard + +"glob@npm:7.2.0": + version: 7.2.0 + resolution: "glob@npm:7.2.0" + dependencies: + fs.realpath: ^1.0.0 + inflight: ^1.0.4 + inherits: 2 + minimatch: ^3.0.4 + once: ^1.3.0 + path-is-absolute: ^1.0.0 + checksum: 78a8ea942331f08ed2e055cb5b9e40fe6f46f579d7fd3d694f3412fe5db23223d29b7fee1575440202e9a7ff9a72ab106a39fee39934c7bedafe5e5f8ae20134 + languageName: node + linkType: hard + +"glob@npm:^10.2.2": + version: 10.3.3 + resolution: "glob@npm:10.3.3" + dependencies: + foreground-child: ^3.1.0 + jackspeak: ^2.0.3 + minimatch: ^9.0.1 + minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 + path-scurry: ^1.10.1 + bin: + glob: dist/cjs/src/bin.js + checksum: 29190d3291f422da0cb40b77a72fc8d2c51a36524e99b8bf412548b7676a6627489528b57250429612b6eec2e6fe7826d328451d3e694a9d15e575389308ec53 + languageName: node + linkType: hard + +"glob@npm:^7.1.3, glob@npm:^7.1.4": + version: 7.2.3 + resolution: "glob@npm:7.2.3" + dependencies: + fs.realpath: ^1.0.0 + inflight: ^1.0.4 + inherits: 2 + minimatch: ^3.1.1 + once: ^1.3.0 + path-is-absolute: ^1.0.0 + checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133 + languageName: node + linkType: hard + +"graceful-fs@npm:^4.2.6": + version: 4.2.11 + resolution: "graceful-fs@npm:4.2.11" + checksum: ac85f94da92d8eb6b7f5a8b20ce65e43d66761c55ce85ac96df6865308390da45a8d3f0296dd3a663de65d30ba497bd46c696cc1e248c72b13d6d567138a4fc7 + languageName: node + linkType: hard + +"growl@npm:1.10.5": + version: 1.10.5 + resolution: "growl@npm:1.10.5" + checksum: 4b86685de6831cebcbb19f93870bea624afee61124b0a20c49017013987cd129e73a8c4baeca295728f41d21265e1f859d25ef36731b142ca59c655fea94bb1a + languageName: node + linkType: hard + +"has-flag@npm:^4.0.0": + version: 4.0.0 + resolution: "has-flag@npm:4.0.0" + checksum: 261a1357037ead75e338156b1f9452c016a37dcd3283a972a30d9e4a87441ba372c8b81f818cd0fbcd9c0354b4ae7e18b9e1afa1971164aef6d18c2b6095a8ad + languageName: node + linkType: hard + +"has-unicode@npm:^2.0.1": + version: 2.0.1 + resolution: "has-unicode@npm:2.0.1" + checksum: 1eab07a7436512db0be40a710b29b5dc21fa04880b7f63c9980b706683127e3c1b57cb80ea96d47991bdae2dfe479604f6a1ba410106ee1046a41d1bd0814400 + languageName: node + linkType: hard + +"he@npm:1.2.0": + version: 1.2.0 + resolution: "he@npm:1.2.0" + bin: + he: bin/he + checksum: 3d4d6babccccd79c5c5a3f929a68af33360d6445587d628087f39a965079d84f18ce9c3d3f917ee1e3978916fc833bb8b29377c3b403f919426f91bc6965e7a7 + languageName: node + linkType: hard + +"http-cache-semantics@npm:^4.1.1": + version: 4.1.1 + resolution: "http-cache-semantics@npm:4.1.1" + checksum: 83ac0bc60b17a3a36f9953e7be55e5c8f41acc61b22583060e8dedc9dd5e3607c823a88d0926f9150e571f90946835c7fe150732801010845c72cd8bbff1a236 + languageName: node + linkType: hard + +"http-proxy-agent@npm:^5.0.0": + version: 5.0.0 + resolution: "http-proxy-agent@npm:5.0.0" + dependencies: + "@tootallnate/once": 2 + agent-base: 6 + debug: 4 + checksum: e2ee1ff1656a131953839b2a19cd1f3a52d97c25ba87bd2559af6ae87114abf60971e498021f9b73f9fd78aea8876d1fb0d4656aac8a03c6caa9fc175f22b786 + languageName: node + linkType: hard + +"https-proxy-agent@npm:^5.0.0": + version: 5.0.1 + resolution: "https-proxy-agent@npm:5.0.1" + dependencies: + agent-base: 6 + debug: 4 + checksum: 571fccdf38184f05943e12d37d6ce38197becdd69e58d03f43637f7fa1269cf303a7d228aa27e5b27bbd3af8f09fd938e1c91dcfefff2df7ba77c20ed8dfc765 + languageName: node + linkType: hard + +"humanize-ms@npm:^1.2.1": + version: 1.2.1 + resolution: "humanize-ms@npm:1.2.1" + dependencies: + ms: ^2.0.0 + checksum: 9c7a74a2827f9294c009266c82031030eae811ca87b0da3dceb8d6071b9bde22c9f3daef0469c3c533cc67a97d8a167cd9fc0389350e5f415f61a79b171ded16 + languageName: node + linkType: hard + +"iconv-lite@npm:^0.6.2": + version: 0.6.3 + resolution: "iconv-lite@npm:0.6.3" + dependencies: + safer-buffer: ">= 2.1.2 < 3.0.0" + checksum: 3f60d47a5c8fc3313317edfd29a00a692cc87a19cac0159e2ce711d0ebc9019064108323b5e493625e25594f11c6236647d8e256fbe7a58f4a3b33b89e6d30bf + languageName: node + linkType: hard + +"ieee754@npm:^1.2.1": + version: 1.2.1 + resolution: "ieee754@npm:1.2.1" + checksum: 5144c0c9815e54ada181d80a0b810221a253562422e7c6c3a60b1901154184f49326ec239d618c416c1c5945a2e197107aee8d986a3dd836b53dffefd99b5e7e + languageName: node + linkType: hard + +"imurmurhash@npm:^0.1.4": + version: 0.1.4 + resolution: "imurmurhash@npm:0.1.4" + checksum: 7cae75c8cd9a50f57dadd77482359f659eaebac0319dd9368bcd1714f55e65badd6929ca58569da2b6494ef13fdd5598cd700b1eba23f8b79c5f19d195a3ecf7 + languageName: node + linkType: hard + +"indent-string@npm:^4.0.0": + version: 4.0.0 + resolution: "indent-string@npm:4.0.0" + checksum: 824cfb9929d031dabf059bebfe08cf3137365e112019086ed3dcff6a0a7b698cb80cf67ccccde0e25b9e2d7527aa6cc1fed1ac490c752162496caba3e6699612 + languageName: node + linkType: hard + +"inflight@npm:^1.0.4": + version: 1.0.6 + resolution: "inflight@npm:1.0.6" + dependencies: + once: ^1.3.0 + wrappy: 1 + checksum: f4f76aa072ce19fae87ce1ef7d221e709afb59d445e05d47fba710e85470923a75de35bfae47da6de1b18afc3ce83d70facf44cfb0aff89f0a3f45c0a0244dfd + languageName: node + linkType: hard + +"inherits@npm:2, inherits@npm:^2.0.3": + version: 2.0.4 + resolution: "inherits@npm:2.0.4" + checksum: 4a48a733847879d6cf6691860a6b1e3f0f4754176e4d71494c41f3475553768b10f84b5ce1d40fbd0e34e6bfbb864ee35858ad4dd2cf31e02fc4a154b724d7f1 + languageName: node + linkType: hard + +"ip@npm:^2.0.0": + version: 2.0.0 + resolution: "ip@npm:2.0.0" + checksum: cfcfac6b873b701996d71ec82a7dd27ba92450afdb421e356f44044ed688df04567344c36cbacea7d01b1c39a4c732dc012570ebe9bebfb06f27314bca625349 + languageName: node + linkType: hard + +"is-binary-path@npm:~2.1.0": + version: 2.1.0 + resolution: "is-binary-path@npm:2.1.0" + dependencies: + binary-extensions: ^2.0.0 + checksum: 84192eb88cff70d320426f35ecd63c3d6d495da9d805b19bc65b518984b7c0760280e57dbf119b7e9be6b161784a5a673ab2c6abe83abb5198a432232ad5b35c + languageName: node + linkType: hard + +"is-extglob@npm:^2.1.1": + version: 2.1.1 + resolution: "is-extglob@npm:2.1.1" + checksum: df033653d06d0eb567461e58a7a8c9f940bd8c22274b94bf7671ab36df5719791aae15eef6d83bbb5e23283967f2f984b8914559d4449efda578c775c4be6f85 + languageName: node + linkType: hard + +"is-fullwidth-code-point@npm:^3.0.0": + version: 3.0.0 + resolution: "is-fullwidth-code-point@npm:3.0.0" + checksum: 44a30c29457c7fb8f00297bce733f0a64cd22eca270f83e58c105e0d015e45c019491a4ab2faef91ab51d4738c670daff901c799f6a700e27f7314029e99e348 + languageName: node + linkType: hard + +"is-glob@npm:^4.0.1, is-glob@npm:~4.0.1": + version: 4.0.3 + resolution: "is-glob@npm:4.0.3" + dependencies: + is-extglob: ^2.1.1 + checksum: d381c1319fcb69d341cc6e6c7cd588e17cd94722d9a32dbd60660b993c4fb7d0f19438674e68dfec686d09b7c73139c9166b47597f846af387450224a8101ab4 + languageName: node + linkType: hard + +"is-lambda@npm:^1.0.1": + version: 1.0.1 + resolution: "is-lambda@npm:1.0.1" + checksum: 93a32f01940220532e5948538699ad610d5924ac86093fcee83022252b363eb0cc99ba53ab084a04e4fb62bf7b5731f55496257a4c38adf87af9c4d352c71c35 + languageName: node + linkType: hard + +"is-number@npm:^7.0.0": + version: 7.0.0 + resolution: "is-number@npm:7.0.0" + checksum: 456ac6f8e0f3111ed34668a624e45315201dff921e5ac181f8ec24923b99e9f32ca1a194912dc79d539c97d33dba17dc635202ff0b2cf98326f608323276d27a + languageName: node + linkType: hard + +"is-plain-obj@npm:^2.1.0": + version: 2.1.0 + resolution: "is-plain-obj@npm:2.1.0" + checksum: cec9100678b0a9fe0248a81743041ed990c2d4c99f893d935545cfbc42876cbe86d207f3b895700c690ad2fa520e568c44afc1605044b535a7820c1d40e38daa + languageName: node + linkType: hard + +"is-unicode-supported@npm:^0.1.0": + version: 0.1.0 + resolution: "is-unicode-supported@npm:0.1.0" + checksum: a2aab86ee7712f5c2f999180daaba5f361bdad1efadc9610ff5b8ab5495b86e4f627839d085c6530363c6d6d4ecbde340fb8e54bdb83da4ba8e0865ed5513c52 + languageName: node + linkType: hard + +"isexe@npm:^2.0.0": + version: 2.0.0 + resolution: "isexe@npm:2.0.0" + checksum: 26bf6c5480dda5161c820c5b5c751ae1e766c587b1f951ea3fcfc973bafb7831ae5b54a31a69bd670220e42e99ec154475025a468eae58ea262f813fdc8d1c62 + languageName: node + linkType: hard + +"isomorphic-ws@npm:^4.0.1": + version: 4.0.1 + resolution: "isomorphic-ws@npm:4.0.1" + peerDependencies: + ws: "*" + checksum: d7190eadefdc28bdb93d67b5f0c603385aaf87724fa2974abb382ac1ec9756ed2cfb27065cbe76122879c2d452e2982bc4314317f3d6c737ddda6c047328771a + languageName: node + linkType: hard + +"jackspeak@npm:^2.0.3": + version: 2.2.1 + resolution: "jackspeak@npm:2.2.1" + dependencies: + "@isaacs/cliui": ^8.0.2 + "@pkgjs/parseargs": ^0.11.0 + dependenciesMeta: + "@pkgjs/parseargs": + optional: true + checksum: e29291c0d0f280a063fa18fbd1e891ab8c2d7519fd34052c0ebde38538a15c603140d60c2c7f432375ff7ee4c5f1c10daa8b2ae19a97c3d4affe308c8360c1df + languageName: node + linkType: hard + +"jayson@npm:^4.1.0": + version: 4.1.0 + resolution: "jayson@npm:4.1.0" + dependencies: + "@types/connect": ^3.4.33 + "@types/node": ^12.12.54 + "@types/ws": ^7.4.4 + JSONStream: ^1.3.5 + commander: ^2.20.3 + delay: ^5.0.0 + es6-promisify: ^5.0.0 + eyes: ^0.1.8 + isomorphic-ws: ^4.0.1 + json-stringify-safe: ^5.0.1 + uuid: ^8.3.2 + ws: ^7.4.5 + bin: + jayson: bin/jayson.js + checksum: 86464322fbdc6db65d2bb4fc278cb6c86fad5c2a506065490d39459f09ba0d30f2b4fb740b33828a1424791419b6c8bd295dc54d361a4ad959bf70cc62b1ca7e + languageName: node + linkType: hard + +"js-sha256@npm:^0.9.0": + version: 0.9.0 + resolution: "js-sha256@npm:0.9.0" + checksum: ffad54b3373f81581e245866abfda50a62c483803a28176dd5c28fd2d313e0bdf830e77dac7ff8afd193c53031618920f3d98daf21cbbe80082753ab639c0365 + languageName: node + linkType: hard + +"js-yaml@npm:4.1.0": + version: 4.1.0 + resolution: "js-yaml@npm:4.1.0" + dependencies: + argparse: ^2.0.1 + bin: + js-yaml: bin/js-yaml.js + checksum: c7830dfd456c3ef2c6e355cc5a92e6700ceafa1d14bba54497b34a99f0376cecbb3e9ac14d3e5849b426d5a5140709a66237a8c991c675431271c4ce5504151a + languageName: node + linkType: hard + +"json-stringify-safe@npm:^5.0.1": + version: 5.0.1 + resolution: "json-stringify-safe@npm:5.0.1" + checksum: 48ec0adad5280b8a96bb93f4563aa1667fd7a36334f79149abd42446d0989f2ddc58274b479f4819f1f00617957e6344c886c55d05a4e15ebb4ab931e4a6a8ee + languageName: node + linkType: hard + +"json5@npm:^1.0.2": + version: 1.0.2 + resolution: "json5@npm:1.0.2" + dependencies: + minimist: ^1.2.0 + bin: + json5: lib/cli.js + checksum: 866458a8c58a95a49bef3adba929c625e82532bcff1fe93f01d29cb02cac7c3fe1f4b79951b7792c2da9de0b32871a8401a6e3c5b36778ad852bf5b8a61165d7 + languageName: node + linkType: hard + +"jsonparse@npm:^1.2.0": + version: 1.3.1 + resolution: "jsonparse@npm:1.3.1" + checksum: 6514a7be4674ebf407afca0eda3ba284b69b07f9958a8d3113ef1005f7ec610860c312be067e450c569aab8b89635e332cee3696789c750692bb60daba627f4d + languageName: node + linkType: hard + +"locate-path@npm:^6.0.0": + version: 6.0.0 + resolution: "locate-path@npm:6.0.0" + dependencies: + p-locate: ^5.0.0 + checksum: 72eb661788a0368c099a184c59d2fee760b3831c9c1c33955e8a19ae4a21b4116e53fa736dc086cdeb9fce9f7cc508f2f92d2d3aae516f133e16a2bb59a39f5a + languageName: node + linkType: hard + +"log-symbols@npm:4.1.0": + version: 4.1.0 + resolution: "log-symbols@npm:4.1.0" + dependencies: + chalk: ^4.1.0 + is-unicode-supported: ^0.1.0 + checksum: fce1497b3135a0198803f9f07464165e9eb83ed02ceb2273930a6f8a508951178d8cf4f0378e9d28300a2ed2bc49050995d2bd5f53ab716bb15ac84d58c6ef74 + languageName: node + linkType: hard + +"loupe@npm:^2.3.1": + version: 2.3.6 + resolution: "loupe@npm:2.3.6" + dependencies: + get-func-name: ^2.0.0 + checksum: cc83f1b124a1df7384601d72d8d1f5fe95fd7a8185469fec48bb2e4027e45243949e7a013e8d91051a138451ff0552310c32aa9786e60b6a30d1e801bdc2163f + languageName: node + linkType: hard + +"lower-case@npm:^2.0.2": + version: 2.0.2 + resolution: "lower-case@npm:2.0.2" + dependencies: + tslib: ^2.0.3 + checksum: 83a0a5f159ad7614bee8bf976b96275f3954335a84fad2696927f609ddae902802c4f3312d86668722e668bef41400254807e1d3a7f2e8c3eede79691aa1f010 + languageName: node + linkType: hard + +"lru-cache@npm:^6.0.0": + version: 6.0.0 + resolution: "lru-cache@npm:6.0.0" + dependencies: + yallist: ^4.0.0 + checksum: f97f499f898f23e4585742138a22f22526254fdba6d75d41a1c2526b3b6cc5747ef59c5612ba7375f42aca4f8461950e925ba08c991ead0651b4918b7c978297 + languageName: node + linkType: hard + +"lru-cache@npm:^7.7.1": + version: 7.18.3 + resolution: "lru-cache@npm:7.18.3" + checksum: e550d772384709deea3f141af34b6d4fa392e2e418c1498c078de0ee63670f1f46f5eee746e8ef7e69e1c895af0d4224e62ee33e66a543a14763b0f2e74c1356 + languageName: node + linkType: hard + +"lru-cache@npm:^9.1.1 || ^10.0.0": + version: 10.0.0 + resolution: "lru-cache@npm:10.0.0" + checksum: 18f101675fe283bc09cda0ef1e3cc83781aeb8373b439f086f758d1d91b28730950db785999cd060d3c825a8571c03073e8c14512b6655af2188d623031baf50 + languageName: node + linkType: hard + +"make-error@npm:^1.1.1": + version: 1.3.6 + resolution: "make-error@npm:1.3.6" + checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 + languageName: node + linkType: hard + +"make-fetch-happen@npm:^11.0.3": + version: 11.1.1 + resolution: "make-fetch-happen@npm:11.1.1" + dependencies: + agentkeepalive: ^4.2.1 + cacache: ^17.0.0 + http-cache-semantics: ^4.1.1 + http-proxy-agent: ^5.0.0 + https-proxy-agent: ^5.0.0 + is-lambda: ^1.0.1 + lru-cache: ^7.7.1 + minipass: ^5.0.0 + minipass-fetch: ^3.0.0 + minipass-flush: ^1.0.5 + minipass-pipeline: ^1.2.4 + negotiator: ^0.6.3 + promise-retry: ^2.0.1 + socks-proxy-agent: ^7.0.0 + ssri: ^10.0.0 + checksum: 7268bf274a0f6dcf0343829489a4506603ff34bd0649c12058753900b0eb29191dce5dba12680719a5d0a983d3e57810f594a12f3c18494e93a1fbc6348a4540 + languageName: node + linkType: hard + +"minimatch@npm:4.2.1": + version: 4.2.1 + resolution: "minimatch@npm:4.2.1" + dependencies: + brace-expansion: ^1.1.7 + checksum: 2b1514e3d0f29a549912f0db7ae7b82c5cab4a8f2dd0369f1c6451a325b3f12b2cf473c95873b6157bb8df183d6cf6db82ff03614b6adaaf1d7e055beccdfd01 + languageName: node + linkType: hard + +"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1": + version: 3.1.2 + resolution: "minimatch@npm:3.1.2" + dependencies: + brace-expansion: ^1.1.7 + checksum: c154e566406683e7bcb746e000b84d74465b3a832c45d59912b9b55cd50dee66e5c4b1e5566dba26154040e51672f9aa450a9aef0c97cfc7336b78b7afb9540a + languageName: node + linkType: hard + +"minimatch@npm:^9.0.1": + version: 9.0.3 + resolution: "minimatch@npm:9.0.3" + dependencies: + brace-expansion: ^2.0.1 + checksum: 253487976bf485b612f16bf57463520a14f512662e592e95c571afdab1442a6a6864b6c88f248ce6fc4ff0b6de04ac7aa6c8bb51e868e99d1d65eb0658a708b5 + languageName: node + linkType: hard + +"minimist@npm:^1.2.0, minimist@npm:^1.2.6": + version: 1.2.8 + resolution: "minimist@npm:1.2.8" + checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0 + languageName: node + linkType: hard + +"minipass-collect@npm:^1.0.2": + version: 1.0.2 + resolution: "minipass-collect@npm:1.0.2" + dependencies: + minipass: ^3.0.0 + checksum: 14df761028f3e47293aee72888f2657695ec66bd7d09cae7ad558da30415fdc4752bbfee66287dcc6fd5e6a2fa3466d6c484dc1cbd986525d9393b9523d97f10 + languageName: node + linkType: hard + +"minipass-fetch@npm:^3.0.0": + version: 3.0.3 + resolution: "minipass-fetch@npm:3.0.3" + dependencies: + encoding: ^0.1.13 + minipass: ^5.0.0 + minipass-sized: ^1.0.3 + minizlib: ^2.1.2 + dependenciesMeta: + encoding: + optional: true + checksum: af5ab2552a16fcf505d35fd7ffb84b57f4a0eeb269e6e1d9a2a75824dda48b36e527083250b7cca4a4def21d9544e2ade441e4730e233c0bc2133f6abda31e18 + languageName: node + linkType: hard + +"minipass-flush@npm:^1.0.5": + version: 1.0.5 + resolution: "minipass-flush@npm:1.0.5" + dependencies: + minipass: ^3.0.0 + checksum: 56269a0b22bad756a08a94b1ffc36b7c9c5de0735a4dd1ab2b06c066d795cfd1f0ac44a0fcae13eece5589b908ecddc867f04c745c7009be0b566421ea0944cf + languageName: node + linkType: hard + +"minipass-pipeline@npm:^1.2.4": + version: 1.2.4 + resolution: "minipass-pipeline@npm:1.2.4" + dependencies: + minipass: ^3.0.0 + checksum: b14240dac0d29823c3d5911c286069e36d0b81173d7bdf07a7e4a91ecdef92cdff4baaf31ea3746f1c61e0957f652e641223970870e2353593f382112257971b + languageName: node + linkType: hard + +"minipass-sized@npm:^1.0.3": + version: 1.0.3 + resolution: "minipass-sized@npm:1.0.3" + dependencies: + minipass: ^3.0.0 + checksum: 79076749fcacf21b5d16dd596d32c3b6bf4d6e62abb43868fac21674078505c8b15eaca4e47ed844985a4514854f917d78f588fcd029693709417d8f98b2bd60 + languageName: node + linkType: hard + +"minipass@npm:^3.0.0": + version: 3.3.6 + resolution: "minipass@npm:3.3.6" + dependencies: + yallist: ^4.0.0 + checksum: a30d083c8054cee83cdcdc97f97e4641a3f58ae743970457b1489ce38ee1167b3aaf7d815cd39ec7a99b9c40397fd4f686e83750e73e652b21cb516f6d845e48 + languageName: node + linkType: hard + +"minipass@npm:^5.0.0": + version: 5.0.0 + resolution: "minipass@npm:5.0.0" + checksum: 425dab288738853fded43da3314a0b5c035844d6f3097a8e3b5b29b328da8f3c1af6fc70618b32c29ff906284cf6406b6841376f21caaadd0793c1d5a6a620ea + languageName: node + linkType: hard + +"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0": + version: 7.0.2 + resolution: "minipass@npm:7.0.2" + checksum: 46776de732eb7cef2c7404a15fb28c41f5c54a22be50d47b03c605bf21f5c18d61a173c0a20b49a97e7a65f78d887245066410642551e45fffe04e9ac9e325bc + languageName: node + linkType: hard + +"minizlib@npm:^2.1.1, minizlib@npm:^2.1.2": + version: 2.1.2 + resolution: "minizlib@npm:2.1.2" + dependencies: + minipass: ^3.0.0 + yallist: ^4.0.0 + checksum: f1fdeac0b07cf8f30fcf12f4b586795b97be856edea22b5e9072707be51fc95d41487faec3f265b42973a304fe3a64acd91a44a3826a963e37b37bafde0212c3 + languageName: node + linkType: hard + +"mkdirp@npm:^0.5.1": + version: 0.5.6 + resolution: "mkdirp@npm:0.5.6" + dependencies: + minimist: ^1.2.6 + bin: + mkdirp: bin/cmd.js + checksum: 0c91b721bb12c3f9af4b77ebf73604baf350e64d80df91754dc509491ae93bf238581e59c7188360cec7cb62fc4100959245a42cfe01834efedc5e9d068376c2 + languageName: node + linkType: hard + +"mkdirp@npm:^1.0.3": + version: 1.0.4 + resolution: "mkdirp@npm:1.0.4" + bin: + mkdirp: bin/cmd.js + checksum: a96865108c6c3b1b8e1d5e9f11843de1e077e57737602de1b82030815f311be11f96f09cce59bd5b903d0b29834733e5313f9301e3ed6d6f6fba2eae0df4298f + languageName: node + linkType: hard + +"mocha@npm:^9.0.3": + version: 9.2.2 + resolution: "mocha@npm:9.2.2" + dependencies: + "@ungap/promise-all-settled": 1.1.2 + ansi-colors: 4.1.1 + browser-stdout: 1.3.1 + chokidar: 3.5.3 + debug: 4.3.3 + diff: 5.0.0 + escape-string-regexp: 4.0.0 + find-up: 5.0.0 + glob: 7.2.0 + growl: 1.10.5 + he: 1.2.0 + js-yaml: 4.1.0 + log-symbols: 4.1.0 + minimatch: 4.2.1 + ms: 2.1.3 + nanoid: 3.3.1 + serialize-javascript: 6.0.0 + strip-json-comments: 3.1.1 + supports-color: 8.1.1 + which: 2.0.2 + workerpool: 6.2.0 + yargs: 16.2.0 + yargs-parser: 20.2.4 + yargs-unparser: 2.0.0 + bin: + _mocha: bin/_mocha + mocha: bin/mocha + checksum: 4d5ca4ce33fc66627e63acdf09a634e2358c9a00f61de7788b1091b6aad430da04f97f9ecb82d56dc034b623cb833b65576136fd010d77679c03fcea5bc1e12d + languageName: node + linkType: hard + +"ms@npm:2.1.2": + version: 2.1.2 + resolution: "ms@npm:2.1.2" + checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f + languageName: node + linkType: hard + +"ms@npm:2.1.3, ms@npm:^2.0.0": + version: 2.1.3 + resolution: "ms@npm:2.1.3" + checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d + languageName: node + linkType: hard + +"mvdan-sh@npm:^0.5.0": + version: 0.5.0 + resolution: "mvdan-sh@npm:0.5.0" + checksum: b662308861c8d77076513d7f154ec2e340b28f34bedcf413450381255408dd6749b92b51b56946945cf016887789decfe7e89f3b201a71e3d908f59bd9e77474 + languageName: node + linkType: hard + +"nanoid@npm:3.3.1": + version: 3.3.1 + resolution: "nanoid@npm:3.3.1" + bin: + nanoid: bin/nanoid.cjs + checksum: 4ef0969e1bbe866fc223eb32276cbccb0961900bfe79104fa5abe34361979dead8d0e061410a5c03bc3d47455685adf32c09d6f27790f4a6898fb51f7df7ec86 + languageName: node + linkType: hard + +"negotiator@npm:^0.6.3": + version: 0.6.3 + resolution: "negotiator@npm:0.6.3" + checksum: b8ffeb1e262eff7968fc90a2b6767b04cfd9842582a9d0ece0af7049537266e7b2506dfb1d107a32f06dd849ab2aea834d5830f7f4d0e5cb7d36e1ae55d021d9 + languageName: node + linkType: hard + +"no-case@npm:^3.0.4": + version: 3.0.4 + resolution: "no-case@npm:3.0.4" + dependencies: + lower-case: ^2.0.2 + tslib: ^2.0.3 + checksum: 0b2ebc113dfcf737d48dde49cfebf3ad2d82a8c3188e7100c6f375e30eafbef9e9124aadc3becef237b042fd5eb0aad2fd78669c20972d045bbe7fea8ba0be5c + languageName: node + linkType: hard + +"node-fetch@npm:^2.6.11, node-fetch@npm:^2.6.12": + version: 2.6.12 + resolution: "node-fetch@npm:2.6.12" + dependencies: + whatwg-url: ^5.0.0 + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true + checksum: 3bc1655203d47ee8e313c0d96664b9673a3d4dd8002740318e9d27d14ef306693a4b2ef8d6525775056fd912a19e23f3ac0d7111ad8925877b7567b29a625592 + languageName: node + linkType: hard + +"node-gyp-build@npm:^4.3.0": + version: 4.6.0 + resolution: "node-gyp-build@npm:4.6.0" + bin: + node-gyp-build: bin.js + node-gyp-build-optional: optional.js + node-gyp-build-test: build-test.js + checksum: 25d78c5ef1f8c24291f4a370c47ba52fcea14f39272041a90a7894cd50d766f7c8cb8fb06c0f42bf6f69b204b49d9be3c8fc344aac09714d5bdb95965499eb15 + languageName: node + linkType: hard + +"node-gyp@npm:latest": + version: 9.4.0 + resolution: "node-gyp@npm:9.4.0" + dependencies: + env-paths: ^2.2.0 + exponential-backoff: ^3.1.1 + glob: ^7.1.4 + graceful-fs: ^4.2.6 + make-fetch-happen: ^11.0.3 + nopt: ^6.0.0 + npmlog: ^6.0.0 + rimraf: ^3.0.2 + semver: ^7.3.5 + tar: ^6.1.2 + which: ^2.0.2 + bin: + node-gyp: bin/node-gyp.js + checksum: 78b404e2e0639d64e145845f7f5a3cb20c0520cdaf6dda2f6e025e9b644077202ea7de1232396ba5bde3fee84cdc79604feebe6ba3ec84d464c85d407bb5da99 + languageName: node + linkType: hard + +"nopt@npm:^6.0.0": + version: 6.0.0 + resolution: "nopt@npm:6.0.0" + dependencies: + abbrev: ^1.0.0 + bin: + nopt: bin/nopt.js + checksum: 82149371f8be0c4b9ec2f863cc6509a7fd0fa729929c009f3a58e4eb0c9e4cae9920e8f1f8eb46e7d032fec8fb01bede7f0f41a67eb3553b7b8e14fa53de1dac + languageName: node + linkType: hard + +"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": + version: 3.0.0 + resolution: "normalize-path@npm:3.0.0" + checksum: 88eeb4da891e10b1318c4b2476b6e2ecbeb5ff97d946815ffea7794c31a89017c70d7f34b3c2ebf23ef4e9fc9fb99f7dffe36da22011b5b5c6ffa34f4873ec20 + languageName: node + linkType: hard + +"npmlog@npm:^6.0.0": + version: 6.0.2 + resolution: "npmlog@npm:6.0.2" + dependencies: + are-we-there-yet: ^3.0.0 + console-control-strings: ^1.1.0 + gauge: ^4.0.3 + set-blocking: ^2.0.0 + checksum: ae238cd264a1c3f22091cdd9e2b106f684297d3c184f1146984ecbe18aaa86343953f26b9520dedd1b1372bc0316905b736c1932d778dbeb1fcf5a1001390e2a + languageName: node + linkType: hard + +"once@npm:^1.3.0": + version: 1.4.0 + resolution: "once@npm:1.4.0" + dependencies: + wrappy: 1 + checksum: cd0a88501333edd640d95f0d2700fbde6bff20b3d4d9bdc521bdd31af0656b5706570d6c6afe532045a20bb8dc0849f8332d6f2a416e0ba6d3d3b98806c7db68 + languageName: node + linkType: hard + +"p-limit@npm:^3.0.2": + version: 3.1.0 + resolution: "p-limit@npm:3.1.0" + dependencies: + yocto-queue: ^0.1.0 + checksum: 7c3690c4dbf62ef625671e20b7bdf1cbc9534e83352a2780f165b0d3ceba21907e77ad63401708145ca4e25bfc51636588d89a8c0aeb715e6c37d1c066430360 + languageName: node + linkType: hard + +"p-locate@npm:^5.0.0": + version: 5.0.0 + resolution: "p-locate@npm:5.0.0" + dependencies: + p-limit: ^3.0.2 + checksum: 1623088f36cf1cbca58e9b61c4e62bf0c60a07af5ae1ca99a720837356b5b6c5ba3eb1b2127e47a06865fee59dd0453cad7cc844cda9d5a62ac1a5a51b7c86d3 + languageName: node + linkType: hard + +"p-map@npm:^4.0.0": + version: 4.0.0 + resolution: "p-map@npm:4.0.0" + dependencies: + aggregate-error: ^3.0.0 + checksum: cb0ab21ec0f32ddffd31dfc250e3afa61e103ef43d957cc45497afe37513634589316de4eb88abdfd969fe6410c22c0b93ab24328833b8eb1ccc087fc0442a1c + languageName: node + linkType: hard + +"pako@npm:^2.0.3": + version: 2.1.0 + resolution: "pako@npm:2.1.0" + checksum: 71666548644c9a4d056bcaba849ca6fd7242c6cf1af0646d3346f3079a1c7f4a66ffec6f7369ee0dc88f61926c10d6ab05da3e1fca44b83551839e89edd75a3e + languageName: node + linkType: hard + +"path-exists@npm:^4.0.0": + version: 4.0.0 + resolution: "path-exists@npm:4.0.0" + checksum: 505807199dfb7c50737b057dd8d351b82c033029ab94cb10a657609e00c1bc53b951cfdbccab8de04c5584d5eff31128ce6afd3db79281874a5ef2adbba55ed1 + languageName: node + linkType: hard + +"path-is-absolute@npm:^1.0.0": + version: 1.0.1 + resolution: "path-is-absolute@npm:1.0.1" + checksum: 060840f92cf8effa293bcc1bea81281bd7d363731d214cbe5c227df207c34cd727430f70c6037b5159c8a870b9157cba65e775446b0ab06fd5ecc7e54615a3b8 + languageName: node + linkType: hard + +"path-key@npm:^3.1.0": + version: 3.1.1 + resolution: "path-key@npm:3.1.1" + checksum: 55cd7a9dd4b343412a8386a743f9c746ef196e57c823d90ca3ab917f90ab9f13dd0ded27252ba49dbdfcab2b091d998bc446f6220cd3cea65db407502a740020 + languageName: node + linkType: hard + +"path-scurry@npm:^1.10.1": + version: 1.10.1 + resolution: "path-scurry@npm:1.10.1" + dependencies: + lru-cache: ^9.1.1 || ^10.0.0 + minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 + checksum: e2557cff3a8fb8bc07afdd6ab163a92587884f9969b05bbbaf6fe7379348bfb09af9ed292af12ed32398b15fb443e81692047b786d1eeb6d898a51eb17ed7d90 + languageName: node + linkType: hard + +"pathval@npm:^1.1.1": + version: 1.1.1 + resolution: "pathval@npm:1.1.1" + checksum: 090e3147716647fb7fb5b4b8c8e5b55e5d0a6086d085b6cd23f3d3c01fcf0ff56fd3cc22f2f4a033bd2e46ed55d61ed8379e123b42afe7d531a2a5fc8bb556d6 + languageName: node + linkType: hard + +"picomatch@npm:^2.0.4, picomatch@npm:^2.2.1": + version: 2.3.1 + resolution: "picomatch@npm:2.3.1" + checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf + languageName: node + linkType: hard + +"prettier-plugin-sh@npm:^0.7.1": + version: 0.7.1 + resolution: "prettier-plugin-sh@npm:0.7.1" + dependencies: + mvdan-sh: ^0.5.0 + peerDependencies: + prettier: ^2.0.5 + checksum: 861d66010cef9d354e96b1d980328dbf538f26b5c888697c2f2982e9d5b99db8df00c787293d9017b483acdcf6b226e9c86ea17b612d1c1c995a85255cc3a480 + languageName: node + linkType: hard + +"prettier-plugin-solidity@npm:^1.0.0-beta.14": + version: 1.0.0-beta.15 + resolution: "prettier-plugin-solidity@npm:1.0.0-beta.15" + dependencies: + "@solidity-parser/parser": ^0.13.2 + emoji-regex: ^9.2.2 + escape-string-regexp: ^4.0.0 + semver: ^7.3.5 + solidity-comments-extractor: ^0.0.7 + string-width: ^4.2.2 + peerDependencies: + prettier: ^2.3.0 + checksum: f2f7c78d871d3e15a9031279f1862c0856b92b04a1441b90b982d68c433f68782fd4d92a74fe9fccc611cadfb7e6030e1716afb7fb2f57309811fb09c6ce790f + languageName: node + linkType: hard + +"prettier@npm:^2.3.2": + version: 2.3.2 + resolution: "prettier@npm:2.3.2" + bin: + prettier: bin-prettier.js + checksum: 17ce5784ac67621c292df58e2da60b2ee150c2d6aebea22a6ad9e52fcd6a5e66c349d0a8436ea3bd8ff9d778920a5f68000d7625b74f43558718a49755aa5259 + languageName: node + linkType: hard + +"prettier@npm:^2.6.2": + version: 2.8.8 + resolution: "prettier@npm:2.8.8" + bin: + prettier: bin-prettier.js + checksum: b49e409431bf129dd89238d64299ba80717b57ff5a6d1c1a8b1a28b590d998a34e083fa13573bc732bb8d2305becb4c9a4407f8486c81fa7d55100eb08263cf8 + languageName: node + linkType: hard + +"promise-retry@npm:^2.0.1": + version: 2.0.1 + resolution: "promise-retry@npm:2.0.1" + dependencies: + err-code: ^2.0.2 + retry: ^0.12.0 + checksum: f96a3f6d90b92b568a26f71e966cbbc0f63ab85ea6ff6c81284dc869b41510e6cdef99b6b65f9030f0db422bf7c96652a3fff9f2e8fb4a0f069d8f4430359429 + languageName: node + linkType: hard + +"randombytes@npm:^2.1.0": + version: 2.1.0 + resolution: "randombytes@npm:2.1.0" + dependencies: + safe-buffer: ^5.1.0 + checksum: d779499376bd4cbb435ef3ab9a957006c8682f343f14089ed5f27764e4645114196e75b7f6abf1cbd84fd247c0cb0651698444df8c9bf30e62120fbbc52269d6 + languageName: node + linkType: hard + +"readable-stream@npm:^3.6.0": + version: 3.6.2 + resolution: "readable-stream@npm:3.6.2" + dependencies: + inherits: ^2.0.3 + string_decoder: ^1.1.1 + util-deprecate: ^1.0.1 + checksum: bdcbe6c22e846b6af075e32cf8f4751c2576238c5043169a1c221c92ee2878458a816a4ea33f4c67623c0b6827c8a400409bfb3cf0bf3381392d0b1dfb52ac8d + languageName: node + linkType: hard + +"readdirp@npm:~3.6.0": + version: 3.6.0 + resolution: "readdirp@npm:3.6.0" + dependencies: + picomatch: ^2.2.1 + checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 + languageName: node + linkType: hard + +"regenerator-runtime@npm:^0.13.11": + version: 0.13.11 + resolution: "regenerator-runtime@npm:0.13.11" + checksum: 27481628d22a1c4e3ff551096a683b424242a216fee44685467307f14d58020af1e19660bf2e26064de946bad7eff28950eae9f8209d55723e2d9351e632bbb4 + languageName: node + linkType: hard + +"require-directory@npm:^2.1.1": + version: 2.1.1 + resolution: "require-directory@npm:2.1.1" + checksum: fb47e70bf0001fdeabdc0429d431863e9475e7e43ea5f94ad86503d918423c1543361cc5166d713eaa7029dd7a3d34775af04764bebff99ef413111a5af18c80 + languageName: node + linkType: hard + +"retry@npm:^0.12.0": + version: 0.12.0 + resolution: "retry@npm:0.12.0" + checksum: 623bd7d2e5119467ba66202d733ec3c2e2e26568074923bc0585b6b99db14f357e79bdedb63cab56cec47491c4a0da7e6021a7465ca6dc4f481d3898fdd3158c + languageName: node + linkType: hard + +"rimraf@npm:^3.0.2": + version: 3.0.2 + resolution: "rimraf@npm:3.0.2" + dependencies: + glob: ^7.1.3 + bin: + rimraf: bin.js + checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0 + languageName: node + linkType: hard + +"root-workspace-0b6124@workspace:.": + version: 0.0.0-use.local + resolution: "root-workspace-0b6124@workspace:." + dependencies: + "@keep-network/prettier-config-keep": "github:keep-network/prettier-config-keep" + prettier: ^2.3.2 + prettier-plugin-sh: ^0.7.1 + prettier-plugin-solidity: ^1.0.0-beta.14 + languageName: unknown + linkType: soft + +"rpc-websockets@npm:^7.5.1": + version: 7.5.1 + resolution: "rpc-websockets@npm:7.5.1" + dependencies: + "@babel/runtime": ^7.17.2 + bufferutil: ^4.0.1 + eventemitter3: ^4.0.7 + utf-8-validate: ^5.0.2 + uuid: ^8.3.2 + ws: ^8.5.0 + dependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 9dda8c63a1d3e85e11597e1c364835ec6aa9a8de1b5cfb1629d0eafc3ae04509011d485025ed4f717c0b1dd048e2aafdd75080e866540b93e55fd8a2cd91bcfe + languageName: node + linkType: hard + +"safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:~5.2.0": + version: 5.2.1 + resolution: "safe-buffer@npm:5.2.1" + checksum: b99c4b41fdd67a6aaf280fcd05e9ffb0813654894223afb78a31f14a19ad220bba8aba1cb14eddce1fcfb037155fe6de4e861784eb434f7d11ed58d1e70dd491 + languageName: node + linkType: hard + +"safer-buffer@npm:>= 2.1.2 < 3.0.0": + version: 2.1.2 + resolution: "safer-buffer@npm:2.1.2" + checksum: cab8f25ae6f1434abee8d80023d7e72b598cf1327164ddab31003c51215526801e40b66c5e65d658a0af1e9d6478cadcb4c745f4bd6751f97d8644786c0978b0 + languageName: node + linkType: hard + +"semver@npm:^7.3.5": + version: 7.3.5 + resolution: "semver@npm:7.3.5" + dependencies: + lru-cache: ^6.0.0 + bin: + semver: bin/semver.js + checksum: 5eafe6102bea2a7439897c1856362e31cc348ccf96efd455c8b5bc2c61e6f7e7b8250dc26b8828c1d76a56f818a7ee907a36ae9fb37a599d3d24609207001d60 + languageName: node + linkType: hard + +"serialize-javascript@npm:6.0.0": + version: 6.0.0 + resolution: "serialize-javascript@npm:6.0.0" + dependencies: + randombytes: ^2.1.0 + checksum: 56f90b562a1bdc92e55afb3e657c6397c01a902c588c0fe3d4c490efdcc97dcd2a3074ba12df9e94630f33a5ce5b76a74784a7041294628a6f4306e0ec84bf93 + languageName: node + linkType: hard + +"set-blocking@npm:^2.0.0": + version: 2.0.0 + resolution: "set-blocking@npm:2.0.0" + checksum: 6e65a05f7cf7ebdf8b7c75b101e18c0b7e3dff4940d480efed8aad3a36a4005140b660fa1d804cb8bce911cac290441dc728084a30504d3516ac2ff7ad607b02 + languageName: node + linkType: hard + +"shebang-command@npm:^2.0.0": + version: 2.0.0 + resolution: "shebang-command@npm:2.0.0" + dependencies: + shebang-regex: ^3.0.0 + checksum: 6b52fe87271c12968f6a054e60f6bde5f0f3d2db483a1e5c3e12d657c488a15474121a1d55cd958f6df026a54374ec38a4a963988c213b7570e1d51575cea7fa + languageName: node + linkType: hard + +"shebang-regex@npm:^3.0.0": + version: 3.0.0 + resolution: "shebang-regex@npm:3.0.0" + checksum: 1a2bcae50de99034fcd92ad4212d8e01eedf52c7ec7830eedcf886622804fe36884278f2be8be0ea5fde3fd1c23911643a4e0f726c8685b61871c8908af01222 + languageName: node + linkType: hard + +"signal-exit@npm:^3.0.7": + version: 3.0.7 + resolution: "signal-exit@npm:3.0.7" + checksum: a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 + languageName: node + linkType: hard + +"signal-exit@npm:^4.0.1": + version: 4.0.2 + resolution: "signal-exit@npm:4.0.2" + checksum: 41f5928431cc6e91087bf0343db786a6313dd7c6fd7e551dbc141c95bb5fb26663444fd9df8ea47c5d7fc202f60aa7468c3162a9365cbb0615fc5e1b1328fe31 + languageName: node + linkType: hard + +"smart-buffer@npm:^4.2.0": + version: 4.2.0 + resolution: "smart-buffer@npm:4.2.0" + checksum: b5167a7142c1da704c0e3af85c402002b597081dd9575031a90b4f229ca5678e9a36e8a374f1814c8156a725d17008ae3bde63b92f9cfd132526379e580bec8b + languageName: node + linkType: hard + +"snake-case@npm:^3.0.4": + version: 3.0.4 + resolution: "snake-case@npm:3.0.4" + dependencies: + dot-case: ^3.0.4 + tslib: ^2.0.3 + checksum: 0a7a79900bbb36f8aaa922cf111702a3647ac6165736d5dc96d3ef367efc50465cac70c53cd172c382b022dac72ec91710608e5393de71f76d7142e6fd80e8a3 + languageName: node + linkType: hard + +"socks-proxy-agent@npm:^7.0.0": + version: 7.0.0 + resolution: "socks-proxy-agent@npm:7.0.0" + dependencies: + agent-base: ^6.0.2 + debug: ^4.3.3 + socks: ^2.6.2 + checksum: 720554370154cbc979e2e9ce6a6ec6ced205d02757d8f5d93fe95adae454fc187a5cbfc6b022afab850a5ce9b4c7d73e0f98e381879cf45f66317a4895953846 + languageName: node + linkType: hard + +"socks@npm:^2.6.2": + version: 2.7.1 + resolution: "socks@npm:2.7.1" + dependencies: + ip: ^2.0.0 + smart-buffer: ^4.2.0 + checksum: 259d9e3e8e1c9809a7f5c32238c3d4d2a36b39b83851d0f573bfde5f21c4b1288417ce1af06af1452569cd1eb0841169afd4998f0e04ba04656f6b7f0e46d748 + languageName: node + linkType: hard + +"solana-tbtc-anchor-924226@workspace:cross-chain/solana/solana-tbtc-anchor": + version: 0.0.0-use.local + resolution: "solana-tbtc-anchor-924226@workspace:cross-chain/solana/solana-tbtc-anchor" + dependencies: + "@coral-xyz/anchor": ^0.28.0 + "@solana/spl-token": ^0.3.8 + "@solana/web3.js": ^1.77.3 + "@types/bn.js": ^5.1.0 + "@types/chai": ^4.3.0 + "@types/mocha": ^9.0.0 + chai: ^4.3.4 + mocha: ^9.0.3 + prettier: ^2.6.2 + ts-mocha: ^10.0.0 + typescript: ^4.3.5 + languageName: unknown + linkType: soft + +"solidity-comments-extractor@npm:^0.0.7": + version: 0.0.7 + resolution: "solidity-comments-extractor@npm:0.0.7" + checksum: a5cedf2310709969bc1783a6c336171478536f2f0ea96ad88437e0ef1e8844c0b37dd75591b0a824ec9c30640ea7e31b5f03128e871e6235bef3426617ce96c4 + languageName: node + linkType: hard + +"source-map-support@npm:^0.5.6": + version: 0.5.21 + resolution: "source-map-support@npm:0.5.21" + dependencies: + buffer-from: ^1.0.0 + source-map: ^0.6.0 + checksum: 43e98d700d79af1d36f859bdb7318e601dfc918c7ba2e98456118ebc4c4872b327773e5a1df09b0524e9e5063bb18f0934538eace60cca2710d1fa687645d137 + languageName: node + linkType: hard + +"source-map@npm:^0.6.0": + version: 0.6.1 + resolution: "source-map@npm:0.6.1" + checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2 + languageName: node + linkType: hard + +"ssri@npm:^10.0.0": + version: 10.0.4 + resolution: "ssri@npm:10.0.4" + dependencies: + minipass: ^5.0.0 + checksum: fb14da9f8a72b04eab163eb13a9dda11d5962cd2317f85457c4e0b575e9a6e0e3a6a87b5bf122c75cb36565830cd5f263fb457571bf6f1587eb5f95d095d6165 + languageName: node + linkType: hard + +"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": + version: 4.2.3 + resolution: "string-width@npm:4.2.3" + dependencies: + emoji-regex: ^8.0.0 + is-fullwidth-code-point: ^3.0.0 + strip-ansi: ^6.0.1 + checksum: e52c10dc3fbfcd6c3a15f159f54a90024241d0f149cf8aed2982a2d801d2e64df0bf1dc351cf8e95c3319323f9f220c16e740b06faecd53e2462df1d2b5443fb + languageName: node + linkType: hard + +"string-width@npm:^4.2.2": + version: 4.2.2 + resolution: "string-width@npm:4.2.2" + dependencies: + emoji-regex: ^8.0.0 + is-fullwidth-code-point: ^3.0.0 + strip-ansi: ^6.0.0 + checksum: 343e089b0e66e0f72aab4ad1d9b6f2c9cc5255844b0c83fd9b53f2a3b3fd0421bdd6cb05be96a73117eb012db0887a6c1d64ca95aaa50c518e48980483fea0ab + languageName: node + linkType: hard + +"string-width@npm:^5.0.1, string-width@npm:^5.1.2": + version: 5.1.2 + resolution: "string-width@npm:5.1.2" + dependencies: + eastasianwidth: ^0.2.0 + emoji-regex: ^9.2.2 + strip-ansi: ^7.0.1 + checksum: 7369deaa29f21dda9a438686154b62c2c5f661f8dda60449088f9f980196f7908fc39fdd1803e3e01541970287cf5deae336798337e9319a7055af89dafa7193 + languageName: node + linkType: hard + +"string_decoder@npm:^1.1.1": + version: 1.3.0 + resolution: "string_decoder@npm:1.3.0" + dependencies: + safe-buffer: ~5.2.0 + checksum: 8417646695a66e73aefc4420eb3b84cc9ffd89572861fe004e6aeb13c7bc00e2f616247505d2dbbef24247c372f70268f594af7126f43548565c68c117bdeb56 + languageName: node + linkType: hard + +"strip-ansi-cjs@npm:strip-ansi@^6.0.1, strip-ansi@npm:^6.0.1": + version: 6.0.1 + resolution: "strip-ansi@npm:6.0.1" + dependencies: + ansi-regex: ^5.0.1 + checksum: f3cd25890aef3ba6e1a74e20896c21a46f482e93df4a06567cebf2b57edabb15133f1f94e57434e0a958d61186087b1008e89c94875d019910a213181a14fc8c + languageName: node + linkType: hard + +"strip-ansi@npm:^6.0.0": + version: 6.0.0 + resolution: "strip-ansi@npm:6.0.0" + dependencies: + ansi-regex: ^5.0.0 + checksum: 04c3239ede44c4d195b0e66c0ad58b932f08bec7d05290416d361ff908ad282ecdaf5d9731e322c84f151d427436bde01f05b7422c3ec26dd927586736b0e5d0 + languageName: node + linkType: hard + +"strip-ansi@npm:^7.0.1": + version: 7.1.0 + resolution: "strip-ansi@npm:7.1.0" + dependencies: + ansi-regex: ^6.0.1 + checksum: 859c73fcf27869c22a4e4d8c6acfe690064659e84bef9458aa6d13719d09ca88dcfd40cbf31fd0be63518ea1a643fe070b4827d353e09533a5b0b9fd4553d64d + languageName: node + linkType: hard + +"strip-bom@npm:^3.0.0": + version: 3.0.0 + resolution: "strip-bom@npm:3.0.0" + checksum: 8d50ff27b7ebe5ecc78f1fe1e00fcdff7af014e73cf724b46fb81ef889eeb1015fc5184b64e81a2efe002180f3ba431bdd77e300da5c6685d702780fbf0c8d5b + languageName: node + linkType: hard + +"strip-json-comments@npm:3.1.1": + version: 3.1.1 + resolution: "strip-json-comments@npm:3.1.1" + checksum: 492f73e27268f9b1c122733f28ecb0e7e8d8a531a6662efbd08e22cccb3f9475e90a1b82cab06a392f6afae6d2de636f977e231296400d0ec5304ba70f166443 + languageName: node + linkType: hard + +"superstruct@npm:^0.14.2": + version: 0.14.2 + resolution: "superstruct@npm:0.14.2" + checksum: c5c4840f432da82125b923ec45faca5113217e83ae416e314d80eae012b8bb603d2e745025d173450758d116348820bc7028157f8c9a72b6beae879f94b837c0 + languageName: node + linkType: hard + +"superstruct@npm:^0.15.4": + version: 0.15.5 + resolution: "superstruct@npm:0.15.5" + checksum: 6d1f5249fee789424b7178fa0a1ffb2ace629c5480c39505885bd8c0046a4ff8b267569a3442fa53b8c560a7ba6599cf3f8af94225aebeb2cf6023f7dd911050 + languageName: node + linkType: hard + +"supports-color@npm:8.1.1": + version: 8.1.1 + resolution: "supports-color@npm:8.1.1" + dependencies: + has-flag: ^4.0.0 + checksum: c052193a7e43c6cdc741eb7f378df605636e01ad434badf7324f17fb60c69a880d8d8fcdcb562cf94c2350e57b937d7425ab5b8326c67c2adc48f7c87c1db406 + languageName: node + linkType: hard + +"supports-color@npm:^7.1.0": + version: 7.2.0 + resolution: "supports-color@npm:7.2.0" + dependencies: + has-flag: ^4.0.0 + checksum: 3dda818de06ebbe5b9653e07842d9479f3555ebc77e9a0280caf5a14fb877ffee9ed57007c3b78f5a6324b8dbeec648d9e97a24e2ed9fdb81ddc69ea07100f4a + languageName: node + linkType: hard + +"tar@npm:^6.1.11, tar@npm:^6.1.2": + version: 6.1.15 + resolution: "tar@npm:6.1.15" + dependencies: + chownr: ^2.0.0 + fs-minipass: ^2.0.0 + minipass: ^5.0.0 + minizlib: ^2.1.1 + mkdirp: ^1.0.3 + yallist: ^4.0.0 + checksum: f23832fceeba7578bf31907aac744ae21e74a66f4a17a9e94507acf460e48f6db598c7023882db33bab75b80e027c21f276d405e4a0322d58f51c7088d428268 + languageName: node + linkType: hard + +"text-encoding-utf-8@npm:^1.0.2": + version: 1.0.2 + resolution: "text-encoding-utf-8@npm:1.0.2" + checksum: ec4c15d50e738c5dba7327ad432ebf0725ec75d4d69c0bd55609254c5a3bc5341272d7003691084a0a73d60d981c8eb0e87603676fdb6f3fed60f4c9192309f9 + languageName: node + linkType: hard + +"through@npm:>=2.2.7 <3": + version: 2.3.8 + resolution: "through@npm:2.3.8" + checksum: a38c3e059853c494af95d50c072b83f8b676a9ba2818dcc5b108ef252230735c54e0185437618596c790bbba8fcdaef5b290405981ffa09dce67b1f1bf190cbd + languageName: node + linkType: hard + +"to-regex-range@npm:^5.0.1": + version: 5.0.1 + resolution: "to-regex-range@npm:5.0.1" + dependencies: + is-number: ^7.0.0 + checksum: f76fa01b3d5be85db6a2a143e24df9f60dd047d151062d0ba3df62953f2f697b16fe5dad9b0ac6191c7efc7b1d9dcaa4b768174b7b29da89d4428e64bc0a20ed + languageName: node + linkType: hard + +"toml@npm:^3.0.0": + version: 3.0.0 + resolution: "toml@npm:3.0.0" + checksum: 5d7f1d8413ad7780e9bdecce8ea4c3f5130dd53b0a4f2e90b93340979a137739879d7b9ce2ce05c938b8cc828897fe9e95085197342a1377dd8850bf5125f15f + languageName: node + linkType: hard + +"tr46@npm:~0.0.3": + version: 0.0.3 + resolution: "tr46@npm:0.0.3" + checksum: 726321c5eaf41b5002e17ffbd1fb7245999a073e8979085dacd47c4b4e8068ff5777142fc6726d6ca1fd2ff16921b48788b87225cbc57c72636f6efa8efbffe3 + languageName: node + linkType: hard + +"ts-mocha@npm:^10.0.0": + version: 10.0.0 + resolution: "ts-mocha@npm:10.0.0" + dependencies: + ts-node: 7.0.1 + tsconfig-paths: ^3.5.0 + peerDependencies: + mocha: ^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X + dependenciesMeta: + tsconfig-paths: + optional: true + bin: + ts-mocha: bin/ts-mocha + checksum: b11f2a8ceecf195b0db724da429159982fef12e4357088fe900289223587217e8c126ead7929679edd58bf19ad96c5da5911535d26f535386632e18fbff10c40 + languageName: node + linkType: hard + +"ts-node@npm:7.0.1": + version: 7.0.1 + resolution: "ts-node@npm:7.0.1" + dependencies: + arrify: ^1.0.0 + buffer-from: ^1.1.0 + diff: ^3.1.0 + make-error: ^1.1.1 + minimist: ^1.2.0 + mkdirp: ^0.5.1 + source-map-support: ^0.5.6 + yn: ^2.0.0 + bin: + ts-node: dist/bin.js + checksum: 07ed6ea1805361828737a767cfd6c57ea6e267ee8679282afb933610af02405e1a87c1f2aea1d38ed8e66b34fcbf6272b6021ab95d78849105d2e57fc283870b + languageName: node + linkType: hard + +"tsconfig-paths@npm:^3.5.0": + version: 3.14.2 + resolution: "tsconfig-paths@npm:3.14.2" + dependencies: + "@types/json5": ^0.0.29 + json5: ^1.0.2 + minimist: ^1.2.6 + strip-bom: ^3.0.0 + checksum: a6162eaa1aed680537f93621b82399c7856afd10ec299867b13a0675e981acac4e0ec00896860480efc59fc10fd0b16fdc928c0b885865b52be62cadac692447 + languageName: node + linkType: hard + +"tslib@npm:^2.0.3": + version: 2.6.0 + resolution: "tslib@npm:2.6.0" + checksum: c01066038f950016a18106ddeca4649b4d76caa76ec5a31e2a26e10586a59fceb4ee45e96719bf6c715648e7c14085a81fee5c62f7e9ebee68e77a5396e5538f + languageName: node + linkType: hard + +"type-detect@npm:^4.0.0, type-detect@npm:^4.0.5": + version: 4.0.8 + resolution: "type-detect@npm:4.0.8" + checksum: 62b5628bff67c0eb0b66afa371bd73e230399a8d2ad30d852716efcc4656a7516904570cd8631a49a3ce57c10225adf5d0cbdcb47f6b0255fe6557c453925a15 + languageName: node + linkType: hard + +"typescript@npm:^4.3.5": + version: 4.9.5 + resolution: "typescript@npm:4.9.5" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db + languageName: node + linkType: hard + +"typescript@patch:typescript@^4.3.5#~builtin": + version: 4.9.5 + resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=289587" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 1f8f3b6aaea19f0f67cba79057674ba580438a7db55057eb89cc06950483c5d632115c14077f6663ea76fd09fce3c190e6414bb98582ec80aa5a4eaf345d5b68 + languageName: node + linkType: hard + +"unique-filename@npm:^3.0.0": + version: 3.0.0 + resolution: "unique-filename@npm:3.0.0" + dependencies: + unique-slug: ^4.0.0 + checksum: 8e2f59b356cb2e54aab14ff98a51ac6c45781d15ceaab6d4f1c2228b780193dc70fae4463ce9e1df4479cb9d3304d7c2043a3fb905bdeca71cc7e8ce27e063df + languageName: node + linkType: hard + +"unique-slug@npm:^4.0.0": + version: 4.0.0 + resolution: "unique-slug@npm:4.0.0" + dependencies: + imurmurhash: ^0.1.4 + checksum: 0884b58365af59f89739e6f71e3feacb5b1b41f2df2d842d0757933620e6de08eff347d27e9d499b43c40476cbaf7988638d3acb2ffbcb9d35fd035591adfd15 + languageName: node + linkType: hard + +"utf-8-validate@npm:^5.0.2": + version: 5.0.10 + resolution: "utf-8-validate@npm:5.0.10" + dependencies: + node-gyp: latest + node-gyp-build: ^4.3.0 + checksum: 5579350a023c66a2326752b6c8804cc7b39dcd251bb088241da38db994b8d78352e388dcc24ad398ab98385ba3c5ffcadb6b5b14b2637e43f767869055e46ba6 + languageName: node + linkType: hard + +"util-deprecate@npm:^1.0.1": + version: 1.0.2 + resolution: "util-deprecate@npm:1.0.2" + checksum: 474acf1146cb2701fe3b074892217553dfcf9a031280919ba1b8d651a068c9b15d863b7303cb15bd00a862b498e6cf4ad7b4a08fb134edd5a6f7641681cb54a2 + languageName: node + linkType: hard + +"uuid@npm:^8.3.2": + version: 8.3.2 + resolution: "uuid@npm:8.3.2" + bin: + uuid: dist/bin/uuid + checksum: 5575a8a75c13120e2f10e6ddc801b2c7ed7d8f3c8ac22c7ed0c7b2ba6383ec0abda88c905085d630e251719e0777045ae3236f04c812184b7c765f63a70e58df + languageName: node + linkType: hard + +"webidl-conversions@npm:^3.0.0": + version: 3.0.1 + resolution: "webidl-conversions@npm:3.0.1" + checksum: c92a0a6ab95314bde9c32e1d0a6dfac83b578f8fa5f21e675bc2706ed6981bc26b7eb7e6a1fab158e5ce4adf9caa4a0aee49a52505d4d13c7be545f15021b17c + languageName: node + linkType: hard + +"whatwg-url@npm:^5.0.0": + version: 5.0.0 + resolution: "whatwg-url@npm:5.0.0" + dependencies: + tr46: ~0.0.3 + webidl-conversions: ^3.0.0 + checksum: b8daed4ad3356cc4899048a15b2c143a9aed0dfae1f611ebd55073310c7b910f522ad75d727346ad64203d7e6c79ef25eafd465f4d12775ca44b90fa82ed9e2c + languageName: node + linkType: hard + +"which@npm:2.0.2, which@npm:^2.0.1, which@npm:^2.0.2": + version: 2.0.2 + resolution: "which@npm:2.0.2" + dependencies: + isexe: ^2.0.0 + bin: + node-which: ./bin/node-which + checksum: 1a5c563d3c1b52d5f893c8b61afe11abc3bab4afac492e8da5bde69d550de701cf9806235f20a47b5c8fa8a1d6a9135841de2596535e998027a54589000e66d1 + languageName: node + linkType: hard + +"wide-align@npm:^1.1.5": + version: 1.1.5 + resolution: "wide-align@npm:1.1.5" + dependencies: + string-width: ^1.0.2 || 2 || 3 || 4 + checksum: d5fc37cd561f9daee3c80e03b92ed3e84d80dde3365a8767263d03dacfc8fa06b065ffe1df00d8c2a09f731482fcacae745abfbb478d4af36d0a891fad4834d3 + languageName: node + linkType: hard + +"workerpool@npm:6.2.0": + version: 6.2.0 + resolution: "workerpool@npm:6.2.0" + checksum: 3493b4f0ef979a23d2c1583d7ef85f62fc9463cc02f82829d3e7e663b517f8ae9707da0249b382e46ac58986deb0ca2232ee1081713741211bda9254b429c9bb + languageName: node + linkType: hard + +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0, wrap-ansi@npm:^7.0.0": + version: 7.0.0 + resolution: "wrap-ansi@npm:7.0.0" + dependencies: + ansi-styles: ^4.0.0 + string-width: ^4.1.0 + strip-ansi: ^6.0.0 + checksum: a790b846fd4505de962ba728a21aaeda189b8ee1c7568ca5e817d85930e06ef8d1689d49dbf0e881e8ef84436af3a88bc49115c2e2788d841ff1b8b5b51a608b + languageName: node + linkType: hard + +"wrap-ansi@npm:^8.1.0": + version: 8.1.0 + resolution: "wrap-ansi@npm:8.1.0" + dependencies: + ansi-styles: ^6.1.0 + string-width: ^5.0.1 + strip-ansi: ^7.0.1 + checksum: 371733296dc2d616900ce15a0049dca0ef67597d6394c57347ba334393599e800bab03c41d4d45221b6bc967b8c453ec3ae4749eff3894202d16800fdfe0e238 + languageName: node + linkType: hard + +"wrappy@npm:1": + version: 1.0.2 + resolution: "wrappy@npm:1.0.2" + checksum: 159da4805f7e84a3d003d8841557196034155008f817172d4e986bd591f74aa82aa7db55929a54222309e01079a65a92a9e6414da5a6aa4b01ee44a511ac3ee5 + languageName: node + linkType: hard + +"ws@npm:^7.4.5": + version: 7.5.9 + resolution: "ws@npm:7.5.9" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: c3c100a181b731f40b7f2fddf004aa023f79d64f489706a28bc23ff88e87f6a64b3c6651fbec3a84a53960b75159574d7a7385709847a62ddb7ad6af76f49138 + languageName: node + linkType: hard + +"ws@npm:^8.5.0": + version: 8.13.0 + resolution: "ws@npm:8.13.0" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ">=5.0.2" + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 53e991bbf928faf5dc6efac9b8eb9ab6497c69feeb94f963d648b7a3530a720b19ec2e0ec037344257e05a4f35bd9ad04d9de6f289615ffb133282031b18c61c + languageName: node + linkType: hard + +"y18n@npm:^5.0.5": + version: 5.0.8 + resolution: "y18n@npm:5.0.8" + checksum: 54f0fb95621ee60898a38c572c515659e51cc9d9f787fb109cef6fde4befbe1c4602dc999d30110feee37456ad0f1660fa2edcfde6a9a740f86a290999550d30 + languageName: node + linkType: hard + +"yallist@npm:^4.0.0": + version: 4.0.0 + resolution: "yallist@npm:4.0.0" + checksum: 343617202af32df2a15a3be36a5a8c0c8545208f3d3dfbc6bb7c3e3b7e8c6f8e7485432e4f3b88da3031a6e20afa7c711eded32ddfb122896ac5d914e75848d5 + languageName: node + linkType: hard + +"yargs-parser@npm:20.2.4": + version: 20.2.4 + resolution: "yargs-parser@npm:20.2.4" + checksum: d251998a374b2743a20271c2fd752b9fbef24eb881d53a3b99a7caa5e8227fcafd9abf1f345ac5de46435821be25ec12189a11030c12ee6481fef6863ed8b924 + languageName: node + linkType: hard + +"yargs-parser@npm:^20.2.2": + version: 20.2.9 + resolution: "yargs-parser@npm:20.2.9" + checksum: 8bb69015f2b0ff9e17b2c8e6bfe224ab463dd00ca211eece72a4cd8a906224d2703fb8a326d36fdd0e68701e201b2a60ed7cf81ce0fd9b3799f9fe7745977ae3 + languageName: node + linkType: hard + +"yargs-unparser@npm:2.0.0": + version: 2.0.0 + resolution: "yargs-unparser@npm:2.0.0" + dependencies: + camelcase: ^6.0.0 + decamelize: ^4.0.0 + flat: ^5.0.2 + is-plain-obj: ^2.1.0 + checksum: 68f9a542c6927c3768c2f16c28f71b19008710abd6b8f8efbac6dcce26bbb68ab6503bed1d5994bdbc2df9a5c87c161110c1dfe04c6a3fe5c6ad1b0e15d9a8a3 + languageName: node + linkType: hard + +"yargs@npm:16.2.0": + version: 16.2.0 + resolution: "yargs@npm:16.2.0" + dependencies: + cliui: ^7.0.2 + escalade: ^3.1.1 + get-caller-file: ^2.0.5 + require-directory: ^2.1.1 + string-width: ^4.2.0 + y18n: ^5.0.5 + yargs-parser: ^20.2.2 + checksum: b14afbb51e3251a204d81937c86a7e9d4bdbf9a2bcee38226c900d00f522969ab675703bee2a6f99f8e20103f608382936034e64d921b74df82b63c07c5e8f59 + languageName: node + linkType: hard + +"yn@npm:^2.0.0": + version: 2.0.0 + resolution: "yn@npm:2.0.0" + checksum: 9d49527cb3e9a0948cc057223810bf30607bf04b9ff7666cc1681a6501d660b60d90000c16f9e29311b0f28d8a06222ada565ccdca5f1049cdfefb1908217572 + languageName: node + linkType: hard + +"yocto-queue@npm:^0.1.0": + version: 0.1.0 + resolution: "yocto-queue@npm:0.1.0" + checksum: f77b3d8d00310def622123df93d4ee654fc6a0096182af8bd60679ddcdfb3474c56c6c7190817c84a2785648cdee9d721c0154eb45698c62176c322fb46fc700 + languageName: node + linkType: hard From 8380f5be1ab559568fbe430bbf91a2446124f50f Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 13 Jul 2023 13:00:17 +0200 Subject: [PATCH 002/205] Added additional system test scenario --- system-tests/test/deposit-redemption.test.ts | 276 ++++++++++++++++++- 1 file changed, 275 insertions(+), 1 deletion(-) diff --git a/system-tests/test/deposit-redemption.test.ts b/system-tests/test/deposit-redemption.test.ts index f72a13894..f2e5310e0 100644 --- a/system-tests/test/deposit-redemption.test.ts +++ b/system-tests/test/deposit-redemption.test.ts @@ -47,6 +47,7 @@ describe("System Test - Deposit and redemption", () => { let systemTestsContext: SystemTestsContext let electrumClient: ElectrumClient let bridgeAddress: string + let vaultAddress: string let maintainerBridgeHandle: EthereumBridge let depositorBridgeHandle: EthereumBridge let bank: Contract @@ -77,6 +78,7 @@ describe("System Test - Deposit and redemption", () => { ) bridgeAddress = deployedContracts.Bridge.address + vaultAddress = deployedContracts.TBTCVault.address maintainerBridgeHandle = new EthereumBridge({ address: bridgeAddress, @@ -103,7 +105,7 @@ describe("System Test - Deposit and redemption", () => { ) }) - context("when deposit is made and revealed", () => { + context("when deposit is made and revealed without a vault", () => { before("make and reveal deposit", async () => { deposit = generateDeposit( systemTestsContext.depositor.address, @@ -372,4 +374,276 @@ describe("System Test - Deposit and redemption", () => { }) }) }) + + context("when deposit is made and revealed with a vault", () => { + before("make and reveal deposit", async () => { + deposit = generateDeposit( + systemTestsContext.depositor.address, + depositAmount, + systemTestsContext.walletBitcoinKeyPair.publicKey.compressed, + vaultAddress, + ) + + console.log(` + Generated deposit data: + ${JSON.stringify(deposit)} + `) + ;({ depositUtxo } = await submitDepositTransaction( + deposit, + systemTestsContext.depositorBitcoinKeyPair.wif, + electrumClient, + true + )) + + console.log(` + Deposit made on BTC chain: + - Transaction hash: ${depositUtxo.transactionHash} + - Output index: ${depositUtxo.outputIndex} + `) + + // Since the reveal deposit logic does not perform SPV proof, we + // can reveal the deposit transaction immediately without waiting + // for confirmations. + await TBTC.revealDeposit( + depositUtxo, + deposit, + electrumClient, + depositorBridgeHandle, + deposit.vault, + ) + + console.log(` + Deposit revealed on Ethereum chain + `) + }) + + it("should broadcast the deposit transaction on the Bitcoin network", async () => { + expect( + (await electrumClient.getRawTransaction(depositUtxo.transactionHash)) + .transactionHex.length + ).to.be.greaterThan(0) + }) + + it("should reveal the deposit to the bridge", async () => { + const { revealedAt } = await TBTC.getRevealedDeposit( + depositUtxo, + maintainerBridgeHandle + ) + expect(revealedAt).to.be.greaterThan(0) + }) + + context("when deposit is swept and sweep proof submitted", () => { + before("sweep the deposit and submit sweep proof", async () => { + ;({ newMainUtxo: sweepUtxo } = await submitDepositSweepTransaction( + electrumClient, + depositSweepTxFee, + systemTestsContext.walletBitcoinKeyPair.wif, + true, + [depositUtxo], + [deposit] + )) + + console.log(` + Deposit swept on Bitcoin chain: + - Transaction hash: ${sweepUtxo.transactionHash} + `) + + // Unlike in the deposit transaction case, we must wait for the sweep + // transaction to have an enough number of confirmations. This is + // because the bridge performs the SPV proof of that transaction. + await waitTransactionConfirmed( + electrumClient, + sweepUtxo.transactionHash + ) + + await fakeRelayDifficulty( + relay, + electrumClient, + sweepUtxo.transactionHash + ) + + // TODO: Consider fetching the current wallet main UTXO and passing it + // here. This will allow running this test scenario multiple + // times for the same wallet. + await SpvMaintainer.submitDepositSweepProof( + sweepUtxo.transactionHash, + // This is the first sweep of the given wallet so there is no main UTXO. + { + // The function expects an unprefixed hash. + transactionHash: BitcoinTransactionHash.from(constants.HashZero), + outputIndex: 0, + value: BigNumber.from(0), + }, + maintainerBridgeHandle, + electrumClient + ) + + console.log(` + Deposit sweep proved on the bridge + `) + }) + + it("should broadcast the sweep transaction on the Bitcoin network", async () => { + expect( + (await electrumClient.getRawTransaction(sweepUtxo.transactionHash)) + .transactionHex.length + ).to.be.greaterThan(0) + }) + + it("should sweep the deposit on the bridge", async () => { + const { sweptAt } = await TBTC.getRevealedDeposit( + depositUtxo, + maintainerBridgeHandle + ) + expect(sweptAt).to.be.greaterThan(0) + }) + + it("should increase depositor's balance in the bank", async () => { + const { treasuryFee } = await TBTC.getRevealedDeposit( + depositUtxo, + maintainerBridgeHandle + ) + + const expectedBalance = depositAmount + .sub(treasuryFee) + .sub(depositSweepTxFee) + + const actualBalance = await bank.balanceOf( + systemTestsContext.depositor.address + ) + + expect(actualBalance).to.be.equal(expectedBalance) + }) + + context("when redemption is requested", () => { + let requestedAmount: BigNumber + let redeemerOutputScript: string + let redemptionRequest: RedemptionRequest + + before("request the redemption", async () => { + // Redeem the full depositor's balance. + requestedAmount = await bank.balanceOf( + systemTestsContext.depositor.address + ) + + // Allow the bridge to take the redeemed bank balance. + await bank + .connect(systemTestsContext.depositor) + .approveBalance(bridgeAddress, requestedAmount) + + // Request redemption to depositor's address. + redeemerOutputScript = `0014${computeHash160( + systemTestsContext.depositorBitcoinKeyPair.publicKey.compressed + )}` + + await depositorBridgeHandle.requestRedemption( + systemTestsContext.walletBitcoinKeyPair.publicKey.compressed, + sweepUtxo, + redeemerOutputScript, + requestedAmount, + ) + + console.log( + `Requested redemption of amount ${requestedAmount} to script ${redeemerOutputScript} on the bridge` + ) + + redemptionRequest = await TBTC.getRedemptionRequest( + systemTestsContext.walletBitcoinKeyPair.publicKey.compressed, + redeemerOutputScript, + "pending", + maintainerBridgeHandle + ) + }) + + it("should transfer depositor's bank balance to the Bridge", async () => { + expect( + await bank.balanceOf(systemTestsContext.depositor.address) + ).to.be.equal(0) + + expect(await bank.balanceOf(bridgeAddress)).to.be.equal( + requestedAmount + ) + }) + + it("should register the redemption request on the bridge", async () => { + expect(redemptionRequest.requestedAt).to.be.greaterThan(0) + expect(redemptionRequest.requestedAmount).to.be.equal(requestedAmount) + expect(redemptionRequest.redeemerOutputScript).to.be.equal( + redeemerOutputScript + ) + }) + + context( + "when redemption is made and redemption proof submitted", + () => { + let redemptionTxHash: BitcoinTransactionHash + + before( + "make the redemption and submit redemption proof", + async () => { + ;({ transactionHash: redemptionTxHash } = + await submitRedemptionTransaction( + electrumClient, + maintainerBridgeHandle, + systemTestsContext.walletBitcoinKeyPair.wif, + sweepUtxo, + [redemptionRequest.redeemerOutputScript], + true + )) + + console.log( + "Redemption made on Bitcoin chain:\n" + + `- Transaction hash: ${redemptionTxHash}` + ) + + await waitTransactionConfirmed(electrumClient, redemptionTxHash) + + await fakeRelayDifficulty( + relay, + electrumClient, + redemptionTxHash + ) + + await SpvMaintainer.submitRedemptionProof( + redemptionTxHash, + sweepUtxo, + systemTestsContext.walletBitcoinKeyPair.publicKey.compressed, + maintainerBridgeHandle, + electrumClient + ) + + console.log("Redemption proved on the bridge") + } + ) + + it("should broadcast the redemption transaction on the Bitcoin network", async () => { + expect( + (await electrumClient.getRawTransaction(redemptionTxHash)) + .transactionHex.length + ).to.be.greaterThan(0) + }) + + it("should close the redemption request on the bridge", async () => { + await expect( + TBTC.getRedemptionRequest( + systemTestsContext.walletBitcoinKeyPair.publicKey.compressed, + redemptionRequest.redeemerOutputScript, + "pending", + maintainerBridgeHandle + ) + ).to.be.rejectedWith( + "Provided redeemer output script and wallet public key do not identify a redemption request" + ) + }) + + it("should decrease Bridge's balance in the bank", async () => { + const actualBalance = await bank.balanceOf(bridgeAddress) + + expect(actualBalance).to.be.equal(0) + }) + } + ) + }) + }) + }) }) From 7347a9359840274ecb08e9f92c09696b937ac60a Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Fri, 14 Jul 2023 14:52:27 +0100 Subject: [PATCH 003/205] Improve tests and add events --- .../programs/solana-tbtc-anchor/src/lib.rs | 36 ++++++++++--- .../tests/solana-tbtc-anchor.ts | 53 +++++++++++++++++++ 2 files changed, 83 insertions(+), 6 deletions(-) diff --git a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs index 8e5f50536..1094db6cd 100644 --- a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs +++ b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs @@ -28,12 +28,14 @@ pub mod solana_tbtc_anchor { minter_info.bump = *ctx.bumps.get("minter_info").unwrap(); ctx.accounts.tbtc.minters += 1; + emit!(MinterAdded { minter: ctx.accounts.minter.key() }); Ok(()) } - pub fn remove_minter(ctx: Context, _minter: Pubkey) -> Result<()> { + pub fn remove_minter(ctx: Context, minter: Pubkey) -> Result<()> { require!(ctx.accounts.tbtc.minters > 0, TbtcError::NoMinters); ctx.accounts.tbtc.minters -= 1; + emit!(MinterRemoved { minter: minter }); Ok(()) } @@ -43,12 +45,14 @@ pub mod solana_tbtc_anchor { guardian_info.bump = *ctx.bumps.get("guardian_info").unwrap(); ctx.accounts.tbtc.guardians += 1; + emit!(GuardianAdded { guardian: ctx.accounts.guardian.key() }); Ok(()) } - pub fn remove_guardian(ctx: Context, _minter: Pubkey) -> Result<()> { + pub fn remove_guardian(ctx: Context, guardian: Pubkey) -> Result<()> { require!(ctx.accounts.tbtc.guardians > 0, TbtcError::NoGuardians); ctx.accounts.tbtc.guardians -= 1; + emit!(GuardianRemoved { guardian: guardian }); Ok(()) } @@ -123,7 +127,7 @@ pub struct Initialize<'info> { seeds = [b"tbtc-mint", tbtc.key().as_ref()], bump, payer = creator, - mint::decimals = 8, + mint::decimals = 9, mint::authority = tbtc_mint, )] pub tbtc_mint: Account<'info, SplMint>, @@ -252,7 +256,7 @@ pub struct SetupMint<'info> { mut, seeds = [b"tbtc-mint", tbtc.key().as_ref()], bump = tbtc.token_bump, - mint::decimals = 8, + mint::decimals = 9, mint::authority = tbtc_mint, )] pub tbtc_mint: Account<'info, SplMint>, @@ -285,7 +289,7 @@ pub struct Mint<'info> { mut, seeds = [b"tbtc-mint", tbtc.key().as_ref()], bump = tbtc.token_bump, - mint::decimals = 8, + mint::decimals = 9, mint::authority = tbtc_mint, )] pub tbtc_mint: Account<'info, SplMint>, @@ -335,4 +339,24 @@ pub enum TbtcError { IsNotCreator, NoMinters, NoGuardians, -} \ No newline at end of file +} + +#[event] +pub struct MinterAdded { + pub minter: Pubkey, +} + +#[event] +pub struct MinterRemoved { + pub minter: Pubkey, +} + +#[event] +pub struct GuardianAdded { + pub guardian: Pubkey, +} + +#[event] +pub struct GuardianRemoved { + pub guardian: Pubkey, +} diff --git a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts index dd276109c..4058a706c 100644 --- a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts +++ b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts @@ -351,6 +351,32 @@ describe("solana-tbtc-anchor", () => { } }); + it('use two minters', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + const minter2InfoPDA = await addMinter(program, tbtcKeys, creator, minter2Keys, creator); + await checkMinter(program, tbtcKeys, minterKeys); + await checkMinter(program, tbtcKeys, minter2Keys); + await checkState(program, tbtcKeys, creator, 2, 0, 0); + await setupMint(program, tbtcKeys, creator, recipientKeys); + + // cannot mint with wrong keys + try { + await mint(program, tbtcKeys, minter2Keys, minterInfoPDA, recipientKeys, 1000); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('ConstraintSeeds'); + expect(err.program.equals(program.programId)).is.true; + } + + await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 500); + await checkState(program, tbtcKeys, creator, 2, 0, 500); + }); + it('remove minter', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); await setup(program, tbtcKeys, creator); @@ -441,4 +467,31 @@ describe("solana-tbtc-anchor", () => { expect(err.program.equals(program.programId)).is.true; } }) + + it('use two guardians', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, creator); + await checkState(program, tbtcKeys, creator, 0, 0, 0); + await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await addGuardian(program, tbtcKeys, creator, guardian2Keys, creator); + await checkGuardian(program, tbtcKeys, guardianKeys); + await checkGuardian(program, tbtcKeys, guardian2Keys); + await checkState(program, tbtcKeys, creator, 0, 2, 0); + + await pause(program, tbtcKeys, guardianKeys); + + try { + await pause(program, tbtcKeys, guardian2Keys); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsPaused'); + expect(err.program.equals(program.programId)).is.true; + } + + await unpause(program, tbtcKeys, creator); + await pause(program, tbtcKeys, guardian2Keys); + await checkPaused(program, tbtcKeys, true); + }); }); From 7aba3cf1f15c8d29d2a6668deafe9259a3b4f352 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 14 Jul 2023 15:55:06 +0200 Subject: [PATCH 004/205] Request redemption via tBTC token --- system-tests/test/deposit-redemption.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/system-tests/test/deposit-redemption.test.ts b/system-tests/test/deposit-redemption.test.ts index f2e5310e0..5d25820d5 100644 --- a/system-tests/test/deposit-redemption.test.ts +++ b/system-tests/test/deposit-redemption.test.ts @@ -21,6 +21,7 @@ import type { UnspentTransactionOutput } from "@keep-network/tbtc-v2.ts/dist/src import type { SystemTestsContext } from "./utils/context" import type { RedemptionRequest } from "@keep-network/tbtc-v2.ts/dist/src/redemption" import type { Deposit } from "@keep-network/tbtc-v2.ts/dist/src/deposit" +import { TBTCToken } from "@keep-network/tbtc-v2.ts/dist/src/ethereum" chai.use(chaiAsPromised) @@ -46,8 +47,10 @@ chai.use(chaiAsPromised) describe("System Test - Deposit and redemption", () => { let systemTestsContext: SystemTestsContext let electrumClient: ElectrumClient + let tbtcTokenAddress: string let bridgeAddress: string let vaultAddress: string + let tbtcTokenHandle: TBTCToken let maintainerBridgeHandle: EthereumBridge let depositorBridgeHandle: EthereumBridge let bank: Contract @@ -77,9 +80,15 @@ describe("System Test - Deposit and redemption", () => { ELECTRUM_RETRY_BACKOFF_STEP_MS ) + tbtcTokenAddress = deployedContracts.TBTC.address bridgeAddress = deployedContracts.Bridge.address vaultAddress = deployedContracts.TBTCVault.address + tbtcTokenHandle = new TBTCToken({ + address: tbtcTokenAddress, + signerOrProvider: depositor, + }) + maintainerBridgeHandle = new EthereumBridge({ address: bridgeAddress, signerOrProvider: maintainer, @@ -536,11 +545,12 @@ describe("System Test - Deposit and redemption", () => { systemTestsContext.depositorBitcoinKeyPair.publicKey.compressed )}` - await depositorBridgeHandle.requestRedemption( + await TBTC.requestRedemption( systemTestsContext.walletBitcoinKeyPair.publicKey.compressed, sweepUtxo, redeemerOutputScript, requestedAmount, + tbtcTokenHandle, ) console.log( From b55734cdcd58a691d1516bc6af35921da512998e Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 18 Jul 2023 12:23:10 +0200 Subject: [PATCH 005/205] Adjusted test scenario to account for the vault presence --- system-tests/test/deposit-redemption.test.ts | 56 ++++++++++++++------ 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/system-tests/test/deposit-redemption.test.ts b/system-tests/test/deposit-redemption.test.ts index 5d25820d5..17cdb3bd0 100644 --- a/system-tests/test/deposit-redemption.test.ts +++ b/system-tests/test/deposit-redemption.test.ts @@ -55,6 +55,7 @@ describe("System Test - Deposit and redemption", () => { let depositorBridgeHandle: EthereumBridge let bank: Contract let relay: Contract + let tbtc: Contract const depositAmount = BigNumber.from(2000000) const depositSweepTxFee = BigNumber.from(10000) @@ -63,6 +64,8 @@ describe("System Test - Deposit and redemption", () => { // Initial backoff step in milliseconds that will be increased exponentially for // subsequent Electrum retry attempts. const ELECTRUM_RETRY_BACKOFF_STEP_MS = 10000 // 10sec + // Multiplier to convert satoshi to TBTC token units. + const SATOSHI_MULTIPLIER: BigNumber = BigNumber.from("10000000000") let deposit: Deposit let depositUtxo: UnspentTransactionOutput @@ -112,6 +115,13 @@ describe("System Test - Deposit and redemption", () => { relayDeploymentInfo.abi, maintainer ) + + const tbtcDeploymentInfo = deployedContracts.TBTC + tbtc = new Contract( + tbtcDeploymentInfo.address, + tbtcDeploymentInfo.abi, + maintainer + ) }) context("when deposit is made and revealed without a vault", () => { @@ -484,7 +494,8 @@ describe("System Test - Deposit and redemption", () => { value: BigNumber.from(0), }, maintainerBridgeHandle, - electrumClient + electrumClient, + deposit.vault, ) console.log(` @@ -507,7 +518,7 @@ describe("System Test - Deposit and redemption", () => { expect(sweptAt).to.be.greaterThan(0) }) - it("should increase depositor's balance in the bank", async () => { + it("should increase vault's balance in the bank", async () => { const { treasuryFee } = await TBTC.getRevealedDeposit( depositUtxo, maintainerBridgeHandle @@ -518,27 +529,44 @@ describe("System Test - Deposit and redemption", () => { .sub(depositSweepTxFee) const actualBalance = await bank.balanceOf( - systemTestsContext.depositor.address + vaultAddress ) expect(actualBalance).to.be.equal(expectedBalance) }) + it("should mint TBTC tokens for the depositor", async () => { + const { treasuryFee } = await TBTC.getRevealedDeposit( + depositUtxo, + maintainerBridgeHandle + ) + + const balanceInSatoshis = depositAmount + .sub(treasuryFee) + .sub(depositSweepTxFee) + + const expectedTbtcBalance = balanceInSatoshis.mul(SATOSHI_MULTIPLIER) + + const actualBalance = tbtc.balanceOf( + systemTestsContext.depositor.address + ) + + expect(actualBalance).to.be.equal(expectedTbtcBalance) + }) + context("when redemption is requested", () => { let requestedAmount: BigNumber let redeemerOutputScript: string let redemptionRequest: RedemptionRequest before("request the redemption", async () => { - // Redeem the full depositor's balance. - requestedAmount = await bank.balanceOf( + // Redeem all of the depositor's TBTC tokens. + const tbtcBalanceOfDepositor = await tbtc.balanceOf( systemTestsContext.depositor.address ) - // Allow the bridge to take the redeemed bank balance. - await bank - .connect(systemTestsContext.depositor) - .approveBalance(bridgeAddress, requestedAmount) + // The depositor's balance converted to satoshis. + requestedAmount = tbtcBalanceOfDepositor.div(SATOSHI_MULTIPLIER) // Request redemption to depositor's address. redeemerOutputScript = `0014${computeHash160( @@ -549,12 +577,12 @@ describe("System Test - Deposit and redemption", () => { systemTestsContext.walletBitcoinKeyPair.publicKey.compressed, sweepUtxo, redeemerOutputScript, - requestedAmount, + tbtcBalanceOfDepositor, tbtcTokenHandle, ) console.log( - `Requested redemption of amount ${requestedAmount} to script ${redeemerOutputScript} on the bridge` + `Requested redemption of ${tbtcBalanceOfDepositor} TBTC tokens to script ${redeemerOutputScript} on the bridge` ) redemptionRequest = await TBTC.getRedemptionRequest( @@ -565,10 +593,8 @@ describe("System Test - Deposit and redemption", () => { ) }) - it("should transfer depositor's bank balance to the Bridge", async () => { - expect( - await bank.balanceOf(systemTestsContext.depositor.address) - ).to.be.equal(0) + it("should transfer vault's bank balance to the Bridge", async () => { + expect(await bank.balanceOf(vaultAddress)).to.be.equal(0) expect(await bank.balanceOf(bridgeAddress)).to.be.equal( requestedAmount From b86a03976f34cac98844e509d53eba9ae20df7e9 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Tue, 18 Jul 2023 15:54:20 +0100 Subject: [PATCH 006/205] Update config and improve tests --- .../solana/solana-tbtc-anchor/Anchor.toml | 2 +- .../programs/solana-tbtc-anchor/src/lib.rs | 16 ++-- .../tests/solana-tbtc-anchor.ts | 76 +++++++++++++++++-- 3 files changed, 77 insertions(+), 17 deletions(-) diff --git a/cross-chain/solana/solana-tbtc-anchor/Anchor.toml b/cross-chain/solana/solana-tbtc-anchor/Anchor.toml index 6fab30aa2..94b4df4ae 100644 --- a/cross-chain/solana/solana-tbtc-anchor/Anchor.toml +++ b/cross-chain/solana/solana-tbtc-anchor/Anchor.toml @@ -9,7 +9,7 @@ url = "https://api.apr.dev" [provider] cluster = "Localnet" -wallet = "/home/eth/.config/solana/id.json" +wallet = "~/.config/solana/id.json" [scripts] test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" diff --git a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs index 1094db6cd..2931a8720 100644 --- a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs +++ b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs @@ -33,7 +33,7 @@ pub mod solana_tbtc_anchor { } pub fn remove_minter(ctx: Context, minter: Pubkey) -> Result<()> { - require!(ctx.accounts.tbtc.minters > 0, TbtcError::NoMinters); + // require!(ctx.accounts.tbtc.minters > 0, TbtcError::NoMinters); ctx.accounts.tbtc.minters -= 1; emit!(MinterRemoved { minter: minter }); Ok(()) @@ -50,7 +50,7 @@ pub mod solana_tbtc_anchor { } pub fn remove_guardian(ctx: Context, guardian: Pubkey) -> Result<()> { - require!(ctx.accounts.tbtc.guardians > 0, TbtcError::NoGuardians); + // require!(ctx.accounts.tbtc.guardians > 0, TbtcError::NoGuardians); ctx.accounts.tbtc.guardians -= 1; emit!(GuardianRemoved { guardian: guardian }); Ok(()) @@ -208,7 +208,7 @@ pub struct AddGuardian<'info> { pub struct RemoveGuardian<'info> { #[account( mut, - has_one = creator @ TbtcError::IsNotCreator + has_one = creator @ TbtcError::IsNotCreator, )] pub tbtc: Account<'info, Tbtc>, pub creator: Signer<'info>, @@ -331,14 +331,14 @@ impl Tbtc { #[error_code] pub enum TbtcError { - AlreadyCreated, + // AlreadyCreated, IsPaused, IsNotPaused, - IsNotMinter, - IsNotGuardian, + // IsNotMinter, + // IsNotGuardian, IsNotCreator, - NoMinters, - NoGuardians, + // NoMinters, + // NoGuardians, } #[event] diff --git a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts index 4058a706c..25031ae30 100644 --- a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts +++ b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts @@ -5,6 +5,13 @@ import * as web3 from '@solana/web3.js'; import { SolanaTbtcAnchor } from "../target/types/solana_tbtc_anchor"; import { expect } from 'chai'; +function maybeCreatorAnd( + signer, + signers +) { + return signers.concat(signer instanceof (anchor.Wallet as any) ? [] : [signer]); +} + async function setup( program: Program, tbtc, @@ -29,7 +36,7 @@ async function checkState( expectedCreator, expectedMinters, expectedGuardians, - expectedTokens + expectedTokensSupply ) { let tbtcState = await program.account.tbtc.fetch(tbtc.publicKey); @@ -41,7 +48,7 @@ async function checkState( let mintState = await spl.getMint(program.provider.connection, tbtcMint); - expect(mintState.supply == expectedTokens).to.be.true; + expect(mintState.supply == expectedTokensSupply).to.be.true; } async function checkPaused( @@ -98,7 +105,7 @@ async function addMinter( payer: payer.publicKey, minterInfo: minterInfoPDA, }) - .signers([minter]) + .signers(maybeCreatorAnd(creator, [minter])) .rpc(); return minterInfoPDA; } @@ -129,7 +136,7 @@ async function removeMinter( creator: creator.publicKey, minterInfo: minterInfo, }) - .signers([]) + .signers(maybeCreatorAnd(creator, [])) .rpc(); } @@ -165,7 +172,7 @@ async function addGuardian( payer: payer.publicKey, guardianInfo: guardianInfoPDA, }) - .signers([guardian]) + .signers(maybeCreatorAnd(creator, [guardian])) .rpc(); return guardianInfoPDA; } @@ -196,7 +203,7 @@ async function removeGuardian( creator: creator.publicKey, guardianInfo: guardianInfo, }) - .signers([]) + .signers(maybeCreatorAnd(creator, [])) .rpc(); } @@ -228,7 +235,7 @@ async function unpause( tbtc: tbtc.publicKey, creator: creator.publicKey }) - .signers([]) + .signers(maybeCreatorAnd(creator, [])) .rpc(); } @@ -314,6 +321,16 @@ describe("solana-tbtc-anchor", () => { await addMinter(program, tbtcKeys, creator, minterKeys, creator); await checkMinter(program, tbtcKeys, minterKeys); await checkState(program, tbtcKeys, creator, 1, 0, 0); + + try { + await addMinter(program, tbtcKeys, impostorKeys, minter2Keys, creator); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsNotCreator'); + expect(err.program.equals(program.programId)).is.true; + } }); it('mint', async () => { @@ -373,6 +390,17 @@ describe("solana-tbtc-anchor", () => { expect(err.program.equals(program.programId)).is.true; } + // cannot remove minter with wrong keys + try { + await removeMinter(program, tbtcKeys, creator, minter2Keys, minterInfoPDA); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('ConstraintSeeds'); + expect(err.program.equals(program.programId)).is.true; + } + await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 500); await checkState(program, tbtcKeys, creator, 2, 0, 500); }); @@ -426,6 +454,15 @@ describe("solana-tbtc-anchor", () => { await checkState(program, tbtcKeys, creator, 0, 1, 0); await removeGuardian(program, tbtcKeys, creator, guardianKeys, guardianInfoPDA); await checkState(program, tbtcKeys, creator, 0, 0, 0); + + try { + await removeGuardian(program, tbtcKeys, creator, guardianKeys, guardianInfoPDA); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('AccountNotInitialized'); + expect(err.program.equals(program.programId)).is.true; + } }); it('pause', async () => { @@ -446,6 +483,17 @@ describe("solana-tbtc-anchor", () => { await checkPaused(program, tbtcKeys, true); await unpause(program, tbtcKeys, creator); await checkPaused(program, tbtcKeys, false); + + try { + await unpause(program, tbtcKeys, creator); + + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsNotPaused'); + expect(err.program.equals(program.programId)).is.true; + } }); it('won\'t mint when paused', async () => { @@ -472,7 +520,7 @@ describe("solana-tbtc-anchor", () => { const tbtcKeys = anchor.web3.Keypair.generate(); await setup(program, tbtcKeys, creator); await checkState(program, tbtcKeys, creator, 0, 0, 0); - await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + const guardianInfoPDA = await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); await addGuardian(program, tbtcKeys, creator, guardian2Keys, creator); await checkGuardian(program, tbtcKeys, guardianKeys); await checkGuardian(program, tbtcKeys, guardian2Keys); @@ -493,5 +541,17 @@ describe("solana-tbtc-anchor", () => { await unpause(program, tbtcKeys, creator); await pause(program, tbtcKeys, guardian2Keys); await checkPaused(program, tbtcKeys, true); + await unpause(program, tbtcKeys, creator); + + // cannot remove guardian with wrong keys + try { + await removeGuardian(program, tbtcKeys, creator, guardian2Keys, guardianInfoPDA); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('ConstraintSeeds'); + expect(err.program.equals(program.programId)).is.true; + } }); }); From d891662b3f181a69752191d054ee3a954fde0778 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Tue, 18 Jul 2023 16:01:58 +0100 Subject: [PATCH 007/205] Test more errors --- .../tests/solana-tbtc-anchor.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts index 25031ae30..29b52d491 100644 --- a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts +++ b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts @@ -423,6 +423,16 @@ describe("solana-tbtc-anchor", () => { const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); await checkMinter(program, tbtcKeys, minterKeys); await checkState(program, tbtcKeys, creator, 1, 0, 0); + + try { + await removeMinter(program, tbtcKeys, impostorKeys, minterKeys, minterInfoPDA); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsNotCreator'); + expect(err.program.equals(program.programId)).is.true; + } + await removeMinter(program, tbtcKeys, creator, minterKeys, minterInfoPDA); await checkState(program, tbtcKeys, creator, 0, 0, 0); @@ -443,6 +453,16 @@ describe("solana-tbtc-anchor", () => { await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); await checkGuardian(program, tbtcKeys, guardianKeys); await checkState(program, tbtcKeys, creator, 0, 1, 0); + + try { + await addGuardian(program, tbtcKeys, impostorKeys, guardian2Keys, creator); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsNotCreator'); + expect(err.program.equals(program.programId)).is.true; + } }); it('remove guardian', async () => { @@ -452,11 +472,23 @@ describe("solana-tbtc-anchor", () => { const guardianInfoPDA = await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); await checkGuardian(program, tbtcKeys, guardianKeys); await checkState(program, tbtcKeys, creator, 0, 1, 0); + + try { + await removeGuardian(program, tbtcKeys, impostorKeys, guardianKeys, guardianInfoPDA); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsNotCreator'); + expect(err.program.equals(program.programId)).is.true; + } + await removeGuardian(program, tbtcKeys, creator, guardianKeys, guardianInfoPDA); await checkState(program, tbtcKeys, creator, 0, 0, 0); try { await removeGuardian(program, tbtcKeys, creator, guardianKeys, guardianInfoPDA); + chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); const err: AnchorError = _err; From 580040f96fbae562b90af74a33bc6209434207a3 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 18 Jul 2023 17:24:16 +0200 Subject: [PATCH 008/205] Added missing unit test checks --- system-tests/test/deposit-redemption.test.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/system-tests/test/deposit-redemption.test.ts b/system-tests/test/deposit-redemption.test.ts index 17cdb3bd0..2ccbc5735 100644 --- a/system-tests/test/deposit-redemption.test.ts +++ b/system-tests/test/deposit-redemption.test.ts @@ -65,7 +65,7 @@ describe("System Test - Deposit and redemption", () => { // subsequent Electrum retry attempts. const ELECTRUM_RETRY_BACKOFF_STEP_MS = 10000 // 10sec // Multiplier to convert satoshi to TBTC token units. - const SATOSHI_MULTIPLIER: BigNumber = BigNumber.from("10000000000") + const SATOSHI_MULTIPLIER = BigNumber.from(10000000000) let deposit: Deposit let depositUtxo: UnspentTransactionOutput @@ -547,7 +547,7 @@ describe("System Test - Deposit and redemption", () => { const expectedTbtcBalance = balanceInSatoshis.mul(SATOSHI_MULTIPLIER) - const actualBalance = tbtc.balanceOf( + const actualBalance = await tbtc.balanceOf( systemTestsContext.depositor.address ) @@ -593,6 +593,14 @@ describe("System Test - Deposit and redemption", () => { ) }) + it("should unmint depositor's TBTC tokens", async () => { + const tbtcBalance = await tbtc.balanceOf( + systemTestsContext.depositor.address + ) + + expect(tbtcBalance).to.be.equal(0) + }) + it("should transfer vault's bank balance to the Bridge", async () => { expect(await bank.balanceOf(vaultAddress)).to.be.equal(0) From 360ee5b7c8084761984a4567ba0f22d9596f88f8 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Wed, 19 Jul 2023 12:32:41 +0100 Subject: [PATCH 009/205] Replace creator with authority --- .../programs/solana-tbtc-anchor/src/lib.rs | 41 ++-- .../tests/solana-tbtc-anchor.ts | 192 +++++++++--------- 2 files changed, 114 insertions(+), 119 deletions(-) diff --git a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs index 2931a8720..288355645 100644 --- a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs +++ b/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs @@ -13,7 +13,7 @@ pub mod solana_tbtc_anchor { pub fn initialize(ctx: Context) -> Result<()> { let tbtc = &mut ctx.accounts.tbtc; - tbtc.creator = ctx.accounts.creator.key(); + tbtc.authority = ctx.accounts.authority.key(); tbtc.token_mint = ctx.accounts.tbtc_mint.key(); tbtc.token_bump = *ctx.bumps.get("tbtc_mint").unwrap(); tbtc.minters = 0; @@ -96,7 +96,7 @@ pub mod solana_tbtc_anchor { #[account] #[derive(Default)] pub struct Tbtc { - creator: Pubkey, + authority: Pubkey, token_mint: Pubkey, token_bump: u8, minters: u8, @@ -126,17 +126,17 @@ pub struct Initialize<'info> { init, seeds = [b"tbtc-mint", tbtc.key().as_ref()], bump, - payer = creator, + payer = authority, mint::decimals = 9, mint::authority = tbtc_mint, )] pub tbtc_mint: Account<'info, SplMint>, - #[account(init, payer = creator, space = 8 + Tbtc::MAXIMUM_SIZE)] + #[account(init, payer = authority, space = 8 + Tbtc::MAXIMUM_SIZE)] pub tbtc: Account<'info, Tbtc>, #[account(mut)] - pub creator: Signer<'info>, + pub authority: Signer<'info>, pub token_program: Program<'info, SplToken>, pub system_program: Program<'info, System> @@ -146,10 +146,10 @@ pub struct Initialize<'info> { pub struct AddMinter<'info> { #[account( mut, - has_one = creator @ TbtcError::IsNotCreator + has_one = authority @ TbtcError::IsNotAuthority )] pub tbtc: Account<'info, Tbtc>, - pub creator: Signer<'info>, + pub authority: Signer<'info>, pub minter: Signer<'info>, #[account(mut)] pub payer: Signer<'info>, @@ -168,14 +168,14 @@ pub struct AddMinter<'info> { pub struct RemoveMinter<'info> { #[account( mut, - has_one = creator @ TbtcError::IsNotCreator + has_one = authority @ TbtcError::IsNotAuthority )] pub tbtc: Account<'info, Tbtc>, - pub creator: Signer<'info>, + pub authority: Signer<'info>, #[account( mut, constraint = minter_info.minter == minter, - close = creator, + close = authority, seeds = [b"minter-info", tbtc.key().as_ref(), minter.as_ref()], bump = minter_info.bump, )] @@ -186,10 +186,10 @@ pub struct RemoveMinter<'info> { pub struct AddGuardian<'info> { #[account( mut, - has_one = creator @ TbtcError::IsNotCreator + has_one = authority @ TbtcError::IsNotAuthority )] pub tbtc: Account<'info, Tbtc>, - pub creator: Signer<'info>, + pub authority: Signer<'info>, pub guardian: Signer<'info>, #[account(mut)] pub payer: Signer<'info>, @@ -208,14 +208,14 @@ pub struct AddGuardian<'info> { pub struct RemoveGuardian<'info> { #[account( mut, - has_one = creator @ TbtcError::IsNotCreator, + has_one = authority @ TbtcError::IsNotAuthority, )] pub tbtc: Account<'info, Tbtc>, - pub creator: Signer<'info>, + pub authority: Signer<'info>, #[account( mut, constraint = guardian_info.guardian == guardian, - close = creator, + close = authority, seeds = [b"guardian-info", tbtc.key().as_ref(), guardian.as_ref()], bump = guardian_info.bump, )] @@ -243,10 +243,10 @@ pub struct Unpause<'info> { #[account( mut, constraint = tbtc.paused @ TbtcError::IsNotPaused, - has_one = creator @ TbtcError::IsNotCreator + has_one = authority @ TbtcError::IsNotAuthority )] pub tbtc: Account<'info, Tbtc>, - pub creator: Signer<'info>, + pub authority: Signer<'info>, } #[derive(Accounts)] @@ -331,14 +331,9 @@ impl Tbtc { #[error_code] pub enum TbtcError { - // AlreadyCreated, IsPaused, IsNotPaused, - // IsNotMinter, - // IsNotGuardian, - IsNotCreator, - // NoMinters, - // NoGuardians, + IsNotAuthority, } #[event] diff --git a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts index 29b52d491..a0a8ea0d5 100644 --- a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts +++ b/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts @@ -5,7 +5,7 @@ import * as web3 from '@solana/web3.js'; import { SolanaTbtcAnchor } from "../target/types/solana_tbtc_anchor"; import { expect } from 'chai'; -function maybeCreatorAnd( +function maybeAuthorityAnd( signer, signers ) { @@ -15,7 +15,7 @@ function maybeCreatorAnd( async function setup( program: Program, tbtc, - creator + authority ) { const [tbtcMintPDA, _] = getTokenPDA(program, tbtc); @@ -24,7 +24,7 @@ async function setup( .accounts({ tbtcMint: tbtcMintPDA, tbtc: tbtc.publicKey, - creator: creator.publicKey + authority: authority.publicKey }) .signers([tbtc]) .rpc(); @@ -33,14 +33,14 @@ async function setup( async function checkState( program: Program, tbtc, - expectedCreator, + expectedAuthority, expectedMinters, expectedGuardians, expectedTokensSupply ) { let tbtcState = await program.account.tbtc.fetch(tbtc.publicKey); - expect(tbtcState.creator).to.eql(expectedCreator.publicKey); + expect(tbtcState.authority).to.eql(expectedAuthority.publicKey); expect(tbtcState.minters).to.equal(expectedMinters); expect(tbtcState.guardians).to.equal(expectedGuardians); @@ -91,7 +91,7 @@ function getMinterPDA( async function addMinter( program: Program, tbtc, - creator, + authority, minter, payer ): Promise { @@ -100,12 +100,12 @@ async function addMinter( .addMinter() .accounts({ tbtc: tbtc.publicKey, - creator: creator.publicKey, + authority: authority.publicKey, minter: minter.publicKey, payer: payer.publicKey, minterInfo: minterInfoPDA, }) - .signers(maybeCreatorAnd(creator, [minter])) + .signers(maybeAuthorityAnd(authority, [minter])) .rpc(); return minterInfoPDA; } @@ -125,7 +125,7 @@ async function checkMinter( async function removeMinter( program: Program, tbtc, - creator, + authority, minter, minterInfo ) { @@ -133,10 +133,10 @@ async function removeMinter( .removeMinter(minter.publicKey) .accounts({ tbtc: tbtc.publicKey, - creator: creator.publicKey, + authority: authority.publicKey, minterInfo: minterInfo, }) - .signers(maybeCreatorAnd(creator, [])) + .signers(maybeAuthorityAnd(authority, [])) .rpc(); } @@ -158,7 +158,7 @@ function getGuardianPDA( async function addGuardian( program: Program, tbtc, - creator, + authority, guardian, payer ): Promise { @@ -167,12 +167,12 @@ async function addGuardian( .addGuardian() .accounts({ tbtc: tbtc.publicKey, - creator: creator.publicKey, + authority: authority.publicKey, guardian: guardian.publicKey, payer: payer.publicKey, guardianInfo: guardianInfoPDA, }) - .signers(maybeCreatorAnd(creator, [guardian])) + .signers(maybeAuthorityAnd(authority, [guardian])) .rpc(); return guardianInfoPDA; } @@ -192,7 +192,7 @@ async function checkGuardian( async function removeGuardian( program: Program, tbtc, - creator, + authority, guardian, guardianInfo ) { @@ -200,10 +200,10 @@ async function removeGuardian( .removeGuardian(guardian.publicKey) .accounts({ tbtc: tbtc.publicKey, - creator: creator.publicKey, + authority: authority.publicKey, guardianInfo: guardianInfo, }) - .signers(maybeCreatorAnd(creator, [])) + .signers(maybeAuthorityAnd(authority, [])) .rpc(); } @@ -227,22 +227,22 @@ async function pause( async function unpause( program: Program, tbtc, - creator + authority ) { await program.methods .unpause() .accounts({ tbtc: tbtc.publicKey, - creator: creator.publicKey + authority: authority.publicKey }) - .signers(maybeCreatorAnd(creator, [])) + .signers(maybeAuthorityAnd(authority, [])) .rpc(); } async function setupMint( program: Program, tbtc, - creator, + authority, recipient, ) { const [tbtcMintPDA, _] = getTokenPDA(program, tbtc); @@ -256,7 +256,7 @@ async function setupMint( .accounts({ tbtcMint: tbtcMintPDA, tbtc: tbtc.publicKey, - payer: creator.publicKey, + payer: authority.publicKey, recipientAccount: associatedTokenAccount, recipient: recipient.publicKey, }) @@ -299,7 +299,7 @@ describe("solana-tbtc-anchor", () => { const program = anchor.workspace.SolanaTbtcAnchor as Program; - const creator = (program.provider as anchor.AnchorProvider).wallet; + const authority = (program.provider as anchor.AnchorProvider).wallet; const minterKeys = anchor.web3.Keypair.generate(); const minter2Keys = anchor.web3.Keypair.generate(); const impostorKeys = anchor.web3.Keypair.generate(); @@ -310,52 +310,52 @@ describe("solana-tbtc-anchor", () => { it('setup', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); }); it('add minter', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); - await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + await addMinter(program, tbtcKeys, authority, minterKeys, authority); await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, creator, 1, 0, 0); + await checkState(program, tbtcKeys, authority, 1, 0, 0); try { - await addMinter(program, tbtcKeys, impostorKeys, minter2Keys, creator); + await addMinter(program, tbtcKeys, impostorKeys, minter2Keys, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotCreator'); + expect(err.error.errorCode.code).to.equal('IsNotAuthority'); expect(err.program.equals(program.programId)).is.true; } }); it('mint', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, creator, 1, 0, 0); + await checkState(program, tbtcKeys, authority, 1, 0, 0); - await setupMint(program, tbtcKeys, creator, recipientKeys); + await setupMint(program, tbtcKeys, authority, recipientKeys); await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000); - await checkState(program, tbtcKeys, creator, 1, 0, 1000); + await checkState(program, tbtcKeys, authority, 1, 0, 1000); }); it('won\'t mint', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, creator, 1, 0, 0); + await checkState(program, tbtcKeys, authority, 1, 0, 0); - await setupMint(program, tbtcKeys, creator, recipientKeys); + await setupMint(program, tbtcKeys, authority, recipientKeys); try { await mint(program, tbtcKeys, impostorKeys, minterInfoPDA, recipientKeys, 1000); @@ -370,14 +370,14 @@ describe("solana-tbtc-anchor", () => { it('use two minters', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); - const minter2InfoPDA = await addMinter(program, tbtcKeys, creator, minter2Keys, creator); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); + const minter2InfoPDA = await addMinter(program, tbtcKeys, authority, minter2Keys, authority); await checkMinter(program, tbtcKeys, minterKeys); await checkMinter(program, tbtcKeys, minter2Keys); - await checkState(program, tbtcKeys, creator, 2, 0, 0); - await setupMint(program, tbtcKeys, creator, recipientKeys); + await checkState(program, tbtcKeys, authority, 2, 0, 0); + await setupMint(program, tbtcKeys, authority, recipientKeys); // cannot mint with wrong keys try { @@ -392,7 +392,7 @@ describe("solana-tbtc-anchor", () => { // cannot remove minter with wrong keys try { - await removeMinter(program, tbtcKeys, creator, minter2Keys, minterInfoPDA); + await removeMinter(program, tbtcKeys, authority, minter2Keys, minterInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -402,42 +402,42 @@ describe("solana-tbtc-anchor", () => { } await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 500); - await checkState(program, tbtcKeys, creator, 2, 0, 500); + await checkState(program, tbtcKeys, authority, 2, 0, 500); }); it('remove minter', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, creator, 1, 0, 0); - await removeMinter(program, tbtcKeys, creator, minterKeys, minterInfoPDA); - await checkState(program, tbtcKeys, creator, 0, 0, 0); + await checkState(program, tbtcKeys, authority, 1, 0, 0); + await removeMinter(program, tbtcKeys, authority, minterKeys, minterInfoPDA); + await checkState(program, tbtcKeys, authority, 0, 0, 0); }); it('won\'t remove minter', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, creator, 1, 0, 0); + await checkState(program, tbtcKeys, authority, 1, 0, 0); try { await removeMinter(program, tbtcKeys, impostorKeys, minterKeys, minterInfoPDA); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotCreator'); + expect(err.error.errorCode.code).to.equal('IsNotAuthority'); expect(err.program.equals(program.programId)).is.true; } - await removeMinter(program, tbtcKeys, creator, minterKeys, minterInfoPDA); - await checkState(program, tbtcKeys, creator, 0, 0, 0); + await removeMinter(program, tbtcKeys, authority, minterKeys, minterInfoPDA); + await checkState(program, tbtcKeys, authority, 0, 0, 0); try { - await removeMinter(program, tbtcKeys, creator, minterKeys, minterInfoPDA); + await removeMinter(program, tbtcKeys, authority, minterKeys, minterInfoPDA); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); const err: AnchorError = _err; @@ -448,30 +448,30 @@ describe("solana-tbtc-anchor", () => { it('add guardian', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); - await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); await checkGuardian(program, tbtcKeys, guardianKeys); - await checkState(program, tbtcKeys, creator, 0, 1, 0); + await checkState(program, tbtcKeys, authority, 0, 1, 0); try { - await addGuardian(program, tbtcKeys, impostorKeys, guardian2Keys, creator); + await addGuardian(program, tbtcKeys, impostorKeys, guardian2Keys, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotCreator'); + expect(err.error.errorCode.code).to.equal('IsNotAuthority'); expect(err.program.equals(program.programId)).is.true; } }); it('remove guardian', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); - const guardianInfoPDA = await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + const guardianInfoPDA = await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); await checkGuardian(program, tbtcKeys, guardianKeys); - await checkState(program, tbtcKeys, creator, 0, 1, 0); + await checkState(program, tbtcKeys, authority, 0, 1, 0); try { await removeGuardian(program, tbtcKeys, impostorKeys, guardianKeys, guardianInfoPDA); @@ -479,15 +479,15 @@ describe("solana-tbtc-anchor", () => { } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotCreator'); + expect(err.error.errorCode.code).to.equal('IsNotAuthority'); expect(err.program.equals(program.programId)).is.true; } - await removeGuardian(program, tbtcKeys, creator, guardianKeys, guardianInfoPDA); - await checkState(program, tbtcKeys, creator, 0, 0, 0); + await removeGuardian(program, tbtcKeys, authority, guardianKeys, guardianInfoPDA); + await checkState(program, tbtcKeys, authority, 0, 0, 0); try { - await removeGuardian(program, tbtcKeys, creator, guardianKeys, guardianInfoPDA); + await removeGuardian(program, tbtcKeys, authority, guardianKeys, guardianInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -499,8 +499,8 @@ describe("solana-tbtc-anchor", () => { it('pause', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await setup(program, tbtcKeys, authority); + await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); await checkPaused(program, tbtcKeys, false); await pause(program, tbtcKeys, guardianKeys); await checkPaused(program, tbtcKeys, true); @@ -508,16 +508,16 @@ describe("solana-tbtc-anchor", () => { it('unpause', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await setup(program, tbtcKeys, authority); + await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); await checkPaused(program, tbtcKeys, false); await pause(program, tbtcKeys, guardianKeys); await checkPaused(program, tbtcKeys, true); - await unpause(program, tbtcKeys, creator); + await unpause(program, tbtcKeys, authority); await checkPaused(program, tbtcKeys, false); try { - await unpause(program, tbtcKeys, creator); + await unpause(program, tbtcKeys, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { @@ -530,11 +530,11 @@ describe("solana-tbtc-anchor", () => { it('won\'t mint when paused', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - const minterInfoPDA = await addMinter(program, tbtcKeys, creator, minterKeys, creator); - await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); + await setup(program, tbtcKeys, authority); + const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); + await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); await pause(program, tbtcKeys, guardianKeys); - await setupMint(program, tbtcKeys, creator, recipientKeys); + await setupMint(program, tbtcKeys, authority, recipientKeys); try { await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000); @@ -550,13 +550,13 @@ describe("solana-tbtc-anchor", () => { it('use two guardians', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, creator); - await checkState(program, tbtcKeys, creator, 0, 0, 0); - const guardianInfoPDA = await addGuardian(program, tbtcKeys, creator, guardianKeys, creator); - await addGuardian(program, tbtcKeys, creator, guardian2Keys, creator); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + const guardianInfoPDA = await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); + await addGuardian(program, tbtcKeys, authority, guardian2Keys, authority); await checkGuardian(program, tbtcKeys, guardianKeys); await checkGuardian(program, tbtcKeys, guardian2Keys); - await checkState(program, tbtcKeys, creator, 0, 2, 0); + await checkState(program, tbtcKeys, authority, 0, 2, 0); await pause(program, tbtcKeys, guardianKeys); @@ -570,14 +570,14 @@ describe("solana-tbtc-anchor", () => { expect(err.program.equals(program.programId)).is.true; } - await unpause(program, tbtcKeys, creator); + await unpause(program, tbtcKeys, authority); await pause(program, tbtcKeys, guardian2Keys); await checkPaused(program, tbtcKeys, true); - await unpause(program, tbtcKeys, creator); + await unpause(program, tbtcKeys, authority); // cannot remove guardian with wrong keys try { - await removeGuardian(program, tbtcKeys, creator, guardian2Keys, guardianInfoPDA); + await removeGuardian(program, tbtcKeys, authority, guardian2Keys, guardianInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); From af4483d97ed3a3bb3835e6496cdc503c8c88ffb4 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Wed, 19 Jul 2023 12:54:50 +0100 Subject: [PATCH 010/205] Update file structure --- .../{solana-tbtc-anchor => }/.gitignore | 0 .../{solana-tbtc-anchor => }/.prettierignore | 0 .../{solana-tbtc-anchor => }/Anchor.toml | 2 +- .../{solana-tbtc-anchor => }/Cargo.lock | 16 ++++---- .../{solana-tbtc-anchor => }/Cargo.toml | 0 .../migrations/deploy.ts | 0 .../{solana-tbtc-anchor => }/package.json | 0 .../tbtc}/Cargo.toml | 4 +- .../tbtc}/Xargo.toml | 0 .../tbtc}/src/lib.rs | 2 +- .../solana-tbtc-anchor.ts => tests/tbtc.ts} | 38 +++++++++---------- .../{solana-tbtc-anchor => }/tsconfig.json | 0 package.json | 2 +- yarn.lock | 4 +- 14 files changed, 34 insertions(+), 34 deletions(-) rename cross-chain/solana/{solana-tbtc-anchor => }/.gitignore (100%) rename cross-chain/solana/{solana-tbtc-anchor => }/.prettierignore (100%) rename cross-chain/solana/{solana-tbtc-anchor => }/Anchor.toml (79%) rename cross-chain/solana/{solana-tbtc-anchor => }/Cargo.lock (99%) rename cross-chain/solana/{solana-tbtc-anchor => }/Cargo.toml (100%) rename cross-chain/solana/{solana-tbtc-anchor => }/migrations/deploy.ts (100%) rename cross-chain/solana/{solana-tbtc-anchor => }/package.json (100%) rename cross-chain/solana/{solana-tbtc-anchor/programs/solana-tbtc-anchor => programs/tbtc}/Cargo.toml (83%) rename cross-chain/solana/{solana-tbtc-anchor/programs/solana-tbtc-anchor => programs/tbtc}/Xargo.toml (100%) rename cross-chain/solana/{solana-tbtc-anchor/programs/solana-tbtc-anchor => programs/tbtc}/src/lib.rs (99%) rename cross-chain/solana/{solana-tbtc-anchor/tests/solana-tbtc-anchor.ts => tests/tbtc.ts} (95%) rename cross-chain/solana/{solana-tbtc-anchor => }/tsconfig.json (100%) diff --git a/cross-chain/solana/solana-tbtc-anchor/.gitignore b/cross-chain/solana/.gitignore similarity index 100% rename from cross-chain/solana/solana-tbtc-anchor/.gitignore rename to cross-chain/solana/.gitignore diff --git a/cross-chain/solana/solana-tbtc-anchor/.prettierignore b/cross-chain/solana/.prettierignore similarity index 100% rename from cross-chain/solana/solana-tbtc-anchor/.prettierignore rename to cross-chain/solana/.prettierignore diff --git a/cross-chain/solana/solana-tbtc-anchor/Anchor.toml b/cross-chain/solana/Anchor.toml similarity index 79% rename from cross-chain/solana/solana-tbtc-anchor/Anchor.toml rename to cross-chain/solana/Anchor.toml index 94b4df4ae..415474b08 100644 --- a/cross-chain/solana/solana-tbtc-anchor/Anchor.toml +++ b/cross-chain/solana/Anchor.toml @@ -2,7 +2,7 @@ seeds = false skip-lint = false [programs.localnet] -solana_tbtc_anchor = "HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG" +tbtc = "HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG" [registry] url = "https://api.apr.dev" diff --git a/cross-chain/solana/solana-tbtc-anchor/Cargo.lock b/cross-chain/solana/Cargo.lock similarity index 99% rename from cross-chain/solana/solana-tbtc-anchor/Cargo.lock rename to cross-chain/solana/Cargo.lock index 2ec9ed067..199b830d0 100644 --- a/cross-chain/solana/solana-tbtc-anchor/Cargo.lock +++ b/cross-chain/solana/Cargo.lock @@ -1943,14 +1943,6 @@ dependencies = [ "syn 2.0.25", ] -[[package]] -name = "solana-tbtc-anchor" -version = "0.1.0" -dependencies = [ - "anchor-lang", - "anchor-spl", -] - [[package]] name = "solana-zk-token-sdk" version = "1.16.3" @@ -2072,6 +2064,14 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tbtc" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-spl", +] + [[package]] name = "termcolor" version = "1.2.0" diff --git a/cross-chain/solana/solana-tbtc-anchor/Cargo.toml b/cross-chain/solana/Cargo.toml similarity index 100% rename from cross-chain/solana/solana-tbtc-anchor/Cargo.toml rename to cross-chain/solana/Cargo.toml diff --git a/cross-chain/solana/solana-tbtc-anchor/migrations/deploy.ts b/cross-chain/solana/migrations/deploy.ts similarity index 100% rename from cross-chain/solana/solana-tbtc-anchor/migrations/deploy.ts rename to cross-chain/solana/migrations/deploy.ts diff --git a/cross-chain/solana/solana-tbtc-anchor/package.json b/cross-chain/solana/package.json similarity index 100% rename from cross-chain/solana/solana-tbtc-anchor/package.json rename to cross-chain/solana/package.json diff --git a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Cargo.toml b/cross-chain/solana/programs/tbtc/Cargo.toml similarity index 83% rename from cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Cargo.toml rename to cross-chain/solana/programs/tbtc/Cargo.toml index 4f6c212af..9aa4c8db8 100644 --- a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Cargo.toml +++ b/cross-chain/solana/programs/tbtc/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "solana-tbtc-anchor" +name = "tbtc" version = "0.1.0" description = "Created with Anchor" edition = "2021" [lib] crate-type = ["cdylib", "lib"] -name = "solana_tbtc_anchor" +name = "tbtc" [features] no-entrypoint = [] diff --git a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Xargo.toml b/cross-chain/solana/programs/tbtc/Xargo.toml similarity index 100% rename from cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/Xargo.toml rename to cross-chain/solana/programs/tbtc/Xargo.toml diff --git a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs b/cross-chain/solana/programs/tbtc/src/lib.rs similarity index 99% rename from cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs rename to cross-chain/solana/programs/tbtc/src/lib.rs index 288355645..9200f3d83 100644 --- a/cross-chain/solana/solana-tbtc-anchor/programs/solana-tbtc-anchor/src/lib.rs +++ b/cross-chain/solana/programs/tbtc/src/lib.rs @@ -8,7 +8,7 @@ use anchor_spl::{ declare_id!("HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG"); #[program] -pub mod solana_tbtc_anchor { +pub mod tbtc { use super::*; pub fn initialize(ctx: Context) -> Result<()> { diff --git a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts b/cross-chain/solana/tests/tbtc.ts similarity index 95% rename from cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts rename to cross-chain/solana/tests/tbtc.ts index a0a8ea0d5..53dff9b49 100644 --- a/cross-chain/solana/solana-tbtc-anchor/tests/solana-tbtc-anchor.ts +++ b/cross-chain/solana/tests/tbtc.ts @@ -2,7 +2,7 @@ import * as anchor from "@coral-xyz/anchor"; import { Program, AnchorError } from "@coral-xyz/anchor"; import * as spl from "@solana/spl-token"; import * as web3 from '@solana/web3.js'; -import { SolanaTbtcAnchor } from "../target/types/solana_tbtc_anchor"; +import { Tbtc } from "../target/types/tbtc"; import { expect } from 'chai'; function maybeAuthorityAnd( @@ -13,7 +13,7 @@ function maybeAuthorityAnd( } async function setup( - program: Program, + program: Program, tbtc, authority ) { @@ -31,7 +31,7 @@ async function setup( } async function checkState( - program: Program, + program: Program, tbtc, expectedAuthority, expectedMinters, @@ -52,7 +52,7 @@ async function checkState( } async function checkPaused( - program: Program, + program: Program, tbtc, paused: boolean ) { @@ -61,7 +61,7 @@ async function checkPaused( } function getTokenPDA( - program: Program, + program: Program, tbtc, ): [anchor.web3.PublicKey, number] { return web3.PublicKey.findProgramAddressSync( @@ -74,7 +74,7 @@ function getTokenPDA( } function getMinterPDA( - program: Program, + program: Program, tbtc, minter ): [anchor.web3.PublicKey, number] { @@ -89,7 +89,7 @@ function getMinterPDA( } async function addMinter( - program: Program, + program: Program, tbtc, authority, minter, @@ -111,7 +111,7 @@ async function addMinter( } async function checkMinter( - program: Program, + program: Program, tbtc, minter ) { @@ -123,7 +123,7 @@ async function checkMinter( } async function removeMinter( - program: Program, + program: Program, tbtc, authority, minter, @@ -141,7 +141,7 @@ async function removeMinter( } function getGuardianPDA( - program: Program, + program: Program, tbtc, guardian ): [anchor.web3.PublicKey, number] { @@ -156,7 +156,7 @@ function getGuardianPDA( } async function addGuardian( - program: Program, + program: Program, tbtc, authority, guardian, @@ -178,7 +178,7 @@ async function addGuardian( } async function checkGuardian( - program: Program, + program: Program, tbtc, guardian ) { @@ -190,7 +190,7 @@ async function checkGuardian( } async function removeGuardian( - program: Program, + program: Program, tbtc, authority, guardian, @@ -208,7 +208,7 @@ async function removeGuardian( } async function pause( - program: Program, + program: Program, tbtc, guardian ) { @@ -225,7 +225,7 @@ async function pause( } async function unpause( - program: Program, + program: Program, tbtc, authority ) { @@ -240,7 +240,7 @@ async function unpause( } async function setupMint( - program: Program, + program: Program, tbtc, authority, recipient, @@ -265,7 +265,7 @@ async function setupMint( } async function mint( - program: Program, + program: Program, tbtc, minter, minterInfoPDA, @@ -292,11 +292,11 @@ async function mint( .rpc(); } -describe("solana-tbtc-anchor", () => { +describe("tbtc", () => { // Configure the client to use the local cluster. anchor.setProvider(anchor.AnchorProvider.env()); - const program = anchor.workspace.SolanaTbtcAnchor as Program; + const program = anchor.workspace.Tbtc as Program; const authority = (program.provider as anchor.AnchorProvider).wallet; diff --git a/cross-chain/solana/solana-tbtc-anchor/tsconfig.json b/cross-chain/solana/tsconfig.json similarity index 100% rename from cross-chain/solana/solana-tbtc-anchor/tsconfig.json rename to cross-chain/solana/tsconfig.json diff --git a/package.json b/package.json index 69cf8e6d2..854ac1535 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,6 @@ "prettier-plugin-solidity": "^1.0.0-beta.14" }, "workspaces": [ - "./cross-chain/solana/*" + "./cross-chain/solana" ] } diff --git a/yarn.lock b/yarn.lock index cd01785e0..1f6b9cfda 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2091,9 +2091,9 @@ __metadata: languageName: node linkType: hard -"solana-tbtc-anchor-924226@workspace:cross-chain/solana/solana-tbtc-anchor": +"solana-d8f61a@workspace:cross-chain/solana": version: 0.0.0-use.local - resolution: "solana-tbtc-anchor-924226@workspace:cross-chain/solana/solana-tbtc-anchor" + resolution: "solana-d8f61a@workspace:cross-chain/solana" dependencies: "@coral-xyz/anchor": ^0.28.0 "@solana/spl-token": ^0.3.8 From 9e8224bc38307fe9154181eeaa92869e4d69e084 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Wed, 19 Jul 2023 14:40:39 +0100 Subject: [PATCH 011/205] Isolate yarn changes to cross-chain/solana --- .gitignore | 1 - cross-chain/solana/yarn.lock | 2493 ++++++++++++++++++++++++++++++++++ package.json | 5 +- 3 files changed, 2494 insertions(+), 5 deletions(-) create mode 100644 cross-chain/solana/yarn.lock diff --git a/.gitignore b/.gitignore index 78b53c1e3..842aea9ee 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,3 @@ dist/ .envrc yarn-error.log -.yarn/ diff --git a/cross-chain/solana/yarn.lock b/cross-chain/solana/yarn.lock new file mode 100644 index 000000000..6a0e35f1f --- /dev/null +++ b/cross-chain/solana/yarn.lock @@ -0,0 +1,2493 @@ +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 6 + cacheKey: 8 + +"@babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.22.3": + version: 7.22.6 + resolution: "@babel/runtime@npm:7.22.6" + dependencies: + regenerator-runtime: ^0.13.11 + checksum: e585338287c4514a713babf4fdb8fc2a67adcebab3e7723a739fc62c79cfda875b314c90fd25f827afb150d781af97bc16c85bfdbfa2889f06053879a1ddb597 + languageName: node + linkType: hard + +"@coral-xyz/anchor@npm:^0.28.0": + version: 0.28.0 + resolution: "@coral-xyz/anchor@npm:0.28.0" + dependencies: + "@coral-xyz/borsh": ^0.28.0 + "@solana/web3.js": ^1.68.0 + base64-js: ^1.5.1 + bn.js: ^5.1.2 + bs58: ^4.0.1 + buffer-layout: ^1.2.2 + camelcase: ^6.3.0 + cross-fetch: ^3.1.5 + crypto-hash: ^1.3.0 + eventemitter3: ^4.0.7 + js-sha256: ^0.9.0 + pako: ^2.0.3 + snake-case: ^3.0.4 + superstruct: ^0.15.4 + toml: ^3.0.0 + checksum: 58b3677b5b2ce2c779045184ce4a0ef696966a6a58f41c1c56f6f178db0491acecb6ec677ce0502f0b382a2c724f9c2860d82cc88601784d556d95fbeda415e5 + languageName: node + linkType: hard + +"@coral-xyz/borsh@npm:^0.28.0": + version: 0.28.0 + resolution: "@coral-xyz/borsh@npm:0.28.0" + dependencies: + bn.js: ^5.1.2 + buffer-layout: ^1.2.0 + peerDependencies: + "@solana/web3.js": ^1.68.0 + checksum: bc2b06b777f9ed43d3b886d2350826bd44d5b932c4fd4471af5956e8755236f5854938c890ee4986d88f61d1439e1d84e715c43dcb6dca4e76198c1ce8dc7a58 + languageName: node + linkType: hard + +"@isaacs/cliui@npm:^8.0.2": + version: 8.0.2 + resolution: "@isaacs/cliui@npm:8.0.2" + dependencies: + string-width: ^5.1.2 + string-width-cjs: "npm:string-width@^4.2.0" + strip-ansi: ^7.0.1 + strip-ansi-cjs: "npm:strip-ansi@^6.0.1" + wrap-ansi: ^8.1.0 + wrap-ansi-cjs: "npm:wrap-ansi@^7.0.0" + checksum: 4a473b9b32a7d4d3cfb7a614226e555091ff0c5a29a1734c28c72a182c2f6699b26fc6b5c2131dfd841e86b185aea714c72201d7c98c2fba5f17709333a67aeb + languageName: node + linkType: hard + +"@noble/curves@npm:^1.0.0": + version: 1.1.0 + resolution: "@noble/curves@npm:1.1.0" + dependencies: + "@noble/hashes": 1.3.1 + checksum: 2658cdd3f84f71079b4e3516c47559d22cf4b55c23ac8ee9d2b1f8e5b72916d9689e59820e0f9d9cb4a46a8423af5b56dc6bb7782405c88be06a015180508db5 + languageName: node + linkType: hard + +"@noble/hashes@npm:1.3.1, @noble/hashes@npm:^1.3.0": + version: 1.3.1 + resolution: "@noble/hashes@npm:1.3.1" + checksum: 7fdefc0f7a0c1ec27acc6ff88841793e3f93ec4ce6b8a6a12bfc0dd70ae6b7c4c82fe305fdfeda1735d5ad4a9eebe761e6693b3d355689c559e91242f4bc95b1 + languageName: node + linkType: hard + +"@npmcli/fs@npm:^3.1.0": + version: 3.1.0 + resolution: "@npmcli/fs@npm:3.1.0" + dependencies: + semver: ^7.3.5 + checksum: a50a6818de5fc557d0b0e6f50ec780a7a02ab8ad07e5ac8b16bf519e0ad60a144ac64f97d05c443c3367235d337182e1d012bbac0eb8dbae8dc7b40b193efd0e + languageName: node + linkType: hard + +"@pkgjs/parseargs@npm:^0.11.0": + version: 0.11.0 + resolution: "@pkgjs/parseargs@npm:0.11.0" + checksum: 6ad6a00fc4f2f2cfc6bff76fb1d88b8ee20bc0601e18ebb01b6d4be583733a860239a521a7fbca73b612e66705078809483549d2b18f370eb346c5155c8e4a0f + languageName: node + linkType: hard + +"@solana/buffer-layout-utils@npm:^0.2.0": + version: 0.2.0 + resolution: "@solana/buffer-layout-utils@npm:0.2.0" + dependencies: + "@solana/buffer-layout": ^4.0.0 + "@solana/web3.js": ^1.32.0 + bigint-buffer: ^1.1.5 + bignumber.js: ^9.0.1 + checksum: 9284242245b18b49577195ba7548263850be865a4a2d183944fa01bb76382039db589aab8473698e9bb734b515ada9b4d70db0a72e341c5d567c59b83d6d0840 + languageName: node + linkType: hard + +"@solana/buffer-layout@npm:^4.0.0": + version: 4.0.1 + resolution: "@solana/buffer-layout@npm:4.0.1" + dependencies: + buffer: ~6.0.3 + checksum: bf846888e813187243d4008a7a9f58b49d16cbd995b9d7f1b72898aa510ed77b1ce5e8468e7b2fd26dd81e557a4e74a666e21fccb95f123c1f740d41138bbacd + languageName: node + linkType: hard + +"@solana/spl-token@npm:^0.3.8": + version: 0.3.8 + resolution: "@solana/spl-token@npm:0.3.8" + dependencies: + "@solana/buffer-layout": ^4.0.0 + "@solana/buffer-layout-utils": ^0.2.0 + buffer: ^6.0.3 + peerDependencies: + "@solana/web3.js": ^1.47.4 + checksum: 01f4f87112b0ad277701a3bcb8e03069b69449b92724b17959107686731082bfd3475b5f105e1e8f04badd2e810a43d5ef811744ced5178eea1232de8fd75147 + languageName: node + linkType: hard + +"@solana/web3.js@npm:^1.32.0, @solana/web3.js@npm:^1.68.0, @solana/web3.js@npm:^1.77.3": + version: 1.78.0 + resolution: "@solana/web3.js@npm:1.78.0" + dependencies: + "@babel/runtime": ^7.22.3 + "@noble/curves": ^1.0.0 + "@noble/hashes": ^1.3.0 + "@solana/buffer-layout": ^4.0.0 + agentkeepalive: ^4.2.1 + bigint-buffer: ^1.1.5 + bn.js: ^5.0.0 + borsh: ^0.7.0 + bs58: ^4.0.1 + buffer: 6.0.3 + fast-stable-stringify: ^1.0.0 + jayson: ^4.1.0 + node-fetch: ^2.6.11 + rpc-websockets: ^7.5.1 + superstruct: ^0.14.2 + checksum: 9f0aae54fa8f2d9285ae525b4f962a17160fd98ac588fbf528742630fb2cf0208ec7b6c0c307d6bba82a92a0e8cbb5411b965d553cc4c62488e24b57c2211d84 + languageName: node + linkType: hard + +"@tootallnate/once@npm:2": + version: 2.0.0 + resolution: "@tootallnate/once@npm:2.0.0" + checksum: ad87447820dd3f24825d2d947ebc03072b20a42bfc96cbafec16bff8bbda6c1a81fcb0be56d5b21968560c5359a0af4038a68ba150c3e1694fe4c109a063bed8 + languageName: node + linkType: hard + +"@types/bn.js@npm:^5.1.0": + version: 5.1.1 + resolution: "@types/bn.js@npm:5.1.1" + dependencies: + "@types/node": "*" + checksum: e50ed2dd3abe997e047caf90e0352c71e54fc388679735217978b4ceb7e336e51477791b715f49fd77195ac26dd296c7bad08a3be9750e235f9b2e1edb1b51c2 + languageName: node + linkType: hard + +"@types/chai@npm:^4.3.0": + version: 4.3.5 + resolution: "@types/chai@npm:4.3.5" + checksum: c8f26a88c6b5b53a3275c7f5ff8f107028e3cbb9ff26795fff5f3d9dea07106a54ce9e2dce5e40347f7c4cc35657900aaf0c83934a25a1ae12e61e0f5516e431 + languageName: node + linkType: hard + +"@types/connect@npm:^3.4.33": + version: 3.4.35 + resolution: "@types/connect@npm:3.4.35" + dependencies: + "@types/node": "*" + checksum: fe81351470f2d3165e8b12ce33542eef89ea893e36dd62e8f7d72566dfb7e448376ae962f9f3ea888547ce8b55a40020ca0e01d637fab5d99567673084542641 + languageName: node + linkType: hard + +"@types/json5@npm:^0.0.29": + version: 0.0.29 + resolution: "@types/json5@npm:0.0.29" + checksum: e60b153664572116dfea673c5bda7778dbff150498f44f998e34b5886d8afc47f16799280e4b6e241c0472aef1bc36add771c569c68fc5125fc2ae519a3eb9ac + languageName: node + linkType: hard + +"@types/mocha@npm:^9.0.0": + version: 9.1.1 + resolution: "@types/mocha@npm:9.1.1" + checksum: 516077c0acd9806dc78317f88aaac0df5aaf0bdc2f63dfdadeabdf0b0137953b6ca65472e6ff7c30bc93ce4e0ae76eae70e8d46764b9a8eae4877a928b6ef49a + languageName: node + linkType: hard + +"@types/node@npm:*": + version: 20.4.2 + resolution: "@types/node@npm:20.4.2" + checksum: 99e544ea7560d51f01f95627fc40394c24a13da8f041121a0da13e4ef0a2aa332932eaf9a5e8d0e30d1c07106e96a183be392cbba62e8cf0bf6a085d5c0f4149 + languageName: node + linkType: hard + +"@types/node@npm:^12.12.54": + version: 12.20.55 + resolution: "@types/node@npm:12.20.55" + checksum: e4f86785f4092706e0d3b0edff8dca5a13b45627e4b36700acd8dfe6ad53db71928c8dee914d4276c7fd3b6ccd829aa919811c9eb708a2c8e4c6eb3701178c37 + languageName: node + linkType: hard + +"@types/ws@npm:^7.4.4": + version: 7.4.7 + resolution: "@types/ws@npm:7.4.7" + dependencies: + "@types/node": "*" + checksum: b4c9b8ad209620c9b21e78314ce4ff07515c0cadab9af101c1651e7bfb992d7fd933bd8b9c99d110738fd6db523ed15f82f29f50b45510288da72e964dedb1a3 + languageName: node + linkType: hard + +"@ungap/promise-all-settled@npm:1.1.2": + version: 1.1.2 + resolution: "@ungap/promise-all-settled@npm:1.1.2" + checksum: 08d37fdfa23a6fe8139f1305313562ebad973f3fac01bcce2773b2bda5bcb0146dfdcf3cb6a722cf0a5f2ca0bc56a827eac8f1e7b3beddc548f654addf1fc34c + languageName: node + linkType: hard + +"JSONStream@npm:^1.3.5": + version: 1.3.5 + resolution: "JSONStream@npm:1.3.5" + dependencies: + jsonparse: ^1.2.0 + through: ">=2.2.7 <3" + bin: + JSONStream: ./bin.js + checksum: 2605fa124260c61bad38bb65eba30d2f72216a78e94d0ab19b11b4e0327d572b8d530c0c9cc3b0764f727ad26d39e00bf7ebad57781ca6368394d73169c59e46 + languageName: node + linkType: hard + +"abbrev@npm:^1.0.0": + version: 1.1.1 + resolution: "abbrev@npm:1.1.1" + checksum: a4a97ec07d7ea112c517036882b2ac22f3109b7b19077dc656316d07d308438aac28e4d9746dc4d84bf6b1e75b4a7b0a5f3cb30592419f128ca9a8cee3bcfa17 + languageName: node + linkType: hard + +"agent-base@npm:6, agent-base@npm:^6.0.2": + version: 6.0.2 + resolution: "agent-base@npm:6.0.2" + dependencies: + debug: 4 + checksum: f52b6872cc96fd5f622071b71ef200e01c7c4c454ee68bc9accca90c98cfb39f2810e3e9aa330435835eedc8c23f4f8a15267f67c6e245d2b33757575bdac49d + languageName: node + linkType: hard + +"agentkeepalive@npm:^4.2.1": + version: 4.3.0 + resolution: "agentkeepalive@npm:4.3.0" + dependencies: + debug: ^4.1.0 + depd: ^2.0.0 + humanize-ms: ^1.2.1 + checksum: 982453aa44c11a06826c836025e5162c846e1200adb56f2d075400da7d32d87021b3b0a58768d949d824811f5654223d5a8a3dad120921a2439625eb847c6260 + languageName: node + linkType: hard + +"aggregate-error@npm:^3.0.0": + version: 3.1.0 + resolution: "aggregate-error@npm:3.1.0" + dependencies: + clean-stack: ^2.0.0 + indent-string: ^4.0.0 + checksum: 1101a33f21baa27a2fa8e04b698271e64616b886795fd43c31068c07533c7b3facfcaf4e9e0cab3624bd88f729a592f1c901a1a229c9e490eafce411a8644b79 + languageName: node + linkType: hard + +"ansi-colors@npm:4.1.1": + version: 4.1.1 + resolution: "ansi-colors@npm:4.1.1" + checksum: 138d04a51076cb085da0a7e2d000c5c0bb09f6e772ed5c65c53cb118d37f6c5f1637506d7155fb5f330f0abcf6f12fa2e489ac3f8cdab9da393bf1bb4f9a32b0 + languageName: node + linkType: hard + +"ansi-regex@npm:^5.0.1": + version: 5.0.1 + resolution: "ansi-regex@npm:5.0.1" + checksum: 2aa4bb54caf2d622f1afdad09441695af2a83aa3fe8b8afa581d205e57ed4261c183c4d3877cee25794443fde5876417d859c108078ab788d6af7e4fe52eb66b + languageName: node + linkType: hard + +"ansi-regex@npm:^6.0.1": + version: 6.0.1 + resolution: "ansi-regex@npm:6.0.1" + checksum: 1ff8b7667cded1de4fa2c9ae283e979fc87036864317da86a2e546725f96406746411d0d85e87a2d12fa5abd715d90006de7fa4fa0477c92321ad3b4c7d4e169 + languageName: node + linkType: hard + +"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0": + version: 4.3.0 + resolution: "ansi-styles@npm:4.3.0" + dependencies: + color-convert: ^2.0.1 + checksum: 513b44c3b2105dd14cc42a19271e80f386466c4be574bccf60b627432f9198571ebf4ab1e4c3ba17347658f4ee1711c163d574248c0c1cdc2d5917a0ad582ec4 + languageName: node + linkType: hard + +"ansi-styles@npm:^6.1.0": + version: 6.2.1 + resolution: "ansi-styles@npm:6.2.1" + checksum: ef940f2f0ced1a6347398da88a91da7930c33ecac3c77b72c5905f8b8fe402c52e6fde304ff5347f616e27a742da3f1dc76de98f6866c69251ad0b07a66776d9 + languageName: node + linkType: hard + +"anymatch@npm:~3.1.2": + version: 3.1.3 + resolution: "anymatch@npm:3.1.3" + dependencies: + normalize-path: ^3.0.0 + picomatch: ^2.0.4 + checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 + languageName: node + linkType: hard + +"aproba@npm:^1.0.3 || ^2.0.0": + version: 2.0.0 + resolution: "aproba@npm:2.0.0" + checksum: 5615cadcfb45289eea63f8afd064ab656006361020e1735112e346593856f87435e02d8dcc7ff0d11928bc7d425f27bc7c2a84f6c0b35ab0ff659c814c138a24 + languageName: node + linkType: hard + +"are-we-there-yet@npm:^3.0.0": + version: 3.0.1 + resolution: "are-we-there-yet@npm:3.0.1" + dependencies: + delegates: ^1.0.0 + readable-stream: ^3.6.0 + checksum: 52590c24860fa7173bedeb69a4c05fb573473e860197f618b9a28432ee4379049336727ae3a1f9c4cb083114601c1140cee578376164d0e651217a9843f9fe83 + languageName: node + linkType: hard + +"argparse@npm:^2.0.1": + version: 2.0.1 + resolution: "argparse@npm:2.0.1" + checksum: 83644b56493e89a254bae05702abf3a1101b4fa4d0ca31df1c9985275a5a5bd47b3c27b7fa0b71098d41114d8ca000e6ed90cad764b306f8a503665e4d517ced + languageName: node + linkType: hard + +"arrify@npm:^1.0.0": + version: 1.0.1 + resolution: "arrify@npm:1.0.1" + checksum: 745075dd4a4624ff0225c331dacb99be501a515d39bcb7c84d24660314a6ec28e68131b137e6f7e16318170842ce97538cd298fc4cd6b2cc798e0b957f2747e7 + languageName: node + linkType: hard + +"assertion-error@npm:^1.1.0": + version: 1.1.0 + resolution: "assertion-error@npm:1.1.0" + checksum: fd9429d3a3d4fd61782eb3962ae76b6d08aa7383123fca0596020013b3ebd6647891a85b05ce821c47d1471ed1271f00b0545cf6a4326cf2fc91efcc3b0fbecf + languageName: node + linkType: hard + +"balanced-match@npm:^1.0.0": + version: 1.0.2 + resolution: "balanced-match@npm:1.0.2" + checksum: 9706c088a283058a8a99e0bf91b0a2f75497f185980d9ffa8b304de1d9e58ebda7c72c07ebf01dadedaac5b2907b2c6f566f660d62bd336c3468e960403b9d65 + languageName: node + linkType: hard + +"base-x@npm:^3.0.2": + version: 3.0.9 + resolution: "base-x@npm:3.0.9" + dependencies: + safe-buffer: ^5.0.1 + checksum: 957101d6fd09e1903e846fd8f69fd7e5e3e50254383e61ab667c725866bec54e5ece5ba49ce385128ae48f9ec93a26567d1d5ebb91f4d56ef4a9cc0d5a5481e8 + languageName: node + linkType: hard + +"base64-js@npm:^1.3.1, base64-js@npm:^1.5.1": + version: 1.5.1 + resolution: "base64-js@npm:1.5.1" + checksum: 669632eb3745404c2f822a18fc3a0122d2f9a7a13f7fb8b5823ee19d1d2ff9ee5b52c53367176ea4ad093c332fd5ab4bd0ebae5a8e27917a4105a4cfc86b1005 + languageName: node + linkType: hard + +"bigint-buffer@npm:^1.1.5": + version: 1.1.5 + resolution: "bigint-buffer@npm:1.1.5" + dependencies: + bindings: ^1.3.0 + node-gyp: latest + checksum: d010c9f57758bcdaccb435d88b483ffcc95fe8bbc6e7fb3a44fb5221f29c894ffaf4a3c5a4a530e0e7d6608203c2cde9b79ee4f2386cd6d4462d1070bc8c9f4e + languageName: node + linkType: hard + +"bignumber.js@npm:^9.0.1": + version: 9.1.1 + resolution: "bignumber.js@npm:9.1.1" + checksum: ad243b7e2f9120b112d670bb3d674128f0bd2ca1745b0a6c9df0433bd2c0252c43e6315d944c2ac07b4c639e7496b425e46842773cf89c6a2dcd4f31e5c4b11e + languageName: node + linkType: hard + +"binary-extensions@npm:^2.0.0": + version: 2.2.0 + resolution: "binary-extensions@npm:2.2.0" + checksum: ccd267956c58d2315f5d3ea6757cf09863c5fc703e50fbeb13a7dc849b812ef76e3cf9ca8f35a0c48498776a7478d7b4a0418e1e2b8cb9cb9731f2922aaad7f8 + languageName: node + linkType: hard + +"bindings@npm:^1.3.0": + version: 1.5.0 + resolution: "bindings@npm:1.5.0" + dependencies: + file-uri-to-path: 1.0.0 + checksum: 65b6b48095717c2e6105a021a7da4ea435aa8d3d3cd085cb9e85bcb6e5773cf318c4745c3f7c504412855940b585bdf9b918236612a1c7a7942491de176f1ae7 + languageName: node + linkType: hard + +"bn.js@npm:^5.0.0, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0": + version: 5.2.1 + resolution: "bn.js@npm:5.2.1" + checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3 + languageName: node + linkType: hard + +"borsh@npm:^0.7.0": + version: 0.7.0 + resolution: "borsh@npm:0.7.0" + dependencies: + bn.js: ^5.2.0 + bs58: ^4.0.0 + text-encoding-utf-8: ^1.0.2 + checksum: e98bfb5f7cfb820819c2870b884dac58dd4b4ce6a86c286c8fbf5c9ca582e73a8c6094df67e81a28c418ff07a309c6b118b2e27fdfea83fd92b8100c741da0b5 + languageName: node + linkType: hard + +"brace-expansion@npm:^1.1.7": + version: 1.1.11 + resolution: "brace-expansion@npm:1.1.11" + dependencies: + balanced-match: ^1.0.0 + concat-map: 0.0.1 + checksum: faf34a7bb0c3fcf4b59c7808bc5d2a96a40988addf2e7e09dfbb67a2251800e0d14cd2bfc1aa79174f2f5095c54ff27f46fb1289fe2d77dac755b5eb3434cc07 + languageName: node + linkType: hard + +"brace-expansion@npm:^2.0.1": + version: 2.0.1 + resolution: "brace-expansion@npm:2.0.1" + dependencies: + balanced-match: ^1.0.0 + checksum: a61e7cd2e8a8505e9f0036b3b6108ba5e926b4b55089eeb5550cd04a471fe216c96d4fe7e4c7f995c728c554ae20ddfc4244cad10aef255e72b62930afd233d1 + languageName: node + linkType: hard + +"braces@npm:~3.0.2": + version: 3.0.2 + resolution: "braces@npm:3.0.2" + dependencies: + fill-range: ^7.0.1 + checksum: e2a8e769a863f3d4ee887b5fe21f63193a891c68b612ddb4b68d82d1b5f3ff9073af066c343e9867a393fe4c2555dcb33e89b937195feb9c1613d259edfcd459 + languageName: node + linkType: hard + +"browser-stdout@npm:1.3.1": + version: 1.3.1 + resolution: "browser-stdout@npm:1.3.1" + checksum: b717b19b25952dd6af483e368f9bcd6b14b87740c3d226c2977a65e84666ffd67000bddea7d911f111a9b6ddc822b234de42d52ab6507bce4119a4cc003ef7b3 + languageName: node + linkType: hard + +"bs58@npm:^4.0.0, bs58@npm:^4.0.1": + version: 4.0.1 + resolution: "bs58@npm:4.0.1" + dependencies: + base-x: ^3.0.2 + checksum: b3c5365bb9e0c561e1a82f1a2d809a1a692059fae016be233a6127ad2f50a6b986467c3a50669ce4c18929dcccb297c5909314dd347a25a68c21b68eb3e95ac2 + languageName: node + linkType: hard + +"buffer-from@npm:^1.0.0, buffer-from@npm:^1.1.0": + version: 1.1.2 + resolution: "buffer-from@npm:1.1.2" + checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb + languageName: node + linkType: hard + +"buffer-layout@npm:^1.2.0, buffer-layout@npm:^1.2.2": + version: 1.2.2 + resolution: "buffer-layout@npm:1.2.2" + checksum: e5809ba275530bf4e52fd09558b7c2111fbda5b405124f581acf364261d9c154e271800271898cd40473f9bcbb42c31584efb04219bde549d3460ca4bafeaa07 + languageName: node + linkType: hard + +"buffer@npm:6.0.3, buffer@npm:^6.0.3, buffer@npm:~6.0.3": + version: 6.0.3 + resolution: "buffer@npm:6.0.3" + dependencies: + base64-js: ^1.3.1 + ieee754: ^1.2.1 + checksum: 5ad23293d9a731e4318e420025800b42bf0d264004c0286c8cc010af7a270c7a0f6522e84f54b9ad65cbd6db20b8badbfd8d2ebf4f80fa03dab093b89e68c3f9 + languageName: node + linkType: hard + +"bufferutil@npm:^4.0.1": + version: 4.0.7 + resolution: "bufferutil@npm:4.0.7" + dependencies: + node-gyp: latest + node-gyp-build: ^4.3.0 + checksum: f75aa87e3d1b99b87a95f60a855e63f70af07b57fb8443e75a2ddfef2e47788d130fdd46e3a78fd7e0c10176082b26dfbed970c5b8632e1cc299cafa0e93ce45 + languageName: node + linkType: hard + +"cacache@npm:^17.0.0": + version: 17.1.3 + resolution: "cacache@npm:17.1.3" + dependencies: + "@npmcli/fs": ^3.1.0 + fs-minipass: ^3.0.0 + glob: ^10.2.2 + lru-cache: ^7.7.1 + minipass: ^5.0.0 + minipass-collect: ^1.0.2 + minipass-flush: ^1.0.5 + minipass-pipeline: ^1.2.4 + p-map: ^4.0.0 + ssri: ^10.0.0 + tar: ^6.1.11 + unique-filename: ^3.0.0 + checksum: 385756781e1e21af089160d89d7462b7ed9883c978e848c7075b90b73cb823680e66092d61513050164588387d2ca87dd6d910e28d64bc13a9ac82cd8580c796 + languageName: node + linkType: hard + +"camelcase@npm:^6.0.0, camelcase@npm:^6.3.0": + version: 6.3.0 + resolution: "camelcase@npm:6.3.0" + checksum: 8c96818a9076434998511251dcb2761a94817ea17dbdc37f47ac080bd088fc62c7369429a19e2178b993497132c8cbcf5cc1f44ba963e76782ba469c0474938d + languageName: node + linkType: hard + +"chai@npm:^4.3.4": + version: 4.3.7 + resolution: "chai@npm:4.3.7" + dependencies: + assertion-error: ^1.1.0 + check-error: ^1.0.2 + deep-eql: ^4.1.2 + get-func-name: ^2.0.0 + loupe: ^2.3.1 + pathval: ^1.1.1 + type-detect: ^4.0.5 + checksum: 0bba7d267848015246a66995f044ce3f0ebc35e530da3cbdf171db744e14cbe301ab913a8d07caf7952b430257ccbb1a4a983c570a7c5748dc537897e5131f7c + languageName: node + linkType: hard + +"chalk@npm:^4.1.0": + version: 4.1.2 + resolution: "chalk@npm:4.1.2" + dependencies: + ansi-styles: ^4.1.0 + supports-color: ^7.1.0 + checksum: fe75c9d5c76a7a98d45495b91b2172fa3b7a09e0cc9370e5c8feb1c567b85c4288e2b3fded7cfdd7359ac28d6b3844feb8b82b8686842e93d23c827c417e83fc + languageName: node + linkType: hard + +"check-error@npm:^1.0.2": + version: 1.0.2 + resolution: "check-error@npm:1.0.2" + checksum: d9d106504404b8addd1ee3f63f8c0eaa7cd962a1a28eb9c519b1c4a1dc7098be38007fc0060f045ee00f075fbb7a2a4f42abcf61d68323677e11ab98dc16042e + languageName: node + linkType: hard + +"chokidar@npm:3.5.3": + version: 3.5.3 + resolution: "chokidar@npm:3.5.3" + dependencies: + anymatch: ~3.1.2 + braces: ~3.0.2 + fsevents: ~2.3.2 + glob-parent: ~5.1.2 + is-binary-path: ~2.1.0 + is-glob: ~4.0.1 + normalize-path: ~3.0.0 + readdirp: ~3.6.0 + dependenciesMeta: + fsevents: + optional: true + checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c + languageName: node + linkType: hard + +"chownr@npm:^2.0.0": + version: 2.0.0 + resolution: "chownr@npm:2.0.0" + checksum: c57cf9dd0791e2f18a5ee9c1a299ae6e801ff58fee96dc8bfd0dcb4738a6ce58dd252a3605b1c93c6418fe4f9d5093b28ffbf4d66648cb2a9c67eaef9679be2f + languageName: node + linkType: hard + +"clean-stack@npm:^2.0.0": + version: 2.2.0 + resolution: "clean-stack@npm:2.2.0" + checksum: 2ac8cd2b2f5ec986a3c743935ec85b07bc174d5421a5efc8017e1f146a1cf5f781ae962618f416352103b32c9cd7e203276e8c28241bbe946160cab16149fb68 + languageName: node + linkType: hard + +"cliui@npm:^7.0.2": + version: 7.0.4 + resolution: "cliui@npm:7.0.4" + dependencies: + string-width: ^4.2.0 + strip-ansi: ^6.0.0 + wrap-ansi: ^7.0.0 + checksum: ce2e8f578a4813806788ac399b9e866297740eecd4ad1823c27fd344d78b22c5f8597d548adbcc46f0573e43e21e751f39446c5a5e804a12aace402b7a315d7f + languageName: node + linkType: hard + +"color-convert@npm:^2.0.1": + version: 2.0.1 + resolution: "color-convert@npm:2.0.1" + dependencies: + color-name: ~1.1.4 + checksum: 79e6bdb9fd479a205c71d89574fccfb22bd9053bd98c6c4d870d65c132e5e904e6034978e55b43d69fcaa7433af2016ee203ce76eeba9cfa554b373e7f7db336 + languageName: node + linkType: hard + +"color-name@npm:~1.1.4": + version: 1.1.4 + resolution: "color-name@npm:1.1.4" + checksum: b0445859521eb4021cd0fb0cc1a75cecf67fceecae89b63f62b201cca8d345baf8b952c966862a9d9a2632987d4f6581f0ec8d957dfacece86f0a7919316f610 + languageName: node + linkType: hard + +"color-support@npm:^1.1.3": + version: 1.1.3 + resolution: "color-support@npm:1.1.3" + bin: + color-support: bin.js + checksum: 9b7356817670b9a13a26ca5af1c21615463b500783b739b7634a0c2047c16cef4b2865d7576875c31c3cddf9dd621fa19285e628f20198b233a5cfdda6d0793b + languageName: node + linkType: hard + +"commander@npm:^2.20.3": + version: 2.20.3 + resolution: "commander@npm:2.20.3" + checksum: ab8c07884e42c3a8dbc5dd9592c606176c7eb5c1ca5ff274bcf907039b2c41de3626f684ea75ccf4d361ba004bbaff1f577d5384c155f3871e456bdf27becf9e + languageName: node + linkType: hard + +"concat-map@npm:0.0.1": + version: 0.0.1 + resolution: "concat-map@npm:0.0.1" + checksum: 902a9f5d8967a3e2faf138d5cb784b9979bad2e6db5357c5b21c568df4ebe62bcb15108af1b2253744844eb964fc023fbd9afbbbb6ddd0bcc204c6fb5b7bf3af + languageName: node + linkType: hard + +"console-control-strings@npm:^1.1.0": + version: 1.1.0 + resolution: "console-control-strings@npm:1.1.0" + checksum: 8755d76787f94e6cf79ce4666f0c5519906d7f5b02d4b884cf41e11dcd759ed69c57da0670afd9236d229a46e0f9cf519db0cd829c6dca820bb5a5c3def584ed + languageName: node + linkType: hard + +"cross-fetch@npm:^3.1.5": + version: 3.1.8 + resolution: "cross-fetch@npm:3.1.8" + dependencies: + node-fetch: ^2.6.12 + checksum: 78f993fa099eaaa041122ab037fe9503ecbbcb9daef234d1d2e0b9230a983f64d645d088c464e21a247b825a08dc444a6e7064adfa93536d3a9454b4745b3632 + languageName: node + linkType: hard + +"cross-spawn@npm:^7.0.0": + version: 7.0.3 + resolution: "cross-spawn@npm:7.0.3" + dependencies: + path-key: ^3.1.0 + shebang-command: ^2.0.0 + which: ^2.0.1 + checksum: 671cc7c7288c3a8406f3c69a3ae2fc85555c04169e9d611def9a675635472614f1c0ed0ef80955d5b6d4e724f6ced67f0ad1bb006c2ea643488fcfef994d7f52 + languageName: node + linkType: hard + +"crypto-hash@npm:^1.3.0": + version: 1.3.0 + resolution: "crypto-hash@npm:1.3.0" + checksum: a3a507e0d2b18fbd2da8088a1c62d0c53c009a99bbfa6d851cac069734ffa546922fa51bdd776d006459701cdda873463e5059ece3431aca048fd99e7573d138 + languageName: node + linkType: hard + +"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.3.3": + version: 4.3.4 + resolution: "debug@npm:4.3.4" + dependencies: + ms: 2.1.2 + peerDependenciesMeta: + supports-color: + optional: true + checksum: 3dbad3f94ea64f34431a9cbf0bafb61853eda57bff2880036153438f50fb5a84f27683ba0d8e5426bf41a8c6ff03879488120cf5b3a761e77953169c0600a708 + languageName: node + linkType: hard + +"debug@npm:4.3.3": + version: 4.3.3 + resolution: "debug@npm:4.3.3" + dependencies: + ms: 2.1.2 + peerDependenciesMeta: + supports-color: + optional: true + checksum: 14472d56fe4a94dbcfaa6dbed2dd3849f1d72ba78104a1a328047bb564643ca49df0224c3a17fa63533fd11dd3d4c8636cd861191232a2c6735af00cc2d4de16 + languageName: node + linkType: hard + +"decamelize@npm:^4.0.0": + version: 4.0.0 + resolution: "decamelize@npm:4.0.0" + checksum: b7d09b82652c39eead4d6678bb578e3bebd848add894b76d0f6b395bc45b2d692fb88d977e7cfb93c4ed6c119b05a1347cef261174916c2e75c0a8ca57da1809 + languageName: node + linkType: hard + +"deep-eql@npm:^4.1.2": + version: 4.1.3 + resolution: "deep-eql@npm:4.1.3" + dependencies: + type-detect: ^4.0.0 + checksum: 7f6d30cb41c713973dc07eaadded848b2ab0b835e518a88b91bea72f34e08c4c71d167a722a6f302d3a6108f05afd8e6d7650689a84d5d29ec7fe6220420397f + languageName: node + linkType: hard + +"delay@npm:^5.0.0": + version: 5.0.0 + resolution: "delay@npm:5.0.0" + checksum: 62f151151ecfde0d9afbb8a6be37a6d103c4cb24f35a20ef3fe56f920b0d0d0bb02bc9c0a3084d0179ef669ca332b91155f2ee4d9854622cd2cdba5fc95285f9 + languageName: node + linkType: hard + +"delegates@npm:^1.0.0": + version: 1.0.0 + resolution: "delegates@npm:1.0.0" + checksum: a51744d9b53c164ba9c0492471a1a2ffa0b6727451bdc89e31627fdf4adda9d51277cfcbfb20f0a6f08ccb3c436f341df3e92631a3440226d93a8971724771fd + languageName: node + linkType: hard + +"depd@npm:^2.0.0": + version: 2.0.0 + resolution: "depd@npm:2.0.0" + checksum: abbe19c768c97ee2eed6282d8ce3031126662252c58d711f646921c9623f9052e3e1906443066beec1095832f534e57c523b7333f8e7e0d93051ab6baef5ab3a + languageName: node + linkType: hard + +"diff@npm:5.0.0": + version: 5.0.0 + resolution: "diff@npm:5.0.0" + checksum: f19fe29284b633afdb2725c2a8bb7d25761ea54d321d8e67987ac851c5294be4afeab532bd84531e02583a3fe7f4014aa314a3eda84f5590e7a9e6b371ef3b46 + languageName: node + linkType: hard + +"diff@npm:^3.1.0": + version: 3.5.0 + resolution: "diff@npm:3.5.0" + checksum: 00842950a6551e26ce495bdbce11047e31667deea546527902661f25cc2e73358967ebc78cf86b1a9736ec3e14286433225f9970678155753a6291c3bca5227b + languageName: node + linkType: hard + +"dot-case@npm:^3.0.4": + version: 3.0.4 + resolution: "dot-case@npm:3.0.4" + dependencies: + no-case: ^3.0.4 + tslib: ^2.0.3 + checksum: a65e3519414856df0228b9f645332f974f2bf5433370f544a681122eab59e66038fc3349b4be1cdc47152779dac71a5864f1ccda2f745e767c46e9c6543b1169 + languageName: node + linkType: hard + +"eastasianwidth@npm:^0.2.0": + version: 0.2.0 + resolution: "eastasianwidth@npm:0.2.0" + checksum: 7d00d7cd8e49b9afa762a813faac332dee781932d6f2c848dc348939c4253f1d4564341b7af1d041853bc3f32c2ef141b58e0a4d9862c17a7f08f68df1e0f1ed + languageName: node + linkType: hard + +"emoji-regex@npm:^8.0.0": + version: 8.0.0 + resolution: "emoji-regex@npm:8.0.0" + checksum: d4c5c39d5a9868b5fa152f00cada8a936868fd3367f33f71be515ecee4c803132d11b31a6222b2571b1e5f7e13890156a94880345594d0ce7e3c9895f560f192 + languageName: node + linkType: hard + +"emoji-regex@npm:^9.2.2": + version: 9.2.2 + resolution: "emoji-regex@npm:9.2.2" + checksum: 8487182da74aabd810ac6d6f1994111dfc0e331b01271ae01ec1eb0ad7b5ecc2bbbbd2f053c05cb55a1ac30449527d819bbfbf0e3de1023db308cbcb47f86601 + languageName: node + linkType: hard + +"encoding@npm:^0.1.13": + version: 0.1.13 + resolution: "encoding@npm:0.1.13" + dependencies: + iconv-lite: ^0.6.2 + checksum: bb98632f8ffa823996e508ce6a58ffcf5856330fde839ae42c9e1f436cc3b5cc651d4aeae72222916545428e54fd0f6aa8862fd8d25bdbcc4589f1e3f3715e7f + languageName: node + linkType: hard + +"env-paths@npm:^2.2.0": + version: 2.2.1 + resolution: "env-paths@npm:2.2.1" + checksum: 65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e + languageName: node + linkType: hard + +"err-code@npm:^2.0.2": + version: 2.0.3 + resolution: "err-code@npm:2.0.3" + checksum: 8b7b1be20d2de12d2255c0bc2ca638b7af5171142693299416e6a9339bd7d88fc8d7707d913d78e0993176005405a236b066b45666b27b797252c771156ace54 + languageName: node + linkType: hard + +"es6-promise@npm:^4.0.3": + version: 4.2.8 + resolution: "es6-promise@npm:4.2.8" + checksum: 95614a88873611cb9165a85d36afa7268af5c03a378b35ca7bda9508e1d4f1f6f19a788d4bc755b3fd37c8ebba40782018e02034564ff24c9d6fa37e959ad57d + languageName: node + linkType: hard + +"es6-promisify@npm:^5.0.0": + version: 5.0.0 + resolution: "es6-promisify@npm:5.0.0" + dependencies: + es6-promise: ^4.0.3 + checksum: fbed9d791598831413be84a5374eca8c24800ec71a16c1c528c43a98e2dadfb99331483d83ae6094ddb9b87e6f799a15d1553cebf756047e0865c753bc346b92 + languageName: node + linkType: hard + +"escalade@npm:^3.1.1": + version: 3.1.1 + resolution: "escalade@npm:3.1.1" + checksum: a3e2a99f07acb74b3ad4989c48ca0c3140f69f923e56d0cba0526240ee470b91010f9d39001f2a4a313841d237ede70a729e92125191ba5d21e74b106800b133 + languageName: node + linkType: hard + +"escape-string-regexp@npm:4.0.0": + version: 4.0.0 + resolution: "escape-string-regexp@npm:4.0.0" + checksum: 98b48897d93060f2322108bf29db0feba7dd774be96cd069458d1453347b25ce8682ecc39859d4bca2203cc0ab19c237bcc71755eff49a0f8d90beadeeba5cc5 + languageName: node + linkType: hard + +"eventemitter3@npm:^4.0.7": + version: 4.0.7 + resolution: "eventemitter3@npm:4.0.7" + checksum: 1875311c42fcfe9c707b2712c32664a245629b42bb0a5a84439762dd0fd637fc54d078155ea83c2af9e0323c9ac13687e03cfba79b03af9f40c89b4960099374 + languageName: node + linkType: hard + +"exponential-backoff@npm:^3.1.1": + version: 3.1.1 + resolution: "exponential-backoff@npm:3.1.1" + checksum: 3d21519a4f8207c99f7457287291316306255a328770d320b401114ec8481986e4e467e854cb9914dd965e0a1ca810a23ccb559c642c88f4c7f55c55778a9b48 + languageName: node + linkType: hard + +"eyes@npm:^0.1.8": + version: 0.1.8 + resolution: "eyes@npm:0.1.8" + checksum: c31703a92bf36ba75ee8d379ee7985c24ee6149f3a6175f44cec7a05b178c38bce9836d3ca48c9acb0329a960ac2c4b2ead4e60cdd4fe6e8c92cad7cd6913687 + languageName: node + linkType: hard + +"fast-stable-stringify@npm:^1.0.0": + version: 1.0.0 + resolution: "fast-stable-stringify@npm:1.0.0" + checksum: ef1203d246a7e8ac15e2bfbda0a89fa375947bccf9f7910be0ea759856dbe8ea5024a0d8cc2cceabe18a9cb67e95927b78bb6173a3ae37ec55a518cf36e5244b + languageName: node + linkType: hard + +"file-uri-to-path@npm:1.0.0": + version: 1.0.0 + resolution: "file-uri-to-path@npm:1.0.0" + checksum: b648580bdd893a008c92c7ecc96c3ee57a5e7b6c4c18a9a09b44fb5d36d79146f8e442578bc0e173dc027adf3987e254ba1dfd6e3ec998b7c282873010502144 + languageName: node + linkType: hard + +"fill-range@npm:^7.0.1": + version: 7.0.1 + resolution: "fill-range@npm:7.0.1" + dependencies: + to-regex-range: ^5.0.1 + checksum: cc283f4e65b504259e64fd969bcf4def4eb08d85565e906b7d36516e87819db52029a76b6363d0f02d0d532f0033c9603b9e2d943d56ee3b0d4f7ad3328ff917 + languageName: node + linkType: hard + +"find-up@npm:5.0.0": + version: 5.0.0 + resolution: "find-up@npm:5.0.0" + dependencies: + locate-path: ^6.0.0 + path-exists: ^4.0.0 + checksum: 07955e357348f34660bde7920783204ff5a26ac2cafcaa28bace494027158a97b9f56faaf2d89a6106211a8174db650dd9f503f9c0d526b1202d5554a00b9095 + languageName: node + linkType: hard + +"flat@npm:^5.0.2": + version: 5.0.2 + resolution: "flat@npm:5.0.2" + bin: + flat: cli.js + checksum: 12a1536ac746db74881316a181499a78ef953632ddd28050b7a3a43c62ef5462e3357c8c29d76072bb635f147f7a9a1f0c02efef6b4be28f8db62ceb3d5c7f5d + languageName: node + linkType: hard + +"foreground-child@npm:^3.1.0": + version: 3.1.1 + resolution: "foreground-child@npm:3.1.1" + dependencies: + cross-spawn: ^7.0.0 + signal-exit: ^4.0.1 + checksum: 139d270bc82dc9e6f8bc045fe2aae4001dc2472157044fdfad376d0a3457f77857fa883c1c8b21b491c6caade9a926a4bed3d3d2e8d3c9202b151a4cbbd0bcd5 + languageName: node + linkType: hard + +"fs-minipass@npm:^2.0.0": + version: 2.1.0 + resolution: "fs-minipass@npm:2.1.0" + dependencies: + minipass: ^3.0.0 + checksum: 1b8d128dae2ac6cc94230cc5ead341ba3e0efaef82dab46a33d171c044caaa6ca001364178d42069b2809c35a1c3c35079a32107c770e9ffab3901b59af8c8b1 + languageName: node + linkType: hard + +"fs-minipass@npm:^3.0.0": + version: 3.0.2 + resolution: "fs-minipass@npm:3.0.2" + dependencies: + minipass: ^5.0.0 + checksum: e9cc0e1f2d01c6f6f62f567aee59530aba65c6c7b2ae88c5027bc34c711ebcfcfaefd0caf254afa6adfe7d1fba16bc2537508a6235196bac7276747d078aef0a + languageName: node + linkType: hard + +"fs.realpath@npm:^1.0.0": + version: 1.0.0 + resolution: "fs.realpath@npm:1.0.0" + checksum: 99ddea01a7e75aa276c250a04eedeffe5662bce66c65c07164ad6264f9de18fb21be9433ead460e54cff20e31721c811f4fb5d70591799df5f85dce6d6746fd0 + languageName: node + linkType: hard + +"fsevents@npm:~2.3.2": + version: 2.3.2 + resolution: "fsevents@npm:2.3.2" + dependencies: + node-gyp: latest + checksum: 97ade64e75091afee5265e6956cb72ba34db7819b4c3e94c431d4be2b19b8bb7a2d4116da417950c3425f17c8fe693d25e20212cac583ac1521ad066b77ae31f + conditions: os=darwin + languageName: node + linkType: hard + +"fsevents@patch:fsevents@~2.3.2#~builtin": + version: 2.3.2 + resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" + dependencies: + node-gyp: latest + conditions: os=darwin + languageName: node + linkType: hard + +"gauge@npm:^4.0.3": + version: 4.0.4 + resolution: "gauge@npm:4.0.4" + dependencies: + aproba: ^1.0.3 || ^2.0.0 + color-support: ^1.1.3 + console-control-strings: ^1.1.0 + has-unicode: ^2.0.1 + signal-exit: ^3.0.7 + string-width: ^4.2.3 + strip-ansi: ^6.0.1 + wide-align: ^1.1.5 + checksum: 788b6bfe52f1dd8e263cda800c26ac0ca2ff6de0b6eee2fe0d9e3abf15e149b651bd27bf5226be10e6e3edb5c4e5d5985a5a1a98137e7a892f75eff76467ad2d + languageName: node + linkType: hard + +"get-caller-file@npm:^2.0.5": + version: 2.0.5 + resolution: "get-caller-file@npm:2.0.5" + checksum: b9769a836d2a98c3ee734a88ba712e62703f1df31b94b784762c433c27a386dd6029ff55c2a920c392e33657d80191edbf18c61487e198844844516f843496b9 + languageName: node + linkType: hard + +"get-func-name@npm:^2.0.0": + version: 2.0.0 + resolution: "get-func-name@npm:2.0.0" + checksum: 8d82e69f3e7fab9e27c547945dfe5cc0c57fc0adf08ce135dddb01081d75684a03e7a0487466f478872b341d52ac763ae49e660d01ab83741f74932085f693c3 + languageName: node + linkType: hard + +"glob-parent@npm:~5.1.2": + version: 5.1.2 + resolution: "glob-parent@npm:5.1.2" + dependencies: + is-glob: ^4.0.1 + checksum: f4f2bfe2425296e8a47e36864e4f42be38a996db40420fe434565e4480e3322f18eb37589617a98640c5dc8fdec1a387007ee18dbb1f3f5553409c34d17f425e + languageName: node + linkType: hard + +"glob@npm:7.2.0": + version: 7.2.0 + resolution: "glob@npm:7.2.0" + dependencies: + fs.realpath: ^1.0.0 + inflight: ^1.0.4 + inherits: 2 + minimatch: ^3.0.4 + once: ^1.3.0 + path-is-absolute: ^1.0.0 + checksum: 78a8ea942331f08ed2e055cb5b9e40fe6f46f579d7fd3d694f3412fe5db23223d29b7fee1575440202e9a7ff9a72ab106a39fee39934c7bedafe5e5f8ae20134 + languageName: node + linkType: hard + +"glob@npm:^10.2.2": + version: 10.3.3 + resolution: "glob@npm:10.3.3" + dependencies: + foreground-child: ^3.1.0 + jackspeak: ^2.0.3 + minimatch: ^9.0.1 + minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 + path-scurry: ^1.10.1 + bin: + glob: dist/cjs/src/bin.js + checksum: 29190d3291f422da0cb40b77a72fc8d2c51a36524e99b8bf412548b7676a6627489528b57250429612b6eec2e6fe7826d328451d3e694a9d15e575389308ec53 + languageName: node + linkType: hard + +"glob@npm:^7.1.3, glob@npm:^7.1.4": + version: 7.2.3 + resolution: "glob@npm:7.2.3" + dependencies: + fs.realpath: ^1.0.0 + inflight: ^1.0.4 + inherits: 2 + minimatch: ^3.1.1 + once: ^1.3.0 + path-is-absolute: ^1.0.0 + checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133 + languageName: node + linkType: hard + +"graceful-fs@npm:^4.2.6": + version: 4.2.11 + resolution: "graceful-fs@npm:4.2.11" + checksum: ac85f94da92d8eb6b7f5a8b20ce65e43d66761c55ce85ac96df6865308390da45a8d3f0296dd3a663de65d30ba497bd46c696cc1e248c72b13d6d567138a4fc7 + languageName: node + linkType: hard + +"growl@npm:1.10.5": + version: 1.10.5 + resolution: "growl@npm:1.10.5" + checksum: 4b86685de6831cebcbb19f93870bea624afee61124b0a20c49017013987cd129e73a8c4baeca295728f41d21265e1f859d25ef36731b142ca59c655fea94bb1a + languageName: node + linkType: hard + +"has-flag@npm:^4.0.0": + version: 4.0.0 + resolution: "has-flag@npm:4.0.0" + checksum: 261a1357037ead75e338156b1f9452c016a37dcd3283a972a30d9e4a87441ba372c8b81f818cd0fbcd9c0354b4ae7e18b9e1afa1971164aef6d18c2b6095a8ad + languageName: node + linkType: hard + +"has-unicode@npm:^2.0.1": + version: 2.0.1 + resolution: "has-unicode@npm:2.0.1" + checksum: 1eab07a7436512db0be40a710b29b5dc21fa04880b7f63c9980b706683127e3c1b57cb80ea96d47991bdae2dfe479604f6a1ba410106ee1046a41d1bd0814400 + languageName: node + linkType: hard + +"he@npm:1.2.0": + version: 1.2.0 + resolution: "he@npm:1.2.0" + bin: + he: bin/he + checksum: 3d4d6babccccd79c5c5a3f929a68af33360d6445587d628087f39a965079d84f18ce9c3d3f917ee1e3978916fc833bb8b29377c3b403f919426f91bc6965e7a7 + languageName: node + linkType: hard + +"http-cache-semantics@npm:^4.1.1": + version: 4.1.1 + resolution: "http-cache-semantics@npm:4.1.1" + checksum: 83ac0bc60b17a3a36f9953e7be55e5c8f41acc61b22583060e8dedc9dd5e3607c823a88d0926f9150e571f90946835c7fe150732801010845c72cd8bbff1a236 + languageName: node + linkType: hard + +"http-proxy-agent@npm:^5.0.0": + version: 5.0.0 + resolution: "http-proxy-agent@npm:5.0.0" + dependencies: + "@tootallnate/once": 2 + agent-base: 6 + debug: 4 + checksum: e2ee1ff1656a131953839b2a19cd1f3a52d97c25ba87bd2559af6ae87114abf60971e498021f9b73f9fd78aea8876d1fb0d4656aac8a03c6caa9fc175f22b786 + languageName: node + linkType: hard + +"https-proxy-agent@npm:^5.0.0": + version: 5.0.1 + resolution: "https-proxy-agent@npm:5.0.1" + dependencies: + agent-base: 6 + debug: 4 + checksum: 571fccdf38184f05943e12d37d6ce38197becdd69e58d03f43637f7fa1269cf303a7d228aa27e5b27bbd3af8f09fd938e1c91dcfefff2df7ba77c20ed8dfc765 + languageName: node + linkType: hard + +"humanize-ms@npm:^1.2.1": + version: 1.2.1 + resolution: "humanize-ms@npm:1.2.1" + dependencies: + ms: ^2.0.0 + checksum: 9c7a74a2827f9294c009266c82031030eae811ca87b0da3dceb8d6071b9bde22c9f3daef0469c3c533cc67a97d8a167cd9fc0389350e5f415f61a79b171ded16 + languageName: node + linkType: hard + +"iconv-lite@npm:^0.6.2": + version: 0.6.3 + resolution: "iconv-lite@npm:0.6.3" + dependencies: + safer-buffer: ">= 2.1.2 < 3.0.0" + checksum: 3f60d47a5c8fc3313317edfd29a00a692cc87a19cac0159e2ce711d0ebc9019064108323b5e493625e25594f11c6236647d8e256fbe7a58f4a3b33b89e6d30bf + languageName: node + linkType: hard + +"ieee754@npm:^1.2.1": + version: 1.2.1 + resolution: "ieee754@npm:1.2.1" + checksum: 5144c0c9815e54ada181d80a0b810221a253562422e7c6c3a60b1901154184f49326ec239d618c416c1c5945a2e197107aee8d986a3dd836b53dffefd99b5e7e + languageName: node + linkType: hard + +"imurmurhash@npm:^0.1.4": + version: 0.1.4 + resolution: "imurmurhash@npm:0.1.4" + checksum: 7cae75c8cd9a50f57dadd77482359f659eaebac0319dd9368bcd1714f55e65badd6929ca58569da2b6494ef13fdd5598cd700b1eba23f8b79c5f19d195a3ecf7 + languageName: node + linkType: hard + +"indent-string@npm:^4.0.0": + version: 4.0.0 + resolution: "indent-string@npm:4.0.0" + checksum: 824cfb9929d031dabf059bebfe08cf3137365e112019086ed3dcff6a0a7b698cb80cf67ccccde0e25b9e2d7527aa6cc1fed1ac490c752162496caba3e6699612 + languageName: node + linkType: hard + +"inflight@npm:^1.0.4": + version: 1.0.6 + resolution: "inflight@npm:1.0.6" + dependencies: + once: ^1.3.0 + wrappy: 1 + checksum: f4f76aa072ce19fae87ce1ef7d221e709afb59d445e05d47fba710e85470923a75de35bfae47da6de1b18afc3ce83d70facf44cfb0aff89f0a3f45c0a0244dfd + languageName: node + linkType: hard + +"inherits@npm:2, inherits@npm:^2.0.3": + version: 2.0.4 + resolution: "inherits@npm:2.0.4" + checksum: 4a48a733847879d6cf6691860a6b1e3f0f4754176e4d71494c41f3475553768b10f84b5ce1d40fbd0e34e6bfbb864ee35858ad4dd2cf31e02fc4a154b724d7f1 + languageName: node + linkType: hard + +"ip@npm:^2.0.0": + version: 2.0.0 + resolution: "ip@npm:2.0.0" + checksum: cfcfac6b873b701996d71ec82a7dd27ba92450afdb421e356f44044ed688df04567344c36cbacea7d01b1c39a4c732dc012570ebe9bebfb06f27314bca625349 + languageName: node + linkType: hard + +"is-binary-path@npm:~2.1.0": + version: 2.1.0 + resolution: "is-binary-path@npm:2.1.0" + dependencies: + binary-extensions: ^2.0.0 + checksum: 84192eb88cff70d320426f35ecd63c3d6d495da9d805b19bc65b518984b7c0760280e57dbf119b7e9be6b161784a5a673ab2c6abe83abb5198a432232ad5b35c + languageName: node + linkType: hard + +"is-extglob@npm:^2.1.1": + version: 2.1.1 + resolution: "is-extglob@npm:2.1.1" + checksum: df033653d06d0eb567461e58a7a8c9f940bd8c22274b94bf7671ab36df5719791aae15eef6d83bbb5e23283967f2f984b8914559d4449efda578c775c4be6f85 + languageName: node + linkType: hard + +"is-fullwidth-code-point@npm:^3.0.0": + version: 3.0.0 + resolution: "is-fullwidth-code-point@npm:3.0.0" + checksum: 44a30c29457c7fb8f00297bce733f0a64cd22eca270f83e58c105e0d015e45c019491a4ab2faef91ab51d4738c670daff901c799f6a700e27f7314029e99e348 + languageName: node + linkType: hard + +"is-glob@npm:^4.0.1, is-glob@npm:~4.0.1": + version: 4.0.3 + resolution: "is-glob@npm:4.0.3" + dependencies: + is-extglob: ^2.1.1 + checksum: d381c1319fcb69d341cc6e6c7cd588e17cd94722d9a32dbd60660b993c4fb7d0f19438674e68dfec686d09b7c73139c9166b47597f846af387450224a8101ab4 + languageName: node + linkType: hard + +"is-lambda@npm:^1.0.1": + version: 1.0.1 + resolution: "is-lambda@npm:1.0.1" + checksum: 93a32f01940220532e5948538699ad610d5924ac86093fcee83022252b363eb0cc99ba53ab084a04e4fb62bf7b5731f55496257a4c38adf87af9c4d352c71c35 + languageName: node + linkType: hard + +"is-number@npm:^7.0.0": + version: 7.0.0 + resolution: "is-number@npm:7.0.0" + checksum: 456ac6f8e0f3111ed34668a624e45315201dff921e5ac181f8ec24923b99e9f32ca1a194912dc79d539c97d33dba17dc635202ff0b2cf98326f608323276d27a + languageName: node + linkType: hard + +"is-plain-obj@npm:^2.1.0": + version: 2.1.0 + resolution: "is-plain-obj@npm:2.1.0" + checksum: cec9100678b0a9fe0248a81743041ed990c2d4c99f893d935545cfbc42876cbe86d207f3b895700c690ad2fa520e568c44afc1605044b535a7820c1d40e38daa + languageName: node + linkType: hard + +"is-unicode-supported@npm:^0.1.0": + version: 0.1.0 + resolution: "is-unicode-supported@npm:0.1.0" + checksum: a2aab86ee7712f5c2f999180daaba5f361bdad1efadc9610ff5b8ab5495b86e4f627839d085c6530363c6d6d4ecbde340fb8e54bdb83da4ba8e0865ed5513c52 + languageName: node + linkType: hard + +"isexe@npm:^2.0.0": + version: 2.0.0 + resolution: "isexe@npm:2.0.0" + checksum: 26bf6c5480dda5161c820c5b5c751ae1e766c587b1f951ea3fcfc973bafb7831ae5b54a31a69bd670220e42e99ec154475025a468eae58ea262f813fdc8d1c62 + languageName: node + linkType: hard + +"isomorphic-ws@npm:^4.0.1": + version: 4.0.1 + resolution: "isomorphic-ws@npm:4.0.1" + peerDependencies: + ws: "*" + checksum: d7190eadefdc28bdb93d67b5f0c603385aaf87724fa2974abb382ac1ec9756ed2cfb27065cbe76122879c2d452e2982bc4314317f3d6c737ddda6c047328771a + languageName: node + linkType: hard + +"jackspeak@npm:^2.0.3": + version: 2.2.1 + resolution: "jackspeak@npm:2.2.1" + dependencies: + "@isaacs/cliui": ^8.0.2 + "@pkgjs/parseargs": ^0.11.0 + dependenciesMeta: + "@pkgjs/parseargs": + optional: true + checksum: e29291c0d0f280a063fa18fbd1e891ab8c2d7519fd34052c0ebde38538a15c603140d60c2c7f432375ff7ee4c5f1c10daa8b2ae19a97c3d4affe308c8360c1df + languageName: node + linkType: hard + +"jayson@npm:^4.1.0": + version: 4.1.0 + resolution: "jayson@npm:4.1.0" + dependencies: + "@types/connect": ^3.4.33 + "@types/node": ^12.12.54 + "@types/ws": ^7.4.4 + JSONStream: ^1.3.5 + commander: ^2.20.3 + delay: ^5.0.0 + es6-promisify: ^5.0.0 + eyes: ^0.1.8 + isomorphic-ws: ^4.0.1 + json-stringify-safe: ^5.0.1 + uuid: ^8.3.2 + ws: ^7.4.5 + bin: + jayson: bin/jayson.js + checksum: 86464322fbdc6db65d2bb4fc278cb6c86fad5c2a506065490d39459f09ba0d30f2b4fb740b33828a1424791419b6c8bd295dc54d361a4ad959bf70cc62b1ca7e + languageName: node + linkType: hard + +"js-sha256@npm:^0.9.0": + version: 0.9.0 + resolution: "js-sha256@npm:0.9.0" + checksum: ffad54b3373f81581e245866abfda50a62c483803a28176dd5c28fd2d313e0bdf830e77dac7ff8afd193c53031618920f3d98daf21cbbe80082753ab639c0365 + languageName: node + linkType: hard + +"js-yaml@npm:4.1.0": + version: 4.1.0 + resolution: "js-yaml@npm:4.1.0" + dependencies: + argparse: ^2.0.1 + bin: + js-yaml: bin/js-yaml.js + checksum: c7830dfd456c3ef2c6e355cc5a92e6700ceafa1d14bba54497b34a99f0376cecbb3e9ac14d3e5849b426d5a5140709a66237a8c991c675431271c4ce5504151a + languageName: node + linkType: hard + +"json-stringify-safe@npm:^5.0.1": + version: 5.0.1 + resolution: "json-stringify-safe@npm:5.0.1" + checksum: 48ec0adad5280b8a96bb93f4563aa1667fd7a36334f79149abd42446d0989f2ddc58274b479f4819f1f00617957e6344c886c55d05a4e15ebb4ab931e4a6a8ee + languageName: node + linkType: hard + +"json5@npm:^1.0.2": + version: 1.0.2 + resolution: "json5@npm:1.0.2" + dependencies: + minimist: ^1.2.0 + bin: + json5: lib/cli.js + checksum: 866458a8c58a95a49bef3adba929c625e82532bcff1fe93f01d29cb02cac7c3fe1f4b79951b7792c2da9de0b32871a8401a6e3c5b36778ad852bf5b8a61165d7 + languageName: node + linkType: hard + +"jsonparse@npm:^1.2.0": + version: 1.3.1 + resolution: "jsonparse@npm:1.3.1" + checksum: 6514a7be4674ebf407afca0eda3ba284b69b07f9958a8d3113ef1005f7ec610860c312be067e450c569aab8b89635e332cee3696789c750692bb60daba627f4d + languageName: node + linkType: hard + +"locate-path@npm:^6.0.0": + version: 6.0.0 + resolution: "locate-path@npm:6.0.0" + dependencies: + p-locate: ^5.0.0 + checksum: 72eb661788a0368c099a184c59d2fee760b3831c9c1c33955e8a19ae4a21b4116e53fa736dc086cdeb9fce9f7cc508f2f92d2d3aae516f133e16a2bb59a39f5a + languageName: node + linkType: hard + +"log-symbols@npm:4.1.0": + version: 4.1.0 + resolution: "log-symbols@npm:4.1.0" + dependencies: + chalk: ^4.1.0 + is-unicode-supported: ^0.1.0 + checksum: fce1497b3135a0198803f9f07464165e9eb83ed02ceb2273930a6f8a508951178d8cf4f0378e9d28300a2ed2bc49050995d2bd5f53ab716bb15ac84d58c6ef74 + languageName: node + linkType: hard + +"loupe@npm:^2.3.1": + version: 2.3.6 + resolution: "loupe@npm:2.3.6" + dependencies: + get-func-name: ^2.0.0 + checksum: cc83f1b124a1df7384601d72d8d1f5fe95fd7a8185469fec48bb2e4027e45243949e7a013e8d91051a138451ff0552310c32aa9786e60b6a30d1e801bdc2163f + languageName: node + linkType: hard + +"lower-case@npm:^2.0.2": + version: 2.0.2 + resolution: "lower-case@npm:2.0.2" + dependencies: + tslib: ^2.0.3 + checksum: 83a0a5f159ad7614bee8bf976b96275f3954335a84fad2696927f609ddae902802c4f3312d86668722e668bef41400254807e1d3a7f2e8c3eede79691aa1f010 + languageName: node + linkType: hard + +"lru-cache@npm:^6.0.0": + version: 6.0.0 + resolution: "lru-cache@npm:6.0.0" + dependencies: + yallist: ^4.0.0 + checksum: f97f499f898f23e4585742138a22f22526254fdba6d75d41a1c2526b3b6cc5747ef59c5612ba7375f42aca4f8461950e925ba08c991ead0651b4918b7c978297 + languageName: node + linkType: hard + +"lru-cache@npm:^7.7.1": + version: 7.18.3 + resolution: "lru-cache@npm:7.18.3" + checksum: e550d772384709deea3f141af34b6d4fa392e2e418c1498c078de0ee63670f1f46f5eee746e8ef7e69e1c895af0d4224e62ee33e66a543a14763b0f2e74c1356 + languageName: node + linkType: hard + +"lru-cache@npm:^9.1.1 || ^10.0.0": + version: 10.0.0 + resolution: "lru-cache@npm:10.0.0" + checksum: 18f101675fe283bc09cda0ef1e3cc83781aeb8373b439f086f758d1d91b28730950db785999cd060d3c825a8571c03073e8c14512b6655af2188d623031baf50 + languageName: node + linkType: hard + +"make-error@npm:^1.1.1": + version: 1.3.6 + resolution: "make-error@npm:1.3.6" + checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 + languageName: node + linkType: hard + +"make-fetch-happen@npm:^11.0.3": + version: 11.1.1 + resolution: "make-fetch-happen@npm:11.1.1" + dependencies: + agentkeepalive: ^4.2.1 + cacache: ^17.0.0 + http-cache-semantics: ^4.1.1 + http-proxy-agent: ^5.0.0 + https-proxy-agent: ^5.0.0 + is-lambda: ^1.0.1 + lru-cache: ^7.7.1 + minipass: ^5.0.0 + minipass-fetch: ^3.0.0 + minipass-flush: ^1.0.5 + minipass-pipeline: ^1.2.4 + negotiator: ^0.6.3 + promise-retry: ^2.0.1 + socks-proxy-agent: ^7.0.0 + ssri: ^10.0.0 + checksum: 7268bf274a0f6dcf0343829489a4506603ff34bd0649c12058753900b0eb29191dce5dba12680719a5d0a983d3e57810f594a12f3c18494e93a1fbc6348a4540 + languageName: node + linkType: hard + +"minimatch@npm:4.2.1": + version: 4.2.1 + resolution: "minimatch@npm:4.2.1" + dependencies: + brace-expansion: ^1.1.7 + checksum: 2b1514e3d0f29a549912f0db7ae7b82c5cab4a8f2dd0369f1c6451a325b3f12b2cf473c95873b6157bb8df183d6cf6db82ff03614b6adaaf1d7e055beccdfd01 + languageName: node + linkType: hard + +"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1": + version: 3.1.2 + resolution: "minimatch@npm:3.1.2" + dependencies: + brace-expansion: ^1.1.7 + checksum: c154e566406683e7bcb746e000b84d74465b3a832c45d59912b9b55cd50dee66e5c4b1e5566dba26154040e51672f9aa450a9aef0c97cfc7336b78b7afb9540a + languageName: node + linkType: hard + +"minimatch@npm:^9.0.1": + version: 9.0.3 + resolution: "minimatch@npm:9.0.3" + dependencies: + brace-expansion: ^2.0.1 + checksum: 253487976bf485b612f16bf57463520a14f512662e592e95c571afdab1442a6a6864b6c88f248ce6fc4ff0b6de04ac7aa6c8bb51e868e99d1d65eb0658a708b5 + languageName: node + linkType: hard + +"minimist@npm:^1.2.0, minimist@npm:^1.2.6": + version: 1.2.8 + resolution: "minimist@npm:1.2.8" + checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0 + languageName: node + linkType: hard + +"minipass-collect@npm:^1.0.2": + version: 1.0.2 + resolution: "minipass-collect@npm:1.0.2" + dependencies: + minipass: ^3.0.0 + checksum: 14df761028f3e47293aee72888f2657695ec66bd7d09cae7ad558da30415fdc4752bbfee66287dcc6fd5e6a2fa3466d6c484dc1cbd986525d9393b9523d97f10 + languageName: node + linkType: hard + +"minipass-fetch@npm:^3.0.0": + version: 3.0.3 + resolution: "minipass-fetch@npm:3.0.3" + dependencies: + encoding: ^0.1.13 + minipass: ^5.0.0 + minipass-sized: ^1.0.3 + minizlib: ^2.1.2 + dependenciesMeta: + encoding: + optional: true + checksum: af5ab2552a16fcf505d35fd7ffb84b57f4a0eeb269e6e1d9a2a75824dda48b36e527083250b7cca4a4def21d9544e2ade441e4730e233c0bc2133f6abda31e18 + languageName: node + linkType: hard + +"minipass-flush@npm:^1.0.5": + version: 1.0.5 + resolution: "minipass-flush@npm:1.0.5" + dependencies: + minipass: ^3.0.0 + checksum: 56269a0b22bad756a08a94b1ffc36b7c9c5de0735a4dd1ab2b06c066d795cfd1f0ac44a0fcae13eece5589b908ecddc867f04c745c7009be0b566421ea0944cf + languageName: node + linkType: hard + +"minipass-pipeline@npm:^1.2.4": + version: 1.2.4 + resolution: "minipass-pipeline@npm:1.2.4" + dependencies: + minipass: ^3.0.0 + checksum: b14240dac0d29823c3d5911c286069e36d0b81173d7bdf07a7e4a91ecdef92cdff4baaf31ea3746f1c61e0957f652e641223970870e2353593f382112257971b + languageName: node + linkType: hard + +"minipass-sized@npm:^1.0.3": + version: 1.0.3 + resolution: "minipass-sized@npm:1.0.3" + dependencies: + minipass: ^3.0.0 + checksum: 79076749fcacf21b5d16dd596d32c3b6bf4d6e62abb43868fac21674078505c8b15eaca4e47ed844985a4514854f917d78f588fcd029693709417d8f98b2bd60 + languageName: node + linkType: hard + +"minipass@npm:^3.0.0": + version: 3.3.6 + resolution: "minipass@npm:3.3.6" + dependencies: + yallist: ^4.0.0 + checksum: a30d083c8054cee83cdcdc97f97e4641a3f58ae743970457b1489ce38ee1167b3aaf7d815cd39ec7a99b9c40397fd4f686e83750e73e652b21cb516f6d845e48 + languageName: node + linkType: hard + +"minipass@npm:^5.0.0": + version: 5.0.0 + resolution: "minipass@npm:5.0.0" + checksum: 425dab288738853fded43da3314a0b5c035844d6f3097a8e3b5b29b328da8f3c1af6fc70618b32c29ff906284cf6406b6841376f21caaadd0793c1d5a6a620ea + languageName: node + linkType: hard + +"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0": + version: 7.0.2 + resolution: "minipass@npm:7.0.2" + checksum: 46776de732eb7cef2c7404a15fb28c41f5c54a22be50d47b03c605bf21f5c18d61a173c0a20b49a97e7a65f78d887245066410642551e45fffe04e9ac9e325bc + languageName: node + linkType: hard + +"minizlib@npm:^2.1.1, minizlib@npm:^2.1.2": + version: 2.1.2 + resolution: "minizlib@npm:2.1.2" + dependencies: + minipass: ^3.0.0 + yallist: ^4.0.0 + checksum: f1fdeac0b07cf8f30fcf12f4b586795b97be856edea22b5e9072707be51fc95d41487faec3f265b42973a304fe3a64acd91a44a3826a963e37b37bafde0212c3 + languageName: node + linkType: hard + +"mkdirp@npm:^0.5.1": + version: 0.5.6 + resolution: "mkdirp@npm:0.5.6" + dependencies: + minimist: ^1.2.6 + bin: + mkdirp: bin/cmd.js + checksum: 0c91b721bb12c3f9af4b77ebf73604baf350e64d80df91754dc509491ae93bf238581e59c7188360cec7cb62fc4100959245a42cfe01834efedc5e9d068376c2 + languageName: node + linkType: hard + +"mkdirp@npm:^1.0.3": + version: 1.0.4 + resolution: "mkdirp@npm:1.0.4" + bin: + mkdirp: bin/cmd.js + checksum: a96865108c6c3b1b8e1d5e9f11843de1e077e57737602de1b82030815f311be11f96f09cce59bd5b903d0b29834733e5313f9301e3ed6d6f6fba2eae0df4298f + languageName: node + linkType: hard + +"mocha@npm:^9.0.3": + version: 9.2.2 + resolution: "mocha@npm:9.2.2" + dependencies: + "@ungap/promise-all-settled": 1.1.2 + ansi-colors: 4.1.1 + browser-stdout: 1.3.1 + chokidar: 3.5.3 + debug: 4.3.3 + diff: 5.0.0 + escape-string-regexp: 4.0.0 + find-up: 5.0.0 + glob: 7.2.0 + growl: 1.10.5 + he: 1.2.0 + js-yaml: 4.1.0 + log-symbols: 4.1.0 + minimatch: 4.2.1 + ms: 2.1.3 + nanoid: 3.3.1 + serialize-javascript: 6.0.0 + strip-json-comments: 3.1.1 + supports-color: 8.1.1 + which: 2.0.2 + workerpool: 6.2.0 + yargs: 16.2.0 + yargs-parser: 20.2.4 + yargs-unparser: 2.0.0 + bin: + _mocha: bin/_mocha + mocha: bin/mocha + checksum: 4d5ca4ce33fc66627e63acdf09a634e2358c9a00f61de7788b1091b6aad430da04f97f9ecb82d56dc034b623cb833b65576136fd010d77679c03fcea5bc1e12d + languageName: node + linkType: hard + +"ms@npm:2.1.2": + version: 2.1.2 + resolution: "ms@npm:2.1.2" + checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f + languageName: node + linkType: hard + +"ms@npm:2.1.3, ms@npm:^2.0.0": + version: 2.1.3 + resolution: "ms@npm:2.1.3" + checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d + languageName: node + linkType: hard + +"nanoid@npm:3.3.1": + version: 3.3.1 + resolution: "nanoid@npm:3.3.1" + bin: + nanoid: bin/nanoid.cjs + checksum: 4ef0969e1bbe866fc223eb32276cbccb0961900bfe79104fa5abe34361979dead8d0e061410a5c03bc3d47455685adf32c09d6f27790f4a6898fb51f7df7ec86 + languageName: node + linkType: hard + +"negotiator@npm:^0.6.3": + version: 0.6.3 + resolution: "negotiator@npm:0.6.3" + checksum: b8ffeb1e262eff7968fc90a2b6767b04cfd9842582a9d0ece0af7049537266e7b2506dfb1d107a32f06dd849ab2aea834d5830f7f4d0e5cb7d36e1ae55d021d9 + languageName: node + linkType: hard + +"no-case@npm:^3.0.4": + version: 3.0.4 + resolution: "no-case@npm:3.0.4" + dependencies: + lower-case: ^2.0.2 + tslib: ^2.0.3 + checksum: 0b2ebc113dfcf737d48dde49cfebf3ad2d82a8c3188e7100c6f375e30eafbef9e9124aadc3becef237b042fd5eb0aad2fd78669c20972d045bbe7fea8ba0be5c + languageName: node + linkType: hard + +"node-fetch@npm:^2.6.11, node-fetch@npm:^2.6.12": + version: 2.6.12 + resolution: "node-fetch@npm:2.6.12" + dependencies: + whatwg-url: ^5.0.0 + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true + checksum: 3bc1655203d47ee8e313c0d96664b9673a3d4dd8002740318e9d27d14ef306693a4b2ef8d6525775056fd912a19e23f3ac0d7111ad8925877b7567b29a625592 + languageName: node + linkType: hard + +"node-gyp-build@npm:^4.3.0": + version: 4.6.0 + resolution: "node-gyp-build@npm:4.6.0" + bin: + node-gyp-build: bin.js + node-gyp-build-optional: optional.js + node-gyp-build-test: build-test.js + checksum: 25d78c5ef1f8c24291f4a370c47ba52fcea14f39272041a90a7894cd50d766f7c8cb8fb06c0f42bf6f69b204b49d9be3c8fc344aac09714d5bdb95965499eb15 + languageName: node + linkType: hard + +"node-gyp@npm:latest": + version: 9.4.0 + resolution: "node-gyp@npm:9.4.0" + dependencies: + env-paths: ^2.2.0 + exponential-backoff: ^3.1.1 + glob: ^7.1.4 + graceful-fs: ^4.2.6 + make-fetch-happen: ^11.0.3 + nopt: ^6.0.0 + npmlog: ^6.0.0 + rimraf: ^3.0.2 + semver: ^7.3.5 + tar: ^6.1.2 + which: ^2.0.2 + bin: + node-gyp: bin/node-gyp.js + checksum: 78b404e2e0639d64e145845f7f5a3cb20c0520cdaf6dda2f6e025e9b644077202ea7de1232396ba5bde3fee84cdc79604feebe6ba3ec84d464c85d407bb5da99 + languageName: node + linkType: hard + +"nopt@npm:^6.0.0": + version: 6.0.0 + resolution: "nopt@npm:6.0.0" + dependencies: + abbrev: ^1.0.0 + bin: + nopt: bin/nopt.js + checksum: 82149371f8be0c4b9ec2f863cc6509a7fd0fa729929c009f3a58e4eb0c9e4cae9920e8f1f8eb46e7d032fec8fb01bede7f0f41a67eb3553b7b8e14fa53de1dac + languageName: node + linkType: hard + +"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": + version: 3.0.0 + resolution: "normalize-path@npm:3.0.0" + checksum: 88eeb4da891e10b1318c4b2476b6e2ecbeb5ff97d946815ffea7794c31a89017c70d7f34b3c2ebf23ef4e9fc9fb99f7dffe36da22011b5b5c6ffa34f4873ec20 + languageName: node + linkType: hard + +"npmlog@npm:^6.0.0": + version: 6.0.2 + resolution: "npmlog@npm:6.0.2" + dependencies: + are-we-there-yet: ^3.0.0 + console-control-strings: ^1.1.0 + gauge: ^4.0.3 + set-blocking: ^2.0.0 + checksum: ae238cd264a1c3f22091cdd9e2b106f684297d3c184f1146984ecbe18aaa86343953f26b9520dedd1b1372bc0316905b736c1932d778dbeb1fcf5a1001390e2a + languageName: node + linkType: hard + +"once@npm:^1.3.0": + version: 1.4.0 + resolution: "once@npm:1.4.0" + dependencies: + wrappy: 1 + checksum: cd0a88501333edd640d95f0d2700fbde6bff20b3d4d9bdc521bdd31af0656b5706570d6c6afe532045a20bb8dc0849f8332d6f2a416e0ba6d3d3b98806c7db68 + languageName: node + linkType: hard + +"p-limit@npm:^3.0.2": + version: 3.1.0 + resolution: "p-limit@npm:3.1.0" + dependencies: + yocto-queue: ^0.1.0 + checksum: 7c3690c4dbf62ef625671e20b7bdf1cbc9534e83352a2780f165b0d3ceba21907e77ad63401708145ca4e25bfc51636588d89a8c0aeb715e6c37d1c066430360 + languageName: node + linkType: hard + +"p-locate@npm:^5.0.0": + version: 5.0.0 + resolution: "p-locate@npm:5.0.0" + dependencies: + p-limit: ^3.0.2 + checksum: 1623088f36cf1cbca58e9b61c4e62bf0c60a07af5ae1ca99a720837356b5b6c5ba3eb1b2127e47a06865fee59dd0453cad7cc844cda9d5a62ac1a5a51b7c86d3 + languageName: node + linkType: hard + +"p-map@npm:^4.0.0": + version: 4.0.0 + resolution: "p-map@npm:4.0.0" + dependencies: + aggregate-error: ^3.0.0 + checksum: cb0ab21ec0f32ddffd31dfc250e3afa61e103ef43d957cc45497afe37513634589316de4eb88abdfd969fe6410c22c0b93ab24328833b8eb1ccc087fc0442a1c + languageName: node + linkType: hard + +"pako@npm:^2.0.3": + version: 2.1.0 + resolution: "pako@npm:2.1.0" + checksum: 71666548644c9a4d056bcaba849ca6fd7242c6cf1af0646d3346f3079a1c7f4a66ffec6f7369ee0dc88f61926c10d6ab05da3e1fca44b83551839e89edd75a3e + languageName: node + linkType: hard + +"path-exists@npm:^4.0.0": + version: 4.0.0 + resolution: "path-exists@npm:4.0.0" + checksum: 505807199dfb7c50737b057dd8d351b82c033029ab94cb10a657609e00c1bc53b951cfdbccab8de04c5584d5eff31128ce6afd3db79281874a5ef2adbba55ed1 + languageName: node + linkType: hard + +"path-is-absolute@npm:^1.0.0": + version: 1.0.1 + resolution: "path-is-absolute@npm:1.0.1" + checksum: 060840f92cf8effa293bcc1bea81281bd7d363731d214cbe5c227df207c34cd727430f70c6037b5159c8a870b9157cba65e775446b0ab06fd5ecc7e54615a3b8 + languageName: node + linkType: hard + +"path-key@npm:^3.1.0": + version: 3.1.1 + resolution: "path-key@npm:3.1.1" + checksum: 55cd7a9dd4b343412a8386a743f9c746ef196e57c823d90ca3ab917f90ab9f13dd0ded27252ba49dbdfcab2b091d998bc446f6220cd3cea65db407502a740020 + languageName: node + linkType: hard + +"path-scurry@npm:^1.10.1": + version: 1.10.1 + resolution: "path-scurry@npm:1.10.1" + dependencies: + lru-cache: ^9.1.1 || ^10.0.0 + minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 + checksum: e2557cff3a8fb8bc07afdd6ab163a92587884f9969b05bbbaf6fe7379348bfb09af9ed292af12ed32398b15fb443e81692047b786d1eeb6d898a51eb17ed7d90 + languageName: node + linkType: hard + +"pathval@npm:^1.1.1": + version: 1.1.1 + resolution: "pathval@npm:1.1.1" + checksum: 090e3147716647fb7fb5b4b8c8e5b55e5d0a6086d085b6cd23f3d3c01fcf0ff56fd3cc22f2f4a033bd2e46ed55d61ed8379e123b42afe7d531a2a5fc8bb556d6 + languageName: node + linkType: hard + +"picomatch@npm:^2.0.4, picomatch@npm:^2.2.1": + version: 2.3.1 + resolution: "picomatch@npm:2.3.1" + checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf + languageName: node + linkType: hard + +"prettier@npm:^2.6.2": + version: 2.8.8 + resolution: "prettier@npm:2.8.8" + bin: + prettier: bin-prettier.js + checksum: b49e409431bf129dd89238d64299ba80717b57ff5a6d1c1a8b1a28b590d998a34e083fa13573bc732bb8d2305becb4c9a4407f8486c81fa7d55100eb08263cf8 + languageName: node + linkType: hard + +"promise-retry@npm:^2.0.1": + version: 2.0.1 + resolution: "promise-retry@npm:2.0.1" + dependencies: + err-code: ^2.0.2 + retry: ^0.12.0 + checksum: f96a3f6d90b92b568a26f71e966cbbc0f63ab85ea6ff6c81284dc869b41510e6cdef99b6b65f9030f0db422bf7c96652a3fff9f2e8fb4a0f069d8f4430359429 + languageName: node + linkType: hard + +"randombytes@npm:^2.1.0": + version: 2.1.0 + resolution: "randombytes@npm:2.1.0" + dependencies: + safe-buffer: ^5.1.0 + checksum: d779499376bd4cbb435ef3ab9a957006c8682f343f14089ed5f27764e4645114196e75b7f6abf1cbd84fd247c0cb0651698444df8c9bf30e62120fbbc52269d6 + languageName: node + linkType: hard + +"readable-stream@npm:^3.6.0": + version: 3.6.2 + resolution: "readable-stream@npm:3.6.2" + dependencies: + inherits: ^2.0.3 + string_decoder: ^1.1.1 + util-deprecate: ^1.0.1 + checksum: bdcbe6c22e846b6af075e32cf8f4751c2576238c5043169a1c221c92ee2878458a816a4ea33f4c67623c0b6827c8a400409bfb3cf0bf3381392d0b1dfb52ac8d + languageName: node + linkType: hard + +"readdirp@npm:~3.6.0": + version: 3.6.0 + resolution: "readdirp@npm:3.6.0" + dependencies: + picomatch: ^2.2.1 + checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 + languageName: node + linkType: hard + +"regenerator-runtime@npm:^0.13.11": + version: 0.13.11 + resolution: "regenerator-runtime@npm:0.13.11" + checksum: 27481628d22a1c4e3ff551096a683b424242a216fee44685467307f14d58020af1e19660bf2e26064de946bad7eff28950eae9f8209d55723e2d9351e632bbb4 + languageName: node + linkType: hard + +"require-directory@npm:^2.1.1": + version: 2.1.1 + resolution: "require-directory@npm:2.1.1" + checksum: fb47e70bf0001fdeabdc0429d431863e9475e7e43ea5f94ad86503d918423c1543361cc5166d713eaa7029dd7a3d34775af04764bebff99ef413111a5af18c80 + languageName: node + linkType: hard + +"retry@npm:^0.12.0": + version: 0.12.0 + resolution: "retry@npm:0.12.0" + checksum: 623bd7d2e5119467ba66202d733ec3c2e2e26568074923bc0585b6b99db14f357e79bdedb63cab56cec47491c4a0da7e6021a7465ca6dc4f481d3898fdd3158c + languageName: node + linkType: hard + +"rimraf@npm:^3.0.2": + version: 3.0.2 + resolution: "rimraf@npm:3.0.2" + dependencies: + glob: ^7.1.3 + bin: + rimraf: bin.js + checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0 + languageName: node + linkType: hard + +"root-workspace-0b6124@workspace:.": + version: 0.0.0-use.local + resolution: "root-workspace-0b6124@workspace:." + dependencies: + "@coral-xyz/anchor": ^0.28.0 + "@solana/spl-token": ^0.3.8 + "@solana/web3.js": ^1.77.3 + "@types/bn.js": ^5.1.0 + "@types/chai": ^4.3.0 + "@types/mocha": ^9.0.0 + chai: ^4.3.4 + mocha: ^9.0.3 + prettier: ^2.6.2 + ts-mocha: ^10.0.0 + typescript: ^4.3.5 + languageName: unknown + linkType: soft + +"rpc-websockets@npm:^7.5.1": + version: 7.5.1 + resolution: "rpc-websockets@npm:7.5.1" + dependencies: + "@babel/runtime": ^7.17.2 + bufferutil: ^4.0.1 + eventemitter3: ^4.0.7 + utf-8-validate: ^5.0.2 + uuid: ^8.3.2 + ws: ^8.5.0 + dependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 9dda8c63a1d3e85e11597e1c364835ec6aa9a8de1b5cfb1629d0eafc3ae04509011d485025ed4f717c0b1dd048e2aafdd75080e866540b93e55fd8a2cd91bcfe + languageName: node + linkType: hard + +"safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:~5.2.0": + version: 5.2.1 + resolution: "safe-buffer@npm:5.2.1" + checksum: b99c4b41fdd67a6aaf280fcd05e9ffb0813654894223afb78a31f14a19ad220bba8aba1cb14eddce1fcfb037155fe6de4e861784eb434f7d11ed58d1e70dd491 + languageName: node + linkType: hard + +"safer-buffer@npm:>= 2.1.2 < 3.0.0": + version: 2.1.2 + resolution: "safer-buffer@npm:2.1.2" + checksum: cab8f25ae6f1434abee8d80023d7e72b598cf1327164ddab31003c51215526801e40b66c5e65d658a0af1e9d6478cadcb4c745f4bd6751f97d8644786c0978b0 + languageName: node + linkType: hard + +"semver@npm:^7.3.5": + version: 7.5.4 + resolution: "semver@npm:7.5.4" + dependencies: + lru-cache: ^6.0.0 + bin: + semver: bin/semver.js + checksum: 12d8ad952fa353b0995bf180cdac205a4068b759a140e5d3c608317098b3575ac2f1e09182206bf2eb26120e1c0ed8fb92c48c592f6099680de56bb071423ca3 + languageName: node + linkType: hard + +"serialize-javascript@npm:6.0.0": + version: 6.0.0 + resolution: "serialize-javascript@npm:6.0.0" + dependencies: + randombytes: ^2.1.0 + checksum: 56f90b562a1bdc92e55afb3e657c6397c01a902c588c0fe3d4c490efdcc97dcd2a3074ba12df9e94630f33a5ce5b76a74784a7041294628a6f4306e0ec84bf93 + languageName: node + linkType: hard + +"set-blocking@npm:^2.0.0": + version: 2.0.0 + resolution: "set-blocking@npm:2.0.0" + checksum: 6e65a05f7cf7ebdf8b7c75b101e18c0b7e3dff4940d480efed8aad3a36a4005140b660fa1d804cb8bce911cac290441dc728084a30504d3516ac2ff7ad607b02 + languageName: node + linkType: hard + +"shebang-command@npm:^2.0.0": + version: 2.0.0 + resolution: "shebang-command@npm:2.0.0" + dependencies: + shebang-regex: ^3.0.0 + checksum: 6b52fe87271c12968f6a054e60f6bde5f0f3d2db483a1e5c3e12d657c488a15474121a1d55cd958f6df026a54374ec38a4a963988c213b7570e1d51575cea7fa + languageName: node + linkType: hard + +"shebang-regex@npm:^3.0.0": + version: 3.0.0 + resolution: "shebang-regex@npm:3.0.0" + checksum: 1a2bcae50de99034fcd92ad4212d8e01eedf52c7ec7830eedcf886622804fe36884278f2be8be0ea5fde3fd1c23911643a4e0f726c8685b61871c8908af01222 + languageName: node + linkType: hard + +"signal-exit@npm:^3.0.7": + version: 3.0.7 + resolution: "signal-exit@npm:3.0.7" + checksum: a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 + languageName: node + linkType: hard + +"signal-exit@npm:^4.0.1": + version: 4.0.2 + resolution: "signal-exit@npm:4.0.2" + checksum: 41f5928431cc6e91087bf0343db786a6313dd7c6fd7e551dbc141c95bb5fb26663444fd9df8ea47c5d7fc202f60aa7468c3162a9365cbb0615fc5e1b1328fe31 + languageName: node + linkType: hard + +"smart-buffer@npm:^4.2.0": + version: 4.2.0 + resolution: "smart-buffer@npm:4.2.0" + checksum: b5167a7142c1da704c0e3af85c402002b597081dd9575031a90b4f229ca5678e9a36e8a374f1814c8156a725d17008ae3bde63b92f9cfd132526379e580bec8b + languageName: node + linkType: hard + +"snake-case@npm:^3.0.4": + version: 3.0.4 + resolution: "snake-case@npm:3.0.4" + dependencies: + dot-case: ^3.0.4 + tslib: ^2.0.3 + checksum: 0a7a79900bbb36f8aaa922cf111702a3647ac6165736d5dc96d3ef367efc50465cac70c53cd172c382b022dac72ec91710608e5393de71f76d7142e6fd80e8a3 + languageName: node + linkType: hard + +"socks-proxy-agent@npm:^7.0.0": + version: 7.0.0 + resolution: "socks-proxy-agent@npm:7.0.0" + dependencies: + agent-base: ^6.0.2 + debug: ^4.3.3 + socks: ^2.6.2 + checksum: 720554370154cbc979e2e9ce6a6ec6ced205d02757d8f5d93fe95adae454fc187a5cbfc6b022afab850a5ce9b4c7d73e0f98e381879cf45f66317a4895953846 + languageName: node + linkType: hard + +"socks@npm:^2.6.2": + version: 2.7.1 + resolution: "socks@npm:2.7.1" + dependencies: + ip: ^2.0.0 + smart-buffer: ^4.2.0 + checksum: 259d9e3e8e1c9809a7f5c32238c3d4d2a36b39b83851d0f573bfde5f21c4b1288417ce1af06af1452569cd1eb0841169afd4998f0e04ba04656f6b7f0e46d748 + languageName: node + linkType: hard + +"source-map-support@npm:^0.5.6": + version: 0.5.21 + resolution: "source-map-support@npm:0.5.21" + dependencies: + buffer-from: ^1.0.0 + source-map: ^0.6.0 + checksum: 43e98d700d79af1d36f859bdb7318e601dfc918c7ba2e98456118ebc4c4872b327773e5a1df09b0524e9e5063bb18f0934538eace60cca2710d1fa687645d137 + languageName: node + linkType: hard + +"source-map@npm:^0.6.0": + version: 0.6.1 + resolution: "source-map@npm:0.6.1" + checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2 + languageName: node + linkType: hard + +"ssri@npm:^10.0.0": + version: 10.0.4 + resolution: "ssri@npm:10.0.4" + dependencies: + minipass: ^5.0.0 + checksum: fb14da9f8a72b04eab163eb13a9dda11d5962cd2317f85457c4e0b575e9a6e0e3a6a87b5bf122c75cb36565830cd5f263fb457571bf6f1587eb5f95d095d6165 + languageName: node + linkType: hard + +"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": + version: 4.2.3 + resolution: "string-width@npm:4.2.3" + dependencies: + emoji-regex: ^8.0.0 + is-fullwidth-code-point: ^3.0.0 + strip-ansi: ^6.0.1 + checksum: e52c10dc3fbfcd6c3a15f159f54a90024241d0f149cf8aed2982a2d801d2e64df0bf1dc351cf8e95c3319323f9f220c16e740b06faecd53e2462df1d2b5443fb + languageName: node + linkType: hard + +"string-width@npm:^5.0.1, string-width@npm:^5.1.2": + version: 5.1.2 + resolution: "string-width@npm:5.1.2" + dependencies: + eastasianwidth: ^0.2.0 + emoji-regex: ^9.2.2 + strip-ansi: ^7.0.1 + checksum: 7369deaa29f21dda9a438686154b62c2c5f661f8dda60449088f9f980196f7908fc39fdd1803e3e01541970287cf5deae336798337e9319a7055af89dafa7193 + languageName: node + linkType: hard + +"string_decoder@npm:^1.1.1": + version: 1.3.0 + resolution: "string_decoder@npm:1.3.0" + dependencies: + safe-buffer: ~5.2.0 + checksum: 8417646695a66e73aefc4420eb3b84cc9ffd89572861fe004e6aeb13c7bc00e2f616247505d2dbbef24247c372f70268f594af7126f43548565c68c117bdeb56 + languageName: node + linkType: hard + +"strip-ansi-cjs@npm:strip-ansi@^6.0.1, strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1": + version: 6.0.1 + resolution: "strip-ansi@npm:6.0.1" + dependencies: + ansi-regex: ^5.0.1 + checksum: f3cd25890aef3ba6e1a74e20896c21a46f482e93df4a06567cebf2b57edabb15133f1f94e57434e0a958d61186087b1008e89c94875d019910a213181a14fc8c + languageName: node + linkType: hard + +"strip-ansi@npm:^7.0.1": + version: 7.1.0 + resolution: "strip-ansi@npm:7.1.0" + dependencies: + ansi-regex: ^6.0.1 + checksum: 859c73fcf27869c22a4e4d8c6acfe690064659e84bef9458aa6d13719d09ca88dcfd40cbf31fd0be63518ea1a643fe070b4827d353e09533a5b0b9fd4553d64d + languageName: node + linkType: hard + +"strip-bom@npm:^3.0.0": + version: 3.0.0 + resolution: "strip-bom@npm:3.0.0" + checksum: 8d50ff27b7ebe5ecc78f1fe1e00fcdff7af014e73cf724b46fb81ef889eeb1015fc5184b64e81a2efe002180f3ba431bdd77e300da5c6685d702780fbf0c8d5b + languageName: node + linkType: hard + +"strip-json-comments@npm:3.1.1": + version: 3.1.1 + resolution: "strip-json-comments@npm:3.1.1" + checksum: 492f73e27268f9b1c122733f28ecb0e7e8d8a531a6662efbd08e22cccb3f9475e90a1b82cab06a392f6afae6d2de636f977e231296400d0ec5304ba70f166443 + languageName: node + linkType: hard + +"superstruct@npm:^0.14.2": + version: 0.14.2 + resolution: "superstruct@npm:0.14.2" + checksum: c5c4840f432da82125b923ec45faca5113217e83ae416e314d80eae012b8bb603d2e745025d173450758d116348820bc7028157f8c9a72b6beae879f94b837c0 + languageName: node + linkType: hard + +"superstruct@npm:^0.15.4": + version: 0.15.5 + resolution: "superstruct@npm:0.15.5" + checksum: 6d1f5249fee789424b7178fa0a1ffb2ace629c5480c39505885bd8c0046a4ff8b267569a3442fa53b8c560a7ba6599cf3f8af94225aebeb2cf6023f7dd911050 + languageName: node + linkType: hard + +"supports-color@npm:8.1.1": + version: 8.1.1 + resolution: "supports-color@npm:8.1.1" + dependencies: + has-flag: ^4.0.0 + checksum: c052193a7e43c6cdc741eb7f378df605636e01ad434badf7324f17fb60c69a880d8d8fcdcb562cf94c2350e57b937d7425ab5b8326c67c2adc48f7c87c1db406 + languageName: node + linkType: hard + +"supports-color@npm:^7.1.0": + version: 7.2.0 + resolution: "supports-color@npm:7.2.0" + dependencies: + has-flag: ^4.0.0 + checksum: 3dda818de06ebbe5b9653e07842d9479f3555ebc77e9a0280caf5a14fb877ffee9ed57007c3b78f5a6324b8dbeec648d9e97a24e2ed9fdb81ddc69ea07100f4a + languageName: node + linkType: hard + +"tar@npm:^6.1.11, tar@npm:^6.1.2": + version: 6.1.15 + resolution: "tar@npm:6.1.15" + dependencies: + chownr: ^2.0.0 + fs-minipass: ^2.0.0 + minipass: ^5.0.0 + minizlib: ^2.1.1 + mkdirp: ^1.0.3 + yallist: ^4.0.0 + checksum: f23832fceeba7578bf31907aac744ae21e74a66f4a17a9e94507acf460e48f6db598c7023882db33bab75b80e027c21f276d405e4a0322d58f51c7088d428268 + languageName: node + linkType: hard + +"text-encoding-utf-8@npm:^1.0.2": + version: 1.0.2 + resolution: "text-encoding-utf-8@npm:1.0.2" + checksum: ec4c15d50e738c5dba7327ad432ebf0725ec75d4d69c0bd55609254c5a3bc5341272d7003691084a0a73d60d981c8eb0e87603676fdb6f3fed60f4c9192309f9 + languageName: node + linkType: hard + +"through@npm:>=2.2.7 <3": + version: 2.3.8 + resolution: "through@npm:2.3.8" + checksum: a38c3e059853c494af95d50c072b83f8b676a9ba2818dcc5b108ef252230735c54e0185437618596c790bbba8fcdaef5b290405981ffa09dce67b1f1bf190cbd + languageName: node + linkType: hard + +"to-regex-range@npm:^5.0.1": + version: 5.0.1 + resolution: "to-regex-range@npm:5.0.1" + dependencies: + is-number: ^7.0.0 + checksum: f76fa01b3d5be85db6a2a143e24df9f60dd047d151062d0ba3df62953f2f697b16fe5dad9b0ac6191c7efc7b1d9dcaa4b768174b7b29da89d4428e64bc0a20ed + languageName: node + linkType: hard + +"toml@npm:^3.0.0": + version: 3.0.0 + resolution: "toml@npm:3.0.0" + checksum: 5d7f1d8413ad7780e9bdecce8ea4c3f5130dd53b0a4f2e90b93340979a137739879d7b9ce2ce05c938b8cc828897fe9e95085197342a1377dd8850bf5125f15f + languageName: node + linkType: hard + +"tr46@npm:~0.0.3": + version: 0.0.3 + resolution: "tr46@npm:0.0.3" + checksum: 726321c5eaf41b5002e17ffbd1fb7245999a073e8979085dacd47c4b4e8068ff5777142fc6726d6ca1fd2ff16921b48788b87225cbc57c72636f6efa8efbffe3 + languageName: node + linkType: hard + +"ts-mocha@npm:^10.0.0": + version: 10.0.0 + resolution: "ts-mocha@npm:10.0.0" + dependencies: + ts-node: 7.0.1 + tsconfig-paths: ^3.5.0 + peerDependencies: + mocha: ^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X + dependenciesMeta: + tsconfig-paths: + optional: true + bin: + ts-mocha: bin/ts-mocha + checksum: b11f2a8ceecf195b0db724da429159982fef12e4357088fe900289223587217e8c126ead7929679edd58bf19ad96c5da5911535d26f535386632e18fbff10c40 + languageName: node + linkType: hard + +"ts-node@npm:7.0.1": + version: 7.0.1 + resolution: "ts-node@npm:7.0.1" + dependencies: + arrify: ^1.0.0 + buffer-from: ^1.1.0 + diff: ^3.1.0 + make-error: ^1.1.1 + minimist: ^1.2.0 + mkdirp: ^0.5.1 + source-map-support: ^0.5.6 + yn: ^2.0.0 + bin: + ts-node: dist/bin.js + checksum: 07ed6ea1805361828737a767cfd6c57ea6e267ee8679282afb933610af02405e1a87c1f2aea1d38ed8e66b34fcbf6272b6021ab95d78849105d2e57fc283870b + languageName: node + linkType: hard + +"tsconfig-paths@npm:^3.5.0": + version: 3.14.2 + resolution: "tsconfig-paths@npm:3.14.2" + dependencies: + "@types/json5": ^0.0.29 + json5: ^1.0.2 + minimist: ^1.2.6 + strip-bom: ^3.0.0 + checksum: a6162eaa1aed680537f93621b82399c7856afd10ec299867b13a0675e981acac4e0ec00896860480efc59fc10fd0b16fdc928c0b885865b52be62cadac692447 + languageName: node + linkType: hard + +"tslib@npm:^2.0.3": + version: 2.6.0 + resolution: "tslib@npm:2.6.0" + checksum: c01066038f950016a18106ddeca4649b4d76caa76ec5a31e2a26e10586a59fceb4ee45e96719bf6c715648e7c14085a81fee5c62f7e9ebee68e77a5396e5538f + languageName: node + linkType: hard + +"type-detect@npm:^4.0.0, type-detect@npm:^4.0.5": + version: 4.0.8 + resolution: "type-detect@npm:4.0.8" + checksum: 62b5628bff67c0eb0b66afa371bd73e230399a8d2ad30d852716efcc4656a7516904570cd8631a49a3ce57c10225adf5d0cbdcb47f6b0255fe6557c453925a15 + languageName: node + linkType: hard + +"typescript@npm:^4.3.5": + version: 4.9.5 + resolution: "typescript@npm:4.9.5" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db + languageName: node + linkType: hard + +"typescript@patch:typescript@^4.3.5#~builtin": + version: 4.9.5 + resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=289587" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 1f8f3b6aaea19f0f67cba79057674ba580438a7db55057eb89cc06950483c5d632115c14077f6663ea76fd09fce3c190e6414bb98582ec80aa5a4eaf345d5b68 + languageName: node + linkType: hard + +"unique-filename@npm:^3.0.0": + version: 3.0.0 + resolution: "unique-filename@npm:3.0.0" + dependencies: + unique-slug: ^4.0.0 + checksum: 8e2f59b356cb2e54aab14ff98a51ac6c45781d15ceaab6d4f1c2228b780193dc70fae4463ce9e1df4479cb9d3304d7c2043a3fb905bdeca71cc7e8ce27e063df + languageName: node + linkType: hard + +"unique-slug@npm:^4.0.0": + version: 4.0.0 + resolution: "unique-slug@npm:4.0.0" + dependencies: + imurmurhash: ^0.1.4 + checksum: 0884b58365af59f89739e6f71e3feacb5b1b41f2df2d842d0757933620e6de08eff347d27e9d499b43c40476cbaf7988638d3acb2ffbcb9d35fd035591adfd15 + languageName: node + linkType: hard + +"utf-8-validate@npm:^5.0.2": + version: 5.0.10 + resolution: "utf-8-validate@npm:5.0.10" + dependencies: + node-gyp: latest + node-gyp-build: ^4.3.0 + checksum: 5579350a023c66a2326752b6c8804cc7b39dcd251bb088241da38db994b8d78352e388dcc24ad398ab98385ba3c5ffcadb6b5b14b2637e43f767869055e46ba6 + languageName: node + linkType: hard + +"util-deprecate@npm:^1.0.1": + version: 1.0.2 + resolution: "util-deprecate@npm:1.0.2" + checksum: 474acf1146cb2701fe3b074892217553dfcf9a031280919ba1b8d651a068c9b15d863b7303cb15bd00a862b498e6cf4ad7b4a08fb134edd5a6f7641681cb54a2 + languageName: node + linkType: hard + +"uuid@npm:^8.3.2": + version: 8.3.2 + resolution: "uuid@npm:8.3.2" + bin: + uuid: dist/bin/uuid + checksum: 5575a8a75c13120e2f10e6ddc801b2c7ed7d8f3c8ac22c7ed0c7b2ba6383ec0abda88c905085d630e251719e0777045ae3236f04c812184b7c765f63a70e58df + languageName: node + linkType: hard + +"webidl-conversions@npm:^3.0.0": + version: 3.0.1 + resolution: "webidl-conversions@npm:3.0.1" + checksum: c92a0a6ab95314bde9c32e1d0a6dfac83b578f8fa5f21e675bc2706ed6981bc26b7eb7e6a1fab158e5ce4adf9caa4a0aee49a52505d4d13c7be545f15021b17c + languageName: node + linkType: hard + +"whatwg-url@npm:^5.0.0": + version: 5.0.0 + resolution: "whatwg-url@npm:5.0.0" + dependencies: + tr46: ~0.0.3 + webidl-conversions: ^3.0.0 + checksum: b8daed4ad3356cc4899048a15b2c143a9aed0dfae1f611ebd55073310c7b910f522ad75d727346ad64203d7e6c79ef25eafd465f4d12775ca44b90fa82ed9e2c + languageName: node + linkType: hard + +"which@npm:2.0.2, which@npm:^2.0.1, which@npm:^2.0.2": + version: 2.0.2 + resolution: "which@npm:2.0.2" + dependencies: + isexe: ^2.0.0 + bin: + node-which: ./bin/node-which + checksum: 1a5c563d3c1b52d5f893c8b61afe11abc3bab4afac492e8da5bde69d550de701cf9806235f20a47b5c8fa8a1d6a9135841de2596535e998027a54589000e66d1 + languageName: node + linkType: hard + +"wide-align@npm:^1.1.5": + version: 1.1.5 + resolution: "wide-align@npm:1.1.5" + dependencies: + string-width: ^1.0.2 || 2 || 3 || 4 + checksum: d5fc37cd561f9daee3c80e03b92ed3e84d80dde3365a8767263d03dacfc8fa06b065ffe1df00d8c2a09f731482fcacae745abfbb478d4af36d0a891fad4834d3 + languageName: node + linkType: hard + +"workerpool@npm:6.2.0": + version: 6.2.0 + resolution: "workerpool@npm:6.2.0" + checksum: 3493b4f0ef979a23d2c1583d7ef85f62fc9463cc02f82829d3e7e663b517f8ae9707da0249b382e46ac58986deb0ca2232ee1081713741211bda9254b429c9bb + languageName: node + linkType: hard + +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0, wrap-ansi@npm:^7.0.0": + version: 7.0.0 + resolution: "wrap-ansi@npm:7.0.0" + dependencies: + ansi-styles: ^4.0.0 + string-width: ^4.1.0 + strip-ansi: ^6.0.0 + checksum: a790b846fd4505de962ba728a21aaeda189b8ee1c7568ca5e817d85930e06ef8d1689d49dbf0e881e8ef84436af3a88bc49115c2e2788d841ff1b8b5b51a608b + languageName: node + linkType: hard + +"wrap-ansi@npm:^8.1.0": + version: 8.1.0 + resolution: "wrap-ansi@npm:8.1.0" + dependencies: + ansi-styles: ^6.1.0 + string-width: ^5.0.1 + strip-ansi: ^7.0.1 + checksum: 371733296dc2d616900ce15a0049dca0ef67597d6394c57347ba334393599e800bab03c41d4d45221b6bc967b8c453ec3ae4749eff3894202d16800fdfe0e238 + languageName: node + linkType: hard + +"wrappy@npm:1": + version: 1.0.2 + resolution: "wrappy@npm:1.0.2" + checksum: 159da4805f7e84a3d003d8841557196034155008f817172d4e986bd591f74aa82aa7db55929a54222309e01079a65a92a9e6414da5a6aa4b01ee44a511ac3ee5 + languageName: node + linkType: hard + +"ws@npm:^7.4.5": + version: 7.5.9 + resolution: "ws@npm:7.5.9" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: c3c100a181b731f40b7f2fddf004aa023f79d64f489706a28bc23ff88e87f6a64b3c6651fbec3a84a53960b75159574d7a7385709847a62ddb7ad6af76f49138 + languageName: node + linkType: hard + +"ws@npm:^8.5.0": + version: 8.13.0 + resolution: "ws@npm:8.13.0" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ">=5.0.2" + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 53e991bbf928faf5dc6efac9b8eb9ab6497c69feeb94f963d648b7a3530a720b19ec2e0ec037344257e05a4f35bd9ad04d9de6f289615ffb133282031b18c61c + languageName: node + linkType: hard + +"y18n@npm:^5.0.5": + version: 5.0.8 + resolution: "y18n@npm:5.0.8" + checksum: 54f0fb95621ee60898a38c572c515659e51cc9d9f787fb109cef6fde4befbe1c4602dc999d30110feee37456ad0f1660fa2edcfde6a9a740f86a290999550d30 + languageName: node + linkType: hard + +"yallist@npm:^4.0.0": + version: 4.0.0 + resolution: "yallist@npm:4.0.0" + checksum: 343617202af32df2a15a3be36a5a8c0c8545208f3d3dfbc6bb7c3e3b7e8c6f8e7485432e4f3b88da3031a6e20afa7c711eded32ddfb122896ac5d914e75848d5 + languageName: node + linkType: hard + +"yargs-parser@npm:20.2.4": + version: 20.2.4 + resolution: "yargs-parser@npm:20.2.4" + checksum: d251998a374b2743a20271c2fd752b9fbef24eb881d53a3b99a7caa5e8227fcafd9abf1f345ac5de46435821be25ec12189a11030c12ee6481fef6863ed8b924 + languageName: node + linkType: hard + +"yargs-parser@npm:^20.2.2": + version: 20.2.9 + resolution: "yargs-parser@npm:20.2.9" + checksum: 8bb69015f2b0ff9e17b2c8e6bfe224ab463dd00ca211eece72a4cd8a906224d2703fb8a326d36fdd0e68701e201b2a60ed7cf81ce0fd9b3799f9fe7745977ae3 + languageName: node + linkType: hard + +"yargs-unparser@npm:2.0.0": + version: 2.0.0 + resolution: "yargs-unparser@npm:2.0.0" + dependencies: + camelcase: ^6.0.0 + decamelize: ^4.0.0 + flat: ^5.0.2 + is-plain-obj: ^2.1.0 + checksum: 68f9a542c6927c3768c2f16c28f71b19008710abd6b8f8efbac6dcce26bbb68ab6503bed1d5994bdbc2df9a5c87c161110c1dfe04c6a3fe5c6ad1b0e15d9a8a3 + languageName: node + linkType: hard + +"yargs@npm:16.2.0": + version: 16.2.0 + resolution: "yargs@npm:16.2.0" + dependencies: + cliui: ^7.0.2 + escalade: ^3.1.1 + get-caller-file: ^2.0.5 + require-directory: ^2.1.1 + string-width: ^4.2.0 + y18n: ^5.0.5 + yargs-parser: ^20.2.2 + checksum: b14afbb51e3251a204d81937c86a7e9d4bdbf9a2bcee38226c900d00f522969ab675703bee2a6f99f8e20103f608382936034e64d921b74df82b63c07c5e8f59 + languageName: node + linkType: hard + +"yn@npm:^2.0.0": + version: 2.0.0 + resolution: "yn@npm:2.0.0" + checksum: 9d49527cb3e9a0948cc057223810bf30607bf04b9ff7666cc1681a6501d660b60d90000c16f9e29311b0f28d8a06222ada565ccdca5f1049cdfefb1908217572 + languageName: node + linkType: hard + +"yocto-queue@npm:^0.1.0": + version: 0.1.0 + resolution: "yocto-queue@npm:0.1.0" + checksum: f77b3d8d00310def622123df93d4ee654fc6a0096182af8bd60679ddcdfb3474c56c6c7190817c84a2785648cdee9d721c0154eb45698c62176c322fb46fc700 + languageName: node + linkType: hard diff --git a/package.json b/package.json index 854ac1535..ecc60378d 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,5 @@ "prettier": "^2.3.2", "prettier-plugin-sh": "^0.7.1", "prettier-plugin-solidity": "^1.0.0-beta.14" - }, - "workspaces": [ - "./cross-chain/solana" - ] + } } From 283fc5de58a8cb3b471d7f6b64d29e4fb5b025a5 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Wed, 19 Jul 2023 14:42:14 +0100 Subject: [PATCH 012/205] Remove traces of yarn in repo root --- .yarnrc.yml | 1 - yarn.lock | 2606 --------------------------------------------------- 2 files changed, 2607 deletions(-) delete mode 100644 .yarnrc.yml delete mode 100644 yarn.lock diff --git a/.yarnrc.yml b/.yarnrc.yml deleted file mode 100644 index 3186f3f07..000000000 --- a/.yarnrc.yml +++ /dev/null @@ -1 +0,0 @@ -nodeLinker: node-modules diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index 1f6b9cfda..000000000 --- a/yarn.lock +++ /dev/null @@ -1,2606 +0,0 @@ -# This file is generated by running "yarn install" inside your project. -# Manual changes might be lost - proceed with caution! - -__metadata: - version: 6 - cacheKey: 8 - -"@babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.22.3": - version: 7.22.6 - resolution: "@babel/runtime@npm:7.22.6" - dependencies: - regenerator-runtime: ^0.13.11 - checksum: e585338287c4514a713babf4fdb8fc2a67adcebab3e7723a739fc62c79cfda875b314c90fd25f827afb150d781af97bc16c85bfdbfa2889f06053879a1ddb597 - languageName: node - linkType: hard - -"@coral-xyz/anchor@npm:^0.28.0": - version: 0.28.0 - resolution: "@coral-xyz/anchor@npm:0.28.0" - dependencies: - "@coral-xyz/borsh": ^0.28.0 - "@solana/web3.js": ^1.68.0 - base64-js: ^1.5.1 - bn.js: ^5.1.2 - bs58: ^4.0.1 - buffer-layout: ^1.2.2 - camelcase: ^6.3.0 - cross-fetch: ^3.1.5 - crypto-hash: ^1.3.0 - eventemitter3: ^4.0.7 - js-sha256: ^0.9.0 - pako: ^2.0.3 - snake-case: ^3.0.4 - superstruct: ^0.15.4 - toml: ^3.0.0 - checksum: 58b3677b5b2ce2c779045184ce4a0ef696966a6a58f41c1c56f6f178db0491acecb6ec677ce0502f0b382a2c724f9c2860d82cc88601784d556d95fbeda415e5 - languageName: node - linkType: hard - -"@coral-xyz/borsh@npm:^0.28.0": - version: 0.28.0 - resolution: "@coral-xyz/borsh@npm:0.28.0" - dependencies: - bn.js: ^5.1.2 - buffer-layout: ^1.2.0 - peerDependencies: - "@solana/web3.js": ^1.68.0 - checksum: bc2b06b777f9ed43d3b886d2350826bd44d5b932c4fd4471af5956e8755236f5854938c890ee4986d88f61d1439e1d84e715c43dcb6dca4e76198c1ce8dc7a58 - languageName: node - linkType: hard - -"@isaacs/cliui@npm:^8.0.2": - version: 8.0.2 - resolution: "@isaacs/cliui@npm:8.0.2" - dependencies: - string-width: ^5.1.2 - string-width-cjs: "npm:string-width@^4.2.0" - strip-ansi: ^7.0.1 - strip-ansi-cjs: "npm:strip-ansi@^6.0.1" - wrap-ansi: ^8.1.0 - wrap-ansi-cjs: "npm:wrap-ansi@^7.0.0" - checksum: 4a473b9b32a7d4d3cfb7a614226e555091ff0c5a29a1734c28c72a182c2f6699b26fc6b5c2131dfd841e86b185aea714c72201d7c98c2fba5f17709333a67aeb - languageName: node - linkType: hard - -"@keep-network/prettier-config-keep@github:keep-network/prettier-config-keep": - version: 0.0.1 - resolution: "@keep-network/prettier-config-keep@https://github.com/keep-network/prettier-config-keep.git#commit=d6ec02e80dd76edfba073ca58ef99aee39002c2c" - peerDependencies: - prettier: ^2.3.0 - checksum: d6825c49952c53ab044b67fb7607eb6cbdc7181b918711818c015396990bd6d594ad6a71029594a12c2ad8ac8e827ff26b5e58fd15eb88c25b7e086069bb99dc - languageName: node - linkType: hard - -"@noble/curves@npm:^1.0.0": - version: 1.1.0 - resolution: "@noble/curves@npm:1.1.0" - dependencies: - "@noble/hashes": 1.3.1 - checksum: 2658cdd3f84f71079b4e3516c47559d22cf4b55c23ac8ee9d2b1f8e5b72916d9689e59820e0f9d9cb4a46a8423af5b56dc6bb7782405c88be06a015180508db5 - languageName: node - linkType: hard - -"@noble/hashes@npm:1.3.1, @noble/hashes@npm:^1.3.0": - version: 1.3.1 - resolution: "@noble/hashes@npm:1.3.1" - checksum: 7fdefc0f7a0c1ec27acc6ff88841793e3f93ec4ce6b8a6a12bfc0dd70ae6b7c4c82fe305fdfeda1735d5ad4a9eebe761e6693b3d355689c559e91242f4bc95b1 - languageName: node - linkType: hard - -"@npmcli/fs@npm:^3.1.0": - version: 3.1.0 - resolution: "@npmcli/fs@npm:3.1.0" - dependencies: - semver: ^7.3.5 - checksum: a50a6818de5fc557d0b0e6f50ec780a7a02ab8ad07e5ac8b16bf519e0ad60a144ac64f97d05c443c3367235d337182e1d012bbac0eb8dbae8dc7b40b193efd0e - languageName: node - linkType: hard - -"@pkgjs/parseargs@npm:^0.11.0": - version: 0.11.0 - resolution: "@pkgjs/parseargs@npm:0.11.0" - checksum: 6ad6a00fc4f2f2cfc6bff76fb1d88b8ee20bc0601e18ebb01b6d4be583733a860239a521a7fbca73b612e66705078809483549d2b18f370eb346c5155c8e4a0f - languageName: node - linkType: hard - -"@solana/buffer-layout-utils@npm:^0.2.0": - version: 0.2.0 - resolution: "@solana/buffer-layout-utils@npm:0.2.0" - dependencies: - "@solana/buffer-layout": ^4.0.0 - "@solana/web3.js": ^1.32.0 - bigint-buffer: ^1.1.5 - bignumber.js: ^9.0.1 - checksum: 9284242245b18b49577195ba7548263850be865a4a2d183944fa01bb76382039db589aab8473698e9bb734b515ada9b4d70db0a72e341c5d567c59b83d6d0840 - languageName: node - linkType: hard - -"@solana/buffer-layout@npm:^4.0.0": - version: 4.0.1 - resolution: "@solana/buffer-layout@npm:4.0.1" - dependencies: - buffer: ~6.0.3 - checksum: bf846888e813187243d4008a7a9f58b49d16cbd995b9d7f1b72898aa510ed77b1ce5e8468e7b2fd26dd81e557a4e74a666e21fccb95f123c1f740d41138bbacd - languageName: node - linkType: hard - -"@solana/spl-token@npm:^0.3.8": - version: 0.3.8 - resolution: "@solana/spl-token@npm:0.3.8" - dependencies: - "@solana/buffer-layout": ^4.0.0 - "@solana/buffer-layout-utils": ^0.2.0 - buffer: ^6.0.3 - peerDependencies: - "@solana/web3.js": ^1.47.4 - checksum: 01f4f87112b0ad277701a3bcb8e03069b69449b92724b17959107686731082bfd3475b5f105e1e8f04badd2e810a43d5ef811744ced5178eea1232de8fd75147 - languageName: node - linkType: hard - -"@solana/web3.js@npm:^1.32.0, @solana/web3.js@npm:^1.68.0, @solana/web3.js@npm:^1.77.3": - version: 1.78.0 - resolution: "@solana/web3.js@npm:1.78.0" - dependencies: - "@babel/runtime": ^7.22.3 - "@noble/curves": ^1.0.0 - "@noble/hashes": ^1.3.0 - "@solana/buffer-layout": ^4.0.0 - agentkeepalive: ^4.2.1 - bigint-buffer: ^1.1.5 - bn.js: ^5.0.0 - borsh: ^0.7.0 - bs58: ^4.0.1 - buffer: 6.0.3 - fast-stable-stringify: ^1.0.0 - jayson: ^4.1.0 - node-fetch: ^2.6.11 - rpc-websockets: ^7.5.1 - superstruct: ^0.14.2 - checksum: 9f0aae54fa8f2d9285ae525b4f962a17160fd98ac588fbf528742630fb2cf0208ec7b6c0c307d6bba82a92a0e8cbb5411b965d553cc4c62488e24b57c2211d84 - languageName: node - linkType: hard - -"@solidity-parser/parser@npm:^0.13.2": - version: 0.13.2 - resolution: "@solidity-parser/parser@npm:0.13.2" - dependencies: - antlr4ts: ^0.5.0-alpha.4 - checksum: bfdd8ec7f7b88f3cc75e333e03202cde5e5dacbec7f00612f22dec5e22b0995713637872ce202064d182bae56a274fcb2ca8715ad5482af5e8b38728a0216cf7 - languageName: node - linkType: hard - -"@tootallnate/once@npm:2": - version: 2.0.0 - resolution: "@tootallnate/once@npm:2.0.0" - checksum: ad87447820dd3f24825d2d947ebc03072b20a42bfc96cbafec16bff8bbda6c1a81fcb0be56d5b21968560c5359a0af4038a68ba150c3e1694fe4c109a063bed8 - languageName: node - linkType: hard - -"@types/bn.js@npm:^5.1.0": - version: 5.1.1 - resolution: "@types/bn.js@npm:5.1.1" - dependencies: - "@types/node": "*" - checksum: e50ed2dd3abe997e047caf90e0352c71e54fc388679735217978b4ceb7e336e51477791b715f49fd77195ac26dd296c7bad08a3be9750e235f9b2e1edb1b51c2 - languageName: node - linkType: hard - -"@types/chai@npm:^4.3.0": - version: 4.3.5 - resolution: "@types/chai@npm:4.3.5" - checksum: c8f26a88c6b5b53a3275c7f5ff8f107028e3cbb9ff26795fff5f3d9dea07106a54ce9e2dce5e40347f7c4cc35657900aaf0c83934a25a1ae12e61e0f5516e431 - languageName: node - linkType: hard - -"@types/connect@npm:^3.4.33": - version: 3.4.35 - resolution: "@types/connect@npm:3.4.35" - dependencies: - "@types/node": "*" - checksum: fe81351470f2d3165e8b12ce33542eef89ea893e36dd62e8f7d72566dfb7e448376ae962f9f3ea888547ce8b55a40020ca0e01d637fab5d99567673084542641 - languageName: node - linkType: hard - -"@types/json5@npm:^0.0.29": - version: 0.0.29 - resolution: "@types/json5@npm:0.0.29" - checksum: e60b153664572116dfea673c5bda7778dbff150498f44f998e34b5886d8afc47f16799280e4b6e241c0472aef1bc36add771c569c68fc5125fc2ae519a3eb9ac - languageName: node - linkType: hard - -"@types/mocha@npm:^9.0.0": - version: 9.1.1 - resolution: "@types/mocha@npm:9.1.1" - checksum: 516077c0acd9806dc78317f88aaac0df5aaf0bdc2f63dfdadeabdf0b0137953b6ca65472e6ff7c30bc93ce4e0ae76eae70e8d46764b9a8eae4877a928b6ef49a - languageName: node - linkType: hard - -"@types/node@npm:*": - version: 20.4.1 - resolution: "@types/node@npm:20.4.1" - checksum: 22cbcc792f2eb636fe4188778ed0f32658ab872aa7fcb9847b3fa289a42b14b9f5e30c6faec50ef3c7adbc6c2a246926e5858136bb8b10c035a3fcaa6afbeed2 - languageName: node - linkType: hard - -"@types/node@npm:^12.12.54": - version: 12.20.55 - resolution: "@types/node@npm:12.20.55" - checksum: e4f86785f4092706e0d3b0edff8dca5a13b45627e4b36700acd8dfe6ad53db71928c8dee914d4276c7fd3b6ccd829aa919811c9eb708a2c8e4c6eb3701178c37 - languageName: node - linkType: hard - -"@types/ws@npm:^7.4.4": - version: 7.4.7 - resolution: "@types/ws@npm:7.4.7" - dependencies: - "@types/node": "*" - checksum: b4c9b8ad209620c9b21e78314ce4ff07515c0cadab9af101c1651e7bfb992d7fd933bd8b9c99d110738fd6db523ed15f82f29f50b45510288da72e964dedb1a3 - languageName: node - linkType: hard - -"@ungap/promise-all-settled@npm:1.1.2": - version: 1.1.2 - resolution: "@ungap/promise-all-settled@npm:1.1.2" - checksum: 08d37fdfa23a6fe8139f1305313562ebad973f3fac01bcce2773b2bda5bcb0146dfdcf3cb6a722cf0a5f2ca0bc56a827eac8f1e7b3beddc548f654addf1fc34c - languageName: node - linkType: hard - -"JSONStream@npm:^1.3.5": - version: 1.3.5 - resolution: "JSONStream@npm:1.3.5" - dependencies: - jsonparse: ^1.2.0 - through: ">=2.2.7 <3" - bin: - JSONStream: ./bin.js - checksum: 2605fa124260c61bad38bb65eba30d2f72216a78e94d0ab19b11b4e0327d572b8d530c0c9cc3b0764f727ad26d39e00bf7ebad57781ca6368394d73169c59e46 - languageName: node - linkType: hard - -"abbrev@npm:^1.0.0": - version: 1.1.1 - resolution: "abbrev@npm:1.1.1" - checksum: a4a97ec07d7ea112c517036882b2ac22f3109b7b19077dc656316d07d308438aac28e4d9746dc4d84bf6b1e75b4a7b0a5f3cb30592419f128ca9a8cee3bcfa17 - languageName: node - linkType: hard - -"agent-base@npm:6, agent-base@npm:^6.0.2": - version: 6.0.2 - resolution: "agent-base@npm:6.0.2" - dependencies: - debug: 4 - checksum: f52b6872cc96fd5f622071b71ef200e01c7c4c454ee68bc9accca90c98cfb39f2810e3e9aa330435835eedc8c23f4f8a15267f67c6e245d2b33757575bdac49d - languageName: node - linkType: hard - -"agentkeepalive@npm:^4.2.1": - version: 4.3.0 - resolution: "agentkeepalive@npm:4.3.0" - dependencies: - debug: ^4.1.0 - depd: ^2.0.0 - humanize-ms: ^1.2.1 - checksum: 982453aa44c11a06826c836025e5162c846e1200adb56f2d075400da7d32d87021b3b0a58768d949d824811f5654223d5a8a3dad120921a2439625eb847c6260 - languageName: node - linkType: hard - -"aggregate-error@npm:^3.0.0": - version: 3.1.0 - resolution: "aggregate-error@npm:3.1.0" - dependencies: - clean-stack: ^2.0.0 - indent-string: ^4.0.0 - checksum: 1101a33f21baa27a2fa8e04b698271e64616b886795fd43c31068c07533c7b3facfcaf4e9e0cab3624bd88f729a592f1c901a1a229c9e490eafce411a8644b79 - languageName: node - linkType: hard - -"ansi-colors@npm:4.1.1": - version: 4.1.1 - resolution: "ansi-colors@npm:4.1.1" - checksum: 138d04a51076cb085da0a7e2d000c5c0bb09f6e772ed5c65c53cb118d37f6c5f1637506d7155fb5f330f0abcf6f12fa2e489ac3f8cdab9da393bf1bb4f9a32b0 - languageName: node - linkType: hard - -"ansi-regex@npm:^5.0.0": - version: 5.0.0 - resolution: "ansi-regex@npm:5.0.0" - checksum: b1bb4e992a5d96327bb4f72eaba9f8047f1d808d273ad19d399e266bfcc7fb19a4d1a127a32f7bc61fe46f1a94a4d04ec4c424e3fbe184929aa866323d8ed4ce - languageName: node - linkType: hard - -"ansi-regex@npm:^5.0.1": - version: 5.0.1 - resolution: "ansi-regex@npm:5.0.1" - checksum: 2aa4bb54caf2d622f1afdad09441695af2a83aa3fe8b8afa581d205e57ed4261c183c4d3877cee25794443fde5876417d859c108078ab788d6af7e4fe52eb66b - languageName: node - linkType: hard - -"ansi-regex@npm:^6.0.1": - version: 6.0.1 - resolution: "ansi-regex@npm:6.0.1" - checksum: 1ff8b7667cded1de4fa2c9ae283e979fc87036864317da86a2e546725f96406746411d0d85e87a2d12fa5abd715d90006de7fa4fa0477c92321ad3b4c7d4e169 - languageName: node - linkType: hard - -"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0": - version: 4.3.0 - resolution: "ansi-styles@npm:4.3.0" - dependencies: - color-convert: ^2.0.1 - checksum: 513b44c3b2105dd14cc42a19271e80f386466c4be574bccf60b627432f9198571ebf4ab1e4c3ba17347658f4ee1711c163d574248c0c1cdc2d5917a0ad582ec4 - languageName: node - linkType: hard - -"ansi-styles@npm:^6.1.0": - version: 6.2.1 - resolution: "ansi-styles@npm:6.2.1" - checksum: ef940f2f0ced1a6347398da88a91da7930c33ecac3c77b72c5905f8b8fe402c52e6fde304ff5347f616e27a742da3f1dc76de98f6866c69251ad0b07a66776d9 - languageName: node - linkType: hard - -"antlr4ts@npm:^0.5.0-alpha.4": - version: 0.5.0-alpha.4 - resolution: "antlr4ts@npm:0.5.0-alpha.4" - checksum: 37948499d59477f5b5a8ea71dfb8b5330e71d5a7cee60f57351dd744219b8619fa6aac1a5b6ec1a9991846e8ddc9ca47680eb166c59b44333369b3115e7aa358 - languageName: node - linkType: hard - -"anymatch@npm:~3.1.2": - version: 3.1.3 - resolution: "anymatch@npm:3.1.3" - dependencies: - normalize-path: ^3.0.0 - picomatch: ^2.0.4 - checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 - languageName: node - linkType: hard - -"aproba@npm:^1.0.3 || ^2.0.0": - version: 2.0.0 - resolution: "aproba@npm:2.0.0" - checksum: 5615cadcfb45289eea63f8afd064ab656006361020e1735112e346593856f87435e02d8dcc7ff0d11928bc7d425f27bc7c2a84f6c0b35ab0ff659c814c138a24 - languageName: node - linkType: hard - -"are-we-there-yet@npm:^3.0.0": - version: 3.0.1 - resolution: "are-we-there-yet@npm:3.0.1" - dependencies: - delegates: ^1.0.0 - readable-stream: ^3.6.0 - checksum: 52590c24860fa7173bedeb69a4c05fb573473e860197f618b9a28432ee4379049336727ae3a1f9c4cb083114601c1140cee578376164d0e651217a9843f9fe83 - languageName: node - linkType: hard - -"argparse@npm:^2.0.1": - version: 2.0.1 - resolution: "argparse@npm:2.0.1" - checksum: 83644b56493e89a254bae05702abf3a1101b4fa4d0ca31df1c9985275a5a5bd47b3c27b7fa0b71098d41114d8ca000e6ed90cad764b306f8a503665e4d517ced - languageName: node - linkType: hard - -"arrify@npm:^1.0.0": - version: 1.0.1 - resolution: "arrify@npm:1.0.1" - checksum: 745075dd4a4624ff0225c331dacb99be501a515d39bcb7c84d24660314a6ec28e68131b137e6f7e16318170842ce97538cd298fc4cd6b2cc798e0b957f2747e7 - languageName: node - linkType: hard - -"assertion-error@npm:^1.1.0": - version: 1.1.0 - resolution: "assertion-error@npm:1.1.0" - checksum: fd9429d3a3d4fd61782eb3962ae76b6d08aa7383123fca0596020013b3ebd6647891a85b05ce821c47d1471ed1271f00b0545cf6a4326cf2fc91efcc3b0fbecf - languageName: node - linkType: hard - -"balanced-match@npm:^1.0.0": - version: 1.0.2 - resolution: "balanced-match@npm:1.0.2" - checksum: 9706c088a283058a8a99e0bf91b0a2f75497f185980d9ffa8b304de1d9e58ebda7c72c07ebf01dadedaac5b2907b2c6f566f660d62bd336c3468e960403b9d65 - languageName: node - linkType: hard - -"base-x@npm:^3.0.2": - version: 3.0.9 - resolution: "base-x@npm:3.0.9" - dependencies: - safe-buffer: ^5.0.1 - checksum: 957101d6fd09e1903e846fd8f69fd7e5e3e50254383e61ab667c725866bec54e5ece5ba49ce385128ae48f9ec93a26567d1d5ebb91f4d56ef4a9cc0d5a5481e8 - languageName: node - linkType: hard - -"base64-js@npm:^1.3.1, base64-js@npm:^1.5.1": - version: 1.5.1 - resolution: "base64-js@npm:1.5.1" - checksum: 669632eb3745404c2f822a18fc3a0122d2f9a7a13f7fb8b5823ee19d1d2ff9ee5b52c53367176ea4ad093c332fd5ab4bd0ebae5a8e27917a4105a4cfc86b1005 - languageName: node - linkType: hard - -"bigint-buffer@npm:^1.1.5": - version: 1.1.5 - resolution: "bigint-buffer@npm:1.1.5" - dependencies: - bindings: ^1.3.0 - node-gyp: latest - checksum: d010c9f57758bcdaccb435d88b483ffcc95fe8bbc6e7fb3a44fb5221f29c894ffaf4a3c5a4a530e0e7d6608203c2cde9b79ee4f2386cd6d4462d1070bc8c9f4e - languageName: node - linkType: hard - -"bignumber.js@npm:^9.0.1": - version: 9.1.1 - resolution: "bignumber.js@npm:9.1.1" - checksum: ad243b7e2f9120b112d670bb3d674128f0bd2ca1745b0a6c9df0433bd2c0252c43e6315d944c2ac07b4c639e7496b425e46842773cf89c6a2dcd4f31e5c4b11e - languageName: node - linkType: hard - -"binary-extensions@npm:^2.0.0": - version: 2.2.0 - resolution: "binary-extensions@npm:2.2.0" - checksum: ccd267956c58d2315f5d3ea6757cf09863c5fc703e50fbeb13a7dc849b812ef76e3cf9ca8f35a0c48498776a7478d7b4a0418e1e2b8cb9cb9731f2922aaad7f8 - languageName: node - linkType: hard - -"bindings@npm:^1.3.0": - version: 1.5.0 - resolution: "bindings@npm:1.5.0" - dependencies: - file-uri-to-path: 1.0.0 - checksum: 65b6b48095717c2e6105a021a7da4ea435aa8d3d3cd085cb9e85bcb6e5773cf318c4745c3f7c504412855940b585bdf9b918236612a1c7a7942491de176f1ae7 - languageName: node - linkType: hard - -"bn.js@npm:^5.0.0, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0": - version: 5.2.1 - resolution: "bn.js@npm:5.2.1" - checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3 - languageName: node - linkType: hard - -"borsh@npm:^0.7.0": - version: 0.7.0 - resolution: "borsh@npm:0.7.0" - dependencies: - bn.js: ^5.2.0 - bs58: ^4.0.0 - text-encoding-utf-8: ^1.0.2 - checksum: e98bfb5f7cfb820819c2870b884dac58dd4b4ce6a86c286c8fbf5c9ca582e73a8c6094df67e81a28c418ff07a309c6b118b2e27fdfea83fd92b8100c741da0b5 - languageName: node - linkType: hard - -"brace-expansion@npm:^1.1.7": - version: 1.1.11 - resolution: "brace-expansion@npm:1.1.11" - dependencies: - balanced-match: ^1.0.0 - concat-map: 0.0.1 - checksum: faf34a7bb0c3fcf4b59c7808bc5d2a96a40988addf2e7e09dfbb67a2251800e0d14cd2bfc1aa79174f2f5095c54ff27f46fb1289fe2d77dac755b5eb3434cc07 - languageName: node - linkType: hard - -"brace-expansion@npm:^2.0.1": - version: 2.0.1 - resolution: "brace-expansion@npm:2.0.1" - dependencies: - balanced-match: ^1.0.0 - checksum: a61e7cd2e8a8505e9f0036b3b6108ba5e926b4b55089eeb5550cd04a471fe216c96d4fe7e4c7f995c728c554ae20ddfc4244cad10aef255e72b62930afd233d1 - languageName: node - linkType: hard - -"braces@npm:~3.0.2": - version: 3.0.2 - resolution: "braces@npm:3.0.2" - dependencies: - fill-range: ^7.0.1 - checksum: e2a8e769a863f3d4ee887b5fe21f63193a891c68b612ddb4b68d82d1b5f3ff9073af066c343e9867a393fe4c2555dcb33e89b937195feb9c1613d259edfcd459 - languageName: node - linkType: hard - -"browser-stdout@npm:1.3.1": - version: 1.3.1 - resolution: "browser-stdout@npm:1.3.1" - checksum: b717b19b25952dd6af483e368f9bcd6b14b87740c3d226c2977a65e84666ffd67000bddea7d911f111a9b6ddc822b234de42d52ab6507bce4119a4cc003ef7b3 - languageName: node - linkType: hard - -"bs58@npm:^4.0.0, bs58@npm:^4.0.1": - version: 4.0.1 - resolution: "bs58@npm:4.0.1" - dependencies: - base-x: ^3.0.2 - checksum: b3c5365bb9e0c561e1a82f1a2d809a1a692059fae016be233a6127ad2f50a6b986467c3a50669ce4c18929dcccb297c5909314dd347a25a68c21b68eb3e95ac2 - languageName: node - linkType: hard - -"buffer-from@npm:^1.0.0, buffer-from@npm:^1.1.0": - version: 1.1.2 - resolution: "buffer-from@npm:1.1.2" - checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb - languageName: node - linkType: hard - -"buffer-layout@npm:^1.2.0, buffer-layout@npm:^1.2.2": - version: 1.2.2 - resolution: "buffer-layout@npm:1.2.2" - checksum: e5809ba275530bf4e52fd09558b7c2111fbda5b405124f581acf364261d9c154e271800271898cd40473f9bcbb42c31584efb04219bde549d3460ca4bafeaa07 - languageName: node - linkType: hard - -"buffer@npm:6.0.3, buffer@npm:^6.0.3, buffer@npm:~6.0.3": - version: 6.0.3 - resolution: "buffer@npm:6.0.3" - dependencies: - base64-js: ^1.3.1 - ieee754: ^1.2.1 - checksum: 5ad23293d9a731e4318e420025800b42bf0d264004c0286c8cc010af7a270c7a0f6522e84f54b9ad65cbd6db20b8badbfd8d2ebf4f80fa03dab093b89e68c3f9 - languageName: node - linkType: hard - -"bufferutil@npm:^4.0.1": - version: 4.0.7 - resolution: "bufferutil@npm:4.0.7" - dependencies: - node-gyp: latest - node-gyp-build: ^4.3.0 - checksum: f75aa87e3d1b99b87a95f60a855e63f70af07b57fb8443e75a2ddfef2e47788d130fdd46e3a78fd7e0c10176082b26dfbed970c5b8632e1cc299cafa0e93ce45 - languageName: node - linkType: hard - -"cacache@npm:^17.0.0": - version: 17.1.3 - resolution: "cacache@npm:17.1.3" - dependencies: - "@npmcli/fs": ^3.1.0 - fs-minipass: ^3.0.0 - glob: ^10.2.2 - lru-cache: ^7.7.1 - minipass: ^5.0.0 - minipass-collect: ^1.0.2 - minipass-flush: ^1.0.5 - minipass-pipeline: ^1.2.4 - p-map: ^4.0.0 - ssri: ^10.0.0 - tar: ^6.1.11 - unique-filename: ^3.0.0 - checksum: 385756781e1e21af089160d89d7462b7ed9883c978e848c7075b90b73cb823680e66092d61513050164588387d2ca87dd6d910e28d64bc13a9ac82cd8580c796 - languageName: node - linkType: hard - -"camelcase@npm:^6.0.0, camelcase@npm:^6.3.0": - version: 6.3.0 - resolution: "camelcase@npm:6.3.0" - checksum: 8c96818a9076434998511251dcb2761a94817ea17dbdc37f47ac080bd088fc62c7369429a19e2178b993497132c8cbcf5cc1f44ba963e76782ba469c0474938d - languageName: node - linkType: hard - -"chai@npm:^4.3.4": - version: 4.3.7 - resolution: "chai@npm:4.3.7" - dependencies: - assertion-error: ^1.1.0 - check-error: ^1.0.2 - deep-eql: ^4.1.2 - get-func-name: ^2.0.0 - loupe: ^2.3.1 - pathval: ^1.1.1 - type-detect: ^4.0.5 - checksum: 0bba7d267848015246a66995f044ce3f0ebc35e530da3cbdf171db744e14cbe301ab913a8d07caf7952b430257ccbb1a4a983c570a7c5748dc537897e5131f7c - languageName: node - linkType: hard - -"chalk@npm:^4.1.0": - version: 4.1.2 - resolution: "chalk@npm:4.1.2" - dependencies: - ansi-styles: ^4.1.0 - supports-color: ^7.1.0 - checksum: fe75c9d5c76a7a98d45495b91b2172fa3b7a09e0cc9370e5c8feb1c567b85c4288e2b3fded7cfdd7359ac28d6b3844feb8b82b8686842e93d23c827c417e83fc - languageName: node - linkType: hard - -"check-error@npm:^1.0.2": - version: 1.0.2 - resolution: "check-error@npm:1.0.2" - checksum: d9d106504404b8addd1ee3f63f8c0eaa7cd962a1a28eb9c519b1c4a1dc7098be38007fc0060f045ee00f075fbb7a2a4f42abcf61d68323677e11ab98dc16042e - languageName: node - linkType: hard - -"chokidar@npm:3.5.3": - version: 3.5.3 - resolution: "chokidar@npm:3.5.3" - dependencies: - anymatch: ~3.1.2 - braces: ~3.0.2 - fsevents: ~2.3.2 - glob-parent: ~5.1.2 - is-binary-path: ~2.1.0 - is-glob: ~4.0.1 - normalize-path: ~3.0.0 - readdirp: ~3.6.0 - dependenciesMeta: - fsevents: - optional: true - checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c - languageName: node - linkType: hard - -"chownr@npm:^2.0.0": - version: 2.0.0 - resolution: "chownr@npm:2.0.0" - checksum: c57cf9dd0791e2f18a5ee9c1a299ae6e801ff58fee96dc8bfd0dcb4738a6ce58dd252a3605b1c93c6418fe4f9d5093b28ffbf4d66648cb2a9c67eaef9679be2f - languageName: node - linkType: hard - -"clean-stack@npm:^2.0.0": - version: 2.2.0 - resolution: "clean-stack@npm:2.2.0" - checksum: 2ac8cd2b2f5ec986a3c743935ec85b07bc174d5421a5efc8017e1f146a1cf5f781ae962618f416352103b32c9cd7e203276e8c28241bbe946160cab16149fb68 - languageName: node - linkType: hard - -"cliui@npm:^7.0.2": - version: 7.0.4 - resolution: "cliui@npm:7.0.4" - dependencies: - string-width: ^4.2.0 - strip-ansi: ^6.0.0 - wrap-ansi: ^7.0.0 - checksum: ce2e8f578a4813806788ac399b9e866297740eecd4ad1823c27fd344d78b22c5f8597d548adbcc46f0573e43e21e751f39446c5a5e804a12aace402b7a315d7f - languageName: node - linkType: hard - -"color-convert@npm:^2.0.1": - version: 2.0.1 - resolution: "color-convert@npm:2.0.1" - dependencies: - color-name: ~1.1.4 - checksum: 79e6bdb9fd479a205c71d89574fccfb22bd9053bd98c6c4d870d65c132e5e904e6034978e55b43d69fcaa7433af2016ee203ce76eeba9cfa554b373e7f7db336 - languageName: node - linkType: hard - -"color-name@npm:~1.1.4": - version: 1.1.4 - resolution: "color-name@npm:1.1.4" - checksum: b0445859521eb4021cd0fb0cc1a75cecf67fceecae89b63f62b201cca8d345baf8b952c966862a9d9a2632987d4f6581f0ec8d957dfacece86f0a7919316f610 - languageName: node - linkType: hard - -"color-support@npm:^1.1.3": - version: 1.1.3 - resolution: "color-support@npm:1.1.3" - bin: - color-support: bin.js - checksum: 9b7356817670b9a13a26ca5af1c21615463b500783b739b7634a0c2047c16cef4b2865d7576875c31c3cddf9dd621fa19285e628f20198b233a5cfdda6d0793b - languageName: node - linkType: hard - -"commander@npm:^2.20.3": - version: 2.20.3 - resolution: "commander@npm:2.20.3" - checksum: ab8c07884e42c3a8dbc5dd9592c606176c7eb5c1ca5ff274bcf907039b2c41de3626f684ea75ccf4d361ba004bbaff1f577d5384c155f3871e456bdf27becf9e - languageName: node - linkType: hard - -"concat-map@npm:0.0.1": - version: 0.0.1 - resolution: "concat-map@npm:0.0.1" - checksum: 902a9f5d8967a3e2faf138d5cb784b9979bad2e6db5357c5b21c568df4ebe62bcb15108af1b2253744844eb964fc023fbd9afbbbb6ddd0bcc204c6fb5b7bf3af - languageName: node - linkType: hard - -"console-control-strings@npm:^1.1.0": - version: 1.1.0 - resolution: "console-control-strings@npm:1.1.0" - checksum: 8755d76787f94e6cf79ce4666f0c5519906d7f5b02d4b884cf41e11dcd759ed69c57da0670afd9236d229a46e0f9cf519db0cd829c6dca820bb5a5c3def584ed - languageName: node - linkType: hard - -"cross-fetch@npm:^3.1.5": - version: 3.1.8 - resolution: "cross-fetch@npm:3.1.8" - dependencies: - node-fetch: ^2.6.12 - checksum: 78f993fa099eaaa041122ab037fe9503ecbbcb9daef234d1d2e0b9230a983f64d645d088c464e21a247b825a08dc444a6e7064adfa93536d3a9454b4745b3632 - languageName: node - linkType: hard - -"cross-spawn@npm:^7.0.0": - version: 7.0.3 - resolution: "cross-spawn@npm:7.0.3" - dependencies: - path-key: ^3.1.0 - shebang-command: ^2.0.0 - which: ^2.0.1 - checksum: 671cc7c7288c3a8406f3c69a3ae2fc85555c04169e9d611def9a675635472614f1c0ed0ef80955d5b6d4e724f6ced67f0ad1bb006c2ea643488fcfef994d7f52 - languageName: node - linkType: hard - -"crypto-hash@npm:^1.3.0": - version: 1.3.0 - resolution: "crypto-hash@npm:1.3.0" - checksum: a3a507e0d2b18fbd2da8088a1c62d0c53c009a99bbfa6d851cac069734ffa546922fa51bdd776d006459701cdda873463e5059ece3431aca048fd99e7573d138 - languageName: node - linkType: hard - -"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.3.3": - version: 4.3.4 - resolution: "debug@npm:4.3.4" - dependencies: - ms: 2.1.2 - peerDependenciesMeta: - supports-color: - optional: true - checksum: 3dbad3f94ea64f34431a9cbf0bafb61853eda57bff2880036153438f50fb5a84f27683ba0d8e5426bf41a8c6ff03879488120cf5b3a761e77953169c0600a708 - languageName: node - linkType: hard - -"debug@npm:4.3.3": - version: 4.3.3 - resolution: "debug@npm:4.3.3" - dependencies: - ms: 2.1.2 - peerDependenciesMeta: - supports-color: - optional: true - checksum: 14472d56fe4a94dbcfaa6dbed2dd3849f1d72ba78104a1a328047bb564643ca49df0224c3a17fa63533fd11dd3d4c8636cd861191232a2c6735af00cc2d4de16 - languageName: node - linkType: hard - -"decamelize@npm:^4.0.0": - version: 4.0.0 - resolution: "decamelize@npm:4.0.0" - checksum: b7d09b82652c39eead4d6678bb578e3bebd848add894b76d0f6b395bc45b2d692fb88d977e7cfb93c4ed6c119b05a1347cef261174916c2e75c0a8ca57da1809 - languageName: node - linkType: hard - -"deep-eql@npm:^4.1.2": - version: 4.1.3 - resolution: "deep-eql@npm:4.1.3" - dependencies: - type-detect: ^4.0.0 - checksum: 7f6d30cb41c713973dc07eaadded848b2ab0b835e518a88b91bea72f34e08c4c71d167a722a6f302d3a6108f05afd8e6d7650689a84d5d29ec7fe6220420397f - languageName: node - linkType: hard - -"delay@npm:^5.0.0": - version: 5.0.0 - resolution: "delay@npm:5.0.0" - checksum: 62f151151ecfde0d9afbb8a6be37a6d103c4cb24f35a20ef3fe56f920b0d0d0bb02bc9c0a3084d0179ef669ca332b91155f2ee4d9854622cd2cdba5fc95285f9 - languageName: node - linkType: hard - -"delegates@npm:^1.0.0": - version: 1.0.0 - resolution: "delegates@npm:1.0.0" - checksum: a51744d9b53c164ba9c0492471a1a2ffa0b6727451bdc89e31627fdf4adda9d51277cfcbfb20f0a6f08ccb3c436f341df3e92631a3440226d93a8971724771fd - languageName: node - linkType: hard - -"depd@npm:^2.0.0": - version: 2.0.0 - resolution: "depd@npm:2.0.0" - checksum: abbe19c768c97ee2eed6282d8ce3031126662252c58d711f646921c9623f9052e3e1906443066beec1095832f534e57c523b7333f8e7e0d93051ab6baef5ab3a - languageName: node - linkType: hard - -"diff@npm:5.0.0": - version: 5.0.0 - resolution: "diff@npm:5.0.0" - checksum: f19fe29284b633afdb2725c2a8bb7d25761ea54d321d8e67987ac851c5294be4afeab532bd84531e02583a3fe7f4014aa314a3eda84f5590e7a9e6b371ef3b46 - languageName: node - linkType: hard - -"diff@npm:^3.1.0": - version: 3.5.0 - resolution: "diff@npm:3.5.0" - checksum: 00842950a6551e26ce495bdbce11047e31667deea546527902661f25cc2e73358967ebc78cf86b1a9736ec3e14286433225f9970678155753a6291c3bca5227b - languageName: node - linkType: hard - -"dot-case@npm:^3.0.4": - version: 3.0.4 - resolution: "dot-case@npm:3.0.4" - dependencies: - no-case: ^3.0.4 - tslib: ^2.0.3 - checksum: a65e3519414856df0228b9f645332f974f2bf5433370f544a681122eab59e66038fc3349b4be1cdc47152779dac71a5864f1ccda2f745e767c46e9c6543b1169 - languageName: node - linkType: hard - -"eastasianwidth@npm:^0.2.0": - version: 0.2.0 - resolution: "eastasianwidth@npm:0.2.0" - checksum: 7d00d7cd8e49b9afa762a813faac332dee781932d6f2c848dc348939c4253f1d4564341b7af1d041853bc3f32c2ef141b58e0a4d9862c17a7f08f68df1e0f1ed - languageName: node - linkType: hard - -"emoji-regex@npm:^8.0.0": - version: 8.0.0 - resolution: "emoji-regex@npm:8.0.0" - checksum: d4c5c39d5a9868b5fa152f00cada8a936868fd3367f33f71be515ecee4c803132d11b31a6222b2571b1e5f7e13890156a94880345594d0ce7e3c9895f560f192 - languageName: node - linkType: hard - -"emoji-regex@npm:^9.2.2": - version: 9.2.2 - resolution: "emoji-regex@npm:9.2.2" - checksum: 8487182da74aabd810ac6d6f1994111dfc0e331b01271ae01ec1eb0ad7b5ecc2bbbbd2f053c05cb55a1ac30449527d819bbfbf0e3de1023db308cbcb47f86601 - languageName: node - linkType: hard - -"encoding@npm:^0.1.13": - version: 0.1.13 - resolution: "encoding@npm:0.1.13" - dependencies: - iconv-lite: ^0.6.2 - checksum: bb98632f8ffa823996e508ce6a58ffcf5856330fde839ae42c9e1f436cc3b5cc651d4aeae72222916545428e54fd0f6aa8862fd8d25bdbcc4589f1e3f3715e7f - languageName: node - linkType: hard - -"env-paths@npm:^2.2.0": - version: 2.2.1 - resolution: "env-paths@npm:2.2.1" - checksum: 65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e - languageName: node - linkType: hard - -"err-code@npm:^2.0.2": - version: 2.0.3 - resolution: "err-code@npm:2.0.3" - checksum: 8b7b1be20d2de12d2255c0bc2ca638b7af5171142693299416e6a9339bd7d88fc8d7707d913d78e0993176005405a236b066b45666b27b797252c771156ace54 - languageName: node - linkType: hard - -"es6-promise@npm:^4.0.3": - version: 4.2.8 - resolution: "es6-promise@npm:4.2.8" - checksum: 95614a88873611cb9165a85d36afa7268af5c03a378b35ca7bda9508e1d4f1f6f19a788d4bc755b3fd37c8ebba40782018e02034564ff24c9d6fa37e959ad57d - languageName: node - linkType: hard - -"es6-promisify@npm:^5.0.0": - version: 5.0.0 - resolution: "es6-promisify@npm:5.0.0" - dependencies: - es6-promise: ^4.0.3 - checksum: fbed9d791598831413be84a5374eca8c24800ec71a16c1c528c43a98e2dadfb99331483d83ae6094ddb9b87e6f799a15d1553cebf756047e0865c753bc346b92 - languageName: node - linkType: hard - -"escalade@npm:^3.1.1": - version: 3.1.1 - resolution: "escalade@npm:3.1.1" - checksum: a3e2a99f07acb74b3ad4989c48ca0c3140f69f923e56d0cba0526240ee470b91010f9d39001f2a4a313841d237ede70a729e92125191ba5d21e74b106800b133 - languageName: node - linkType: hard - -"escape-string-regexp@npm:4.0.0, escape-string-regexp@npm:^4.0.0": - version: 4.0.0 - resolution: "escape-string-regexp@npm:4.0.0" - checksum: 98b48897d93060f2322108bf29db0feba7dd774be96cd069458d1453347b25ce8682ecc39859d4bca2203cc0ab19c237bcc71755eff49a0f8d90beadeeba5cc5 - languageName: node - linkType: hard - -"eventemitter3@npm:^4.0.7": - version: 4.0.7 - resolution: "eventemitter3@npm:4.0.7" - checksum: 1875311c42fcfe9c707b2712c32664a245629b42bb0a5a84439762dd0fd637fc54d078155ea83c2af9e0323c9ac13687e03cfba79b03af9f40c89b4960099374 - languageName: node - linkType: hard - -"exponential-backoff@npm:^3.1.1": - version: 3.1.1 - resolution: "exponential-backoff@npm:3.1.1" - checksum: 3d21519a4f8207c99f7457287291316306255a328770d320b401114ec8481986e4e467e854cb9914dd965e0a1ca810a23ccb559c642c88f4c7f55c55778a9b48 - languageName: node - linkType: hard - -"eyes@npm:^0.1.8": - version: 0.1.8 - resolution: "eyes@npm:0.1.8" - checksum: c31703a92bf36ba75ee8d379ee7985c24ee6149f3a6175f44cec7a05b178c38bce9836d3ca48c9acb0329a960ac2c4b2ead4e60cdd4fe6e8c92cad7cd6913687 - languageName: node - linkType: hard - -"fast-stable-stringify@npm:^1.0.0": - version: 1.0.0 - resolution: "fast-stable-stringify@npm:1.0.0" - checksum: ef1203d246a7e8ac15e2bfbda0a89fa375947bccf9f7910be0ea759856dbe8ea5024a0d8cc2cceabe18a9cb67e95927b78bb6173a3ae37ec55a518cf36e5244b - languageName: node - linkType: hard - -"file-uri-to-path@npm:1.0.0": - version: 1.0.0 - resolution: "file-uri-to-path@npm:1.0.0" - checksum: b648580bdd893a008c92c7ecc96c3ee57a5e7b6c4c18a9a09b44fb5d36d79146f8e442578bc0e173dc027adf3987e254ba1dfd6e3ec998b7c282873010502144 - languageName: node - linkType: hard - -"fill-range@npm:^7.0.1": - version: 7.0.1 - resolution: "fill-range@npm:7.0.1" - dependencies: - to-regex-range: ^5.0.1 - checksum: cc283f4e65b504259e64fd969bcf4def4eb08d85565e906b7d36516e87819db52029a76b6363d0f02d0d532f0033c9603b9e2d943d56ee3b0d4f7ad3328ff917 - languageName: node - linkType: hard - -"find-up@npm:5.0.0": - version: 5.0.0 - resolution: "find-up@npm:5.0.0" - dependencies: - locate-path: ^6.0.0 - path-exists: ^4.0.0 - checksum: 07955e357348f34660bde7920783204ff5a26ac2cafcaa28bace494027158a97b9f56faaf2d89a6106211a8174db650dd9f503f9c0d526b1202d5554a00b9095 - languageName: node - linkType: hard - -"flat@npm:^5.0.2": - version: 5.0.2 - resolution: "flat@npm:5.0.2" - bin: - flat: cli.js - checksum: 12a1536ac746db74881316a181499a78ef953632ddd28050b7a3a43c62ef5462e3357c8c29d76072bb635f147f7a9a1f0c02efef6b4be28f8db62ceb3d5c7f5d - languageName: node - linkType: hard - -"foreground-child@npm:^3.1.0": - version: 3.1.1 - resolution: "foreground-child@npm:3.1.1" - dependencies: - cross-spawn: ^7.0.0 - signal-exit: ^4.0.1 - checksum: 139d270bc82dc9e6f8bc045fe2aae4001dc2472157044fdfad376d0a3457f77857fa883c1c8b21b491c6caade9a926a4bed3d3d2e8d3c9202b151a4cbbd0bcd5 - languageName: node - linkType: hard - -"fs-minipass@npm:^2.0.0": - version: 2.1.0 - resolution: "fs-minipass@npm:2.1.0" - dependencies: - minipass: ^3.0.0 - checksum: 1b8d128dae2ac6cc94230cc5ead341ba3e0efaef82dab46a33d171c044caaa6ca001364178d42069b2809c35a1c3c35079a32107c770e9ffab3901b59af8c8b1 - languageName: node - linkType: hard - -"fs-minipass@npm:^3.0.0": - version: 3.0.2 - resolution: "fs-minipass@npm:3.0.2" - dependencies: - minipass: ^5.0.0 - checksum: e9cc0e1f2d01c6f6f62f567aee59530aba65c6c7b2ae88c5027bc34c711ebcfcfaefd0caf254afa6adfe7d1fba16bc2537508a6235196bac7276747d078aef0a - languageName: node - linkType: hard - -"fs.realpath@npm:^1.0.0": - version: 1.0.0 - resolution: "fs.realpath@npm:1.0.0" - checksum: 99ddea01a7e75aa276c250a04eedeffe5662bce66c65c07164ad6264f9de18fb21be9433ead460e54cff20e31721c811f4fb5d70591799df5f85dce6d6746fd0 - languageName: node - linkType: hard - -"fsevents@npm:~2.3.2": - version: 2.3.2 - resolution: "fsevents@npm:2.3.2" - dependencies: - node-gyp: latest - checksum: 97ade64e75091afee5265e6956cb72ba34db7819b4c3e94c431d4be2b19b8bb7a2d4116da417950c3425f17c8fe693d25e20212cac583ac1521ad066b77ae31f - conditions: os=darwin - languageName: node - linkType: hard - -"fsevents@patch:fsevents@~2.3.2#~builtin": - version: 2.3.2 - resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" - dependencies: - node-gyp: latest - conditions: os=darwin - languageName: node - linkType: hard - -"gauge@npm:^4.0.3": - version: 4.0.4 - resolution: "gauge@npm:4.0.4" - dependencies: - aproba: ^1.0.3 || ^2.0.0 - color-support: ^1.1.3 - console-control-strings: ^1.1.0 - has-unicode: ^2.0.1 - signal-exit: ^3.0.7 - string-width: ^4.2.3 - strip-ansi: ^6.0.1 - wide-align: ^1.1.5 - checksum: 788b6bfe52f1dd8e263cda800c26ac0ca2ff6de0b6eee2fe0d9e3abf15e149b651bd27bf5226be10e6e3edb5c4e5d5985a5a1a98137e7a892f75eff76467ad2d - languageName: node - linkType: hard - -"get-caller-file@npm:^2.0.5": - version: 2.0.5 - resolution: "get-caller-file@npm:2.0.5" - checksum: b9769a836d2a98c3ee734a88ba712e62703f1df31b94b784762c433c27a386dd6029ff55c2a920c392e33657d80191edbf18c61487e198844844516f843496b9 - languageName: node - linkType: hard - -"get-func-name@npm:^2.0.0": - version: 2.0.0 - resolution: "get-func-name@npm:2.0.0" - checksum: 8d82e69f3e7fab9e27c547945dfe5cc0c57fc0adf08ce135dddb01081d75684a03e7a0487466f478872b341d52ac763ae49e660d01ab83741f74932085f693c3 - languageName: node - linkType: hard - -"glob-parent@npm:~5.1.2": - version: 5.1.2 - resolution: "glob-parent@npm:5.1.2" - dependencies: - is-glob: ^4.0.1 - checksum: f4f2bfe2425296e8a47e36864e4f42be38a996db40420fe434565e4480e3322f18eb37589617a98640c5dc8fdec1a387007ee18dbb1f3f5553409c34d17f425e - languageName: node - linkType: hard - -"glob@npm:7.2.0": - version: 7.2.0 - resolution: "glob@npm:7.2.0" - dependencies: - fs.realpath: ^1.0.0 - inflight: ^1.0.4 - inherits: 2 - minimatch: ^3.0.4 - once: ^1.3.0 - path-is-absolute: ^1.0.0 - checksum: 78a8ea942331f08ed2e055cb5b9e40fe6f46f579d7fd3d694f3412fe5db23223d29b7fee1575440202e9a7ff9a72ab106a39fee39934c7bedafe5e5f8ae20134 - languageName: node - linkType: hard - -"glob@npm:^10.2.2": - version: 10.3.3 - resolution: "glob@npm:10.3.3" - dependencies: - foreground-child: ^3.1.0 - jackspeak: ^2.0.3 - minimatch: ^9.0.1 - minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 - path-scurry: ^1.10.1 - bin: - glob: dist/cjs/src/bin.js - checksum: 29190d3291f422da0cb40b77a72fc8d2c51a36524e99b8bf412548b7676a6627489528b57250429612b6eec2e6fe7826d328451d3e694a9d15e575389308ec53 - languageName: node - linkType: hard - -"glob@npm:^7.1.3, glob@npm:^7.1.4": - version: 7.2.3 - resolution: "glob@npm:7.2.3" - dependencies: - fs.realpath: ^1.0.0 - inflight: ^1.0.4 - inherits: 2 - minimatch: ^3.1.1 - once: ^1.3.0 - path-is-absolute: ^1.0.0 - checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133 - languageName: node - linkType: hard - -"graceful-fs@npm:^4.2.6": - version: 4.2.11 - resolution: "graceful-fs@npm:4.2.11" - checksum: ac85f94da92d8eb6b7f5a8b20ce65e43d66761c55ce85ac96df6865308390da45a8d3f0296dd3a663de65d30ba497bd46c696cc1e248c72b13d6d567138a4fc7 - languageName: node - linkType: hard - -"growl@npm:1.10.5": - version: 1.10.5 - resolution: "growl@npm:1.10.5" - checksum: 4b86685de6831cebcbb19f93870bea624afee61124b0a20c49017013987cd129e73a8c4baeca295728f41d21265e1f859d25ef36731b142ca59c655fea94bb1a - languageName: node - linkType: hard - -"has-flag@npm:^4.0.0": - version: 4.0.0 - resolution: "has-flag@npm:4.0.0" - checksum: 261a1357037ead75e338156b1f9452c016a37dcd3283a972a30d9e4a87441ba372c8b81f818cd0fbcd9c0354b4ae7e18b9e1afa1971164aef6d18c2b6095a8ad - languageName: node - linkType: hard - -"has-unicode@npm:^2.0.1": - version: 2.0.1 - resolution: "has-unicode@npm:2.0.1" - checksum: 1eab07a7436512db0be40a710b29b5dc21fa04880b7f63c9980b706683127e3c1b57cb80ea96d47991bdae2dfe479604f6a1ba410106ee1046a41d1bd0814400 - languageName: node - linkType: hard - -"he@npm:1.2.0": - version: 1.2.0 - resolution: "he@npm:1.2.0" - bin: - he: bin/he - checksum: 3d4d6babccccd79c5c5a3f929a68af33360d6445587d628087f39a965079d84f18ce9c3d3f917ee1e3978916fc833bb8b29377c3b403f919426f91bc6965e7a7 - languageName: node - linkType: hard - -"http-cache-semantics@npm:^4.1.1": - version: 4.1.1 - resolution: "http-cache-semantics@npm:4.1.1" - checksum: 83ac0bc60b17a3a36f9953e7be55e5c8f41acc61b22583060e8dedc9dd5e3607c823a88d0926f9150e571f90946835c7fe150732801010845c72cd8bbff1a236 - languageName: node - linkType: hard - -"http-proxy-agent@npm:^5.0.0": - version: 5.0.0 - resolution: "http-proxy-agent@npm:5.0.0" - dependencies: - "@tootallnate/once": 2 - agent-base: 6 - debug: 4 - checksum: e2ee1ff1656a131953839b2a19cd1f3a52d97c25ba87bd2559af6ae87114abf60971e498021f9b73f9fd78aea8876d1fb0d4656aac8a03c6caa9fc175f22b786 - languageName: node - linkType: hard - -"https-proxy-agent@npm:^5.0.0": - version: 5.0.1 - resolution: "https-proxy-agent@npm:5.0.1" - dependencies: - agent-base: 6 - debug: 4 - checksum: 571fccdf38184f05943e12d37d6ce38197becdd69e58d03f43637f7fa1269cf303a7d228aa27e5b27bbd3af8f09fd938e1c91dcfefff2df7ba77c20ed8dfc765 - languageName: node - linkType: hard - -"humanize-ms@npm:^1.2.1": - version: 1.2.1 - resolution: "humanize-ms@npm:1.2.1" - dependencies: - ms: ^2.0.0 - checksum: 9c7a74a2827f9294c009266c82031030eae811ca87b0da3dceb8d6071b9bde22c9f3daef0469c3c533cc67a97d8a167cd9fc0389350e5f415f61a79b171ded16 - languageName: node - linkType: hard - -"iconv-lite@npm:^0.6.2": - version: 0.6.3 - resolution: "iconv-lite@npm:0.6.3" - dependencies: - safer-buffer: ">= 2.1.2 < 3.0.0" - checksum: 3f60d47a5c8fc3313317edfd29a00a692cc87a19cac0159e2ce711d0ebc9019064108323b5e493625e25594f11c6236647d8e256fbe7a58f4a3b33b89e6d30bf - languageName: node - linkType: hard - -"ieee754@npm:^1.2.1": - version: 1.2.1 - resolution: "ieee754@npm:1.2.1" - checksum: 5144c0c9815e54ada181d80a0b810221a253562422e7c6c3a60b1901154184f49326ec239d618c416c1c5945a2e197107aee8d986a3dd836b53dffefd99b5e7e - languageName: node - linkType: hard - -"imurmurhash@npm:^0.1.4": - version: 0.1.4 - resolution: "imurmurhash@npm:0.1.4" - checksum: 7cae75c8cd9a50f57dadd77482359f659eaebac0319dd9368bcd1714f55e65badd6929ca58569da2b6494ef13fdd5598cd700b1eba23f8b79c5f19d195a3ecf7 - languageName: node - linkType: hard - -"indent-string@npm:^4.0.0": - version: 4.0.0 - resolution: "indent-string@npm:4.0.0" - checksum: 824cfb9929d031dabf059bebfe08cf3137365e112019086ed3dcff6a0a7b698cb80cf67ccccde0e25b9e2d7527aa6cc1fed1ac490c752162496caba3e6699612 - languageName: node - linkType: hard - -"inflight@npm:^1.0.4": - version: 1.0.6 - resolution: "inflight@npm:1.0.6" - dependencies: - once: ^1.3.0 - wrappy: 1 - checksum: f4f76aa072ce19fae87ce1ef7d221e709afb59d445e05d47fba710e85470923a75de35bfae47da6de1b18afc3ce83d70facf44cfb0aff89f0a3f45c0a0244dfd - languageName: node - linkType: hard - -"inherits@npm:2, inherits@npm:^2.0.3": - version: 2.0.4 - resolution: "inherits@npm:2.0.4" - checksum: 4a48a733847879d6cf6691860a6b1e3f0f4754176e4d71494c41f3475553768b10f84b5ce1d40fbd0e34e6bfbb864ee35858ad4dd2cf31e02fc4a154b724d7f1 - languageName: node - linkType: hard - -"ip@npm:^2.0.0": - version: 2.0.0 - resolution: "ip@npm:2.0.0" - checksum: cfcfac6b873b701996d71ec82a7dd27ba92450afdb421e356f44044ed688df04567344c36cbacea7d01b1c39a4c732dc012570ebe9bebfb06f27314bca625349 - languageName: node - linkType: hard - -"is-binary-path@npm:~2.1.0": - version: 2.1.0 - resolution: "is-binary-path@npm:2.1.0" - dependencies: - binary-extensions: ^2.0.0 - checksum: 84192eb88cff70d320426f35ecd63c3d6d495da9d805b19bc65b518984b7c0760280e57dbf119b7e9be6b161784a5a673ab2c6abe83abb5198a432232ad5b35c - languageName: node - linkType: hard - -"is-extglob@npm:^2.1.1": - version: 2.1.1 - resolution: "is-extglob@npm:2.1.1" - checksum: df033653d06d0eb567461e58a7a8c9f940bd8c22274b94bf7671ab36df5719791aae15eef6d83bbb5e23283967f2f984b8914559d4449efda578c775c4be6f85 - languageName: node - linkType: hard - -"is-fullwidth-code-point@npm:^3.0.0": - version: 3.0.0 - resolution: "is-fullwidth-code-point@npm:3.0.0" - checksum: 44a30c29457c7fb8f00297bce733f0a64cd22eca270f83e58c105e0d015e45c019491a4ab2faef91ab51d4738c670daff901c799f6a700e27f7314029e99e348 - languageName: node - linkType: hard - -"is-glob@npm:^4.0.1, is-glob@npm:~4.0.1": - version: 4.0.3 - resolution: "is-glob@npm:4.0.3" - dependencies: - is-extglob: ^2.1.1 - checksum: d381c1319fcb69d341cc6e6c7cd588e17cd94722d9a32dbd60660b993c4fb7d0f19438674e68dfec686d09b7c73139c9166b47597f846af387450224a8101ab4 - languageName: node - linkType: hard - -"is-lambda@npm:^1.0.1": - version: 1.0.1 - resolution: "is-lambda@npm:1.0.1" - checksum: 93a32f01940220532e5948538699ad610d5924ac86093fcee83022252b363eb0cc99ba53ab084a04e4fb62bf7b5731f55496257a4c38adf87af9c4d352c71c35 - languageName: node - linkType: hard - -"is-number@npm:^7.0.0": - version: 7.0.0 - resolution: "is-number@npm:7.0.0" - checksum: 456ac6f8e0f3111ed34668a624e45315201dff921e5ac181f8ec24923b99e9f32ca1a194912dc79d539c97d33dba17dc635202ff0b2cf98326f608323276d27a - languageName: node - linkType: hard - -"is-plain-obj@npm:^2.1.0": - version: 2.1.0 - resolution: "is-plain-obj@npm:2.1.0" - checksum: cec9100678b0a9fe0248a81743041ed990c2d4c99f893d935545cfbc42876cbe86d207f3b895700c690ad2fa520e568c44afc1605044b535a7820c1d40e38daa - languageName: node - linkType: hard - -"is-unicode-supported@npm:^0.1.0": - version: 0.1.0 - resolution: "is-unicode-supported@npm:0.1.0" - checksum: a2aab86ee7712f5c2f999180daaba5f361bdad1efadc9610ff5b8ab5495b86e4f627839d085c6530363c6d6d4ecbde340fb8e54bdb83da4ba8e0865ed5513c52 - languageName: node - linkType: hard - -"isexe@npm:^2.0.0": - version: 2.0.0 - resolution: "isexe@npm:2.0.0" - checksum: 26bf6c5480dda5161c820c5b5c751ae1e766c587b1f951ea3fcfc973bafb7831ae5b54a31a69bd670220e42e99ec154475025a468eae58ea262f813fdc8d1c62 - languageName: node - linkType: hard - -"isomorphic-ws@npm:^4.0.1": - version: 4.0.1 - resolution: "isomorphic-ws@npm:4.0.1" - peerDependencies: - ws: "*" - checksum: d7190eadefdc28bdb93d67b5f0c603385aaf87724fa2974abb382ac1ec9756ed2cfb27065cbe76122879c2d452e2982bc4314317f3d6c737ddda6c047328771a - languageName: node - linkType: hard - -"jackspeak@npm:^2.0.3": - version: 2.2.1 - resolution: "jackspeak@npm:2.2.1" - dependencies: - "@isaacs/cliui": ^8.0.2 - "@pkgjs/parseargs": ^0.11.0 - dependenciesMeta: - "@pkgjs/parseargs": - optional: true - checksum: e29291c0d0f280a063fa18fbd1e891ab8c2d7519fd34052c0ebde38538a15c603140d60c2c7f432375ff7ee4c5f1c10daa8b2ae19a97c3d4affe308c8360c1df - languageName: node - linkType: hard - -"jayson@npm:^4.1.0": - version: 4.1.0 - resolution: "jayson@npm:4.1.0" - dependencies: - "@types/connect": ^3.4.33 - "@types/node": ^12.12.54 - "@types/ws": ^7.4.4 - JSONStream: ^1.3.5 - commander: ^2.20.3 - delay: ^5.0.0 - es6-promisify: ^5.0.0 - eyes: ^0.1.8 - isomorphic-ws: ^4.0.1 - json-stringify-safe: ^5.0.1 - uuid: ^8.3.2 - ws: ^7.4.5 - bin: - jayson: bin/jayson.js - checksum: 86464322fbdc6db65d2bb4fc278cb6c86fad5c2a506065490d39459f09ba0d30f2b4fb740b33828a1424791419b6c8bd295dc54d361a4ad959bf70cc62b1ca7e - languageName: node - linkType: hard - -"js-sha256@npm:^0.9.0": - version: 0.9.0 - resolution: "js-sha256@npm:0.9.0" - checksum: ffad54b3373f81581e245866abfda50a62c483803a28176dd5c28fd2d313e0bdf830e77dac7ff8afd193c53031618920f3d98daf21cbbe80082753ab639c0365 - languageName: node - linkType: hard - -"js-yaml@npm:4.1.0": - version: 4.1.0 - resolution: "js-yaml@npm:4.1.0" - dependencies: - argparse: ^2.0.1 - bin: - js-yaml: bin/js-yaml.js - checksum: c7830dfd456c3ef2c6e355cc5a92e6700ceafa1d14bba54497b34a99f0376cecbb3e9ac14d3e5849b426d5a5140709a66237a8c991c675431271c4ce5504151a - languageName: node - linkType: hard - -"json-stringify-safe@npm:^5.0.1": - version: 5.0.1 - resolution: "json-stringify-safe@npm:5.0.1" - checksum: 48ec0adad5280b8a96bb93f4563aa1667fd7a36334f79149abd42446d0989f2ddc58274b479f4819f1f00617957e6344c886c55d05a4e15ebb4ab931e4a6a8ee - languageName: node - linkType: hard - -"json5@npm:^1.0.2": - version: 1.0.2 - resolution: "json5@npm:1.0.2" - dependencies: - minimist: ^1.2.0 - bin: - json5: lib/cli.js - checksum: 866458a8c58a95a49bef3adba929c625e82532bcff1fe93f01d29cb02cac7c3fe1f4b79951b7792c2da9de0b32871a8401a6e3c5b36778ad852bf5b8a61165d7 - languageName: node - linkType: hard - -"jsonparse@npm:^1.2.0": - version: 1.3.1 - resolution: "jsonparse@npm:1.3.1" - checksum: 6514a7be4674ebf407afca0eda3ba284b69b07f9958a8d3113ef1005f7ec610860c312be067e450c569aab8b89635e332cee3696789c750692bb60daba627f4d - languageName: node - linkType: hard - -"locate-path@npm:^6.0.0": - version: 6.0.0 - resolution: "locate-path@npm:6.0.0" - dependencies: - p-locate: ^5.0.0 - checksum: 72eb661788a0368c099a184c59d2fee760b3831c9c1c33955e8a19ae4a21b4116e53fa736dc086cdeb9fce9f7cc508f2f92d2d3aae516f133e16a2bb59a39f5a - languageName: node - linkType: hard - -"log-symbols@npm:4.1.0": - version: 4.1.0 - resolution: "log-symbols@npm:4.1.0" - dependencies: - chalk: ^4.1.0 - is-unicode-supported: ^0.1.0 - checksum: fce1497b3135a0198803f9f07464165e9eb83ed02ceb2273930a6f8a508951178d8cf4f0378e9d28300a2ed2bc49050995d2bd5f53ab716bb15ac84d58c6ef74 - languageName: node - linkType: hard - -"loupe@npm:^2.3.1": - version: 2.3.6 - resolution: "loupe@npm:2.3.6" - dependencies: - get-func-name: ^2.0.0 - checksum: cc83f1b124a1df7384601d72d8d1f5fe95fd7a8185469fec48bb2e4027e45243949e7a013e8d91051a138451ff0552310c32aa9786e60b6a30d1e801bdc2163f - languageName: node - linkType: hard - -"lower-case@npm:^2.0.2": - version: 2.0.2 - resolution: "lower-case@npm:2.0.2" - dependencies: - tslib: ^2.0.3 - checksum: 83a0a5f159ad7614bee8bf976b96275f3954335a84fad2696927f609ddae902802c4f3312d86668722e668bef41400254807e1d3a7f2e8c3eede79691aa1f010 - languageName: node - linkType: hard - -"lru-cache@npm:^6.0.0": - version: 6.0.0 - resolution: "lru-cache@npm:6.0.0" - dependencies: - yallist: ^4.0.0 - checksum: f97f499f898f23e4585742138a22f22526254fdba6d75d41a1c2526b3b6cc5747ef59c5612ba7375f42aca4f8461950e925ba08c991ead0651b4918b7c978297 - languageName: node - linkType: hard - -"lru-cache@npm:^7.7.1": - version: 7.18.3 - resolution: "lru-cache@npm:7.18.3" - checksum: e550d772384709deea3f141af34b6d4fa392e2e418c1498c078de0ee63670f1f46f5eee746e8ef7e69e1c895af0d4224e62ee33e66a543a14763b0f2e74c1356 - languageName: node - linkType: hard - -"lru-cache@npm:^9.1.1 || ^10.0.0": - version: 10.0.0 - resolution: "lru-cache@npm:10.0.0" - checksum: 18f101675fe283bc09cda0ef1e3cc83781aeb8373b439f086f758d1d91b28730950db785999cd060d3c825a8571c03073e8c14512b6655af2188d623031baf50 - languageName: node - linkType: hard - -"make-error@npm:^1.1.1": - version: 1.3.6 - resolution: "make-error@npm:1.3.6" - checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 - languageName: node - linkType: hard - -"make-fetch-happen@npm:^11.0.3": - version: 11.1.1 - resolution: "make-fetch-happen@npm:11.1.1" - dependencies: - agentkeepalive: ^4.2.1 - cacache: ^17.0.0 - http-cache-semantics: ^4.1.1 - http-proxy-agent: ^5.0.0 - https-proxy-agent: ^5.0.0 - is-lambda: ^1.0.1 - lru-cache: ^7.7.1 - minipass: ^5.0.0 - minipass-fetch: ^3.0.0 - minipass-flush: ^1.0.5 - minipass-pipeline: ^1.2.4 - negotiator: ^0.6.3 - promise-retry: ^2.0.1 - socks-proxy-agent: ^7.0.0 - ssri: ^10.0.0 - checksum: 7268bf274a0f6dcf0343829489a4506603ff34bd0649c12058753900b0eb29191dce5dba12680719a5d0a983d3e57810f594a12f3c18494e93a1fbc6348a4540 - languageName: node - linkType: hard - -"minimatch@npm:4.2.1": - version: 4.2.1 - resolution: "minimatch@npm:4.2.1" - dependencies: - brace-expansion: ^1.1.7 - checksum: 2b1514e3d0f29a549912f0db7ae7b82c5cab4a8f2dd0369f1c6451a325b3f12b2cf473c95873b6157bb8df183d6cf6db82ff03614b6adaaf1d7e055beccdfd01 - languageName: node - linkType: hard - -"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1": - version: 3.1.2 - resolution: "minimatch@npm:3.1.2" - dependencies: - brace-expansion: ^1.1.7 - checksum: c154e566406683e7bcb746e000b84d74465b3a832c45d59912b9b55cd50dee66e5c4b1e5566dba26154040e51672f9aa450a9aef0c97cfc7336b78b7afb9540a - languageName: node - linkType: hard - -"minimatch@npm:^9.0.1": - version: 9.0.3 - resolution: "minimatch@npm:9.0.3" - dependencies: - brace-expansion: ^2.0.1 - checksum: 253487976bf485b612f16bf57463520a14f512662e592e95c571afdab1442a6a6864b6c88f248ce6fc4ff0b6de04ac7aa6c8bb51e868e99d1d65eb0658a708b5 - languageName: node - linkType: hard - -"minimist@npm:^1.2.0, minimist@npm:^1.2.6": - version: 1.2.8 - resolution: "minimist@npm:1.2.8" - checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0 - languageName: node - linkType: hard - -"minipass-collect@npm:^1.0.2": - version: 1.0.2 - resolution: "minipass-collect@npm:1.0.2" - dependencies: - minipass: ^3.0.0 - checksum: 14df761028f3e47293aee72888f2657695ec66bd7d09cae7ad558da30415fdc4752bbfee66287dcc6fd5e6a2fa3466d6c484dc1cbd986525d9393b9523d97f10 - languageName: node - linkType: hard - -"minipass-fetch@npm:^3.0.0": - version: 3.0.3 - resolution: "minipass-fetch@npm:3.0.3" - dependencies: - encoding: ^0.1.13 - minipass: ^5.0.0 - minipass-sized: ^1.0.3 - minizlib: ^2.1.2 - dependenciesMeta: - encoding: - optional: true - checksum: af5ab2552a16fcf505d35fd7ffb84b57f4a0eeb269e6e1d9a2a75824dda48b36e527083250b7cca4a4def21d9544e2ade441e4730e233c0bc2133f6abda31e18 - languageName: node - linkType: hard - -"minipass-flush@npm:^1.0.5": - version: 1.0.5 - resolution: "minipass-flush@npm:1.0.5" - dependencies: - minipass: ^3.0.0 - checksum: 56269a0b22bad756a08a94b1ffc36b7c9c5de0735a4dd1ab2b06c066d795cfd1f0ac44a0fcae13eece5589b908ecddc867f04c745c7009be0b566421ea0944cf - languageName: node - linkType: hard - -"minipass-pipeline@npm:^1.2.4": - version: 1.2.4 - resolution: "minipass-pipeline@npm:1.2.4" - dependencies: - minipass: ^3.0.0 - checksum: b14240dac0d29823c3d5911c286069e36d0b81173d7bdf07a7e4a91ecdef92cdff4baaf31ea3746f1c61e0957f652e641223970870e2353593f382112257971b - languageName: node - linkType: hard - -"minipass-sized@npm:^1.0.3": - version: 1.0.3 - resolution: "minipass-sized@npm:1.0.3" - dependencies: - minipass: ^3.0.0 - checksum: 79076749fcacf21b5d16dd596d32c3b6bf4d6e62abb43868fac21674078505c8b15eaca4e47ed844985a4514854f917d78f588fcd029693709417d8f98b2bd60 - languageName: node - linkType: hard - -"minipass@npm:^3.0.0": - version: 3.3.6 - resolution: "minipass@npm:3.3.6" - dependencies: - yallist: ^4.0.0 - checksum: a30d083c8054cee83cdcdc97f97e4641a3f58ae743970457b1489ce38ee1167b3aaf7d815cd39ec7a99b9c40397fd4f686e83750e73e652b21cb516f6d845e48 - languageName: node - linkType: hard - -"minipass@npm:^5.0.0": - version: 5.0.0 - resolution: "minipass@npm:5.0.0" - checksum: 425dab288738853fded43da3314a0b5c035844d6f3097a8e3b5b29b328da8f3c1af6fc70618b32c29ff906284cf6406b6841376f21caaadd0793c1d5a6a620ea - languageName: node - linkType: hard - -"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0": - version: 7.0.2 - resolution: "minipass@npm:7.0.2" - checksum: 46776de732eb7cef2c7404a15fb28c41f5c54a22be50d47b03c605bf21f5c18d61a173c0a20b49a97e7a65f78d887245066410642551e45fffe04e9ac9e325bc - languageName: node - linkType: hard - -"minizlib@npm:^2.1.1, minizlib@npm:^2.1.2": - version: 2.1.2 - resolution: "minizlib@npm:2.1.2" - dependencies: - minipass: ^3.0.0 - yallist: ^4.0.0 - checksum: f1fdeac0b07cf8f30fcf12f4b586795b97be856edea22b5e9072707be51fc95d41487faec3f265b42973a304fe3a64acd91a44a3826a963e37b37bafde0212c3 - languageName: node - linkType: hard - -"mkdirp@npm:^0.5.1": - version: 0.5.6 - resolution: "mkdirp@npm:0.5.6" - dependencies: - minimist: ^1.2.6 - bin: - mkdirp: bin/cmd.js - checksum: 0c91b721bb12c3f9af4b77ebf73604baf350e64d80df91754dc509491ae93bf238581e59c7188360cec7cb62fc4100959245a42cfe01834efedc5e9d068376c2 - languageName: node - linkType: hard - -"mkdirp@npm:^1.0.3": - version: 1.0.4 - resolution: "mkdirp@npm:1.0.4" - bin: - mkdirp: bin/cmd.js - checksum: a96865108c6c3b1b8e1d5e9f11843de1e077e57737602de1b82030815f311be11f96f09cce59bd5b903d0b29834733e5313f9301e3ed6d6f6fba2eae0df4298f - languageName: node - linkType: hard - -"mocha@npm:^9.0.3": - version: 9.2.2 - resolution: "mocha@npm:9.2.2" - dependencies: - "@ungap/promise-all-settled": 1.1.2 - ansi-colors: 4.1.1 - browser-stdout: 1.3.1 - chokidar: 3.5.3 - debug: 4.3.3 - diff: 5.0.0 - escape-string-regexp: 4.0.0 - find-up: 5.0.0 - glob: 7.2.0 - growl: 1.10.5 - he: 1.2.0 - js-yaml: 4.1.0 - log-symbols: 4.1.0 - minimatch: 4.2.1 - ms: 2.1.3 - nanoid: 3.3.1 - serialize-javascript: 6.0.0 - strip-json-comments: 3.1.1 - supports-color: 8.1.1 - which: 2.0.2 - workerpool: 6.2.0 - yargs: 16.2.0 - yargs-parser: 20.2.4 - yargs-unparser: 2.0.0 - bin: - _mocha: bin/_mocha - mocha: bin/mocha - checksum: 4d5ca4ce33fc66627e63acdf09a634e2358c9a00f61de7788b1091b6aad430da04f97f9ecb82d56dc034b623cb833b65576136fd010d77679c03fcea5bc1e12d - languageName: node - linkType: hard - -"ms@npm:2.1.2": - version: 2.1.2 - resolution: "ms@npm:2.1.2" - checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f - languageName: node - linkType: hard - -"ms@npm:2.1.3, ms@npm:^2.0.0": - version: 2.1.3 - resolution: "ms@npm:2.1.3" - checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d - languageName: node - linkType: hard - -"mvdan-sh@npm:^0.5.0": - version: 0.5.0 - resolution: "mvdan-sh@npm:0.5.0" - checksum: b662308861c8d77076513d7f154ec2e340b28f34bedcf413450381255408dd6749b92b51b56946945cf016887789decfe7e89f3b201a71e3d908f59bd9e77474 - languageName: node - linkType: hard - -"nanoid@npm:3.3.1": - version: 3.3.1 - resolution: "nanoid@npm:3.3.1" - bin: - nanoid: bin/nanoid.cjs - checksum: 4ef0969e1bbe866fc223eb32276cbccb0961900bfe79104fa5abe34361979dead8d0e061410a5c03bc3d47455685adf32c09d6f27790f4a6898fb51f7df7ec86 - languageName: node - linkType: hard - -"negotiator@npm:^0.6.3": - version: 0.6.3 - resolution: "negotiator@npm:0.6.3" - checksum: b8ffeb1e262eff7968fc90a2b6767b04cfd9842582a9d0ece0af7049537266e7b2506dfb1d107a32f06dd849ab2aea834d5830f7f4d0e5cb7d36e1ae55d021d9 - languageName: node - linkType: hard - -"no-case@npm:^3.0.4": - version: 3.0.4 - resolution: "no-case@npm:3.0.4" - dependencies: - lower-case: ^2.0.2 - tslib: ^2.0.3 - checksum: 0b2ebc113dfcf737d48dde49cfebf3ad2d82a8c3188e7100c6f375e30eafbef9e9124aadc3becef237b042fd5eb0aad2fd78669c20972d045bbe7fea8ba0be5c - languageName: node - linkType: hard - -"node-fetch@npm:^2.6.11, node-fetch@npm:^2.6.12": - version: 2.6.12 - resolution: "node-fetch@npm:2.6.12" - dependencies: - whatwg-url: ^5.0.0 - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - checksum: 3bc1655203d47ee8e313c0d96664b9673a3d4dd8002740318e9d27d14ef306693a4b2ef8d6525775056fd912a19e23f3ac0d7111ad8925877b7567b29a625592 - languageName: node - linkType: hard - -"node-gyp-build@npm:^4.3.0": - version: 4.6.0 - resolution: "node-gyp-build@npm:4.6.0" - bin: - node-gyp-build: bin.js - node-gyp-build-optional: optional.js - node-gyp-build-test: build-test.js - checksum: 25d78c5ef1f8c24291f4a370c47ba52fcea14f39272041a90a7894cd50d766f7c8cb8fb06c0f42bf6f69b204b49d9be3c8fc344aac09714d5bdb95965499eb15 - languageName: node - linkType: hard - -"node-gyp@npm:latest": - version: 9.4.0 - resolution: "node-gyp@npm:9.4.0" - dependencies: - env-paths: ^2.2.0 - exponential-backoff: ^3.1.1 - glob: ^7.1.4 - graceful-fs: ^4.2.6 - make-fetch-happen: ^11.0.3 - nopt: ^6.0.0 - npmlog: ^6.0.0 - rimraf: ^3.0.2 - semver: ^7.3.5 - tar: ^6.1.2 - which: ^2.0.2 - bin: - node-gyp: bin/node-gyp.js - checksum: 78b404e2e0639d64e145845f7f5a3cb20c0520cdaf6dda2f6e025e9b644077202ea7de1232396ba5bde3fee84cdc79604feebe6ba3ec84d464c85d407bb5da99 - languageName: node - linkType: hard - -"nopt@npm:^6.0.0": - version: 6.0.0 - resolution: "nopt@npm:6.0.0" - dependencies: - abbrev: ^1.0.0 - bin: - nopt: bin/nopt.js - checksum: 82149371f8be0c4b9ec2f863cc6509a7fd0fa729929c009f3a58e4eb0c9e4cae9920e8f1f8eb46e7d032fec8fb01bede7f0f41a67eb3553b7b8e14fa53de1dac - languageName: node - linkType: hard - -"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": - version: 3.0.0 - resolution: "normalize-path@npm:3.0.0" - checksum: 88eeb4da891e10b1318c4b2476b6e2ecbeb5ff97d946815ffea7794c31a89017c70d7f34b3c2ebf23ef4e9fc9fb99f7dffe36da22011b5b5c6ffa34f4873ec20 - languageName: node - linkType: hard - -"npmlog@npm:^6.0.0": - version: 6.0.2 - resolution: "npmlog@npm:6.0.2" - dependencies: - are-we-there-yet: ^3.0.0 - console-control-strings: ^1.1.0 - gauge: ^4.0.3 - set-blocking: ^2.0.0 - checksum: ae238cd264a1c3f22091cdd9e2b106f684297d3c184f1146984ecbe18aaa86343953f26b9520dedd1b1372bc0316905b736c1932d778dbeb1fcf5a1001390e2a - languageName: node - linkType: hard - -"once@npm:^1.3.0": - version: 1.4.0 - resolution: "once@npm:1.4.0" - dependencies: - wrappy: 1 - checksum: cd0a88501333edd640d95f0d2700fbde6bff20b3d4d9bdc521bdd31af0656b5706570d6c6afe532045a20bb8dc0849f8332d6f2a416e0ba6d3d3b98806c7db68 - languageName: node - linkType: hard - -"p-limit@npm:^3.0.2": - version: 3.1.0 - resolution: "p-limit@npm:3.1.0" - dependencies: - yocto-queue: ^0.1.0 - checksum: 7c3690c4dbf62ef625671e20b7bdf1cbc9534e83352a2780f165b0d3ceba21907e77ad63401708145ca4e25bfc51636588d89a8c0aeb715e6c37d1c066430360 - languageName: node - linkType: hard - -"p-locate@npm:^5.0.0": - version: 5.0.0 - resolution: "p-locate@npm:5.0.0" - dependencies: - p-limit: ^3.0.2 - checksum: 1623088f36cf1cbca58e9b61c4e62bf0c60a07af5ae1ca99a720837356b5b6c5ba3eb1b2127e47a06865fee59dd0453cad7cc844cda9d5a62ac1a5a51b7c86d3 - languageName: node - linkType: hard - -"p-map@npm:^4.0.0": - version: 4.0.0 - resolution: "p-map@npm:4.0.0" - dependencies: - aggregate-error: ^3.0.0 - checksum: cb0ab21ec0f32ddffd31dfc250e3afa61e103ef43d957cc45497afe37513634589316de4eb88abdfd969fe6410c22c0b93ab24328833b8eb1ccc087fc0442a1c - languageName: node - linkType: hard - -"pako@npm:^2.0.3": - version: 2.1.0 - resolution: "pako@npm:2.1.0" - checksum: 71666548644c9a4d056bcaba849ca6fd7242c6cf1af0646d3346f3079a1c7f4a66ffec6f7369ee0dc88f61926c10d6ab05da3e1fca44b83551839e89edd75a3e - languageName: node - linkType: hard - -"path-exists@npm:^4.0.0": - version: 4.0.0 - resolution: "path-exists@npm:4.0.0" - checksum: 505807199dfb7c50737b057dd8d351b82c033029ab94cb10a657609e00c1bc53b951cfdbccab8de04c5584d5eff31128ce6afd3db79281874a5ef2adbba55ed1 - languageName: node - linkType: hard - -"path-is-absolute@npm:^1.0.0": - version: 1.0.1 - resolution: "path-is-absolute@npm:1.0.1" - checksum: 060840f92cf8effa293bcc1bea81281bd7d363731d214cbe5c227df207c34cd727430f70c6037b5159c8a870b9157cba65e775446b0ab06fd5ecc7e54615a3b8 - languageName: node - linkType: hard - -"path-key@npm:^3.1.0": - version: 3.1.1 - resolution: "path-key@npm:3.1.1" - checksum: 55cd7a9dd4b343412a8386a743f9c746ef196e57c823d90ca3ab917f90ab9f13dd0ded27252ba49dbdfcab2b091d998bc446f6220cd3cea65db407502a740020 - languageName: node - linkType: hard - -"path-scurry@npm:^1.10.1": - version: 1.10.1 - resolution: "path-scurry@npm:1.10.1" - dependencies: - lru-cache: ^9.1.1 || ^10.0.0 - minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 - checksum: e2557cff3a8fb8bc07afdd6ab163a92587884f9969b05bbbaf6fe7379348bfb09af9ed292af12ed32398b15fb443e81692047b786d1eeb6d898a51eb17ed7d90 - languageName: node - linkType: hard - -"pathval@npm:^1.1.1": - version: 1.1.1 - resolution: "pathval@npm:1.1.1" - checksum: 090e3147716647fb7fb5b4b8c8e5b55e5d0a6086d085b6cd23f3d3c01fcf0ff56fd3cc22f2f4a033bd2e46ed55d61ed8379e123b42afe7d531a2a5fc8bb556d6 - languageName: node - linkType: hard - -"picomatch@npm:^2.0.4, picomatch@npm:^2.2.1": - version: 2.3.1 - resolution: "picomatch@npm:2.3.1" - checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf - languageName: node - linkType: hard - -"prettier-plugin-sh@npm:^0.7.1": - version: 0.7.1 - resolution: "prettier-plugin-sh@npm:0.7.1" - dependencies: - mvdan-sh: ^0.5.0 - peerDependencies: - prettier: ^2.0.5 - checksum: 861d66010cef9d354e96b1d980328dbf538f26b5c888697c2f2982e9d5b99db8df00c787293d9017b483acdcf6b226e9c86ea17b612d1c1c995a85255cc3a480 - languageName: node - linkType: hard - -"prettier-plugin-solidity@npm:^1.0.0-beta.14": - version: 1.0.0-beta.15 - resolution: "prettier-plugin-solidity@npm:1.0.0-beta.15" - dependencies: - "@solidity-parser/parser": ^0.13.2 - emoji-regex: ^9.2.2 - escape-string-regexp: ^4.0.0 - semver: ^7.3.5 - solidity-comments-extractor: ^0.0.7 - string-width: ^4.2.2 - peerDependencies: - prettier: ^2.3.0 - checksum: f2f7c78d871d3e15a9031279f1862c0856b92b04a1441b90b982d68c433f68782fd4d92a74fe9fccc611cadfb7e6030e1716afb7fb2f57309811fb09c6ce790f - languageName: node - linkType: hard - -"prettier@npm:^2.3.2": - version: 2.3.2 - resolution: "prettier@npm:2.3.2" - bin: - prettier: bin-prettier.js - checksum: 17ce5784ac67621c292df58e2da60b2ee150c2d6aebea22a6ad9e52fcd6a5e66c349d0a8436ea3bd8ff9d778920a5f68000d7625b74f43558718a49755aa5259 - languageName: node - linkType: hard - -"prettier@npm:^2.6.2": - version: 2.8.8 - resolution: "prettier@npm:2.8.8" - bin: - prettier: bin-prettier.js - checksum: b49e409431bf129dd89238d64299ba80717b57ff5a6d1c1a8b1a28b590d998a34e083fa13573bc732bb8d2305becb4c9a4407f8486c81fa7d55100eb08263cf8 - languageName: node - linkType: hard - -"promise-retry@npm:^2.0.1": - version: 2.0.1 - resolution: "promise-retry@npm:2.0.1" - dependencies: - err-code: ^2.0.2 - retry: ^0.12.0 - checksum: f96a3f6d90b92b568a26f71e966cbbc0f63ab85ea6ff6c81284dc869b41510e6cdef99b6b65f9030f0db422bf7c96652a3fff9f2e8fb4a0f069d8f4430359429 - languageName: node - linkType: hard - -"randombytes@npm:^2.1.0": - version: 2.1.0 - resolution: "randombytes@npm:2.1.0" - dependencies: - safe-buffer: ^5.1.0 - checksum: d779499376bd4cbb435ef3ab9a957006c8682f343f14089ed5f27764e4645114196e75b7f6abf1cbd84fd247c0cb0651698444df8c9bf30e62120fbbc52269d6 - languageName: node - linkType: hard - -"readable-stream@npm:^3.6.0": - version: 3.6.2 - resolution: "readable-stream@npm:3.6.2" - dependencies: - inherits: ^2.0.3 - string_decoder: ^1.1.1 - util-deprecate: ^1.0.1 - checksum: bdcbe6c22e846b6af075e32cf8f4751c2576238c5043169a1c221c92ee2878458a816a4ea33f4c67623c0b6827c8a400409bfb3cf0bf3381392d0b1dfb52ac8d - languageName: node - linkType: hard - -"readdirp@npm:~3.6.0": - version: 3.6.0 - resolution: "readdirp@npm:3.6.0" - dependencies: - picomatch: ^2.2.1 - checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 - languageName: node - linkType: hard - -"regenerator-runtime@npm:^0.13.11": - version: 0.13.11 - resolution: "regenerator-runtime@npm:0.13.11" - checksum: 27481628d22a1c4e3ff551096a683b424242a216fee44685467307f14d58020af1e19660bf2e26064de946bad7eff28950eae9f8209d55723e2d9351e632bbb4 - languageName: node - linkType: hard - -"require-directory@npm:^2.1.1": - version: 2.1.1 - resolution: "require-directory@npm:2.1.1" - checksum: fb47e70bf0001fdeabdc0429d431863e9475e7e43ea5f94ad86503d918423c1543361cc5166d713eaa7029dd7a3d34775af04764bebff99ef413111a5af18c80 - languageName: node - linkType: hard - -"retry@npm:^0.12.0": - version: 0.12.0 - resolution: "retry@npm:0.12.0" - checksum: 623bd7d2e5119467ba66202d733ec3c2e2e26568074923bc0585b6b99db14f357e79bdedb63cab56cec47491c4a0da7e6021a7465ca6dc4f481d3898fdd3158c - languageName: node - linkType: hard - -"rimraf@npm:^3.0.2": - version: 3.0.2 - resolution: "rimraf@npm:3.0.2" - dependencies: - glob: ^7.1.3 - bin: - rimraf: bin.js - checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0 - languageName: node - linkType: hard - -"root-workspace-0b6124@workspace:.": - version: 0.0.0-use.local - resolution: "root-workspace-0b6124@workspace:." - dependencies: - "@keep-network/prettier-config-keep": "github:keep-network/prettier-config-keep" - prettier: ^2.3.2 - prettier-plugin-sh: ^0.7.1 - prettier-plugin-solidity: ^1.0.0-beta.14 - languageName: unknown - linkType: soft - -"rpc-websockets@npm:^7.5.1": - version: 7.5.1 - resolution: "rpc-websockets@npm:7.5.1" - dependencies: - "@babel/runtime": ^7.17.2 - bufferutil: ^4.0.1 - eventemitter3: ^4.0.7 - utf-8-validate: ^5.0.2 - uuid: ^8.3.2 - ws: ^8.5.0 - dependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 9dda8c63a1d3e85e11597e1c364835ec6aa9a8de1b5cfb1629d0eafc3ae04509011d485025ed4f717c0b1dd048e2aafdd75080e866540b93e55fd8a2cd91bcfe - languageName: node - linkType: hard - -"safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:~5.2.0": - version: 5.2.1 - resolution: "safe-buffer@npm:5.2.1" - checksum: b99c4b41fdd67a6aaf280fcd05e9ffb0813654894223afb78a31f14a19ad220bba8aba1cb14eddce1fcfb037155fe6de4e861784eb434f7d11ed58d1e70dd491 - languageName: node - linkType: hard - -"safer-buffer@npm:>= 2.1.2 < 3.0.0": - version: 2.1.2 - resolution: "safer-buffer@npm:2.1.2" - checksum: cab8f25ae6f1434abee8d80023d7e72b598cf1327164ddab31003c51215526801e40b66c5e65d658a0af1e9d6478cadcb4c745f4bd6751f97d8644786c0978b0 - languageName: node - linkType: hard - -"semver@npm:^7.3.5": - version: 7.3.5 - resolution: "semver@npm:7.3.5" - dependencies: - lru-cache: ^6.0.0 - bin: - semver: bin/semver.js - checksum: 5eafe6102bea2a7439897c1856362e31cc348ccf96efd455c8b5bc2c61e6f7e7b8250dc26b8828c1d76a56f818a7ee907a36ae9fb37a599d3d24609207001d60 - languageName: node - linkType: hard - -"serialize-javascript@npm:6.0.0": - version: 6.0.0 - resolution: "serialize-javascript@npm:6.0.0" - dependencies: - randombytes: ^2.1.0 - checksum: 56f90b562a1bdc92e55afb3e657c6397c01a902c588c0fe3d4c490efdcc97dcd2a3074ba12df9e94630f33a5ce5b76a74784a7041294628a6f4306e0ec84bf93 - languageName: node - linkType: hard - -"set-blocking@npm:^2.0.0": - version: 2.0.0 - resolution: "set-blocking@npm:2.0.0" - checksum: 6e65a05f7cf7ebdf8b7c75b101e18c0b7e3dff4940d480efed8aad3a36a4005140b660fa1d804cb8bce911cac290441dc728084a30504d3516ac2ff7ad607b02 - languageName: node - linkType: hard - -"shebang-command@npm:^2.0.0": - version: 2.0.0 - resolution: "shebang-command@npm:2.0.0" - dependencies: - shebang-regex: ^3.0.0 - checksum: 6b52fe87271c12968f6a054e60f6bde5f0f3d2db483a1e5c3e12d657c488a15474121a1d55cd958f6df026a54374ec38a4a963988c213b7570e1d51575cea7fa - languageName: node - linkType: hard - -"shebang-regex@npm:^3.0.0": - version: 3.0.0 - resolution: "shebang-regex@npm:3.0.0" - checksum: 1a2bcae50de99034fcd92ad4212d8e01eedf52c7ec7830eedcf886622804fe36884278f2be8be0ea5fde3fd1c23911643a4e0f726c8685b61871c8908af01222 - languageName: node - linkType: hard - -"signal-exit@npm:^3.0.7": - version: 3.0.7 - resolution: "signal-exit@npm:3.0.7" - checksum: a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 - languageName: node - linkType: hard - -"signal-exit@npm:^4.0.1": - version: 4.0.2 - resolution: "signal-exit@npm:4.0.2" - checksum: 41f5928431cc6e91087bf0343db786a6313dd7c6fd7e551dbc141c95bb5fb26663444fd9df8ea47c5d7fc202f60aa7468c3162a9365cbb0615fc5e1b1328fe31 - languageName: node - linkType: hard - -"smart-buffer@npm:^4.2.0": - version: 4.2.0 - resolution: "smart-buffer@npm:4.2.0" - checksum: b5167a7142c1da704c0e3af85c402002b597081dd9575031a90b4f229ca5678e9a36e8a374f1814c8156a725d17008ae3bde63b92f9cfd132526379e580bec8b - languageName: node - linkType: hard - -"snake-case@npm:^3.0.4": - version: 3.0.4 - resolution: "snake-case@npm:3.0.4" - dependencies: - dot-case: ^3.0.4 - tslib: ^2.0.3 - checksum: 0a7a79900bbb36f8aaa922cf111702a3647ac6165736d5dc96d3ef367efc50465cac70c53cd172c382b022dac72ec91710608e5393de71f76d7142e6fd80e8a3 - languageName: node - linkType: hard - -"socks-proxy-agent@npm:^7.0.0": - version: 7.0.0 - resolution: "socks-proxy-agent@npm:7.0.0" - dependencies: - agent-base: ^6.0.2 - debug: ^4.3.3 - socks: ^2.6.2 - checksum: 720554370154cbc979e2e9ce6a6ec6ced205d02757d8f5d93fe95adae454fc187a5cbfc6b022afab850a5ce9b4c7d73e0f98e381879cf45f66317a4895953846 - languageName: node - linkType: hard - -"socks@npm:^2.6.2": - version: 2.7.1 - resolution: "socks@npm:2.7.1" - dependencies: - ip: ^2.0.0 - smart-buffer: ^4.2.0 - checksum: 259d9e3e8e1c9809a7f5c32238c3d4d2a36b39b83851d0f573bfde5f21c4b1288417ce1af06af1452569cd1eb0841169afd4998f0e04ba04656f6b7f0e46d748 - languageName: node - linkType: hard - -"solana-d8f61a@workspace:cross-chain/solana": - version: 0.0.0-use.local - resolution: "solana-d8f61a@workspace:cross-chain/solana" - dependencies: - "@coral-xyz/anchor": ^0.28.0 - "@solana/spl-token": ^0.3.8 - "@solana/web3.js": ^1.77.3 - "@types/bn.js": ^5.1.0 - "@types/chai": ^4.3.0 - "@types/mocha": ^9.0.0 - chai: ^4.3.4 - mocha: ^9.0.3 - prettier: ^2.6.2 - ts-mocha: ^10.0.0 - typescript: ^4.3.5 - languageName: unknown - linkType: soft - -"solidity-comments-extractor@npm:^0.0.7": - version: 0.0.7 - resolution: "solidity-comments-extractor@npm:0.0.7" - checksum: a5cedf2310709969bc1783a6c336171478536f2f0ea96ad88437e0ef1e8844c0b37dd75591b0a824ec9c30640ea7e31b5f03128e871e6235bef3426617ce96c4 - languageName: node - linkType: hard - -"source-map-support@npm:^0.5.6": - version: 0.5.21 - resolution: "source-map-support@npm:0.5.21" - dependencies: - buffer-from: ^1.0.0 - source-map: ^0.6.0 - checksum: 43e98d700d79af1d36f859bdb7318e601dfc918c7ba2e98456118ebc4c4872b327773e5a1df09b0524e9e5063bb18f0934538eace60cca2710d1fa687645d137 - languageName: node - linkType: hard - -"source-map@npm:^0.6.0": - version: 0.6.1 - resolution: "source-map@npm:0.6.1" - checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2 - languageName: node - linkType: hard - -"ssri@npm:^10.0.0": - version: 10.0.4 - resolution: "ssri@npm:10.0.4" - dependencies: - minipass: ^5.0.0 - checksum: fb14da9f8a72b04eab163eb13a9dda11d5962cd2317f85457c4e0b575e9a6e0e3a6a87b5bf122c75cb36565830cd5f263fb457571bf6f1587eb5f95d095d6165 - languageName: node - linkType: hard - -"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": - version: 4.2.3 - resolution: "string-width@npm:4.2.3" - dependencies: - emoji-regex: ^8.0.0 - is-fullwidth-code-point: ^3.0.0 - strip-ansi: ^6.0.1 - checksum: e52c10dc3fbfcd6c3a15f159f54a90024241d0f149cf8aed2982a2d801d2e64df0bf1dc351cf8e95c3319323f9f220c16e740b06faecd53e2462df1d2b5443fb - languageName: node - linkType: hard - -"string-width@npm:^4.2.2": - version: 4.2.2 - resolution: "string-width@npm:4.2.2" - dependencies: - emoji-regex: ^8.0.0 - is-fullwidth-code-point: ^3.0.0 - strip-ansi: ^6.0.0 - checksum: 343e089b0e66e0f72aab4ad1d9b6f2c9cc5255844b0c83fd9b53f2a3b3fd0421bdd6cb05be96a73117eb012db0887a6c1d64ca95aaa50c518e48980483fea0ab - languageName: node - linkType: hard - -"string-width@npm:^5.0.1, string-width@npm:^5.1.2": - version: 5.1.2 - resolution: "string-width@npm:5.1.2" - dependencies: - eastasianwidth: ^0.2.0 - emoji-regex: ^9.2.2 - strip-ansi: ^7.0.1 - checksum: 7369deaa29f21dda9a438686154b62c2c5f661f8dda60449088f9f980196f7908fc39fdd1803e3e01541970287cf5deae336798337e9319a7055af89dafa7193 - languageName: node - linkType: hard - -"string_decoder@npm:^1.1.1": - version: 1.3.0 - resolution: "string_decoder@npm:1.3.0" - dependencies: - safe-buffer: ~5.2.0 - checksum: 8417646695a66e73aefc4420eb3b84cc9ffd89572861fe004e6aeb13c7bc00e2f616247505d2dbbef24247c372f70268f594af7126f43548565c68c117bdeb56 - languageName: node - linkType: hard - -"strip-ansi-cjs@npm:strip-ansi@^6.0.1, strip-ansi@npm:^6.0.1": - version: 6.0.1 - resolution: "strip-ansi@npm:6.0.1" - dependencies: - ansi-regex: ^5.0.1 - checksum: f3cd25890aef3ba6e1a74e20896c21a46f482e93df4a06567cebf2b57edabb15133f1f94e57434e0a958d61186087b1008e89c94875d019910a213181a14fc8c - languageName: node - linkType: hard - -"strip-ansi@npm:^6.0.0": - version: 6.0.0 - resolution: "strip-ansi@npm:6.0.0" - dependencies: - ansi-regex: ^5.0.0 - checksum: 04c3239ede44c4d195b0e66c0ad58b932f08bec7d05290416d361ff908ad282ecdaf5d9731e322c84f151d427436bde01f05b7422c3ec26dd927586736b0e5d0 - languageName: node - linkType: hard - -"strip-ansi@npm:^7.0.1": - version: 7.1.0 - resolution: "strip-ansi@npm:7.1.0" - dependencies: - ansi-regex: ^6.0.1 - checksum: 859c73fcf27869c22a4e4d8c6acfe690064659e84bef9458aa6d13719d09ca88dcfd40cbf31fd0be63518ea1a643fe070b4827d353e09533a5b0b9fd4553d64d - languageName: node - linkType: hard - -"strip-bom@npm:^3.0.0": - version: 3.0.0 - resolution: "strip-bom@npm:3.0.0" - checksum: 8d50ff27b7ebe5ecc78f1fe1e00fcdff7af014e73cf724b46fb81ef889eeb1015fc5184b64e81a2efe002180f3ba431bdd77e300da5c6685d702780fbf0c8d5b - languageName: node - linkType: hard - -"strip-json-comments@npm:3.1.1": - version: 3.1.1 - resolution: "strip-json-comments@npm:3.1.1" - checksum: 492f73e27268f9b1c122733f28ecb0e7e8d8a531a6662efbd08e22cccb3f9475e90a1b82cab06a392f6afae6d2de636f977e231296400d0ec5304ba70f166443 - languageName: node - linkType: hard - -"superstruct@npm:^0.14.2": - version: 0.14.2 - resolution: "superstruct@npm:0.14.2" - checksum: c5c4840f432da82125b923ec45faca5113217e83ae416e314d80eae012b8bb603d2e745025d173450758d116348820bc7028157f8c9a72b6beae879f94b837c0 - languageName: node - linkType: hard - -"superstruct@npm:^0.15.4": - version: 0.15.5 - resolution: "superstruct@npm:0.15.5" - checksum: 6d1f5249fee789424b7178fa0a1ffb2ace629c5480c39505885bd8c0046a4ff8b267569a3442fa53b8c560a7ba6599cf3f8af94225aebeb2cf6023f7dd911050 - languageName: node - linkType: hard - -"supports-color@npm:8.1.1": - version: 8.1.1 - resolution: "supports-color@npm:8.1.1" - dependencies: - has-flag: ^4.0.0 - checksum: c052193a7e43c6cdc741eb7f378df605636e01ad434badf7324f17fb60c69a880d8d8fcdcb562cf94c2350e57b937d7425ab5b8326c67c2adc48f7c87c1db406 - languageName: node - linkType: hard - -"supports-color@npm:^7.1.0": - version: 7.2.0 - resolution: "supports-color@npm:7.2.0" - dependencies: - has-flag: ^4.0.0 - checksum: 3dda818de06ebbe5b9653e07842d9479f3555ebc77e9a0280caf5a14fb877ffee9ed57007c3b78f5a6324b8dbeec648d9e97a24e2ed9fdb81ddc69ea07100f4a - languageName: node - linkType: hard - -"tar@npm:^6.1.11, tar@npm:^6.1.2": - version: 6.1.15 - resolution: "tar@npm:6.1.15" - dependencies: - chownr: ^2.0.0 - fs-minipass: ^2.0.0 - minipass: ^5.0.0 - minizlib: ^2.1.1 - mkdirp: ^1.0.3 - yallist: ^4.0.0 - checksum: f23832fceeba7578bf31907aac744ae21e74a66f4a17a9e94507acf460e48f6db598c7023882db33bab75b80e027c21f276d405e4a0322d58f51c7088d428268 - languageName: node - linkType: hard - -"text-encoding-utf-8@npm:^1.0.2": - version: 1.0.2 - resolution: "text-encoding-utf-8@npm:1.0.2" - checksum: ec4c15d50e738c5dba7327ad432ebf0725ec75d4d69c0bd55609254c5a3bc5341272d7003691084a0a73d60d981c8eb0e87603676fdb6f3fed60f4c9192309f9 - languageName: node - linkType: hard - -"through@npm:>=2.2.7 <3": - version: 2.3.8 - resolution: "through@npm:2.3.8" - checksum: a38c3e059853c494af95d50c072b83f8b676a9ba2818dcc5b108ef252230735c54e0185437618596c790bbba8fcdaef5b290405981ffa09dce67b1f1bf190cbd - languageName: node - linkType: hard - -"to-regex-range@npm:^5.0.1": - version: 5.0.1 - resolution: "to-regex-range@npm:5.0.1" - dependencies: - is-number: ^7.0.0 - checksum: f76fa01b3d5be85db6a2a143e24df9f60dd047d151062d0ba3df62953f2f697b16fe5dad9b0ac6191c7efc7b1d9dcaa4b768174b7b29da89d4428e64bc0a20ed - languageName: node - linkType: hard - -"toml@npm:^3.0.0": - version: 3.0.0 - resolution: "toml@npm:3.0.0" - checksum: 5d7f1d8413ad7780e9bdecce8ea4c3f5130dd53b0a4f2e90b93340979a137739879d7b9ce2ce05c938b8cc828897fe9e95085197342a1377dd8850bf5125f15f - languageName: node - linkType: hard - -"tr46@npm:~0.0.3": - version: 0.0.3 - resolution: "tr46@npm:0.0.3" - checksum: 726321c5eaf41b5002e17ffbd1fb7245999a073e8979085dacd47c4b4e8068ff5777142fc6726d6ca1fd2ff16921b48788b87225cbc57c72636f6efa8efbffe3 - languageName: node - linkType: hard - -"ts-mocha@npm:^10.0.0": - version: 10.0.0 - resolution: "ts-mocha@npm:10.0.0" - dependencies: - ts-node: 7.0.1 - tsconfig-paths: ^3.5.0 - peerDependencies: - mocha: ^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X - dependenciesMeta: - tsconfig-paths: - optional: true - bin: - ts-mocha: bin/ts-mocha - checksum: b11f2a8ceecf195b0db724da429159982fef12e4357088fe900289223587217e8c126ead7929679edd58bf19ad96c5da5911535d26f535386632e18fbff10c40 - languageName: node - linkType: hard - -"ts-node@npm:7.0.1": - version: 7.0.1 - resolution: "ts-node@npm:7.0.1" - dependencies: - arrify: ^1.0.0 - buffer-from: ^1.1.0 - diff: ^3.1.0 - make-error: ^1.1.1 - minimist: ^1.2.0 - mkdirp: ^0.5.1 - source-map-support: ^0.5.6 - yn: ^2.0.0 - bin: - ts-node: dist/bin.js - checksum: 07ed6ea1805361828737a767cfd6c57ea6e267ee8679282afb933610af02405e1a87c1f2aea1d38ed8e66b34fcbf6272b6021ab95d78849105d2e57fc283870b - languageName: node - linkType: hard - -"tsconfig-paths@npm:^3.5.0": - version: 3.14.2 - resolution: "tsconfig-paths@npm:3.14.2" - dependencies: - "@types/json5": ^0.0.29 - json5: ^1.0.2 - minimist: ^1.2.6 - strip-bom: ^3.0.0 - checksum: a6162eaa1aed680537f93621b82399c7856afd10ec299867b13a0675e981acac4e0ec00896860480efc59fc10fd0b16fdc928c0b885865b52be62cadac692447 - languageName: node - linkType: hard - -"tslib@npm:^2.0.3": - version: 2.6.0 - resolution: "tslib@npm:2.6.0" - checksum: c01066038f950016a18106ddeca4649b4d76caa76ec5a31e2a26e10586a59fceb4ee45e96719bf6c715648e7c14085a81fee5c62f7e9ebee68e77a5396e5538f - languageName: node - linkType: hard - -"type-detect@npm:^4.0.0, type-detect@npm:^4.0.5": - version: 4.0.8 - resolution: "type-detect@npm:4.0.8" - checksum: 62b5628bff67c0eb0b66afa371bd73e230399a8d2ad30d852716efcc4656a7516904570cd8631a49a3ce57c10225adf5d0cbdcb47f6b0255fe6557c453925a15 - languageName: node - linkType: hard - -"typescript@npm:^4.3.5": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db - languageName: node - linkType: hard - -"typescript@patch:typescript@^4.3.5#~builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=289587" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 1f8f3b6aaea19f0f67cba79057674ba580438a7db55057eb89cc06950483c5d632115c14077f6663ea76fd09fce3c190e6414bb98582ec80aa5a4eaf345d5b68 - languageName: node - linkType: hard - -"unique-filename@npm:^3.0.0": - version: 3.0.0 - resolution: "unique-filename@npm:3.0.0" - dependencies: - unique-slug: ^4.0.0 - checksum: 8e2f59b356cb2e54aab14ff98a51ac6c45781d15ceaab6d4f1c2228b780193dc70fae4463ce9e1df4479cb9d3304d7c2043a3fb905bdeca71cc7e8ce27e063df - languageName: node - linkType: hard - -"unique-slug@npm:^4.0.0": - version: 4.0.0 - resolution: "unique-slug@npm:4.0.0" - dependencies: - imurmurhash: ^0.1.4 - checksum: 0884b58365af59f89739e6f71e3feacb5b1b41f2df2d842d0757933620e6de08eff347d27e9d499b43c40476cbaf7988638d3acb2ffbcb9d35fd035591adfd15 - languageName: node - linkType: hard - -"utf-8-validate@npm:^5.0.2": - version: 5.0.10 - resolution: "utf-8-validate@npm:5.0.10" - dependencies: - node-gyp: latest - node-gyp-build: ^4.3.0 - checksum: 5579350a023c66a2326752b6c8804cc7b39dcd251bb088241da38db994b8d78352e388dcc24ad398ab98385ba3c5ffcadb6b5b14b2637e43f767869055e46ba6 - languageName: node - linkType: hard - -"util-deprecate@npm:^1.0.1": - version: 1.0.2 - resolution: "util-deprecate@npm:1.0.2" - checksum: 474acf1146cb2701fe3b074892217553dfcf9a031280919ba1b8d651a068c9b15d863b7303cb15bd00a862b498e6cf4ad7b4a08fb134edd5a6f7641681cb54a2 - languageName: node - linkType: hard - -"uuid@npm:^8.3.2": - version: 8.3.2 - resolution: "uuid@npm:8.3.2" - bin: - uuid: dist/bin/uuid - checksum: 5575a8a75c13120e2f10e6ddc801b2c7ed7d8f3c8ac22c7ed0c7b2ba6383ec0abda88c905085d630e251719e0777045ae3236f04c812184b7c765f63a70e58df - languageName: node - linkType: hard - -"webidl-conversions@npm:^3.0.0": - version: 3.0.1 - resolution: "webidl-conversions@npm:3.0.1" - checksum: c92a0a6ab95314bde9c32e1d0a6dfac83b578f8fa5f21e675bc2706ed6981bc26b7eb7e6a1fab158e5ce4adf9caa4a0aee49a52505d4d13c7be545f15021b17c - languageName: node - linkType: hard - -"whatwg-url@npm:^5.0.0": - version: 5.0.0 - resolution: "whatwg-url@npm:5.0.0" - dependencies: - tr46: ~0.0.3 - webidl-conversions: ^3.0.0 - checksum: b8daed4ad3356cc4899048a15b2c143a9aed0dfae1f611ebd55073310c7b910f522ad75d727346ad64203d7e6c79ef25eafd465f4d12775ca44b90fa82ed9e2c - languageName: node - linkType: hard - -"which@npm:2.0.2, which@npm:^2.0.1, which@npm:^2.0.2": - version: 2.0.2 - resolution: "which@npm:2.0.2" - dependencies: - isexe: ^2.0.0 - bin: - node-which: ./bin/node-which - checksum: 1a5c563d3c1b52d5f893c8b61afe11abc3bab4afac492e8da5bde69d550de701cf9806235f20a47b5c8fa8a1d6a9135841de2596535e998027a54589000e66d1 - languageName: node - linkType: hard - -"wide-align@npm:^1.1.5": - version: 1.1.5 - resolution: "wide-align@npm:1.1.5" - dependencies: - string-width: ^1.0.2 || 2 || 3 || 4 - checksum: d5fc37cd561f9daee3c80e03b92ed3e84d80dde3365a8767263d03dacfc8fa06b065ffe1df00d8c2a09f731482fcacae745abfbb478d4af36d0a891fad4834d3 - languageName: node - linkType: hard - -"workerpool@npm:6.2.0": - version: 6.2.0 - resolution: "workerpool@npm:6.2.0" - checksum: 3493b4f0ef979a23d2c1583d7ef85f62fc9463cc02f82829d3e7e663b517f8ae9707da0249b382e46ac58986deb0ca2232ee1081713741211bda9254b429c9bb - languageName: node - linkType: hard - -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0, wrap-ansi@npm:^7.0.0": - version: 7.0.0 - resolution: "wrap-ansi@npm:7.0.0" - dependencies: - ansi-styles: ^4.0.0 - string-width: ^4.1.0 - strip-ansi: ^6.0.0 - checksum: a790b846fd4505de962ba728a21aaeda189b8ee1c7568ca5e817d85930e06ef8d1689d49dbf0e881e8ef84436af3a88bc49115c2e2788d841ff1b8b5b51a608b - languageName: node - linkType: hard - -"wrap-ansi@npm:^8.1.0": - version: 8.1.0 - resolution: "wrap-ansi@npm:8.1.0" - dependencies: - ansi-styles: ^6.1.0 - string-width: ^5.0.1 - strip-ansi: ^7.0.1 - checksum: 371733296dc2d616900ce15a0049dca0ef67597d6394c57347ba334393599e800bab03c41d4d45221b6bc967b8c453ec3ae4749eff3894202d16800fdfe0e238 - languageName: node - linkType: hard - -"wrappy@npm:1": - version: 1.0.2 - resolution: "wrappy@npm:1.0.2" - checksum: 159da4805f7e84a3d003d8841557196034155008f817172d4e986bd591f74aa82aa7db55929a54222309e01079a65a92a9e6414da5a6aa4b01ee44a511ac3ee5 - languageName: node - linkType: hard - -"ws@npm:^7.4.5": - version: 7.5.9 - resolution: "ws@npm:7.5.9" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: c3c100a181b731f40b7f2fddf004aa023f79d64f489706a28bc23ff88e87f6a64b3c6651fbec3a84a53960b75159574d7a7385709847a62ddb7ad6af76f49138 - languageName: node - linkType: hard - -"ws@npm:^8.5.0": - version: 8.13.0 - resolution: "ws@npm:8.13.0" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 53e991bbf928faf5dc6efac9b8eb9ab6497c69feeb94f963d648b7a3530a720b19ec2e0ec037344257e05a4f35bd9ad04d9de6f289615ffb133282031b18c61c - languageName: node - linkType: hard - -"y18n@npm:^5.0.5": - version: 5.0.8 - resolution: "y18n@npm:5.0.8" - checksum: 54f0fb95621ee60898a38c572c515659e51cc9d9f787fb109cef6fde4befbe1c4602dc999d30110feee37456ad0f1660fa2edcfde6a9a740f86a290999550d30 - languageName: node - linkType: hard - -"yallist@npm:^4.0.0": - version: 4.0.0 - resolution: "yallist@npm:4.0.0" - checksum: 343617202af32df2a15a3be36a5a8c0c8545208f3d3dfbc6bb7c3e3b7e8c6f8e7485432e4f3b88da3031a6e20afa7c711eded32ddfb122896ac5d914e75848d5 - languageName: node - linkType: hard - -"yargs-parser@npm:20.2.4": - version: 20.2.4 - resolution: "yargs-parser@npm:20.2.4" - checksum: d251998a374b2743a20271c2fd752b9fbef24eb881d53a3b99a7caa5e8227fcafd9abf1f345ac5de46435821be25ec12189a11030c12ee6481fef6863ed8b924 - languageName: node - linkType: hard - -"yargs-parser@npm:^20.2.2": - version: 20.2.9 - resolution: "yargs-parser@npm:20.2.9" - checksum: 8bb69015f2b0ff9e17b2c8e6bfe224ab463dd00ca211eece72a4cd8a906224d2703fb8a326d36fdd0e68701e201b2a60ed7cf81ce0fd9b3799f9fe7745977ae3 - languageName: node - linkType: hard - -"yargs-unparser@npm:2.0.0": - version: 2.0.0 - resolution: "yargs-unparser@npm:2.0.0" - dependencies: - camelcase: ^6.0.0 - decamelize: ^4.0.0 - flat: ^5.0.2 - is-plain-obj: ^2.1.0 - checksum: 68f9a542c6927c3768c2f16c28f71b19008710abd6b8f8efbac6dcce26bbb68ab6503bed1d5994bdbc2df9a5c87c161110c1dfe04c6a3fe5c6ad1b0e15d9a8a3 - languageName: node - linkType: hard - -"yargs@npm:16.2.0": - version: 16.2.0 - resolution: "yargs@npm:16.2.0" - dependencies: - cliui: ^7.0.2 - escalade: ^3.1.1 - get-caller-file: ^2.0.5 - require-directory: ^2.1.1 - string-width: ^4.2.0 - y18n: ^5.0.5 - yargs-parser: ^20.2.2 - checksum: b14afbb51e3251a204d81937c86a7e9d4bdbf9a2bcee38226c900d00f522969ab675703bee2a6f99f8e20103f608382936034e64d921b74df82b63c07c5e8f59 - languageName: node - linkType: hard - -"yn@npm:^2.0.0": - version: 2.0.0 - resolution: "yn@npm:2.0.0" - checksum: 9d49527cb3e9a0948cc057223810bf30607bf04b9ff7666cc1681a6501d660b60d90000c16f9e29311b0f28d8a06222ada565ccdca5f1049cdfefb1908217572 - languageName: node - linkType: hard - -"yocto-queue@npm:^0.1.0": - version: 0.1.0 - resolution: "yocto-queue@npm:0.1.0" - checksum: f77b3d8d00310def622123df93d4ee654fc6a0096182af8bd60679ddcdfb3474c56c6c7190817c84a2785648cdee9d721c0154eb45698c62176c322fb46fc700 - languageName: node - linkType: hard From 336d2b31adbab526a0a2f87eb52069d10f30901b Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Wed, 19 Jul 2023 14:43:35 +0100 Subject: [PATCH 013/205] Restore old yarn.lock --- yarn.lock | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 yarn.lock diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 000000000..0c915b052 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,114 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@keep-network/prettier-config-keep@github:keep-network/prettier-config-keep": + version "0.0.1" + resolved "https://codeload.github.com/keep-network/prettier-config-keep/tar.gz/d6ec02e80dd76edfba073ca58ef99aee39002c2c" + +"@solidity-parser/parser@^0.13.2": + version "0.13.2" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.13.2.tgz#b6c71d8ca0b382d90a7bbed241f9bc110af65cbe" + integrity sha512-RwHnpRnfrnD2MSPveYoPh8nhofEvX7fgjHk1Oq+NNvCcLx4r1js91CO9o+F/F3fBzOCyvm8kKRTriFICX/odWw== + dependencies: + antlr4ts "^0.5.0-alpha.4" + +ansi-regex@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" + integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== + +antlr4ts@^0.5.0-alpha.4: + version "0.5.0-alpha.4" + resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a" + integrity sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + +escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +mvdan-sh@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/mvdan-sh/-/mvdan-sh-0.5.0.tgz#fa76f611a103595ad0f04f5d18e582892c46e87c" + integrity sha512-UWbdl4LHd2fUnaEcOUFVWRdWGLkNoV12cKVIPiirYd8qM5VkCoCTXErlDubevrkEG7kGohvjRxAlTQmOqG80tw== + +prettier-plugin-sh@^0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/prettier-plugin-sh/-/prettier-plugin-sh-0.7.1.tgz#a2d38de10e55919ea945a6e72c4815b16d6614ad" + integrity sha512-2MWRdGOSz0yf/z2kTKF1AqxDuH9MZD8faoDAz5ySGphxssi9oyM3Ys+jp7AfqsCXvGUDbRA4EJOlKS0yZKAW6w== + dependencies: + mvdan-sh "^0.5.0" + +prettier-plugin-solidity@^1.0.0-beta.14: + version "1.0.0-beta.15" + resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.15.tgz#ca7388e17e2620dc6251746e405150479abdc0a3" + integrity sha512-5+pM/Z1BgQN6xMCe/AfXmiVhoteaVgruVoGT8aa0zJMRiNOiK+SeaW2kOyzTI6sgg3QsUW58+ahf1hxlc/Adbw== + dependencies: + "@solidity-parser/parser" "^0.13.2" + emoji-regex "^9.2.2" + escape-string-regexp "^4.0.0" + semver "^7.3.5" + solidity-comments-extractor "^0.0.7" + string-width "^4.2.2" + +prettier@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d" + integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ== + +semver@^7.3.5: + version "7.3.5" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" + integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== + dependencies: + lru-cache "^6.0.0" + +solidity-comments-extractor@^0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19" + integrity sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw== + +string-width@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5" + integrity sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.0" + +strip-ansi@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.0.tgz#0b1571dd7669ccd4f3e06e14ef1eed26225ae532" + integrity sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w== + dependencies: + ansi-regex "^5.0.0" + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + \ No newline at end of file From e96d92605d6fcf092fc9a8ec576b6596d3e1cf80 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Wed, 19 Jul 2023 14:44:20 +0100 Subject: [PATCH 014/205] Fix file ending in yarn.lock --- yarn.lock | 1 - 1 file changed, 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 0c915b052..3f3c6dba3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -111,4 +111,3 @@ yallist@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - \ No newline at end of file From 3ec25f6ff33d10da59b8be2cc37db3c3b5374fbd Mon Sep 17 00:00:00 2001 From: Michalina Date: Wed, 19 Jul 2023 15:54:05 +0200 Subject: [PATCH 015/205] Add `pull_request` trigger We want the workflows building the cross chain projects to execute when changes are commited to the feature branches of PRs modifying files of those projects. We had all the config required to do that, except the most important part - the `pull_request` trigger, which we somehow missed. --- .github/workflows/cross-chain-arbitrum.yml | 1 + .github/workflows/cross-chain-optimism.yml | 1 + .github/workflows/cross-chain-polygon.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/cross-chain-arbitrum.yml b/.github/workflows/cross-chain-arbitrum.yml index 90b02a3d4..c6a836536 100644 --- a/.github/workflows/cross-chain-arbitrum.yml +++ b/.github/workflows/cross-chain-arbitrum.yml @@ -9,6 +9,7 @@ on: paths: - "cross-chain/arbitrum/**" - ".github/workflows/cross-chain-arbitrum.yml" + pull_request: jobs: contracts-detect-changes: diff --git a/.github/workflows/cross-chain-optimism.yml b/.github/workflows/cross-chain-optimism.yml index bb8508b1c..ae0e62147 100644 --- a/.github/workflows/cross-chain-optimism.yml +++ b/.github/workflows/cross-chain-optimism.yml @@ -9,6 +9,7 @@ on: paths: - "cross-chain/optimism/**" - ".github/workflows/cross-chain-optimism.yml" + pull_request: jobs: contracts-detect-changes: diff --git a/.github/workflows/cross-chain-polygon.yml b/.github/workflows/cross-chain-polygon.yml index 1ccc029e4..a250c5c54 100644 --- a/.github/workflows/cross-chain-polygon.yml +++ b/.github/workflows/cross-chain-polygon.yml @@ -9,6 +9,7 @@ on: paths: - "cross-chain/polygon/**" - ".github/workflows/cross-chain-polygon.yml" + pull_request: jobs: contracts-detect-changes: From ef3528bbb4ffeb37753df37d00e4f43faf7e1cbd Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 20 Jul 2023 10:40:01 +0200 Subject: [PATCH 016/205] TypeScript: Start version 1.4.0-dev We released version 1.3.0, so need to start a next one for development. --- typescript/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/package.json b/typescript/package.json index 94094e38c..b1be0c883 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@keep-network/tbtc-v2.ts", - "version": "1.3.0-dev", + "version": "1.4.0-dev", "license": "MIT", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", From 4d7074138476783a8e2954fefcbc48152d791c0b Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 24 Jul 2023 12:17:44 +0200 Subject: [PATCH 017/205] Used main UTXO data from previous test case --- system-tests/test/deposit-redemption.test.ts | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/system-tests/test/deposit-redemption.test.ts b/system-tests/test/deposit-redemption.test.ts index 2ccbc5735..f40c0c6d0 100644 --- a/system-tests/test/deposit-redemption.test.ts +++ b/system-tests/test/deposit-redemption.test.ts @@ -70,6 +70,7 @@ describe("System Test - Deposit and redemption", () => { let deposit: Deposit let depositUtxo: UnspentTransactionOutput let sweepUtxo: UnspentTransactionOutput + let redemptionUtxo: UnspentTransactionOutput | undefined before(async () => { systemTestsContext = await setupSystemTestsContext() @@ -328,7 +329,7 @@ describe("System Test - Deposit and redemption", () => { before( "make the redemption and submit redemption proof", async () => { - ;({ transactionHash: redemptionTxHash } = + ;({ transactionHash: redemptionTxHash, newMainUtxo: redemptionUtxo } = await submitRedemptionTransaction( electrumClient, maintainerBridgeHandle, @@ -459,7 +460,8 @@ describe("System Test - Deposit and redemption", () => { systemTestsContext.walletBitcoinKeyPair.wif, true, [depositUtxo], - [deposit] + [deposit], + redemptionUtxo // The UTXO from the previous test became the new main UTXO. )) console.log(` @@ -481,18 +483,16 @@ describe("System Test - Deposit and redemption", () => { sweepUtxo.transactionHash ) - // TODO: Consider fetching the current wallet main UTXO and passing it - // here. This will allow running this test scenario multiple - // times for the same wallet. + // If the redemption transaction from the previous test created a new + // main UTXO, use it. Otherwise call it with a zero-filled main UTXO. + const mainUtxo = redemptionUtxo ? redemptionUtxo : { + transactionHash: BitcoinTransactionHash.from(constants.HashZero), + outputIndex: 0, + value: BigNumber.from(0), + }; await SpvMaintainer.submitDepositSweepProof( sweepUtxo.transactionHash, - // This is the first sweep of the given wallet so there is no main UTXO. - { - // The function expects an unprefixed hash. - transactionHash: BitcoinTransactionHash.from(constants.HashZero), - outputIndex: 0, - value: BigNumber.from(0), - }, + mainUtxo, maintainerBridgeHandle, electrumClient, deposit.vault, From 69683044692d76ceb6aac25d8ec075d46e566afd Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 27 Jul 2023 18:50:53 +0200 Subject: [PATCH 018/205] Adding Base module for canonical TBTC Most of the files were copied from the Optimism module and adjusted for the Base chain, ie. ids and addresses. There is one change that had to be added which is a custom network for hardhat etherscan plugin. Base is not supported by this plugin by default and a custom network configuration had to be added. --- cross-chain/base/.eslintignore | 8 + cross-chain/base/.eslintrc | 18 + cross-chain/base/.gitignore | 15 + cross-chain/base/.mocharc.json | 3 + cross-chain/base/.prettierignore | 9 + cross-chain/base/.prettierrc.js | 11 + cross-chain/base/.solhint.json | 7 + cross-chain/base/.solhintignore | 2 + cross-chain/base/.tsconfig-eslint.json | 1 + cross-chain/base/README.adoc | 59 + .../base/contracts/test/BaseTBTCUpgraded.sol | 18 + .../test/BaseWormholeGatewayUpgraded.sol | 18 + .../00_resolve_arbitrum_wormhole_gateway.ts | 28 + .../deploy_l2/00_resolve_base_token_bridge.ts | 21 + .../00_resolve_base_wormhole_tbtc.ts | 21 + .../00_resolve_optimism_wormhole_gateway.ts | 28 + .../00_resolve_polygon_wormhole_gateway.ts | 28 + .../deploy_l2/01_deploy_base_tbtc_token.ts | 36 + .../02_deploy_base_wormhole_gateway.ts | 67 + ...11_authorize_wormhole_gateway_as_minter.ts | 22 + ...update_self_in_wormhole_gateway_mapping.ts | 27 + ...th_arbitrum_in_wormhole_gateway_mapping.ts | 41 + ...ith_polygon_in_wormhole_gateway_mapping.ts | 39 + ...th_optimism_in_wormhole_gateway_mapping.ts | 41 + .../21_transfer_base_tbtc_ownership.ts | 15 + ...ransfer_base_wormhole_gateway_ownership.ts | 19 + .../23_transfer_proxy_admin_ownership.ts | 27 + .../31_upgrade_base_wormhole_gateway.ts | 50 + .../base/ArbitrumWormholeGateway.json | 3 + .../base/external/base/BaseTokenBridge.json | 3 + .../base/external/base/BaseWormholeTBTC.json | 3 + .../base/OptimismWormholeGateway.json | 3 + .../external/base/PolygonWormholeGateway.json | 3 + .../baseGoerli/ArbitrumWormholeGateway.json | 3 + .../external/baseGoerli/BaseTokenBridge.json | 3 + .../external/baseGoerli/BaseWormholeTBTC.json | 3 + .../baseGoerli/OptimismWormholeGateway.json | 3 + .../baseGoerli/PolygonWormholeGateway.json | 3 + .../base/external/goerli/TokenBridge.json | 3 + .../base/external/mainnet/TokenBridge.json | 3 + cross-chain/base/hardhat.config.ts | 151 + cross-chain/base/package.json | 77 + cross-chain/base/slither.config.json | 5 + .../base/test/BaseTBTC.Upgrade.test.ts | 65 + .../test/BaseWormholeGateway.Upgrade.test.ts | 81 + cross-chain/base/tsconfig.export.json | 8 + cross-chain/base/tsconfig.json | 11 + cross-chain/base/yarn.lock | 12996 ++++++++++++++++ 48 files changed, 14109 insertions(+) create mode 100644 cross-chain/base/.eslintignore create mode 100644 cross-chain/base/.eslintrc create mode 100644 cross-chain/base/.gitignore create mode 100644 cross-chain/base/.mocharc.json create mode 100644 cross-chain/base/.prettierignore create mode 100644 cross-chain/base/.prettierrc.js create mode 100644 cross-chain/base/.solhint.json create mode 100644 cross-chain/base/.solhintignore create mode 120000 cross-chain/base/.tsconfig-eslint.json create mode 100644 cross-chain/base/README.adoc create mode 100644 cross-chain/base/contracts/test/BaseTBTCUpgraded.sol create mode 100644 cross-chain/base/contracts/test/BaseWormholeGatewayUpgraded.sol create mode 100644 cross-chain/base/deploy_l2/00_resolve_arbitrum_wormhole_gateway.ts create mode 100644 cross-chain/base/deploy_l2/00_resolve_base_token_bridge.ts create mode 100644 cross-chain/base/deploy_l2/00_resolve_base_wormhole_tbtc.ts create mode 100644 cross-chain/base/deploy_l2/00_resolve_optimism_wormhole_gateway.ts create mode 100644 cross-chain/base/deploy_l2/00_resolve_polygon_wormhole_gateway.ts create mode 100644 cross-chain/base/deploy_l2/01_deploy_base_tbtc_token.ts create mode 100644 cross-chain/base/deploy_l2/02_deploy_base_wormhole_gateway.ts create mode 100644 cross-chain/base/deploy_l2/11_authorize_wormhole_gateway_as_minter.ts create mode 100644 cross-chain/base/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/base/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/base/deploy_l2/14_update_with_polygon_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/base/deploy_l2/15_update_with_optimism_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/base/deploy_l2/21_transfer_base_tbtc_ownership.ts create mode 100644 cross-chain/base/deploy_l2/22_transfer_base_wormhole_gateway_ownership.ts create mode 100644 cross-chain/base/deploy_l2/23_transfer_proxy_admin_ownership.ts create mode 100644 cross-chain/base/deploy_l2/31_upgrade_base_wormhole_gateway.ts create mode 100644 cross-chain/base/external/base/ArbitrumWormholeGateway.json create mode 100644 cross-chain/base/external/base/BaseTokenBridge.json create mode 100644 cross-chain/base/external/base/BaseWormholeTBTC.json create mode 100644 cross-chain/base/external/base/OptimismWormholeGateway.json create mode 100644 cross-chain/base/external/base/PolygonWormholeGateway.json create mode 100644 cross-chain/base/external/baseGoerli/ArbitrumWormholeGateway.json create mode 100644 cross-chain/base/external/baseGoerli/BaseTokenBridge.json create mode 100644 cross-chain/base/external/baseGoerli/BaseWormholeTBTC.json create mode 100644 cross-chain/base/external/baseGoerli/OptimismWormholeGateway.json create mode 100644 cross-chain/base/external/baseGoerli/PolygonWormholeGateway.json create mode 100644 cross-chain/base/external/goerli/TokenBridge.json create mode 100644 cross-chain/base/external/mainnet/TokenBridge.json create mode 100644 cross-chain/base/hardhat.config.ts create mode 100644 cross-chain/base/package.json create mode 100644 cross-chain/base/slither.config.json create mode 100644 cross-chain/base/test/BaseTBTC.Upgrade.test.ts create mode 100644 cross-chain/base/test/BaseWormholeGateway.Upgrade.test.ts create mode 100644 cross-chain/base/tsconfig.export.json create mode 100644 cross-chain/base/tsconfig.json create mode 100644 cross-chain/base/yarn.lock diff --git a/cross-chain/base/.eslintignore b/cross-chain/base/.eslintignore new file mode 100644 index 000000000..6604016c5 --- /dev/null +++ b/cross-chain/base/.eslintignore @@ -0,0 +1,8 @@ +artifacts/ +build/ +cache/ +deployments/ +export/ +hardhat-dependency-compiler/ +typechain/ +export.json diff --git a/cross-chain/base/.eslintrc b/cross-chain/base/.eslintrc new file mode 100644 index 000000000..dd3a06164 --- /dev/null +++ b/cross-chain/base/.eslintrc @@ -0,0 +1,18 @@ +{ + "root": true, + "extends": ["@thesis-co"], + "parserOptions": { + "ecmaVersion": 2017, + "sourceType": "module" + }, + "env": { + "es6": true, + "mocha": true + }, + "rules": { + "new-cap": "off", + "import/no-extraneous-dependencies": "off", + "@typescript-eslint/no-use-before-define": "off", + "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }] + } +} diff --git a/cross-chain/base/.gitignore b/cross-chain/base/.gitignore new file mode 100644 index 000000000..e0803a259 --- /dev/null +++ b/cross-chain/base/.gitignore @@ -0,0 +1,15 @@ +# Hardhat +/artifacts/ +/build/ +/cache/ +/export/ +/external/npm +/typechain/ +/export.json +/deployments/* +!/deployments/mainnet/ +!/deployments/base/ +!/deployments/baseGoerli/ + +# OZ +/.openzeppelin/unknown-*.json diff --git a/cross-chain/base/.mocharc.json b/cross-chain/base/.mocharc.json new file mode 100644 index 000000000..bf101bf08 --- /dev/null +++ b/cross-chain/base/.mocharc.json @@ -0,0 +1,3 @@ +{ + "require": "ts-node/register/files" +} diff --git a/cross-chain/base/.prettierignore b/cross-chain/base/.prettierignore new file mode 100644 index 000000000..6d3a1b378 --- /dev/null +++ b/cross-chain/base/.prettierignore @@ -0,0 +1,9 @@ +.openzeppelin/ +artifacts/ +build/ +cache/ +deployments/ +export/ +hardhat-dependency-compiler/ +typechain/ +export.json diff --git a/cross-chain/base/.prettierrc.js b/cross-chain/base/.prettierrc.js new file mode 100644 index 000000000..49faa7bb9 --- /dev/null +++ b/cross-chain/base/.prettierrc.js @@ -0,0 +1,11 @@ +module.exports = { + ...require("@thesis-co/prettier-config"), + overrides: [ + { + files: "*.sol", + options: { + tabWidth: 4, + }, + }, + ], +} diff --git a/cross-chain/base/.solhint.json b/cross-chain/base/.solhint.json new file mode 100644 index 000000000..474c9ec09 --- /dev/null +++ b/cross-chain/base/.solhint.json @@ -0,0 +1,7 @@ +{ + "extends": "keep", + "plugins": [], + "rules": { + "func-visibility": ["error", { "ignoreConstructors": true }] + } +} diff --git a/cross-chain/base/.solhintignore b/cross-chain/base/.solhintignore new file mode 100644 index 000000000..ef4020b60 --- /dev/null +++ b/cross-chain/base/.solhintignore @@ -0,0 +1,2 @@ +hardhat-dependency-compiler/ +node_modules/ diff --git a/cross-chain/base/.tsconfig-eslint.json b/cross-chain/base/.tsconfig-eslint.json new file mode 120000 index 000000000..e14426659 --- /dev/null +++ b/cross-chain/base/.tsconfig-eslint.json @@ -0,0 +1 @@ +node_modules/@thesis-co/eslint-config/.tsconfig-eslint.json \ No newline at end of file diff --git a/cross-chain/base/README.adoc b/cross-chain/base/README.adoc new file mode 100644 index 000000000..bb33b7545 --- /dev/null +++ b/cross-chain/base/README.adoc @@ -0,0 +1,59 @@ +:toc: macro + += Threshold cross-chain - Base + +This package brings Bitcoin to Ethereum L2 Base. For more details please +see link:https://github.com/keep-network/tbtc-v2/blob/main/docs/rfc/rfc-8.adoc[RFC 8: Cross-chain Tokenized Threshold BTC] + +== How it works? + +``` ++----------------------------+ +-------------------------------------------------------------------+ +| Ethereum | | Base | +| | | | +| +----------------------+ | | +----------------------+ +---------------------+ +----------+ | +| | Wormhole TokenBridge |--|---------|--| Wormhole TokenBridge |--| BaseWormholeGateway |--| BaseTBTC | | +| +----------------------+ | | +----------------------+ +---------------------+ +----------+ | +| | | | ++----------------------------+ +-------------------------------------------------------------------+ +``` + +- `BaseTBTC` canonical tBTC token on Base with a minting authority +delegated to `BaseWormholeGateway`. +- `BaseWormholeGateway` is a smart contract wrapping and unwrapping +Wormhole-specific tBTC representation into the canonical `BaseTBTC` token. + +=== Updating Wormhole Gateway mapping + +The deployment scripts are responsible for managing updates of the tBTC gateway +addresses across various chains. These addresses are stored in the `external/` +directory for a specific network, such as `arbitrumGoerli/ArbitrumWormholeGateway.json.` +It is important to note that these addresses should remain constant for the +mainnet network. However, there may be instances where a new version of a +cross-chain module is deployed to the testing network, which would require a +manual update of the corresponding address. + +=== Deploy contracts + +To deploy all contracts on the given network, please run: +``` +yarn deploy --network +``` + +Supported networks: +- `hardhat` - for local development +- `baseGoerli` - L2 testing network +- `base` - L2 mainnet + +Currently, this module does not deploy any contracts on L1. All the existing +Wormhole contract addresses that are used in this module are stored under +`external/` dir. + +If contracts haven't been built yet or changes occurred, `deploy` task will build +the contracts before running the deployment script. This command produces +an `export.json` file containing contract deployment info. Note that for the +chains other than `hardhat` the following environment variables are needed: + +- `L2_CHAIN_API_URL` - URL to access blockchain services, e.g. `https://opt-goerli.g.alchemy.com/v2/` +- `L2_ACCOUNTS_PRIVATE_KEYS` - Private keys for the deployer and council `<0xOwnerPrivKey,0xCouncilPrivKey>` +- `BASESCAN_API_KEY` - Base Etherscan API key diff --git a/cross-chain/base/contracts/test/BaseTBTCUpgraded.sol b/cross-chain/base/contracts/test/BaseTBTCUpgraded.sol new file mode 100644 index 000000000..c22b62d3b --- /dev/null +++ b/cross-chain/base/contracts/test/BaseTBTCUpgraded.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0-only + +pragma solidity ^0.8.17; + +import "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol"; + +/// @notice Canonical tBTC Token on Base - upgraded version. +/// @dev This contract is intended solely for testing purposes. As it currently +/// stands in the implementation of L2TBTC.sol, there are no reserved +/// storage gap slots available, thereby limiting the upgradability to a +/// child contract only. +contract BaseTBTCUpgraded is L2TBTC { + string public newVar; + + function initializeV2(string memory _newVar) public { + newVar = _newVar; + } +} diff --git a/cross-chain/base/contracts/test/BaseWormholeGatewayUpgraded.sol b/cross-chain/base/contracts/test/BaseWormholeGatewayUpgraded.sol new file mode 100644 index 000000000..85048b349 --- /dev/null +++ b/cross-chain/base/contracts/test/BaseWormholeGatewayUpgraded.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0-only + +pragma solidity ^0.8.17; + +import "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol"; + +/// @notice Wormhole gateway for L2 Base - upgraded version. +/// @dev This contract is intended solely for testing purposes. As it currently +/// stands in the implementation of L2WormholeGateway.sol, there are no +/// reserved storage gap slots available, thereby limiting the upgradability +/// to a child contract only. +contract BaseWormholeGatewayUpgraded is L2WormholeGateway { + string public newVar; + + function initializeV2(string memory _newVar) public { + newVar = _newVar; + } +} diff --git a/cross-chain/base/deploy_l2/00_resolve_arbitrum_wormhole_gateway.ts b/cross-chain/base/deploy_l2/00_resolve_arbitrum_wormhole_gateway.ts new file mode 100644 index 000000000..b5bae6abc --- /dev/null +++ b/cross-chain/base/deploy_l2/00_resolve_arbitrum_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const ArbitrumWormholeGateway = await deployments.getOrNull( + "ArbitrumWormholeGateway" + ) + + if ( + ArbitrumWormholeGateway && + helpers.address.isValid(ArbitrumWormholeGateway.address) + ) { + log( + `using existing ArbitrumWormholeGateway at ${ArbitrumWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake ArbitrumWormholeGateway for hardhat network") + } else { + throw new Error("deployed ArbitrumWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["ArbitrumWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/00_resolve_base_token_bridge.ts b/cross-chain/base/deploy_l2/00_resolve_base_token_bridge.ts new file mode 100644 index 000000000..4bbc45080 --- /dev/null +++ b/cross-chain/base/deploy_l2/00_resolve_base_token_bridge.ts @@ -0,0 +1,21 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const BaseTokenBridge = await deployments.getOrNull("BaseTokenBridge") + + if (BaseTokenBridge && helpers.address.isValid(BaseTokenBridge.address)) { + log(`using existing Base TokenBridge at ${BaseTokenBridge.address}`) + } else if (hre.network.name === "hardhat") { + log("using fake Base TokenBridge for hardhat network") + } else { + throw new Error("deployed Base TokenBridge contract not found") + } +} + +export default func + +func.tags = ["BaseTokenBridge"] diff --git a/cross-chain/base/deploy_l2/00_resolve_base_wormhole_tbtc.ts b/cross-chain/base/deploy_l2/00_resolve_base_wormhole_tbtc.ts new file mode 100644 index 000000000..f0c240053 --- /dev/null +++ b/cross-chain/base/deploy_l2/00_resolve_base_wormhole_tbtc.ts @@ -0,0 +1,21 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const BaseWormholeTBTC = await deployments.getOrNull("BaseWormholeTBTC") + + if (BaseWormholeTBTC && helpers.address.isValid(BaseWormholeTBTC.address)) { + log(`using existing Base WormholeTBTC at ${BaseWormholeTBTC.address}`) + } else if (hre.network.name === "hardhat") { + log("using fake Base WormholeTBTC for hardhat network") + } else { + throw new Error("deployed Base WormholeTBTC contract not found") + } +} + +export default func + +func.tags = ["BaseWormholeTBTC"] diff --git a/cross-chain/base/deploy_l2/00_resolve_optimism_wormhole_gateway.ts b/cross-chain/base/deploy_l2/00_resolve_optimism_wormhole_gateway.ts new file mode 100644 index 000000000..5be6e22e5 --- /dev/null +++ b/cross-chain/base/deploy_l2/00_resolve_optimism_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const OptimismWormholeGateway = await deployments.getOrNull( + "OptimismWormholeGateway" + ) + + if ( + OptimismWormholeGateway && + helpers.address.isValid(OptimismWormholeGateway.address) + ) { + log( + `using existing OptimismWormholeGateway at ${OptimismWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake OptimismWormholeGateway for hardhat network") + } else { + throw new Error("deployed OptimismWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["OptimismWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/00_resolve_polygon_wormhole_gateway.ts b/cross-chain/base/deploy_l2/00_resolve_polygon_wormhole_gateway.ts new file mode 100644 index 000000000..8ab3573d8 --- /dev/null +++ b/cross-chain/base/deploy_l2/00_resolve_polygon_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const PolygonWormholeGateway = await deployments.getOrNull( + "PolygonWormholeGateway" + ) + + if ( + PolygonWormholeGateway && + helpers.address.isValid(PolygonWormholeGateway.address) + ) { + log( + `using existing PolygonWormholeGateway at ${PolygonWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake PolygonWormholeGateway for hardhat network") + } else { + throw new Error("deployed PolygonWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["PolygonWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/01_deploy_base_tbtc_token.ts b/cross-chain/base/deploy_l2/01_deploy_base_tbtc_token.ts new file mode 100644 index 000000000..e5e599758 --- /dev/null +++ b/cross-chain/base/deploy_l2/01_deploy_base_tbtc_token.ts @@ -0,0 +1,36 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { ethers, getNamedAccounts, helpers } = hre + const { deployer } = await getNamedAccounts() + + const [, proxyDeployment] = await helpers.upgrades.deployProxy("BaseTBTC", { + contractName: "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol:L2TBTC", + initializerArgs: ["Base tBTC v2", "tBTC"], + factoryOpts: { signer: await ethers.getSigner(deployer) }, + proxyOpts: { + kind: "transparent", + }, + }) + + // TODO: Investigate the possibility of adding Tenderly verification for + // L2 and upgradable proxy. + + // Contracts can be verified on L2 Base Etherscan in a similar way as we + // do it on L1 Etherscan + if (hre.network.tags.basescan) { + // We use `verify` instead of `verify:verify` as the `verify` task is defined + // in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation + // contract, the proxy itself and any proxy-related contracts, as well as + // link the proxy to the implementation contract’s ABI on (Ether)scan. + await hre.run("verify", { + address: proxyDeployment.address, + constructorArgsParams: proxyDeployment.args, + }) + } +} + +export default func + +func.tags = ["BaseTBTC"] diff --git a/cross-chain/base/deploy_l2/02_deploy_base_wormhole_gateway.ts b/cross-chain/base/deploy_l2/02_deploy_base_wormhole_gateway.ts new file mode 100644 index 000000000..2cb5e2548 --- /dev/null +++ b/cross-chain/base/deploy_l2/02_deploy_base_wormhole_gateway.ts @@ -0,0 +1,67 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { ethers, getNamedAccounts, helpers, deployments } = hre + const { log } = deployments + const { deployer } = await getNamedAccounts() + + // These are the fake random addresses for local development purposes only. + const fakeTokenBridge = "0x0af5DC16568EFF2d480a43A77E6C409e497FcFb9" + const fakeWormholeTBTC = "0xe1F0b28a3518cCeC430d0d86Ea1725e6256b0296" + + const baseTokenBridge = await deployments.getOrNull("BaseTokenBridge") + const baseWormholeTBTC = await deployments.getOrNull("BaseWormholeTBTC") + + const baseTBTC = await deployments.get("BaseTBTC") + + let baseTokenBridgeAddress = baseTokenBridge?.address + if (!baseTokenBridgeAddress && hre.network.name === "hardhat") { + baseTokenBridgeAddress = fakeTokenBridge + log(`fake Base TokenBridge address ${baseTokenBridgeAddress}`) + } + + let baseWormholeTBTCAddress = baseWormholeTBTC?.address + if (!baseWormholeTBTCAddress && hre.network.name === "hardhat") { + baseWormholeTBTCAddress = fakeWormholeTBTC + log(`fake Base WormholeTBTC address ${baseWormholeTBTCAddress}`) + } + + const [, proxyDeployment] = await helpers.upgrades.deployProxy( + "BaseWormholeGateway", + { + contractName: + "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:L2WormholeGateway", + initializerArgs: [ + baseTokenBridgeAddress, + baseWormholeTBTCAddress, + baseTBTC.address, + ], + factoryOpts: { signer: await ethers.getSigner(deployer) }, + proxyOpts: { + kind: "transparent", + }, + } + ) + + // TODO: Investigate the possibility of adding Tenderly verification for + // L2 and upgradable proxy. + + // Contracts can be verified on L2 Base Etherscan in a similar way as we + // do it on L1 Etherscan + if (hre.network.tags.basescan) { + // We use `verify` instead of `verify:verify` as the `verify` task is defined + // in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation + // contract, the proxy itself and any proxy-related contracts, as well as + // link the proxy to the implementation contract’s ABI on (Ether)scan. + await hre.run("verify", { + address: proxyDeployment.address, + constructorArgsParams: proxyDeployment.args, + }) + } +} + +export default func + +func.tags = ["BaseWormholeGateway"] +func.dependencies = ["BaseTokenBridge", "BaseWormholeTBTC"] diff --git a/cross-chain/base/deploy_l2/11_authorize_wormhole_gateway_as_minter.ts b/cross-chain/base/deploy_l2/11_authorize_wormhole_gateway_as_minter.ts new file mode 100644 index 000000000..49e75e422 --- /dev/null +++ b/cross-chain/base/deploy_l2/11_authorize_wormhole_gateway_as_minter.ts @@ -0,0 +1,22 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre + const { execute } = deployments + const { deployer } = await getNamedAccounts() + + const baseWormholeGateway = await deployments.get("BaseWormholeGateway") + + await execute( + "BaseTBTC", + { from: deployer, log: true, waitConfirmations: 1 }, + "addMinter", + baseWormholeGateway.address + ) +} + +export default func + +func.tags = ["AuthorizeWormholeGateway"] +func.dependencies = ["BaseTBTC", "BaseWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..dc13a978f --- /dev/null +++ b/cross-chain/base/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts @@ -0,0 +1,27 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, ethers } = hre + const { execute } = deployments + const { deployer } = await getNamedAccounts() + + // See https://docs.wormhole.com/wormhole/reference/environments/evm#base + // This ID is valid for both Base Goerli and Base Mainnet + const wormholeChainID = 30 + + const baseWormholeGateway = await deployments.get("BaseWormholeGateway") + + await execute( + "BaseWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + wormholeChainID, + ethers.utils.hexZeroPad(baseWormholeGateway.address, 32) + ) +} + +export default func + +func.tags = ["SetBaseGatewayAddress"] +func.dependencies = ["BaseWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..fd7788645 --- /dev/null +++ b/cross-chain/base/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts @@ -0,0 +1,41 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, ethers } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake ArbitrumWormholeGateway for local development purposes only. + const fakeArbitrumWormholeGateway = + "0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9" + + // See https://book.wormhole.com/reference/contracts.html + // This ID is valid for both Arbitrum Goerli and Mainnet + const arbitrumWormholeChainID = 23 + + const arbitrumWormholeGateway = await deployments.getOrNull( + "ArbitrumWormholeGateway" + ) + + let arbitrumWormholeGatewayAddress = arbitrumWormholeGateway?.address + if (!arbitrumWormholeGatewayAddress && hre.network.name === "hardhat") { + arbitrumWormholeGatewayAddress = fakeArbitrumWormholeGateway + log( + `fake ArbitrumWormholeGateway address ${arbitrumWormholeGatewayAddress}` + ) + } + + await execute( + "BaseWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + arbitrumWormholeChainID, + ethers.utils.hexZeroPad(arbitrumWormholeGatewayAddress, 32) + ) +} + +export default func + +func.tags = ["SetArbitrumGatewayAddress"] +func.dependencies = ["BaseWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/14_update_with_polygon_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/14_update_with_polygon_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..69f4659df --- /dev/null +++ b/cross-chain/base/deploy_l2/14_update_with_polygon_in_wormhole_gateway_mapping.ts @@ -0,0 +1,39 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, ethers } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake PolygonWormholeGateway for local development purposes only. + const fakePolygonWormholeGateway = + "0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9" + + // See https://book.wormhole.com/reference/contracts.html + // This ID is valid for both Polygon Testnet (Mumbai) and Mainnet + const polygonWormholeChainID = 5 + + const polygonWormholeGateway = await deployments.getOrNull( + "PolygonWormholeGateway" + ) + + let polygonWormholeGatewayAddress = polygonWormholeGateway?.address + if (!polygonWormholeGatewayAddress && hre.network.name === "hardhat") { + polygonWormholeGatewayAddress = fakePolygonWormholeGateway + log(`fake PolygonWormholeGateway address ${polygonWormholeGatewayAddress}`) + } + + await execute( + "BaseWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + polygonWormholeChainID, + ethers.utils.hexZeroPad(polygonWormholeGatewayAddress, 32) + ) +} + +export default func + +func.tags = ["SetPolygonGatewayAddress"] +func.dependencies = ["BaseWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/15_update_with_optimism_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/15_update_with_optimism_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..fb2b61d9f --- /dev/null +++ b/cross-chain/base/deploy_l2/15_update_with_optimism_in_wormhole_gateway_mapping.ts @@ -0,0 +1,41 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, ethers } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake OptimismWormholeGateway for local development purposes only. + const fakeOptimismWormholeGateway = + "0x2af5DC16568EFF2d480a43A77E6C409e497FcFb9" + + // See https://book.wormhole.com/reference/contracts.html + // This ID is valid for both Optimism Goerli and Mainnet + const optimismWormholeChainID = 24 + + const optimismWormholeGateway = await deployments.getOrNull( + "OptimismWormholeGateway" + ) + + let optimismWormholeGatewayAddress = optimismWormholeGateway?.address + if (!optimismWormholeGatewayAddress && hre.network.name === "hardhat") { + optimismWormholeGatewayAddress = fakeOptimismWormholeGateway + log( + `fake OptimismWormholeGateway address ${optimismWormholeGatewayAddress}` + ) + } + + await execute( + "BaseWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + optimismWormholeChainID, + ethers.utils.hexZeroPad(optimismWormholeGatewayAddress, 32) + ) +} + +export default func + +func.tags = ["SetOptimismGatewayAddress"] +func.dependencies = ["BaseWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/21_transfer_base_tbtc_ownership.ts b/cross-chain/base/deploy_l2/21_transfer_base_tbtc_ownership.ts new file mode 100644 index 000000000..20d3bfc34 --- /dev/null +++ b/cross-chain/base/deploy_l2/21_transfer_base_tbtc_ownership.ts @@ -0,0 +1,15 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { getNamedAccounts, helpers } = hre + const { deployer, governance } = await getNamedAccounts() + + await helpers.ownable.transferOwnership("BaseTBTC", governance, deployer) +} + +export default func + +func.tags = ["TransferBaseTBTCOwnership"] +func.dependencies = ["BaseTBTC", "AuthorizeWormholeGateway"] +func.runAtTheEnd = true diff --git a/cross-chain/base/deploy_l2/22_transfer_base_wormhole_gateway_ownership.ts b/cross-chain/base/deploy_l2/22_transfer_base_wormhole_gateway_ownership.ts new file mode 100644 index 000000000..7f08e8310 --- /dev/null +++ b/cross-chain/base/deploy_l2/22_transfer_base_wormhole_gateway_ownership.ts @@ -0,0 +1,19 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { getNamedAccounts, helpers } = hre + const { deployer, governance } = await getNamedAccounts() + + await helpers.ownable.transferOwnership( + "BaseWormholeGateway", + governance, + deployer + ) +} + +export default func + +func.tags = ["TransferBaseWormholeGatewayOwnership"] +func.dependencies = ["BaseWormholeGateway"] +func.runAtTheEnd = true diff --git a/cross-chain/base/deploy_l2/23_transfer_proxy_admin_ownership.ts b/cross-chain/base/deploy_l2/23_transfer_proxy_admin_ownership.ts new file mode 100644 index 000000000..ef06b4907 --- /dev/null +++ b/cross-chain/base/deploy_l2/23_transfer_proxy_admin_ownership.ts @@ -0,0 +1,27 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async (hre: HardhatRuntimeEnvironment) => { + const { helpers, upgrades, deployments } = hre + const { governance, deployer } = await helpers.signers.getNamedSigners() + const { log } = deployments + + const proxyAdmin = await upgrades.admin.getInstance() + const currentOwner = await proxyAdmin.owner() + + // The `@openzeppelin/hardhat-upgrades` plugin deploys a single ProxyAdmin + // per network. We don't want to transfer the ownership if the owner is already + // set to the desired address. + if (!helpers.address.equal(currentOwner, governance.address)) { + log(`transferring ownership of ProxyAdmin to ${governance.address}`) + await ( + await proxyAdmin.connect(deployer).transferOwnership(governance.address) + ).wait() + } +} + +export default func + +func.tags = ["TransferProxyAdminOwnership"] +func.dependencies = ["BaseTBTC", "BaseWormholeGateway"] +func.runAtTheEnd = true diff --git a/cross-chain/base/deploy_l2/31_upgrade_base_wormhole_gateway.ts b/cross-chain/base/deploy_l2/31_upgrade_base_wormhole_gateway.ts new file mode 100644 index 000000000..d5a09751b --- /dev/null +++ b/cross-chain/base/deploy_l2/31_upgrade_base_wormhole_gateway.ts @@ -0,0 +1,50 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { ethers, getNamedAccounts, helpers, deployments } = hre + const { deployer } = await getNamedAccounts() + + const BaseTokenBridge = await deployments.get("BaseTokenBridge") + const BaseWormholeTBTC = await deployments.get("BaseWormholeTBTC") + const BaseTBTC = await deployments.get("BaseTBTC") + + const [, proxyDeployment] = await helpers.upgrades.upgradeProxy( + "BaseWormholeGateway", + "BaseWormholeGateway", + { + contractName: + "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:L2WormholeGateway", + initializerArgs: [ + BaseTokenBridge.address, + BaseWormholeTBTC.address, + BaseTBTC.address, + ], + factoryOpts: { signer: await ethers.getSigner(deployer) }, + proxyOpts: { + kind: "transparent", + }, + } + ) + + // Contracts can be verified on L2 Base Etherscan in a similar way as we do + // it on L1 Etherscan + if (hre.network.tags.basescan) { + // We use `verify` instead of `verify:verify` as the `verify` task is defined + // in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation + // contract, the proxy itself and any proxy-related contracts, as well as + // link the proxy to the implementation contract’s ABI on (Ether)scan. + await hre.run("verify", { + address: proxyDeployment.address, + constructorArgsParams: proxyDeployment.args, + }) + } +} + +export default func + +func.tags = ["UpgradeBaseWormholeGateway"] + +// Comment this line when running an upgrade. +// yarn deploy --tags UpgradeBaseWormholeGateway --network +func.skip = async () => true diff --git a/cross-chain/base/external/base/ArbitrumWormholeGateway.json b/cross-chain/base/external/base/ArbitrumWormholeGateway.json new file mode 100644 index 000000000..ffd563462 --- /dev/null +++ b/cross-chain/base/external/base/ArbitrumWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x1293a54e160D1cd7075487898d65266081A15458" +} diff --git a/cross-chain/base/external/base/BaseTokenBridge.json b/cross-chain/base/external/base/BaseTokenBridge.json new file mode 100644 index 000000000..ee686bc2b --- /dev/null +++ b/cross-chain/base/external/base/BaseTokenBridge.json @@ -0,0 +1,3 @@ +{ + "address": "0x8d2de8d2f73F1F4cAB472AC9A881C9b123C79627" +} diff --git a/cross-chain/base/external/base/BaseWormholeTBTC.json b/cross-chain/base/external/base/BaseWormholeTBTC.json new file mode 100644 index 000000000..b13fbf0fc --- /dev/null +++ b/cross-chain/base/external/base/BaseWormholeTBTC.json @@ -0,0 +1,3 @@ +{ + "address": "0xeC0a755664271b87002dDa33CA2484B24aF68912" +} diff --git a/cross-chain/base/external/base/OptimismWormholeGateway.json b/cross-chain/base/external/base/OptimismWormholeGateway.json new file mode 100644 index 000000000..ffd563462 --- /dev/null +++ b/cross-chain/base/external/base/OptimismWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x1293a54e160D1cd7075487898d65266081A15458" +} diff --git a/cross-chain/base/external/base/PolygonWormholeGateway.json b/cross-chain/base/external/base/PolygonWormholeGateway.json new file mode 100644 index 000000000..6571efe8d --- /dev/null +++ b/cross-chain/base/external/base/PolygonWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab" +} diff --git a/cross-chain/base/external/baseGoerli/ArbitrumWormholeGateway.json b/cross-chain/base/external/baseGoerli/ArbitrumWormholeGateway.json new file mode 100644 index 000000000..ea8693dc5 --- /dev/null +++ b/cross-chain/base/external/baseGoerli/ArbitrumWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x31A15e213B59E230b45e8c5c99dAFAc3d1236Ee2" +} diff --git a/cross-chain/base/external/baseGoerli/BaseTokenBridge.json b/cross-chain/base/external/baseGoerli/BaseTokenBridge.json new file mode 100644 index 000000000..3a5aef78a --- /dev/null +++ b/cross-chain/base/external/baseGoerli/BaseTokenBridge.json @@ -0,0 +1,3 @@ +{ + "address": "0xA31aa3FDb7aF7Db93d18DDA4e19F811342EDF780" +} diff --git a/cross-chain/base/external/baseGoerli/BaseWormholeTBTC.json b/cross-chain/base/external/baseGoerli/BaseWormholeTBTC.json new file mode 100644 index 000000000..d8483e704 --- /dev/null +++ b/cross-chain/base/external/baseGoerli/BaseWormholeTBTC.json @@ -0,0 +1,3 @@ +{ + "address": "0x5D89a5BcB86F15a2CCAb05e7E3bEE23fDF246a64" +} diff --git a/cross-chain/base/external/baseGoerli/OptimismWormholeGateway.json b/cross-chain/base/external/baseGoerli/OptimismWormholeGateway.json new file mode 100644 index 000000000..283665601 --- /dev/null +++ b/cross-chain/base/external/baseGoerli/OptimismWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x6449F4381f3d63bDfb36B3bDc375724aD3cD4621" +} diff --git a/cross-chain/base/external/baseGoerli/PolygonWormholeGateway.json b/cross-chain/base/external/baseGoerli/PolygonWormholeGateway.json new file mode 100644 index 000000000..c9c6cfe9a --- /dev/null +++ b/cross-chain/base/external/baseGoerli/PolygonWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x91Fe7128f74dBd4F031ea3D90FC5Ea4DCfD81818" +} diff --git a/cross-chain/base/external/goerli/TokenBridge.json b/cross-chain/base/external/goerli/TokenBridge.json new file mode 100644 index 000000000..99dc89ed5 --- /dev/null +++ b/cross-chain/base/external/goerli/TokenBridge.json @@ -0,0 +1,3 @@ +{ + "address": "0xF890982f9310df57d00f659cf4fd87e65adEd8d7" +} diff --git a/cross-chain/base/external/mainnet/TokenBridge.json b/cross-chain/base/external/mainnet/TokenBridge.json new file mode 100644 index 000000000..984412777 --- /dev/null +++ b/cross-chain/base/external/mainnet/TokenBridge.json @@ -0,0 +1,3 @@ +{ + "address": "0x3ee18B2214AFF97000D974cf647E7C347E8fa585" +} diff --git a/cross-chain/base/hardhat.config.ts b/cross-chain/base/hardhat.config.ts new file mode 100644 index 000000000..5778ad859 --- /dev/null +++ b/cross-chain/base/hardhat.config.ts @@ -0,0 +1,151 @@ +import type { HardhatUserConfig } from "hardhat/config" + +import "@nomiclabs/hardhat-etherscan" +import "@keep-network/hardhat-helpers" +import "@nomiclabs/hardhat-waffle" +import "hardhat-gas-reporter" +import "hardhat-contract-sizer" +import "hardhat-deploy" +import "@typechain/hardhat" +import "hardhat-dependency-compiler" + +const config: HardhatUserConfig = { + solidity: { + compilers: [ + { + version: "0.8.17", + settings: { + optimizer: { + enabled: true, + runs: 1000, + }, + }, + }, + ], + }, + + paths: { + artifacts: "./build", + }, + + networks: { + hardhat: { + deploy: [ + // "deploy_l1", + "deploy_l2", + ], + }, + goerli: { + url: process.env.L1_CHAIN_API_URL || "", + chainId: 5, + deploy: ["deploy_l1"], + accounts: process.env.L1_ACCOUNTS_PRIVATE_KEYS + ? process.env.L1_ACCOUNTS_PRIVATE_KEYS.split(",") + : undefined, + tags: ["etherscan"], + }, + mainnet: { + url: process.env.L1_CHAIN_API_URL || "", + chainId: 1, + deploy: ["deploy_l1"], + accounts: process.env.L1_ACCOUNTS_PRIVATE_KEYS + ? process.env.L1_ACCOUNTS_PRIVATE_KEYS.split(",") + : undefined, + tags: ["etherscan"], + }, + baseGoerli: { + url: process.env.L2_CHAIN_API_URL || "", + chainId: 84531, + deploy: ["deploy_l2"], + accounts: process.env.L2_ACCOUNTS_PRIVATE_KEYS + ? process.env.L2_ACCOUNTS_PRIVATE_KEYS.split(",") + : undefined, + tags: ["basescan"], + gasPrice: 1000000000, + // companionNetworks: { + // l1: "goerli", + // }, + }, + base: { + url: process.env.L2_CHAIN_API_URL || "", + chainId: 8453, + deploy: ["deploy_l2"], + accounts: process.env.L2_ACCOUNTS_PRIVATE_KEYS + ? process.env.L2_ACCOUNTS_PRIVATE_KEYS.split(",") + : undefined, + tags: ["basescan"], + gasPrice: 1000000000, + // companionNetworks: { + // l1: "mainnet", + // }, + }, + }, + + external: { + deployments: { + goerli: ["./external/goerli"], + mainnet: ["./external/mainnet"], + baseGoerli: ["./external/baseGoerli"], + base: ["./external/base"], + }, + }, + + deploymentArtifactsExport: { + goerli: "artifacts/l1", + mainnet: "artifacts/l1", + baseGoerli: "artifacts/l2", + base: "artifacts/l2", + }, + + etherscan: { + apiKey: { + goerli: process.env.ETHERSCAN_API_KEY, + mainnet: process.env.ETHERSCAN_API_KEY, + "base-goerli": process.env.BASESCAN_API_KEY, + "base-mainnet": process.env.BASESCAN_API_KEY, + }, + customChains: [ + { + network: "base-goerli", + chainId: 84531, + urls: { + apiURL: "https://api-goerli.basescan.org/api", + browserURL: "https://goerli.basescan.org", + }, + }, + { + network: "base-mainnet", + chainId: 8453, + urls: { + apiURL: "https://api.basescan.org/api", + browserURL: "https://basescan.org", + }, + }, + ], + }, + + namedAccounts: { + deployer: { + default: 1, + goerli: 0, + baseGoerli: 0, + mainnet: "0x123694886DBf5Ac94DDA07135349534536D14cAf", + base: "0x123694886DBf5Ac94DDA07135349534536D14cAf", + }, + governance: { + default: 2, + goerli: 0, + baseGoerli: 0, + mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", + base: "", + }, + }, + mocha: { + timeout: 60_000, + }, + typechain: { + outDir: "typechain", + }, +} + +export default config diff --git a/cross-chain/base/package.json b/cross-chain/base/package.json new file mode 100644 index 000000000..149659c80 --- /dev/null +++ b/cross-chain/base/package.json @@ -0,0 +1,77 @@ +{ + "name": "@keep-network/tbtc-v2-base", + "version": "1.0.0-dev", + "description": "tBTC v2 on Base", + "license": "GPL-3.0-only", + "files": [ + "artifacts/", + "build/contracts/", + "contracts/", + "!contracts/hardhat-dependency-compiler", + "!**/test/", + "deploy_l1/", + "deploy_l2/", + "export/", + "tasks/", + "export.json" + ], + "scripts": { + "build": "hardhat compile", + "clean": "hardhat clean && rm -rf cache/ export/ external/npm typechain/ export.json", + "deploy": "hardhat deploy --export export.json", + "format": "npm run lint", + "format:fix": "npm run lint:fix", + "lint": "npm run lint:eslint && npm run lint:sol && npm run lint:config", + "lint:fix": "npm run lint:fix:eslint && npm run lint:fix:sol && npm run lint:config:fix", + "lint:eslint": "eslint .", + "lint:fix:eslint": "eslint . --fix", + "lint:sol": "solhint 'contracts/**/*.sol' && prettier --check '**/*.sol'", + "lint:fix:sol": "solhint 'contracts/**/*.sol' --fix && prettier --write '**/*.sol'", + "lint:config": "prettier --check '**/*.@(json|yaml)'", + "lint:config:fix": "prettier --write '**/*.@(json|yaml)'", + "prepack": "tsc -p tsconfig.export.json && hardhat export-artifacts export/artifacts", + "export-artifacts:goerli": "yarn hardhat export-deployment-artifacts --network baseGoerli", + "export-artifacts:mainnet": "yarn hardhat export-deployment-artifacts --network base", + "prepublishOnly": "npm run export-artifacts:$npm_config_network", + "test": "hardhat test" + }, + "dependencies": { + "@keep-network/tbtc-v2": "development", + "@openzeppelin/contracts": "^4.8.1", + "@openzeppelin/contracts-upgradeable": "^4.8.1" + }, + "devDependencies": { + "@keep-network/hardhat-helpers": "^0.6.0-pre.20", + "@nomiclabs/hardhat-ethers": "^2.0.6", + "@nomiclabs/hardhat-etherscan": "3.1.0", + "@nomiclabs/hardhat-waffle": "2.0.3", + "@openzeppelin/hardhat-upgrades": "^1.20.0", + "@thesis-co/eslint-config": "github:thesis/eslint-config", + "@typechain/ethers-v5": "^8.0.5", + "@typechain/hardhat": "^4.0.0", + "@types/chai": "^4.3.0", + "@types/chai-as-promised": "^7.1.1", + "@types/mocha": "^9.1.0", + "@types/node": "^18.11.18", + "chai": "4.3.4", + "eslint": "^7.32.0", + "ethereum-waffle": "3.4.0", + "ethers": "^5.5.3", + "hardhat": "^2.10.0", + "hardhat-contract-sizer": "^2.5.0", + "hardhat-dependency-compiler": "^1.1.2", + "hardhat-deploy": "^0.11.11", + "hardhat-gas-reporter": "^1.0.8", + "prettier": "^2.5.1", + "prettier-plugin-sh": "^0.8.1", + "prettier-plugin-solidity": "^1.0.0-beta.19", + "solhint": "3.3.6", + "solhint-config-keep": "github:keep-network/solhint-config-keep", + "ts-node": "^10.4.0", + "typechain": "^6.1.0", + "typescript": "^4.5.4" + }, + "engines": { + "node": ">=14" + } +} diff --git a/cross-chain/base/slither.config.json b/cross-chain/base/slither.config.json new file mode 100644 index 000000000..c1495a7e4 --- /dev/null +++ b/cross-chain/base/slither.config.json @@ -0,0 +1,5 @@ +{ + "detectors_to_exclude": "assembly,naming-convention,solc-version,timestamp,too-many-digits,similar-names", + "hardhat_artifacts_directory": "build", + "filter_paths": "contracts/test|node_modules" +} diff --git a/cross-chain/base/test/BaseTBTC.Upgrade.test.ts b/cross-chain/base/test/BaseTBTC.Upgrade.test.ts new file mode 100644 index 000000000..855b74a36 --- /dev/null +++ b/cross-chain/base/test/BaseTBTC.Upgrade.test.ts @@ -0,0 +1,65 @@ +import { deployments, helpers } from "hardhat" +import { expect } from "chai" + +import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers" + +import type { BaseTBTC, BaseTBTCUpgraded } from "../typechain" + +describe("BaseTBTC - Upgrade", async () => { + let governance: SignerWithAddress + let baseTBTC: BaseTBTC + + before(async () => { + await deployments.fixture() + ;({ governance } = await helpers.signers.getNamedSigners()) + + baseTBTC = (await helpers.contracts.getContract("BaseTBTC")) as BaseTBTC + }) + + describe("when a new contract is valid", () => { + let baseTBTCUpgraded: BaseTBTCUpgraded + + before(async () => { + const [upgradedContract] = await helpers.upgrades.upgradeProxy( + "BaseTBTC", + "BaseTBTCUpgraded", + { + proxyOpts: { + call: { + fn: "initializeV2", + args: ["Hello darkness my old friend"], + }, + }, + factoryOpts: { + signer: governance, + }, + } + ) + baseTBTCUpgraded = upgradedContract as BaseTBTCUpgraded + }) + + it("new instance should have the same address as the old one", async () => { + expect(baseTBTCUpgraded.address).equal(baseTBTC.address) + }) + + it("should initialize new variable", async () => { + expect(await baseTBTCUpgraded.newVar()).to.be.equal( + "Hello darkness my old friend" + ) + }) + + it("should not update already set name", async () => { + expect(await baseTBTCUpgraded.name()).to.be.equal("Base tBTC v2") + }) + + it("should not update already set symbol", async () => { + expect(await baseTBTCUpgraded.symbol()).to.be.equal("tBTC") + }) + + it("should revert when V1's initializer is called", async () => { + await expect( + baseTBTCUpgraded.initialize("BaseTBTCv2", "BaseTBTCv2") + ).to.be.revertedWith("Initializable: contract is already initialized") + }) + }) +}) diff --git a/cross-chain/base/test/BaseWormholeGateway.Upgrade.test.ts b/cross-chain/base/test/BaseWormholeGateway.Upgrade.test.ts new file mode 100644 index 000000000..9e772c1f3 --- /dev/null +++ b/cross-chain/base/test/BaseWormholeGateway.Upgrade.test.ts @@ -0,0 +1,81 @@ +import { ethers, deployments, helpers } from "hardhat" +import { expect } from "chai" + +import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers" + +import type { + BaseTBTC, + BaseWormholeGateway, + BaseWormholeGatewayUpgraded, +} from "../typechain" + +const ZERO_ADDRESS = ethers.constants.AddressZero + +describe("BaseWormholeGatewayUpgraded - Upgrade", async () => { + let governance: SignerWithAddress + let baseWormholeGateway: BaseWormholeGateway + + before(async () => { + await deployments.fixture() + ;({ governance } = await helpers.signers.getNamedSigners()) + + baseWormholeGateway = (await helpers.contracts.getContract( + "BaseWormholeGateway" + )) as BaseWormholeGateway + }) + + describe("when a new contract is valid", () => { + let baseWormholeGatewayUpgraded: BaseWormholeGatewayUpgraded + let BaseTBTC: BaseTBTC + + before(async () => { + BaseTBTC = (await helpers.contracts.getContract("BaseTBTC")) as BaseTBTC + + const [upgradedContract] = await helpers.upgrades.upgradeProxy( + "BaseWormholeGateway", + "BaseWormholeGatewayUpgraded", + { + proxyOpts: { + call: { + fn: "initializeV2", + args: ["Hello darkness my old friend"], + }, + }, + factoryOpts: { + signer: governance, + }, + } + ) + baseWormholeGatewayUpgraded = + upgradedContract as BaseWormholeGatewayUpgraded + }) + + it("new instance should have the same address as the old one", async () => { + expect(baseWormholeGatewayUpgraded.address).equal( + baseWormholeGateway.address + ) + }) + + it("should initialize new variable", async () => { + expect(await baseWormholeGatewayUpgraded.newVar()).to.be.equal( + "Hello darkness my old friend" + ) + }) + + it("should not update already set variable", async () => { + expect(await baseWormholeGatewayUpgraded.tbtc()).to.be.equal( + BaseTBTC.address + ) + }) + + it("should revert when V1's initializer is called", async () => { + await expect( + baseWormholeGatewayUpgraded.initialize( + ZERO_ADDRESS, + ZERO_ADDRESS, + ZERO_ADDRESS + ) + ).to.be.revertedWith("Initializable: contract is already initialized") + }) + }) +}) diff --git a/cross-chain/base/tsconfig.export.json b/cross-chain/base/tsconfig.export.json new file mode 100644 index 000000000..7832a5ea3 --- /dev/null +++ b/cross-chain/base/tsconfig.export.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["./test", "./typechain"], + "compilerOptions": { + "target": "es5", + "outDir": "export" + } +} diff --git a/cross-chain/base/tsconfig.json b/cross-chain/base/tsconfig.json new file mode 100644 index 000000000..ae53d78aa --- /dev/null +++ b/cross-chain/base/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "ES2018", + "module": "commonJS", + "downlevelIteration": true, + "esModuleInterop": true, + "resolveJsonModule": true + }, + "files": ["./hardhat.config.ts"], + "include": ["./deploy_l1", "./deploy_l2", "./test", "./typechain"] +} diff --git a/cross-chain/base/yarn.lock b/cross-chain/base/yarn.lock new file mode 100644 index 000000000..c1be5cc86 --- /dev/null +++ b/cross-chain/base/yarn.lock @@ -0,0 +1,12996 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@aws-crypto/sha256-js@1.2.2": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@aws-crypto/sha256-js/-/sha256-js-1.2.2.tgz#02acd1a1fda92896fc5a28ec7c6e164644ea32fc" + integrity sha512-Nr1QJIbW/afYYGzYvrF70LtaHrIRtd4TNAglX8BvlfxJLZ45SAmueIKYl5tWoNBPzp65ymXGFK0Bb1vZUpuc9g== + dependencies: + "@aws-crypto/util" "^1.2.2" + "@aws-sdk/types" "^3.1.0" + tslib "^1.11.1" + +"@aws-crypto/util@^1.2.2": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@aws-crypto/util/-/util-1.2.2.tgz#b28f7897730eb6538b21c18bd4de22d0ea09003c" + integrity sha512-H8PjG5WJ4wz0UXAFXeJjWCW1vkvIJ3qUUD+rGRwJ2/hj+xT58Qle2MTql/2MGzkU+1JLAFuR6aJpLAjHwhmwwg== + dependencies: + "@aws-sdk/types" "^3.1.0" + "@aws-sdk/util-utf8-browser" "^3.0.0" + tslib "^1.11.1" + +"@aws-sdk/types@^3.1.0": + version "3.378.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/types/-/types-3.378.0.tgz#93a811ccdf15c81b1947f1cd67922c4690792189" + integrity sha512-qP0CvR/ItgktmN8YXpGQglzzR/6s0nrsQ4zIfx3HMwpsBTwuouYahcCtF1Vr82P4NFcoDA412EJahJ2pIqEd+w== + dependencies: + "@smithy/types" "^2.0.2" + tslib "^2.5.0" + +"@aws-sdk/util-utf8-browser@^3.0.0": + version "3.259.0" + resolved "https://registry.yarnpkg.com/@aws-sdk/util-utf8-browser/-/util-utf8-browser-3.259.0.tgz#3275a6f5eb334f96ca76635b961d3c50259fd9ff" + integrity sha512-UvFa/vR+e19XookZF8RzFZBrw2EUkQWxiBW0yYQAhvk3C+QVGl0H3ouca8LDBlBfQKXwmW3huo/59H8rwb1wJw== + dependencies: + tslib "^2.3.1" + +"@babel/code-frame@7.12.11": + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f" + integrity sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw== + dependencies: + "@babel/highlight" "^7.10.4" + +"@babel/code-frame@^7.0.0": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a" + integrity sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q== + dependencies: + "@babel/highlight" "^7.18.6" + +"@babel/helper-validator-identifier@^7.18.6": + version "7.19.1" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2" + integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w== + +"@babel/highlight@^7.10.4", "@babel/highlight@^7.18.6": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.18.6.tgz#81158601e93e2563795adcbfbdf5d64be3f2ecdf" + integrity sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g== + dependencies: + "@babel/helper-validator-identifier" "^7.18.6" + chalk "^2.0.0" + js-tokens "^4.0.0" + +"@babel/runtime@^7.20.7": + version "7.21.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673" + integrity sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw== + dependencies: + regenerator-runtime "^0.13.11" + +"@celo/base@1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@celo/base/-/base-1.5.2.tgz#168ab5e4e30b374079d8d139fafc52ca6bfd4100" + integrity sha512-KGf6Dl9E6D01vAfkgkjL2sG+zqAjspAogILIpWstljWdG5ifyA75jihrnDEHaMCoQS0KxHvTdP1XYS/GS6BEyQ== + +"@celo/connect@1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@celo/connect/-/connect-1.5.2.tgz#09f0b03bda6f8a6d523fd010492f204cbe82aabd" + integrity sha512-IHsvYp1HizIPfPPeIHyvsmJytIf7HNtNWo9CqCbsqfNfmw53q6dFJu2p5X0qz/fUnR5840cUga8cEyuYZTfp+w== + dependencies: + "@celo/utils" "1.5.2" + "@types/debug" "^4.1.5" + "@types/utf8" "^2.1.6" + bignumber.js "^9.0.0" + debug "^4.1.1" + utf8 "3.0.0" + +"@celo/contractkit@^0.3.3": + version "0.3.8" + resolved "https://registry.yarnpkg.com/@celo/contractkit/-/contractkit-0.3.8.tgz#aea543761a4921dddd1b1f906d23f8730cce15c7" + integrity sha512-lEXciI3tYnDKNdyazW6etR/ZFm0wrNlX1OxNgzv5D8HCPJcFSUF3Bi4fYtL/Ocx2oHNpK4k3eDZ6aj+ZbkRC+Q== + dependencies: + "@celo/utils" "0.1.11" + "@ledgerhq/hw-app-eth" "^5.11.0" + "@ledgerhq/hw-transport" "^5.11.0" + "@types/debug" "^4.1.5" + bignumber.js "^9.0.0" + cross-fetch "3.0.4" + debug "^4.1.1" + eth-lib "^0.2.8" + ethereumjs-util "^5.2.0" + fp-ts "2.1.1" + io-ts "2.0.1" + web3 "1.2.4" + web3-core "1.2.4" + web3-core-helpers "1.2.4" + web3-eth-abi "1.2.4" + web3-eth-contract "1.2.4" + web3-utils "1.2.4" + +"@celo/contractkit@^1.0.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@celo/contractkit/-/contractkit-1.5.2.tgz#be15d570f3044a190dabb6bbe53d5081c78ea605" + integrity sha512-b0r5TlfYDEscxze1Ai2jyJayiVElA9jvEehMD6aOSNtVhfP8oirjFIIffRe0Wzw1MSDGkw+q1c4m0Yw5sEOlvA== + dependencies: + "@celo/base" "1.5.2" + "@celo/connect" "1.5.2" + "@celo/utils" "1.5.2" + "@celo/wallet-local" "1.5.2" + "@types/debug" "^4.1.5" + bignumber.js "^9.0.0" + cross-fetch "^3.0.6" + debug "^4.1.1" + fp-ts "2.1.1" + io-ts "2.0.1" + semver "^7.3.5" + web3 "1.3.6" + +"@celo/utils@0.1.11": + version "0.1.11" + resolved "https://registry.yarnpkg.com/@celo/utils/-/utils-0.1.11.tgz#c35e3b385091fc6f0c0c355b73270f4a8559ad38" + integrity sha512-i3oK1guBxH89AEBaVA1d5CHnANehL36gPIcSpPBWiYZrKTGGVvbwNmVoaDwaKFXih0N22vXQAf2Rul8w5VzC3w== + dependencies: + "@umpirsky/country-list" "git://github.com/umpirsky/country-list#05fda51" + bigi "^1.1.0" + bignumber.js "^9.0.0" + bip32 "2.0.5" + bip39 "3.0.2" + bls12377js "https://github.com/celo-org/bls12377js#400bcaeec9e7620b040bfad833268f5289699cac" + bn.js "4.11.8" + buffer-reverse "^1.0.1" + country-data "^0.0.31" + crypto-js "^3.1.9-1" + elliptic "^6.4.1" + ethereumjs-util "^5.2.0" + futoin-hkdf "^1.0.3" + google-libphonenumber "^3.2.4" + keccak256 "^1.0.0" + lodash "^4.17.14" + numeral "^2.0.6" + web3-utils "1.2.4" + +"@celo/utils@1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@celo/utils/-/utils-1.5.2.tgz#ddb7f3b50c801225ab41d2355fbe010976329099" + integrity sha512-JyKjuVMbdkyFOb1TpQw6zqamPQWYg7I9hOnva3MeIcQ3ZrJIaNHx0/I+JXFjuu3YYBc1mG8nXp2uPJJTGrwzCQ== + dependencies: + "@celo/base" "1.5.2" + "@types/country-data" "^0.0.0" + "@types/elliptic" "^6.4.9" + "@types/ethereumjs-util" "^5.2.0" + "@types/google-libphonenumber" "^7.4.17" + "@types/lodash" "^4.14.170" + "@types/node" "^10.12.18" + "@types/randombytes" "^2.0.0" + bigi "^1.1.0" + bignumber.js "^9.0.0" + bip32 "2.0.5" + bip39 "https://github.com/bitcoinjs/bip39#d8ea080a18b40f301d4e2219a2991cd2417e83c2" + bls12377js "https://github.com/celo-org/bls12377js#cb38a4cfb643c778619d79b20ca3e5283a2122a6" + bn.js "4.11.8" + buffer-reverse "^1.0.1" + country-data "^0.0.31" + crypto-js "^3.1.9-1" + elliptic "^6.5.4" + ethereumjs-util "^5.2.0" + fp-ts "2.1.1" + google-libphonenumber "^3.2.15" + io-ts "2.0.1" + keccak256 "^1.0.0" + lodash "^4.17.21" + numeral "^2.0.6" + web3-eth-abi "1.3.6" + web3-utils "1.3.6" + +"@celo/wallet-base@1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@celo/wallet-base/-/wallet-base-1.5.2.tgz#ae8df425bf3c702277bb1b63a761a2ec8429e7aa" + integrity sha512-NYJu7OtSRFpGcvSMl2Wc8zN32S6oTkAzKqhH7rXisQ0I2q4yNwCzoquzPVYB0G2UVUFKuuxgsA5V+Zda/LQCyw== + dependencies: + "@celo/base" "1.5.2" + "@celo/connect" "1.5.2" + "@celo/utils" "1.5.2" + "@types/debug" "^4.1.5" + "@types/ethereumjs-util" "^5.2.0" + bignumber.js "^9.0.0" + debug "^4.1.1" + eth-lib "^0.2.8" + ethereumjs-util "^5.2.0" + +"@celo/wallet-local@1.5.2": + version "1.5.2" + resolved "https://registry.yarnpkg.com/@celo/wallet-local/-/wallet-local-1.5.2.tgz#66ea5fb763e19724309e3d56f312f1a342e12b91" + integrity sha512-Aas4SwqQc8ap0OFAOZc+jBR4cXr20V9AReHNEI8Y93R3g1+RlSEJ1Zmsu4vN+Rriz58YqgMnr+pihorw8QydFQ== + dependencies: + "@celo/connect" "1.5.2" + "@celo/utils" "1.5.2" + "@celo/wallet-base" "1.5.2" + "@types/ethereumjs-util" "^5.2.0" + eth-lib "^0.2.8" + ethereumjs-util "^5.2.0" + +"@colors/colors@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" + integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== + +"@cspotcode/source-map-support@^0.8.0": + version "0.8.1" + resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" + integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== + dependencies: + "@jridgewell/trace-mapping" "0.3.9" + +"@ensdomains/ens@^0.4.4": + version "0.4.5" + resolved "https://registry.yarnpkg.com/@ensdomains/ens/-/ens-0.4.5.tgz#e0aebc005afdc066447c6e22feb4eda89a5edbfc" + integrity sha512-JSvpj1iNMFjK6K+uVl4unqMoa9rf5jopb8cya5UGBWz23Nw8hSNT7efgUx4BTlAPAgpNlEioUfeTyQ6J9ZvTVw== + dependencies: + bluebird "^3.5.2" + eth-ens-namehash "^2.0.8" + solc "^0.4.20" + testrpc "0.0.1" + web3-utils "^1.0.0-beta.31" + +"@ensdomains/resolver@^0.2.4": + version "0.2.4" + resolved "https://registry.yarnpkg.com/@ensdomains/resolver/-/resolver-0.2.4.tgz#c10fe28bf5efbf49bff4666d909aed0265efbc89" + integrity sha512-bvaTH34PMCbv6anRa9I/0zjLJgY4EuznbEMgbV77JBCQ9KNC46rzi0avuxpOfu+xDjPEtSFGqVEOr5GlUSGudA== + +"@eslint-community/eslint-utils@^4.2.0": + version "4.4.0" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" + integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA== + dependencies: + eslint-visitor-keys "^3.3.0" + +"@eslint-community/regexpp@^4.4.0": + version "4.5.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.5.0.tgz#f6f729b02feee2c749f57e334b7a1b5f40a81724" + integrity sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ== + +"@eslint/eslintrc@^0.4.3": + version "0.4.3" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c" + integrity sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw== + dependencies: + ajv "^6.12.4" + debug "^4.1.1" + espree "^7.3.0" + globals "^13.9.0" + ignore "^4.0.6" + import-fresh "^3.2.1" + js-yaml "^3.13.1" + minimatch "^3.0.4" + strip-json-comments "^3.1.1" + +"@ethereum-waffle/chai@^3.4.0": + version "3.4.4" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/chai/-/chai-3.4.4.tgz#16c4cc877df31b035d6d92486dfdf983df9138ff" + integrity sha512-/K8czydBtXXkcM9X6q29EqEkc5dN3oYenyH2a9hF7rGAApAJUpH8QBtojxOY/xQ2up5W332jqgxwp0yPiYug1g== + dependencies: + "@ethereum-waffle/provider" "^3.4.4" + ethers "^5.5.2" + +"@ethereum-waffle/compiler@^3.4.0": + version "3.4.4" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/compiler/-/compiler-3.4.4.tgz#d568ee0f6029e68b5c645506079fbf67d0dfcf19" + integrity sha512-RUK3axJ8IkD5xpWjWoJgyHclOeEzDLQFga6gKpeGxiS/zBu+HB0W2FvsrrLalTFIaPw/CGYACRBSIxqiCqwqTQ== + dependencies: + "@resolver-engine/imports" "^0.3.3" + "@resolver-engine/imports-fs" "^0.3.3" + "@typechain/ethers-v5" "^2.0.0" + "@types/mkdirp" "^0.5.2" + "@types/node-fetch" "^2.5.5" + ethers "^5.0.1" + mkdirp "^0.5.1" + node-fetch "^2.6.1" + solc "^0.6.3" + ts-generator "^0.1.1" + typechain "^3.0.0" + +"@ethereum-waffle/ens@^3.4.4": + version "3.4.4" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/ens/-/ens-3.4.4.tgz#db97ea2c9decbb70b9205d53de2ccbd6f3182ba1" + integrity sha512-0m4NdwWxliy3heBYva1Wr4WbJKLnwXizmy5FfSSr5PMbjI7SIGCdCB59U7/ZzY773/hY3bLnzLwvG5mggVjJWg== + dependencies: + "@ensdomains/ens" "^0.4.4" + "@ensdomains/resolver" "^0.2.4" + ethers "^5.5.2" + +"@ethereum-waffle/mock-contract@^3.3.0": + version "3.4.4" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/mock-contract/-/mock-contract-3.4.4.tgz#fc6ffa18813546f4950a69f5892d4dd54b2c685a" + integrity sha512-Mp0iB2YNWYGUV+VMl5tjPsaXKbKo8MDH9wSJ702l9EBjdxFf/vBvnMBAC1Fub1lLtmD0JHtp1pq+mWzg/xlLnA== + dependencies: + "@ethersproject/abi" "^5.5.0" + ethers "^5.5.2" + +"@ethereum-waffle/provider@^3.4.0", "@ethereum-waffle/provider@^3.4.4": + version "3.4.4" + resolved "https://registry.yarnpkg.com/@ethereum-waffle/provider/-/provider-3.4.4.tgz#398fc1f7eb91cc2df7d011272eacba8af0c7fffb" + integrity sha512-GK8oKJAM8+PKy2nK08yDgl4A80mFuI8zBkE0C9GqTRYQqvuxIyXoLmJ5NZU9lIwyWVv5/KsoA11BgAv2jXE82g== + dependencies: + "@ethereum-waffle/ens" "^3.4.4" + ethers "^5.5.2" + ganache-core "^2.13.2" + patch-package "^6.2.2" + postinstall-postinstall "^2.1.0" + +"@ethersproject/abi@5.0.0-beta.153": + version "5.0.0-beta.153" + resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.0.0-beta.153.tgz#43a37172b33794e4562999f6e2d555b7599a8eee" + integrity sha512-aXweZ1Z7vMNzJdLpR1CZUAIgnwjrZeUSvN9syCwlBaEBUFJmFY+HHnfuTI5vIhVs/mRkfJVrbEyl51JZQqyjAg== + dependencies: + "@ethersproject/address" ">=5.0.0-beta.128" + "@ethersproject/bignumber" ">=5.0.0-beta.130" + "@ethersproject/bytes" ">=5.0.0-beta.129" + "@ethersproject/constants" ">=5.0.0-beta.128" + "@ethersproject/hash" ">=5.0.0-beta.128" + "@ethersproject/keccak256" ">=5.0.0-beta.127" + "@ethersproject/logger" ">=5.0.0-beta.129" + "@ethersproject/properties" ">=5.0.0-beta.131" + "@ethersproject/strings" ">=5.0.0-beta.130" + +"@ethersproject/abi@5.0.7": + version "5.0.7" + resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.0.7.tgz#79e52452bd3ca2956d0e1c964207a58ad1a0ee7b" + integrity sha512-Cqktk+hSIckwP/W8O47Eef60VwmoSC/L3lY0+dIBhQPCNn9E4V7rwmm2aFrNRRDJfFlGuZ1khkQUOc3oBX+niw== + dependencies: + "@ethersproject/address" "^5.0.4" + "@ethersproject/bignumber" "^5.0.7" + "@ethersproject/bytes" "^5.0.4" + "@ethersproject/constants" "^5.0.4" + "@ethersproject/hash" "^5.0.4" + "@ethersproject/keccak256" "^5.0.3" + "@ethersproject/logger" "^5.0.5" + "@ethersproject/properties" "^5.0.3" + "@ethersproject/strings" "^5.0.4" + +"@ethersproject/abi@5.7.0", "@ethersproject/abi@^5.0.0-beta.146", "@ethersproject/abi@^5.1.2", "@ethersproject/abi@^5.5.0", "@ethersproject/abi@^5.6.3", "@ethersproject/abi@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.7.0.tgz#b3f3e045bbbeed1af3947335c247ad625a44e449" + integrity sha512-351ktp42TiRcYB3H1OP8yajPeAQstMW/yCFokj/AthP9bLHzQFPlOrxOcwYEDkUAICmOHljvN4K39OMTMUa9RA== + dependencies: + "@ethersproject/address" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/hash" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + +"@ethersproject/abstract-provider@5.7.0", "@ethersproject/abstract-provider@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz#b0a8550f88b6bf9d51f90e4795d48294630cb9ef" + integrity sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw== + dependencies: + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/networks" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + "@ethersproject/web" "^5.7.0" + +"@ethersproject/abstract-signer@5.7.0", "@ethersproject/abstract-signer@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.7.0.tgz#13f4f32117868452191a4649723cb086d2b596b2" + integrity sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ== + dependencies: + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + +"@ethersproject/address@5.7.0", "@ethersproject/address@>=5.0.0-beta.128", "@ethersproject/address@^5.0.2", "@ethersproject/address@^5.0.4", "@ethersproject/address@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.7.0.tgz#19b56c4d74a3b0a46bfdbb6cfcc0a153fc697f37" + integrity sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA== + dependencies: + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + +"@ethersproject/base64@5.7.0", "@ethersproject/base64@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.7.0.tgz#ac4ee92aa36c1628173e221d0d01f53692059e1c" + integrity sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ== + dependencies: + "@ethersproject/bytes" "^5.7.0" + +"@ethersproject/basex@5.7.0", "@ethersproject/basex@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.7.0.tgz#97034dc7e8938a8ca943ab20f8a5e492ece4020b" + integrity sha512-ywlh43GwZLv2Voc2gQVTKBoVQ1mti3d8HK5aMxsfu/nRDnMmNqaSJ3r3n85HBByT8OpoY96SXM1FogC533T4zw== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + +"@ethersproject/bignumber@5.7.0", "@ethersproject/bignumber@>=5.0.0-beta.130", "@ethersproject/bignumber@^5.0.7", "@ethersproject/bignumber@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.7.0.tgz#e2f03837f268ba655ffba03a57853e18a18dc9c2" + integrity sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + bn.js "^5.2.1" + +"@ethersproject/bytes@5.7.0", "@ethersproject/bytes@>=5.0.0-beta.129", "@ethersproject/bytes@^5.0.4", "@ethersproject/bytes@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.7.0.tgz#a00f6ea8d7e7534d6d87f47188af1148d71f155d" + integrity sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A== + dependencies: + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/constants@5.7.0", "@ethersproject/constants@>=5.0.0-beta.128", "@ethersproject/constants@^5.0.4", "@ethersproject/constants@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.7.0.tgz#df80a9705a7e08984161f09014ea012d1c75295e" + integrity sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA== + dependencies: + "@ethersproject/bignumber" "^5.7.0" + +"@ethersproject/contracts@5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.7.0.tgz#c305e775abd07e48aa590e1a877ed5c316f8bd1e" + integrity sha512-5GJbzEU3X+d33CdfPhcyS+z8MzsTrBGk/sc+G+59+tPa9yFkl6HQ9D6L0QMgNTA9q8dT0XKxxkyp883XsQvbbg== + dependencies: + "@ethersproject/abi" "^5.7.0" + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + +"@ethersproject/hash@5.7.0", "@ethersproject/hash@>=5.0.0-beta.128", "@ethersproject/hash@^5.0.4", "@ethersproject/hash@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.7.0.tgz#eb7aca84a588508369562e16e514b539ba5240a7" + integrity sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g== + dependencies: + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/base64" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + +"@ethersproject/hdnode@5.7.0", "@ethersproject/hdnode@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/hdnode/-/hdnode-5.7.0.tgz#e627ddc6b466bc77aebf1a6b9e47405ca5aef9cf" + integrity sha512-OmyYo9EENBPPf4ERhR7oj6uAtUAhYGqOnIS+jE5pTXvdKBS99ikzq1E7Iv0ZQZ5V36Lqx1qZLeak0Ra16qpeOg== + dependencies: + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/basex" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/pbkdf2" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/sha2" "^5.7.0" + "@ethersproject/signing-key" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + "@ethersproject/wordlists" "^5.7.0" + +"@ethersproject/json-wallets@5.7.0", "@ethersproject/json-wallets@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/json-wallets/-/json-wallets-5.7.0.tgz#5e3355287b548c32b368d91014919ebebddd5360" + integrity sha512-8oee5Xgu6+RKgJTkvEMl2wDgSPSAQ9MB/3JYjFV9jlKvcYHUXZC+cQp0njgmxdHkYWn8s6/IqIZYm0YWCjO/0g== + dependencies: + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/hdnode" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/pbkdf2" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/random" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + aes-js "3.0.0" + scrypt-js "3.0.1" + +"@ethersproject/keccak256@5.7.0", "@ethersproject/keccak256@>=5.0.0-beta.127", "@ethersproject/keccak256@^5.0.3", "@ethersproject/keccak256@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/keccak256/-/keccak256-5.7.0.tgz#3186350c6e1cd6aba7940384ec7d6d9db01f335a" + integrity sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg== + dependencies: + "@ethersproject/bytes" "^5.7.0" + js-sha3 "0.8.0" + +"@ethersproject/logger@5.7.0", "@ethersproject/logger@>=5.0.0-beta.129", "@ethersproject/logger@^5.0.5", "@ethersproject/logger@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.7.0.tgz#6ce9ae168e74fecf287be17062b590852c311892" + integrity sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig== + +"@ethersproject/networks@5.7.1", "@ethersproject/networks@^5.7.0": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.7.1.tgz#118e1a981d757d45ccea6bb58d9fd3d9db14ead6" + integrity sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ== + dependencies: + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/pbkdf2@5.7.0", "@ethersproject/pbkdf2@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/pbkdf2/-/pbkdf2-5.7.0.tgz#d2267d0a1f6e123f3771007338c47cccd83d3102" + integrity sha512-oR/dBRZR6GTyaofd86DehG72hY6NpAjhabkhxgr3X2FpJtJuodEl2auADWBZfhDHgVCbu3/H/Ocq2uC6dpNjjw== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/sha2" "^5.7.0" + +"@ethersproject/properties@5.7.0", "@ethersproject/properties@>=5.0.0-beta.131", "@ethersproject/properties@^5.0.3", "@ethersproject/properties@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.7.0.tgz#a6e12cb0439b878aaf470f1902a176033067ed30" + integrity sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw== + dependencies: + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/providers@5.7.2": + version "5.7.2" + resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.7.2.tgz#f8b1a4f275d7ce58cf0a2eec222269a08beb18cb" + integrity sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg== + dependencies: + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/base64" "^5.7.0" + "@ethersproject/basex" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/hash" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/networks" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/random" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + "@ethersproject/sha2" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + "@ethersproject/web" "^5.7.0" + bech32 "1.1.4" + ws "7.4.6" + +"@ethersproject/random@5.7.0", "@ethersproject/random@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.7.0.tgz#af19dcbc2484aae078bb03656ec05df66253280c" + integrity sha512-19WjScqRA8IIeWclFme75VMXSBvi4e6InrUNuaR4s5pTF2qNhcGdCUwdxUVGtDDqC00sDLCO93jPQoDUH4HVmQ== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/rlp@5.7.0", "@ethersproject/rlp@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.7.0.tgz#de39e4d5918b9d74d46de93af80b7685a9c21304" + integrity sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/sha2@5.7.0", "@ethersproject/sha2@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.7.0.tgz#9a5f7a7824ef784f7f7680984e593a800480c9fb" + integrity sha512-gKlH42riwb3KYp0reLsFTokByAKoJdgFCwI+CCiX/k+Jm2mbNs6oOaCjYQSlI1+XBVejwH2KrmCbMAT/GnRDQw== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + hash.js "1.1.7" + +"@ethersproject/signing-key@5.7.0", "@ethersproject/signing-key@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.7.0.tgz#06b2df39411b00bc57c7c09b01d1e41cf1b16ab3" + integrity sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + bn.js "^5.2.1" + elliptic "6.5.4" + hash.js "1.1.7" + +"@ethersproject/solidity@5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/solidity/-/solidity-5.7.0.tgz#5e9c911d8a2acce2a5ebb48a5e2e0af20b631cb8" + integrity sha512-HmabMd2Dt/raavyaGukF4XxizWKhKQ24DoLtdNbBmNKUOPqwjsKQSdV9GQtj9CBEea9DlzETlVER1gYeXXBGaA== + dependencies: + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/sha2" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + +"@ethersproject/strings@5.7.0", "@ethersproject/strings@>=5.0.0-beta.130", "@ethersproject/strings@^5.0.4", "@ethersproject/strings@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.7.0.tgz#54c9d2a7c57ae8f1205c88a9d3a56471e14d5ed2" + integrity sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/transactions@5.7.0", "@ethersproject/transactions@^5.0.0-beta.135", "@ethersproject/transactions@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.7.0.tgz#91318fc24063e057885a6af13fdb703e1f993d3b" + integrity sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ== + dependencies: + "@ethersproject/address" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/rlp" "^5.7.0" + "@ethersproject/signing-key" "^5.7.0" + +"@ethersproject/units@5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/units/-/units-5.7.0.tgz#637b563d7e14f42deeee39245275d477aae1d8b1" + integrity sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg== + dependencies: + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/constants" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + +"@ethersproject/wallet@5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/wallet/-/wallet-5.7.0.tgz#4e5d0790d96fe21d61d38fb40324e6c7ef350b2d" + integrity sha512-MhmXlJXEJFBFVKrDLB4ZdDzxcBxQ3rLyCkhNqVu3CDYvR97E+8r01UgrI+TI99Le+aYm/in/0vp86guJuM7FCA== + dependencies: + "@ethersproject/abstract-provider" "^5.7.0" + "@ethersproject/abstract-signer" "^5.7.0" + "@ethersproject/address" "^5.7.0" + "@ethersproject/bignumber" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/hash" "^5.7.0" + "@ethersproject/hdnode" "^5.7.0" + "@ethersproject/json-wallets" "^5.7.0" + "@ethersproject/keccak256" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/random" "^5.7.0" + "@ethersproject/signing-key" "^5.7.0" + "@ethersproject/transactions" "^5.7.0" + "@ethersproject/wordlists" "^5.7.0" + +"@ethersproject/web@5.7.1", "@ethersproject/web@^5.7.0": + version "5.7.1" + resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.7.1.tgz#de1f285b373149bee5928f4eb7bcb87ee5fbb4ae" + integrity sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w== + dependencies: + "@ethersproject/base64" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + +"@ethersproject/wordlists@5.7.0", "@ethersproject/wordlists@^5.7.0": + version "5.7.0" + resolved "https://registry.yarnpkg.com/@ethersproject/wordlists/-/wordlists-5.7.0.tgz#8fb2c07185d68c3e09eb3bfd6e779ba2774627f5" + integrity sha512-S2TFNJNfHWVHNE6cNDjbVlZ6MgE17MIxMbMg2zv3wn+3XSJGosL1m9ZVv3GXCf/2ymSsQ+hRI5IzoMJTG6aoVA== + dependencies: + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/hash" "^5.7.0" + "@ethersproject/logger" "^5.7.0" + "@ethersproject/properties" "^5.7.0" + "@ethersproject/strings" "^5.7.0" + +"@humanwhocodes/config-array@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9" + integrity sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg== + dependencies: + "@humanwhocodes/object-schema" "^1.2.0" + debug "^4.1.1" + minimatch "^3.0.4" + +"@humanwhocodes/object-schema@^1.2.0": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" + integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== + +"@jridgewell/resolve-uri@^3.0.3": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" + integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.14" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" + integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== + +"@jridgewell/trace-mapping@0.3.9": + version "0.3.9" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" + integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== + dependencies: + "@jridgewell/resolve-uri" "^3.0.3" + "@jridgewell/sourcemap-codec" "^1.4.10" + +"@keep-network/bitcoin-spv-sol@3.4.0-solc-0.8": + version "3.4.0-solc-0.8" + resolved "https://registry.yarnpkg.com/@keep-network/bitcoin-spv-sol/-/bitcoin-spv-sol-3.4.0-solc-0.8.tgz#8b44c246ffab8ea993efe196f6bf385b1a3b84dc" + integrity sha512-KlpY9BbasyLvYXSS7dsJktgRChu/yjdFLOX8ldGA/pltLicCm/l0F4oqxL8wSws9XD12vq9x0B5qzPygVLB2TQ== + +"@keep-network/ecdsa@2.1.0-dev.10": + version "2.1.0-dev.10" + resolved "https://registry.yarnpkg.com/@keep-network/ecdsa/-/ecdsa-2.1.0-dev.10.tgz#aa9075416a960a640298e4095f3fb94de83866fb" + integrity sha512-axUrpyoGvIVKqNVohdzuqlwHGb9QoCdmfdHGy6mONncMkEJsc/BZqUMOSlJtW42QVddMfG672kvgNZF5zsTjNQ== + dependencies: + "@keep-network/random-beacon" "2.1.0-dev.8" + "@keep-network/sortition-pools" "^2.0.0-pre.16" + "@openzeppelin/contracts" "^4.6.0" + "@openzeppelin/contracts-upgradeable" "^4.6.0" + "@threshold-network/solidity-contracts" "1.3.0-dev.3" + +"@keep-network/hardhat-helpers@^0.6.0-pre.20": + version "0.6.0-pre.20" + resolved "https://registry.yarnpkg.com/@keep-network/hardhat-helpers/-/hardhat-helpers-0.6.0-pre.20.tgz#9634c9f013df653f7dfbf2c70307e1a5d0748d1e" + integrity sha512-Qz1waJM3nRo7mrm9+7RbsSL3CtL44i6WN/R6X6+2g9l9vWxWjQMeWW5lBKT6WAxBZYsFQ1opFTm5MxFlcUHB3Q== + +"@keep-network/keep-core@1.8.1-goerli.0": + version "1.8.1-goerli.0" + resolved "https://registry.yarnpkg.com/@keep-network/keep-core/-/keep-core-1.8.1-goerli.0.tgz#238485aab51902021d42357bf59695225002f0ab" + integrity sha512-h3La/RqbyEZjBBPg8V+pcRFo3UpWZUF4CxWfXHZnUR4PnkZKnIDrTNFQPhpV2uYFZwrbJxTR9mzOq/DOAiXPwA== + dependencies: + "@openzeppelin/upgrades" "^2.7.2" + openzeppelin-solidity "2.4.0" + +"@keep-network/keep-core@>1.8.1-dev <1.8.1-goerli": + version "1.8.1-dev.0" + resolved "https://registry.yarnpkg.com/@keep-network/keep-core/-/keep-core-1.8.1-dev.0.tgz#d95864b25800214de43d8840376a68336cb12055" + integrity sha512-gFXkgN4PYOYCZ14AskL7fZHEFW5mu3BDd+TJKBuKZc1q9CgRMOK+dxpJnSctxmSH1tV+Ln9v9yqlSkfPCoiBHw== + dependencies: + "@openzeppelin/upgrades" "^2.7.2" + openzeppelin-solidity "2.4.0" + +"@keep-network/keep-ecdsa@>1.9.0-dev <1.9.0-ropsten": + version "1.9.0-goerli.0" + resolved "https://registry.yarnpkg.com/@keep-network/keep-ecdsa/-/keep-ecdsa-1.9.0-goerli.0.tgz#ce58b6639062bb4f73a257557aebb16447889e08" + integrity sha512-EA/oTcxmia5nznQ35ub9/5xBqBK4T+78oWYxASCc+THdPLalzriSAtQ517R4QnvkHi82NFhJjZH8WBoRXniddA== + dependencies: + "@keep-network/keep-core" "1.8.1-goerli.0" + "@keep-network/sortition-pools" "1.2.0-dev.1" + "@openzeppelin/upgrades" "^2.7.2" + openzeppelin-solidity "2.3.0" + +"@keep-network/random-beacon@2.1.0-dev.8": + version "2.1.0-dev.8" + resolved "https://registry.yarnpkg.com/@keep-network/random-beacon/-/random-beacon-2.1.0-dev.8.tgz#d21466250448175d2c9a21b876386196a4fe47f6" + integrity sha512-mnQ7eh49A8NiQ+9Y83kF0Rdr9Do/s2CcXaL4L+NdLPzVJW5SvXmOMfaJ9mghvHr9pqmqcSgpVzLyHL0EnrR51Q== + dependencies: + "@keep-network/sortition-pools" "^2.0.0-pre.16" + "@openzeppelin/contracts" "^4.6.0" + "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" + "@threshold-network/solidity-contracts" "1.3.0-dev.3" + +"@keep-network/random-beacon@2.1.0-dev.9": + version "2.1.0-dev.9" + resolved "https://registry.yarnpkg.com/@keep-network/random-beacon/-/random-beacon-2.1.0-dev.9.tgz#1058f1eff13e12d2831ec13fa61ecca399d92247" + integrity sha512-W4/AgMRWbYU4NO7YB0URbicjH89DMYHlOCT+GbyL/znZ7DLhLXzZCMJW4EvxM1lm8/wA6NsZev/2E25mHeqDIA== + dependencies: + "@keep-network/sortition-pools" "^2.0.0-pre.16" + "@openzeppelin/contracts" "^4.6.0" + "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" + "@threshold-network/solidity-contracts" "1.3.0-dev.3" + +"@keep-network/sortition-pools@1.2.0-dev.1": + version "1.2.0-dev.1" + resolved "https://registry.yarnpkg.com/@keep-network/sortition-pools/-/sortition-pools-1.2.0-dev.1.tgz#2ee371f1dd1ff71f6d05c9ddc2a83a4a93ff56b3" + integrity sha512-CaOsvxNWHgXRFwPThDn3C/LiCwq9pL8ICLXXkysRSLw1Hx69wLnToaXYuwyXeIEy5pGqe5+288DBIqvJ3T4+jA== + dependencies: + "@openzeppelin/contracts" "^2.4.0" + +"@keep-network/sortition-pools@^2.0.0-pre.16": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@keep-network/sortition-pools/-/sortition-pools-2.0.0.tgz#04e29ec756d74e00d13505a3e2a7763b06d7a08d" + integrity sha512-82pDOKcDBvHBFblCt0ALVr6qC6mxk339ZqnCfYx1zIPaPhzkw1RKOv28AqPoqzhzcdqLIoPh8g9RS/M2Lplh1A== + dependencies: + "@openzeppelin/contracts" "^4.3.2" + "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" + +"@keep-network/tbtc-v2@development": + version "1.4.0-dev.0" + resolved "https://registry.yarnpkg.com/@keep-network/tbtc-v2/-/tbtc-v2-1.4.0-dev.0.tgz#3c3b40d36917ad3e35a4f64d4b45f64e6ce46b8a" + integrity sha512-aOoo+WxgV8eR03z0vjstG7lX0q9B5K4VAi7GYT8lVO0uLErXpHawveNZKNnt+DBh4Sp1c3IZuF21EYJKKCLEyw== + dependencies: + "@keep-network/bitcoin-spv-sol" "3.4.0-solc-0.8" + "@keep-network/ecdsa" "2.1.0-dev.10" + "@keep-network/random-beacon" "2.1.0-dev.9" + "@keep-network/tbtc" "1.1.2-dev.1" + "@openzeppelin/contracts" "^4.8.1" + "@openzeppelin/contracts-upgradeable" "^4.8.1" + "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" + +"@keep-network/tbtc@1.1.2-dev.1": + version "1.1.2-dev.1" + resolved "https://registry.yarnpkg.com/@keep-network/tbtc/-/tbtc-1.1.2-dev.1.tgz#dd1e734c0fed50474c74d7170c8749127231d1f9" + integrity sha512-IRa0j1D7JBG8UpduaFxkaq2Ii6F61HhNMUBmxr7kAIZwj/yx8sYXWi921mn0L2Z+hAYNcwEUVhCM91VKQH29pQ== + dependencies: + "@celo/contractkit" "^1.0.2" + "@keep-network/keep-ecdsa" ">1.9.0-dev <1.9.0-ropsten" + "@summa-tx/bitcoin-spv-sol" "^3.1.0" + "@summa-tx/relay-sol" "^2.0.2" + openzeppelin-solidity "2.3.0" + +"@ledgerhq/cryptoassets@^5.53.0": + version "5.53.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/cryptoassets/-/cryptoassets-5.53.0.tgz#11dcc93211960c6fd6620392e4dd91896aaabe58" + integrity sha512-M3ibc3LRuHid5UtL7FI3IC6nMEppvly98QHFoSa7lJU0HDzQxY6zHec/SPM4uuJUC8sXoGVAiRJDkgny54damw== + dependencies: + invariant "2" + +"@ledgerhq/devices@^5.51.1": + version "5.51.1" + resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-5.51.1.tgz#d741a4a5d8f17c2f9d282fd27147e6fe1999edb7" + integrity sha512-4w+P0VkbjzEXC7kv8T1GJ/9AVaP9I6uasMZ/JcdwZBS3qwvKo5A5z9uGhP5c7TvItzcmPb44b5Mw2kT+WjUuAA== + dependencies: + "@ledgerhq/errors" "^5.50.0" + "@ledgerhq/logs" "^5.50.0" + rxjs "6" + semver "^7.3.5" + +"@ledgerhq/errors@^5.50.0": + version "5.50.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-5.50.0.tgz#e3a6834cb8c19346efca214c1af84ed28e69dad9" + integrity sha512-gu6aJ/BHuRlpU7kgVpy2vcYk6atjB4iauP2ymF7Gk0ez0Y/6VSMVSJvubeEQN+IV60+OBK0JgeIZG7OiHaw8ow== + +"@ledgerhq/hw-app-eth@^5.11.0": + version "5.53.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-eth/-/hw-app-eth-5.53.0.tgz#5df2d7427db9f387099d0cc437e9730101d7c404" + integrity sha512-LKi/lDA9tW0GdoYP1ng0VY/PXNYjSrwZ1cj0R0MQ9z+knmFlPcVkGK2MEqE8W8cXrC0tjsUXITMcngvpk5yfKA== + dependencies: + "@ledgerhq/cryptoassets" "^5.53.0" + "@ledgerhq/errors" "^5.50.0" + "@ledgerhq/hw-transport" "^5.51.1" + "@ledgerhq/logs" "^5.50.0" + bignumber.js "^9.0.1" + ethers "^5.2.0" + +"@ledgerhq/hw-transport@^5.11.0", "@ledgerhq/hw-transport@^5.51.1": + version "5.51.1" + resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-5.51.1.tgz#8dd14a8e58cbee4df0c29eaeef983a79f5f22578" + integrity sha512-6wDYdbWrw9VwHIcoDnqWBaDFyviyjZWv6H9vz9Vyhe4Qd7TIFmbTl/eWs6hZvtZBza9K8y7zD8ChHwRI4s9tSw== + dependencies: + "@ledgerhq/devices" "^5.51.1" + "@ledgerhq/errors" "^5.50.0" + events "^3.3.0" + +"@ledgerhq/logs@^5.50.0": + version "5.50.0" + resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-5.50.0.tgz#29c6419e8379d496ab6d0426eadf3c4d100cd186" + integrity sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA== + +"@metamask/eth-sig-util@^4.0.0": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@metamask/eth-sig-util/-/eth-sig-util-4.0.1.tgz#3ad61f6ea9ad73ba5b19db780d40d9aae5157088" + integrity sha512-tghyZKLHZjcdlDqCA3gNZmLeR0XvOE9U1qoQO9ohyAZT6Pya+H9vkBPcsyXytmYLNgVoin7CKCmweo/R43V+tQ== + dependencies: + ethereumjs-abi "^0.6.8" + ethereumjs-util "^6.2.1" + ethjs-util "^0.1.6" + tweetnacl "^1.0.3" + tweetnacl-util "^0.15.1" + +"@morgan-stanley/ts-mocking-bird@^0.6.2": + version "0.6.4" + resolved "https://registry.yarnpkg.com/@morgan-stanley/ts-mocking-bird/-/ts-mocking-bird-0.6.4.tgz#2e4b60d42957bab3b50b67dbf14c3da2f62a39f7" + integrity sha512-57VJIflP8eR2xXa9cD1LUawh+Gh+BVQfVu0n6GALyg/AqV/Nz25kDRvws3i9kIe1PTrbsZZOYpsYp6bXPd6nVA== + dependencies: + lodash "^4.17.16" + uuid "^7.0.3" + +"@noble/hashes@1.2.0", "@noble/hashes@~1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.2.0.tgz#a3150eeb09cc7ab207ebf6d7b9ad311a9bdbed12" + integrity sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ== + +"@noble/secp256k1@1.7.1", "@noble/secp256k1@~1.7.0": + version "1.7.1" + resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c" + integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw== + +"@nodelib/fs.scandir@2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" + integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== + dependencies: + "@nodelib/fs.stat" "2.0.5" + run-parallel "^1.1.9" + +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" + integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== + +"@nodelib/fs.walk@^1.2.3": + version "1.2.8" + resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" + integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== + dependencies: + "@nodelib/fs.scandir" "2.1.5" + fastq "^1.6.0" + +"@nomicfoundation/ethereumjs-block@4.2.2", "@nomicfoundation/ethereumjs-block@^4.0.0": + version "4.2.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-block/-/ethereumjs-block-4.2.2.tgz#f317078c810a54381c682d0c12e1e81acfc11599" + integrity sha512-atjpt4gc6ZGZUPHBAQaUJsm1l/VCo7FmyQ780tMGO8QStjLdhz09dXynmhwVTy5YbRr0FOh/uX3QaEM0yIB2Zg== + dependencies: + "@nomicfoundation/ethereumjs-common" "3.1.2" + "@nomicfoundation/ethereumjs-rlp" "4.0.3" + "@nomicfoundation/ethereumjs-trie" "5.0.5" + "@nomicfoundation/ethereumjs-tx" "4.1.2" + "@nomicfoundation/ethereumjs-util" "8.0.6" + ethereum-cryptography "0.1.3" + +"@nomicfoundation/ethereumjs-blockchain@6.2.2", "@nomicfoundation/ethereumjs-blockchain@^6.0.0": + version "6.2.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-blockchain/-/ethereumjs-blockchain-6.2.2.tgz#9f79dd2b3dc73f5d5a220f7d8a734330c4c26320" + integrity sha512-6AIB2MoTEPZJLl6IRKcbd8mUmaBAQ/NMe3O7OsAOIiDjMNPPH5KaUQiLfbVlegT4wKIg/GOsFH7XlH2KDVoJNg== + dependencies: + "@nomicfoundation/ethereumjs-block" "4.2.2" + "@nomicfoundation/ethereumjs-common" "3.1.2" + "@nomicfoundation/ethereumjs-ethash" "2.0.5" + "@nomicfoundation/ethereumjs-rlp" "4.0.3" + "@nomicfoundation/ethereumjs-trie" "5.0.5" + "@nomicfoundation/ethereumjs-util" "8.0.6" + abstract-level "^1.0.3" + debug "^4.3.3" + ethereum-cryptography "0.1.3" + level "^8.0.0" + lru-cache "^5.1.1" + memory-level "^1.0.0" + +"@nomicfoundation/ethereumjs-common@3.1.2", "@nomicfoundation/ethereumjs-common@^3.0.0": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-common/-/ethereumjs-common-3.1.2.tgz#041086da66ed40f2bf2a2116a1f2f0fcf33fb80d" + integrity sha512-JAEBpIua62dyObHM9KI2b4wHZcRQYYge9gxiygTWa3lNCr2zo+K0TbypDpgiNij5MCGNWP1eboNfNfx1a3vkvA== + dependencies: + "@nomicfoundation/ethereumjs-util" "8.0.6" + crc-32 "^1.2.0" + +"@nomicfoundation/ethereumjs-ethash@2.0.5": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-ethash/-/ethereumjs-ethash-2.0.5.tgz#0c605812f6f4589a9f6d597db537bbf3b86469db" + integrity sha512-xlLdcICGgAYyYmnI3r1t0R5fKGBJNDQSOQxXNjVO99JmxJIdXR5MgPo5CSJO1RpyzKOgzi3uIFn8agv564dZEQ== + dependencies: + "@nomicfoundation/ethereumjs-block" "4.2.2" + "@nomicfoundation/ethereumjs-rlp" "4.0.3" + "@nomicfoundation/ethereumjs-util" "8.0.6" + abstract-level "^1.0.3" + bigint-crypto-utils "^3.0.23" + ethereum-cryptography "0.1.3" + +"@nomicfoundation/ethereumjs-evm@1.3.2", "@nomicfoundation/ethereumjs-evm@^1.0.0": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-evm/-/ethereumjs-evm-1.3.2.tgz#f9d6bafd5c23d07ab75b8649d589af1a43b60bfc" + integrity sha512-I00d4MwXuobyoqdPe/12dxUQxTYzX8OckSaWsMcWAfQhgVDvBx6ffPyP/w1aL0NW7MjyerySPcSVfDJAMHjilw== + dependencies: + "@nomicfoundation/ethereumjs-common" "3.1.2" + "@nomicfoundation/ethereumjs-util" "8.0.6" + "@types/async-eventemitter" "^0.2.1" + async-eventemitter "^0.2.4" + debug "^4.3.3" + ethereum-cryptography "0.1.3" + mcl-wasm "^0.7.1" + rustbn.js "~0.2.0" + +"@nomicfoundation/ethereumjs-rlp@4.0.3", "@nomicfoundation/ethereumjs-rlp@^4.0.0": + version "4.0.3" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-rlp/-/ethereumjs-rlp-4.0.3.tgz#8d9147fbd0d49e8f4c5ce729d226694a8fe03eb8" + integrity sha512-DZMzB/lqPK78T6MluyXqtlRmOMcsZbTTbbEyAjo0ncaff2mqu/k8a79PBcyvpgAhWD/R59Fjq/x3ro5Lof0AtA== + +"@nomicfoundation/ethereumjs-statemanager@1.0.5", "@nomicfoundation/ethereumjs-statemanager@^1.0.0": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-statemanager/-/ethereumjs-statemanager-1.0.5.tgz#951cc9ff2c421d40233d2e9d0fe033db2391ee44" + integrity sha512-CAhzpzTR5toh/qOJIZUUOnWekUXuRqkkzaGAQrVcF457VhtCmr+ddZjjK50KNZ524c1XP8cISguEVNqJ6ij1sA== + dependencies: + "@nomicfoundation/ethereumjs-common" "3.1.2" + "@nomicfoundation/ethereumjs-rlp" "4.0.3" + "@nomicfoundation/ethereumjs-trie" "5.0.5" + "@nomicfoundation/ethereumjs-util" "8.0.6" + debug "^4.3.3" + ethereum-cryptography "0.1.3" + functional-red-black-tree "^1.0.1" + +"@nomicfoundation/ethereumjs-trie@5.0.5", "@nomicfoundation/ethereumjs-trie@^5.0.0": + version "5.0.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-trie/-/ethereumjs-trie-5.0.5.tgz#bf31c9306dcbba2007fad668e96109ddb147040c" + integrity sha512-+8sNZrXkzvA1NH5F4kz5RSYl1I6iaRz7mAZRsyxOm0IVY4UaP43Ofvfp/TwOalFunurQrYB5pRO40+8FBcxFMA== + dependencies: + "@nomicfoundation/ethereumjs-rlp" "4.0.3" + "@nomicfoundation/ethereumjs-util" "8.0.6" + ethereum-cryptography "0.1.3" + readable-stream "^3.6.0" + +"@nomicfoundation/ethereumjs-tx@4.1.2", "@nomicfoundation/ethereumjs-tx@^4.0.0": + version "4.1.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-tx/-/ethereumjs-tx-4.1.2.tgz#8659fad7f9094b7eb82aa6cc3c8097cb1c42ff31" + integrity sha512-emJBJZpmTdUa09cqxQqHaysbBI9Od353ZazeH7WgPb35miMgNY6mb7/3vBA98N5lUW/rgkiItjX0KZfIzihSoQ== + dependencies: + "@nomicfoundation/ethereumjs-common" "3.1.2" + "@nomicfoundation/ethereumjs-rlp" "4.0.3" + "@nomicfoundation/ethereumjs-util" "8.0.6" + ethereum-cryptography "0.1.3" + +"@nomicfoundation/ethereumjs-util@8.0.6", "@nomicfoundation/ethereumjs-util@^8.0.0": + version "8.0.6" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-util/-/ethereumjs-util-8.0.6.tgz#dbce5d258b017b37aa58b3a7c330ad59d10ccf0b" + integrity sha512-jOQfF44laa7xRfbfLXojdlcpkvxeHrE2Xu7tSeITsWFgoII163MzjOwFEzSNozHYieFysyoEMhCdP+NY5ikstw== + dependencies: + "@nomicfoundation/ethereumjs-rlp" "4.0.3" + ethereum-cryptography "0.1.3" + +"@nomicfoundation/ethereumjs-vm@^6.0.0": + version "6.4.2" + resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-vm/-/ethereumjs-vm-6.4.2.tgz#af1cf62e6c0054bc2b7febc8556d032433d1b18c" + integrity sha512-PRTyxZMP6kx+OdAzBhuH1LD2Yw+hrSpaytftvaK//thDy2OI07S0nrTdbrdk7b8ZVPAc9H9oTwFBl3/wJ3w15g== + dependencies: + "@nomicfoundation/ethereumjs-block" "4.2.2" + "@nomicfoundation/ethereumjs-blockchain" "6.2.2" + "@nomicfoundation/ethereumjs-common" "3.1.2" + "@nomicfoundation/ethereumjs-evm" "1.3.2" + "@nomicfoundation/ethereumjs-rlp" "4.0.3" + "@nomicfoundation/ethereumjs-statemanager" "1.0.5" + "@nomicfoundation/ethereumjs-trie" "5.0.5" + "@nomicfoundation/ethereumjs-tx" "4.1.2" + "@nomicfoundation/ethereumjs-util" "8.0.6" + "@types/async-eventemitter" "^0.2.1" + async-eventemitter "^0.2.4" + debug "^4.3.3" + ethereum-cryptography "0.1.3" + functional-red-black-tree "^1.0.1" + mcl-wasm "^0.7.1" + rustbn.js "~0.2.0" + +"@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.1.1.tgz#4c858096b1c17fe58a474fe81b46815f93645c15" + integrity sha512-KcTodaQw8ivDZyF+D76FokN/HdpgGpfjc/gFCImdLUyqB6eSWVaZPazMbeAjmfhx3R0zm/NYVzxwAokFKgrc0w== + +"@nomicfoundation/solidity-analyzer-darwin-x64@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-darwin-x64/-/solidity-analyzer-darwin-x64-0.1.1.tgz#6e25ccdf6e2d22389c35553b64fe6f3fdaec432c" + integrity sha512-XhQG4BaJE6cIbjAVtzGOGbK3sn1BO9W29uhk9J8y8fZF1DYz0Doj8QDMfpMu+A6TjPDs61lbsmeYodIDnfveSA== + +"@nomicfoundation/solidity-analyzer-freebsd-x64@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-freebsd-x64/-/solidity-analyzer-freebsd-x64-0.1.1.tgz#0a224ea50317139caeebcdedd435c28a039d169c" + integrity sha512-GHF1VKRdHW3G8CndkwdaeLkVBi5A9u2jwtlS7SLhBc8b5U/GcoL39Q+1CSO3hYqePNP+eV5YI7Zgm0ea6kMHoA== + +"@nomicfoundation/solidity-analyzer-linux-arm64-gnu@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-gnu/-/solidity-analyzer-linux-arm64-gnu-0.1.1.tgz#dfa085d9ffab9efb2e7b383aed3f557f7687ac2b" + integrity sha512-g4Cv2fO37ZsUENQ2vwPnZc2zRenHyAxHcyBjKcjaSmmkKrFr64yvzeNO8S3GBFCo90rfochLs99wFVGT/0owpg== + +"@nomicfoundation/solidity-analyzer-linux-arm64-musl@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-arm64-musl/-/solidity-analyzer-linux-arm64-musl-0.1.1.tgz#c9e06b5d513dd3ab02a7ac069c160051675889a4" + integrity sha512-WJ3CE5Oek25OGE3WwzK7oaopY8xMw9Lhb0mlYuJl/maZVo+WtP36XoQTb7bW/i8aAdHW5Z+BqrHMux23pvxG3w== + +"@nomicfoundation/solidity-analyzer-linux-x64-gnu@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-gnu/-/solidity-analyzer-linux-x64-gnu-0.1.1.tgz#8d328d16839e52571f72f2998c81e46bf320f893" + integrity sha512-5WN7leSr5fkUBBjE4f3wKENUy9HQStu7HmWqbtknfXkkil+eNWiBV275IOlpXku7v3uLsXTOKpnnGHJYI2qsdA== + +"@nomicfoundation/solidity-analyzer-linux-x64-musl@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-linux-x64-musl/-/solidity-analyzer-linux-x64-musl-0.1.1.tgz#9b49d0634b5976bb5ed1604a1e1b736f390959bb" + integrity sha512-KdYMkJOq0SYPQMmErv/63CwGwMm5XHenEna9X9aB8mQmhDBrYrlAOSsIPgFCUSL0hjxE3xHP65/EPXR/InD2+w== + +"@nomicfoundation/solidity-analyzer-win32-arm64-msvc@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-arm64-msvc/-/solidity-analyzer-win32-arm64-msvc-0.1.1.tgz#e2867af7264ebbcc3131ef837878955dd6a3676f" + integrity sha512-VFZASBfl4qiBYwW5xeY20exWhmv6ww9sWu/krWSesv3q5hA0o1JuzmPHR4LPN6SUZj5vcqci0O6JOL8BPw+APg== + +"@nomicfoundation/solidity-analyzer-win32-ia32-msvc@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-ia32-msvc/-/solidity-analyzer-win32-ia32-msvc-0.1.1.tgz#0685f78608dd516c8cdfb4896ed451317e559585" + integrity sha512-JnFkYuyCSA70j6Si6cS1A9Gh1aHTEb8kOTBApp/c7NRTFGNMH8eaInKlyuuiIbvYFhlXW4LicqyYuWNNq9hkpQ== + +"@nomicfoundation/solidity-analyzer-win32-x64-msvc@0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer-win32-x64-msvc/-/solidity-analyzer-win32-x64-msvc-0.1.1.tgz#c9a44f7108646f083b82e851486e0f6aeb785836" + integrity sha512-HrVJr6+WjIXGnw3Q9u6KQcbZCtk0caVWhCdFADySvRyUxJ8PnzlaP+MhwNE8oyT8OZ6ejHBRrrgjSqDCFXGirw== + +"@nomicfoundation/solidity-analyzer@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nomicfoundation/solidity-analyzer/-/solidity-analyzer-0.1.1.tgz#f5f4d36d3f66752f59a57e7208cd856f3ddf6f2d" + integrity sha512-1LMtXj1puAxyFusBgUIy5pZk3073cNXYnXUpuNKFghHbIit/xZgbk0AokpUADbNm3gyD6bFWl3LRFh3dhVdREg== + optionalDependencies: + "@nomicfoundation/solidity-analyzer-darwin-arm64" "0.1.1" + "@nomicfoundation/solidity-analyzer-darwin-x64" "0.1.1" + "@nomicfoundation/solidity-analyzer-freebsd-x64" "0.1.1" + "@nomicfoundation/solidity-analyzer-linux-arm64-gnu" "0.1.1" + "@nomicfoundation/solidity-analyzer-linux-arm64-musl" "0.1.1" + "@nomicfoundation/solidity-analyzer-linux-x64-gnu" "0.1.1" + "@nomicfoundation/solidity-analyzer-linux-x64-musl" "0.1.1" + "@nomicfoundation/solidity-analyzer-win32-arm64-msvc" "0.1.1" + "@nomicfoundation/solidity-analyzer-win32-ia32-msvc" "0.1.1" + "@nomicfoundation/solidity-analyzer-win32-x64-msvc" "0.1.1" + +"@nomiclabs/hardhat-ethers@^2.0.6": + version "2.2.2" + resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.2.tgz#812d48929c3bf8fe840ec29eab4b613693467679" + integrity sha512-NLDlDFL2us07C0jB/9wzvR0kuLivChJWCXTKcj3yqjZqMoYp7g7wwS157F70VHx/+9gHIBGzak5pKDwG8gEefA== + +"@nomiclabs/hardhat-etherscan@3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-3.1.0.tgz#7137554862b3b1c914f1b1bf110f0529fd2dec53" + integrity sha512-JroYgfN1AlYFkQTQ3nRwFi4o8NtZF7K/qFR2dxDUgHbCtIagkUseca9L4E/D2ScUm4XT40+8PbCdqZi+XmHyQA== + dependencies: + "@ethersproject/abi" "^5.1.2" + "@ethersproject/address" "^5.0.2" + cbor "^5.0.2" + chalk "^2.4.2" + debug "^4.1.1" + fs-extra "^7.0.1" + lodash "^4.17.11" + semver "^6.3.0" + table "^6.8.0" + undici "^5.4.0" + +"@nomiclabs/hardhat-waffle@2.0.3": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-waffle/-/hardhat-waffle-2.0.3.tgz#9c538a09c5ed89f68f5fd2dc3f78f16ed1d6e0b1" + integrity sha512-049PHSnI1CZq6+XTbrMbMv5NaL7cednTfPenx02k3cEh8wBMLa6ys++dBETJa6JjfwgA9nBhhHQ173LJv6k2Pg== + dependencies: + "@types/sinon-chai" "^3.2.3" + "@types/web3" "1.0.19" + +"@openzeppelin/contracts-upgradeable@^4.6.0", "@openzeppelin/contracts-upgradeable@^4.8.1": + version "4.8.2" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.8.2.tgz#edef522bdbc46d478481391553bababdd2199e27" + integrity sha512-zIggnBwemUmmt9IS73qxi+tumALxCY4QEs3zLCII78k0Gfse2hAOdAkuAeLUzvWUpneMUfFE5sGHzEUSTvn4Ag== + +"@openzeppelin/contracts-upgradeable@~4.5.2": + version "4.5.2" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.5.2.tgz#90d9e47bacfd8693bfad0ac8a394645575528d05" + integrity sha512-xgWZYaPlrEOQo3cBj97Ufiuv79SPd8Brh4GcFYhPgb6WvAq4ppz8dWKL6h+jLAK01rUqMRp/TS9AdXgAeNvCLA== + +"@openzeppelin/contracts@^2.4.0": + version "2.5.1" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-2.5.1.tgz#c76e3fc57aa224da3718ec351812a4251289db31" + integrity sha512-qIy6tLx8rtybEsIOAlrM4J/85s2q2nPkDqj/Rx46VakBZ0LwtFhXIVub96LXHczQX0vaqmAueDqNPXtbSXSaYQ== + +"@openzeppelin/contracts@^4.1.0", "@openzeppelin/contracts@^4.3.2", "@openzeppelin/contracts@^4.6.0", "@openzeppelin/contracts@^4.8.1": + version "4.8.2" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.2.tgz#d815ade0027b50beb9bcca67143c6bcc3e3923d6" + integrity sha512-kEUOgPQszC0fSYWpbh2kT94ltOJwj1qfT2DWo+zVttmGmf97JZ99LspePNaeeaLhCImaHVeBbjaQFZQn7+Zc5g== + +"@openzeppelin/contracts@~4.5.0": + version "4.5.0" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.5.0.tgz#3fd75d57de172b3743cdfc1206883f56430409cc" + integrity sha512-fdkzKPYMjrRiPK6K4y64e6GzULR7R7RwxSigHS8DDp7aWDeoReqsQI+cxHV1UuhAqX69L1lAaWDxenfP+xiqzA== + +"@openzeppelin/defender-base-client@^1.46.0": + version "1.47.0" + resolved "https://registry.yarnpkg.com/@openzeppelin/defender-base-client/-/defender-base-client-1.47.0.tgz#f9d47f4cf0a75b4e4e5139dec780a3f26f5e2019" + integrity sha512-y9dDm+gX0MHHEn17W7f7oO3X083JAVMk3YcuXHavSE7kjiCLoFOaZ23joYqoHeaccL10nGt7KOOzZ0sh9iJHTQ== + dependencies: + amazon-cognito-identity-js "^6.0.1" + async-retry "^1.3.3" + axios "^1.4.0" + lodash "^4.17.19" + node-fetch "^2.6.0" + +"@openzeppelin/hardhat-upgrades@^1.20.0": + version "1.28.0" + resolved "https://registry.yarnpkg.com/@openzeppelin/hardhat-upgrades/-/hardhat-upgrades-1.28.0.tgz#6361f313a8a879d8a08a5e395acf0933bc190950" + integrity sha512-7sb/Jf+X+uIufOBnmHR0FJVWuxEs2lpxjJnLNN6eCJCP8nD0v+Ot5lTOW2Qb/GFnh+fLvJtEkhkowz4ZQ57+zQ== + dependencies: + "@openzeppelin/defender-base-client" "^1.46.0" + "@openzeppelin/platform-deploy-client" "^0.8.0" + "@openzeppelin/upgrades-core" "^1.27.0" + chalk "^4.1.0" + debug "^4.1.1" + proper-lockfile "^4.1.1" + +"@openzeppelin/platform-deploy-client@^0.8.0": + version "0.8.0" + resolved "https://registry.yarnpkg.com/@openzeppelin/platform-deploy-client/-/platform-deploy-client-0.8.0.tgz#af6596275a19c283d6145f0128cc1247d18223c1" + integrity sha512-POx3AsnKwKSV/ZLOU/gheksj0Lq7Is1q2F3pKmcFjGZiibf+4kjGxr4eSMrT+2qgKYZQH1ZLQZ+SkbguD8fTvA== + dependencies: + "@ethersproject/abi" "^5.6.3" + "@openzeppelin/defender-base-client" "^1.46.0" + axios "^0.21.2" + lodash "^4.17.19" + node-fetch "^2.6.0" + +"@openzeppelin/upgrades-core@^1.27.0": + version "1.27.3" + resolved "https://registry.yarnpkg.com/@openzeppelin/upgrades-core/-/upgrades-core-1.27.3.tgz#d5578e3a3ccd18a61fc585945be67951480238b5" + integrity sha512-IqlSMUkno1XKF4L46aUqZ4BqHxj4dF0BRGrFcKeG2Q0vrsKoazhY67JG9bO+wMYG4zxl6jgmG0bd5ef9HLcLmw== + dependencies: + cbor "^8.0.0" + chalk "^4.1.0" + compare-versions "^6.0.0" + debug "^4.1.1" + ethereumjs-util "^7.0.3" + minimist "^1.2.7" + proper-lockfile "^4.1.1" + solidity-ast "^0.4.15" + +"@openzeppelin/upgrades@^2.7.2": + version "2.8.0" + resolved "https://registry.yarnpkg.com/@openzeppelin/upgrades/-/upgrades-2.8.0.tgz#8086ab9c99d9f8dac7205030b0f9e7e4a280c4a3" + integrity sha512-LzjTQPeljPsgHDPdZyH9cMCbIHZILgd2cpNcYEkdsC2IylBYRHShlbEDXJV9snnqg9JWfzPiKIqyj3XVliwtqQ== + dependencies: + "@types/cbor" "^2.0.0" + axios "^0.18.0" + bignumber.js "^7.2.0" + cbor "^4.1.5" + chalk "^2.4.1" + ethers "^4.0.20" + glob "^7.1.3" + lodash "^4.17.15" + semver "^5.5.1" + spinnies "^0.4.2" + truffle-flattener "^1.4.0" + web3 "1.2.2" + web3-eth "1.2.2" + web3-eth-contract "1.2.2" + web3-utils "1.2.2" + +"@resolver-engine/core@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@resolver-engine/core/-/core-0.2.1.tgz#0d71803f6d3b8cb2e9ed481a1bf0ca5f5256d0c0" + integrity sha512-nsLQHmPJ77QuifqsIvqjaF5B9aHnDzJjp73Q1z6apY3e9nqYrx4Dtowhpsf7Jwftg/XzVDEMQC+OzUBNTS+S1A== + dependencies: + debug "^3.1.0" + request "^2.85.0" + +"@resolver-engine/core@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@resolver-engine/core/-/core-0.3.3.tgz#590f77d85d45bc7ecc4e06c654f41345db6ca967" + integrity sha512-eB8nEbKDJJBi5p5SrvrvILn4a0h42bKtbCTri3ZxCGt6UvoQyp7HnGOfki944bUjBSHKK3RvgfViHn+kqdXtnQ== + dependencies: + debug "^3.1.0" + is-url "^1.2.4" + request "^2.85.0" + +"@resolver-engine/fs@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@resolver-engine/fs/-/fs-0.2.1.tgz#f98a308d77568cc02651d03636f46536b941b241" + integrity sha512-7kJInM1Qo2LJcKyDhuYzh9ZWd+mal/fynfL9BNjWOiTcOpX+jNfqb/UmGUqros5pceBITlWGqS4lU709yHFUbg== + dependencies: + "@resolver-engine/core" "^0.2.1" + debug "^3.1.0" + +"@resolver-engine/fs@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@resolver-engine/fs/-/fs-0.3.3.tgz#fbf83fa0c4f60154a82c817d2fe3f3b0c049a973" + integrity sha512-wQ9RhPUcny02Wm0IuJwYMyAG8fXVeKdmhm8xizNByD4ryZlx6PP6kRen+t/haF43cMfmaV7T3Cx6ChOdHEhFUQ== + dependencies: + "@resolver-engine/core" "^0.3.3" + debug "^3.1.0" + +"@resolver-engine/imports-fs@^0.2.2": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@resolver-engine/imports-fs/-/imports-fs-0.2.2.tgz#5a81ef3285dbf0411ab3b15205080a1ad7622d9e" + integrity sha512-gFCgMvCwyppjwq0UzIjde/WI+yDs3oatJhozG9xdjJdewwtd7LiF0T5i9lrHAUtqrQbqoFE4E+ZMRVHWpWHpKQ== + dependencies: + "@resolver-engine/fs" "^0.2.1" + "@resolver-engine/imports" "^0.2.2" + debug "^3.1.0" + +"@resolver-engine/imports-fs@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@resolver-engine/imports-fs/-/imports-fs-0.3.3.tgz#4085db4b8d3c03feb7a425fbfcf5325c0d1e6c1b" + integrity sha512-7Pjg/ZAZtxpeyCFlZR5zqYkz+Wdo84ugB5LApwriT8XFeQoLwGUj4tZFFvvCuxaNCcqZzCYbonJgmGObYBzyCA== + dependencies: + "@resolver-engine/fs" "^0.3.3" + "@resolver-engine/imports" "^0.3.3" + debug "^3.1.0" + +"@resolver-engine/imports@^0.2.2": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@resolver-engine/imports/-/imports-0.2.2.tgz#d3de55a1bb5f3beb7703fdde743298f321175843" + integrity sha512-u5/HUkvo8q34AA+hnxxqqXGfby5swnH0Myw91o3Sm2TETJlNKXibFGSKBavAH+wvWdBi4Z5gS2Odu0PowgVOUg== + dependencies: + "@resolver-engine/core" "^0.2.1" + debug "^3.1.0" + hosted-git-info "^2.6.0" + +"@resolver-engine/imports@^0.3.3": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@resolver-engine/imports/-/imports-0.3.3.tgz#badfb513bb3ff3c1ee9fd56073e3144245588bcc" + integrity sha512-anHpS4wN4sRMwsAbMXhMfOD/y4a4Oo0Cw/5+rue7hSwGWsDOQaAU1ClK1OxjUC35/peazxEl8JaSRRS+Xb8t3Q== + dependencies: + "@resolver-engine/core" "^0.3.3" + debug "^3.1.0" + hosted-git-info "^2.6.0" + path-browserify "^1.0.0" + url "^0.11.0" + +"@scure/base@~1.1.0": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.1.tgz#ebb651ee52ff84f420097055f4bf46cfba403938" + integrity sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA== + +"@scure/bip32@1.1.5": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.1.5.tgz#d2ccae16dcc2e75bc1d75f5ef3c66a338d1ba300" + integrity sha512-XyNh1rB0SkEqd3tXcXMi+Xe1fvg+kUIcoRIEujP1Jgv7DqW2r9lg3Ah0NkFaCs9sTkQAQA8kw7xiRXzENi9Rtw== + dependencies: + "@noble/hashes" "~1.2.0" + "@noble/secp256k1" "~1.7.0" + "@scure/base" "~1.1.0" + +"@scure/bip39@1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.1.1.tgz#b54557b2e86214319405db819c4b6a370cf340c5" + integrity sha512-t+wDck2rVkh65Hmv280fYdVdY25J9YeEUIgn2LG1WM6gxFkGzcksoDiUkWVpVp3Oex9xGC68JU2dSbUfwZ2jPg== + dependencies: + "@noble/hashes" "~1.2.0" + "@scure/base" "~1.1.0" + +"@sentry/core@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.30.0.tgz#6b203664f69e75106ee8b5a2fe1d717379b331f3" + integrity sha512-TmfrII8w1PQZSZgPpUESqjB+jC6MvZJZdLtE/0hZ+SrnKhW3x5WlYLvTXZpcWePYBku7rl2wn1RZu6uT0qCTeg== + dependencies: + "@sentry/hub" "5.30.0" + "@sentry/minimal" "5.30.0" + "@sentry/types" "5.30.0" + "@sentry/utils" "5.30.0" + tslib "^1.9.3" + +"@sentry/hub@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.30.0.tgz#2453be9b9cb903404366e198bd30c7ca74cdc100" + integrity sha512-2tYrGnzb1gKz2EkMDQcfLrDTvmGcQPuWxLnJKXJvYTQDGLlEvi2tWz1VIHjunmOvJrB5aIQLhm+dcMRwFZDCqQ== + dependencies: + "@sentry/types" "5.30.0" + "@sentry/utils" "5.30.0" + tslib "^1.9.3" + +"@sentry/minimal@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.30.0.tgz#ce3d3a6a273428e0084adcb800bc12e72d34637b" + integrity sha512-BwWb/owZKtkDX+Sc4zCSTNcvZUq7YcH3uAVlmh/gtR9rmUvbzAA3ewLuB3myi4wWRAMEtny6+J/FN/x+2wn9Xw== + dependencies: + "@sentry/hub" "5.30.0" + "@sentry/types" "5.30.0" + tslib "^1.9.3" + +"@sentry/node@^5.18.1": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.30.0.tgz#4ca479e799b1021285d7fe12ac0858951c11cd48" + integrity sha512-Br5oyVBF0fZo6ZS9bxbJZG4ApAjRqAnqFFurMVJJdunNb80brh7a5Qva2kjhm+U6r9NJAB5OmDyPkA1Qnt+QVg== + dependencies: + "@sentry/core" "5.30.0" + "@sentry/hub" "5.30.0" + "@sentry/tracing" "5.30.0" + "@sentry/types" "5.30.0" + "@sentry/utils" "5.30.0" + cookie "^0.4.1" + https-proxy-agent "^5.0.0" + lru_map "^0.3.3" + tslib "^1.9.3" + +"@sentry/tracing@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-5.30.0.tgz#501d21f00c3f3be7f7635d8710da70d9419d4e1f" + integrity sha512-dUFowCr0AIMwiLD7Fs314Mdzcug+gBVo/+NCMyDw8tFxJkwWAKl7Qa2OZxLQ0ZHjakcj1hNKfCQJ9rhyfOl4Aw== + dependencies: + "@sentry/hub" "5.30.0" + "@sentry/minimal" "5.30.0" + "@sentry/types" "5.30.0" + "@sentry/utils" "5.30.0" + tslib "^1.9.3" + +"@sentry/types@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.30.0.tgz#19709bbe12a1a0115bc790b8942917da5636f402" + integrity sha512-R8xOqlSTZ+htqrfteCWU5Nk0CDN5ApUTvrlvBuiH1DyP6czDZ4ktbZB0hAgBlVcK0U+qpD3ag3Tqqpa5Q67rPw== + +"@sentry/utils@5.30.0": + version "5.30.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.30.0.tgz#9a5bd7ccff85ccfe7856d493bffa64cabc41e980" + integrity sha512-zaYmoH0NWWtvnJjC9/CBseXMtKHm/tm40sz3YfJRxeQjyzRqNQPgivpd9R/oDJCYj999mzdW382p/qi2ypjLww== + dependencies: + "@sentry/types" "5.30.0" + tslib "^1.9.3" + +"@sindresorhus/is@^0.14.0": + version "0.14.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" + integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== + +"@sindresorhus/is@^4.0.0": + version "4.6.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" + integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== + +"@smithy/types@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@smithy/types/-/types-2.0.2.tgz#49d42724c909e845bfd80a2e195740614ce497f3" + integrity sha512-wcymEjIXQ9+NEfE5Yt5TInAqe1o4n+Nh+rh00AwoazppmUt8tdo6URhc5gkDcOYrcvlDVAZE7uG69nDpEGUKxw== + dependencies: + tslib "^2.5.0" + +"@solidity-parser/parser@^0.13.2": + version "0.13.2" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.13.2.tgz#b6c71d8ca0b382d90a7bbed241f9bc110af65cbe" + integrity sha512-RwHnpRnfrnD2MSPveYoPh8nhofEvX7fgjHk1Oq+NNvCcLx4r1js91CO9o+F/F3fBzOCyvm8kKRTriFICX/odWw== + dependencies: + antlr4ts "^0.5.0-alpha.4" + +"@solidity-parser/parser@^0.14.0", "@solidity-parser/parser@^0.14.1": + version "0.14.5" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.14.5.tgz#87bc3cc7b068e08195c219c91cd8ddff5ef1a804" + integrity sha512-6dKnHZn7fg/iQATVEzqyUOyEidbn05q7YA2mQ9hC0MMXhhV3/JrsxmFSYZAcr7j1yUP700LLhTruvJ3MiQmjJg== + dependencies: + antlr4ts "^0.5.0-alpha.4" + +"@solidity-parser/parser@^0.16.0": + version "0.16.0" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.16.0.tgz#1fb418c816ca1fc3a1e94b08bcfe623ec4e1add4" + integrity sha512-ESipEcHyRHg4Np4SqBCfcXwyxxna1DgFVz69bgpLV8vzl/NP1DtcKsJ4dJZXWQhY/Z4J2LeKBiOkOVZn9ct33Q== + dependencies: + antlr4ts "^0.5.0-alpha.4" + +"@stablelib/binary@^0.7.2": + version "0.7.2" + resolved "https://registry.yarnpkg.com/@stablelib/binary/-/binary-0.7.2.tgz#1b3392170c8a8741c8b8f843ea294de71aeb2cf7" + integrity sha512-J7iGppeKR112ICTZTAoALcT3yBpTrd2Z/F0wwiOUZPVPTDFTQFWHZZdYzfal9+mY1uMUPRSEnNmDuXRZbtE8Xg== + dependencies: + "@stablelib/int" "^0.5.0" + +"@stablelib/blake2s@^0.10.4": + version "0.10.4" + resolved "https://registry.yarnpkg.com/@stablelib/blake2s/-/blake2s-0.10.4.tgz#8a708f28a9c78d4a1a9fbcc6ce8bacbda469f302" + integrity sha512-IasdklC7YfXXLmVbnsxqmd66+Ki+Ysbp0BtcrNxAtrGx/HRGjkUZbSTbEa7HxFhBWIstJRcE5ExgY+RCqAiULQ== + dependencies: + "@stablelib/binary" "^0.7.2" + "@stablelib/hash" "^0.5.0" + "@stablelib/wipe" "^0.5.0" + +"@stablelib/blake2xs@0.10.4": + version "0.10.4" + resolved "https://registry.yarnpkg.com/@stablelib/blake2xs/-/blake2xs-0.10.4.tgz#b3ae9e145cbf924a7f598412b586e4af24d10cb7" + integrity sha512-1N0S4cruso/StV9TmoujPGj3RU0Cy42wlZneBWLWby7m2ssnY57l/CsYQSm03TshOoYss4hqc5kwSy5pmWAdUA== + dependencies: + "@stablelib/blake2s" "^0.10.4" + "@stablelib/hash" "^0.5.0" + "@stablelib/wipe" "^0.5.0" + +"@stablelib/hash@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@stablelib/hash/-/hash-0.5.0.tgz#89fe9040a3d4383b1921c7d8a60948bc30846068" + integrity sha512-rlNEBTskjKVl9f4rpRgM2GV3IrZWfNJFY5Y/2tmQtA2ozEkPLoUp9J/uJnBRnOpCsuflPW2z+pwqPbEYOPCHwQ== + +"@stablelib/int@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@stablelib/int/-/int-0.5.0.tgz#cca9225951d55d2de48656755784788633660c2b" + integrity sha512-cuaPoxm3K14LiEICiA3iz0aeGurg75v+haZMV+xloVTw3CT25oMRJgQ6VxZ2p2cHy4kjhVI68kX4oaYrhnTm+g== + +"@stablelib/wipe@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@stablelib/wipe/-/wipe-0.5.0.tgz#a682d5f9448e950e099e537e6f72fc960275d151" + integrity sha512-SifvRV0rTTFR1qEF6G1hondGZyrmiM1laR8PPrO6TZwQG03hJduVbUX8uQk+Q6FdkND2Z9B8uLPyUAquQIk3iA== + +"@summa-tx/bitcoin-spv-sol@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@summa-tx/bitcoin-spv-sol/-/bitcoin-spv-sol-3.1.0.tgz#a2a5391f4430f7bbd87aa3a0bd403bf87a48b7d9" + integrity sha512-YIwxTNCTIsL+qgzcMhzQk9f0A7yQ6dimlLj4i3gGhWrnqBIg3ljBxJ/aj9JRQyIdNDoCPmqS2s8ZZIdyM+vaGQ== + +"@summa-tx/relay-sol@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@summa-tx/relay-sol/-/relay-sol-2.0.2.tgz#32078cf12c1fb7331cb64391bd90af2eb8827211" + integrity sha512-r5pNimQwpHklxrP+LAvNrhz4jdngVw8ret/98Ls1rLhleVCKKOFHpsRnh9zUzIDqlhIOOQwTZNe5wn7Ex63HNA== + dependencies: + "@celo/contractkit" "^0.3.3" + "@summa-tx/bitcoin-spv-sol" "^3.1.0" + bn.js "^5.1.1" + dotenv "^8.2.0" + +"@szmarczak/http-timer@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" + integrity sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA== + dependencies: + defer-to-connect "^1.0.1" + +"@szmarczak/http-timer@^4.0.5": + version "4.0.6" + resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807" + integrity sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w== + dependencies: + defer-to-connect "^2.0.0" + +"@thesis-co/eslint-config@github:thesis/eslint-config": + version "0.5.0-pre" + resolved "https://codeload.github.com/thesis/eslint-config/tar.gz/495d98594315527450bba336c4319acebcaebb7f" + dependencies: + "@thesis-co/prettier-config" "github:thesis/prettier-config" + "@typescript-eslint/eslint-plugin" ">4.32.0" + "@typescript-eslint/parser" ">4.32.0" + eslint-config-airbnb "^19.0.0" + eslint-config-airbnb-typescript "^17.0.0" + eslint-config-prettier "^8.5.0" + eslint-plugin-import "^2.26.0" + eslint-plugin-jsx-a11y "^6.6.1" + eslint-plugin-no-only-tests "^3.1.0" + eslint-plugin-prettier "^4.2.1" + eslint-plugin-react "^7.31.11" + eslint-plugin-react-hooks "^4.3.0" + +"@thesis-co/prettier-config@github:thesis/prettier-config": + version "0.0.1" + resolved "https://codeload.github.com/thesis/prettier-config/tar.gz/a057ca0bab89fee9ee81ac580c446618c722d75d" + +"@thesis/solidity-contracts@github:thesis/solidity-contracts#4985bcf": + version "0.0.1" + resolved "https://codeload.github.com/thesis/solidity-contracts/tar.gz/4985bcfc28e36eed9838993b16710e1b500f9e85" + dependencies: + "@openzeppelin/contracts" "^4.1.0" + +"@threshold-network/solidity-contracts@1.3.0-dev.3": + version "1.3.0-dev.3" + resolved "https://registry.yarnpkg.com/@threshold-network/solidity-contracts/-/solidity-contracts-1.3.0-dev.3.tgz#aa896b80a083ca8a7cb5219e3c9d1c47e3d86b03" + integrity sha512-BNm5+JKrFvg9hZ02Sp/A+vKs1PQB37rYdcZqLrLhvwDFzHFvL+XA2IXqvN1CznQTeehwnX3DtCcONTVP42i56A== + dependencies: + "@keep-network/keep-core" ">1.8.1-dev <1.8.1-goerli" + "@openzeppelin/contracts" "~4.5.0" + "@openzeppelin/contracts-upgradeable" "~4.5.2" + "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" + +"@tsconfig/node10@^1.0.7": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" + integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== + +"@tsconfig/node12@^1.0.7": + version "1.0.11" + resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" + integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== + +"@tsconfig/node14@^1.0.0": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" + integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== + +"@tsconfig/node16@^1.0.2": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e" + integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ== + +"@typechain/ethers-v5@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@typechain/ethers-v5/-/ethers-v5-2.0.0.tgz#cd3ca1590240d587ca301f4c029b67bfccd08810" + integrity sha512-0xdCkyGOzdqh4h5JSf+zoWx85IusEjDcPIwNEHP8mrWSnCae4rvrqB+/gtpdNfX7zjlFlZiMeePn2r63EI3Lrw== + dependencies: + ethers "^5.0.2" + +"@typechain/ethers-v5@^8.0.5": + version "8.0.5" + resolved "https://registry.yarnpkg.com/@typechain/ethers-v5/-/ethers-v5-8.0.5.tgz#d469420e9a73deb7fa076cde9edb45d713dd1b8c" + integrity sha512-ntpj4cS3v4WlDu+hSKSyj9A3o1tKtWC30RX1gobeYymZColeJiUemC1Kgfa0MWGmInm5CKxoHVhEvYVgPOZn1A== + dependencies: + lodash "^4.17.15" + ts-essentials "^7.0.1" + +"@typechain/hardhat@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@typechain/hardhat/-/hardhat-4.0.0.tgz#976d4dcc0d9237602d722801d30adc573c529981" + integrity sha512-SeEKtiHu4Io3LHhE8VV3orJbsj7dwJZX8pzSTv7WQR38P18vOLm2M52GrykVinMpkLK0uVc88ICT58emvfn74w== + dependencies: + fs-extra "^9.1.0" + +"@types/async-eventemitter@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@types/async-eventemitter/-/async-eventemitter-0.2.1.tgz#f8e6280e87e8c60b2b938624b0a3530fb3e24712" + integrity sha512-M2P4Ng26QbAeITiH7w1d7OxtldgfAe0wobpyJzVK/XOb0cUGKU2R4pfAhqcJBXAe2ife5ZOhSv4wk7p+ffURtg== + +"@types/bignumber.js@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@types/bignumber.js/-/bignumber.js-5.0.0.tgz#d9f1a378509f3010a3255e9cc822ad0eeb4ab969" + integrity sha512-0DH7aPGCClywOFaxxjE6UwpN2kQYe9LwuDQMv+zYA97j5GkOMo8e66LYT+a8JYU7jfmUFRZLa9KycxHDsKXJCA== + dependencies: + bignumber.js "*" + +"@types/bn.js@*", "@types/bn.js@^5.1.0": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.1.tgz#b51e1b55920a4ca26e9285ff79936bbdec910682" + integrity sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g== + dependencies: + "@types/node" "*" + +"@types/bn.js@^4.11.3", "@types/bn.js@^4.11.4", "@types/bn.js@^4.11.5": + version "4.11.6" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c" + integrity sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg== + dependencies: + "@types/node" "*" + +"@types/cacheable-request@^6.0.1": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.3.tgz#a430b3260466ca7b5ca5bfd735693b36e7a9d183" + integrity sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw== + dependencies: + "@types/http-cache-semantics" "*" + "@types/keyv" "^3.1.4" + "@types/node" "*" + "@types/responselike" "^1.0.0" + +"@types/cbor@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@types/cbor/-/cbor-2.0.0.tgz#c627afc2ee22f23f2337fecb34628a4f97c6afbb" + integrity sha512-yQH0JLcrHrH/GBIFFFq6DAsj9M4rmYsmSpGGGs67JrLGWPepYr2c1YugGjMd2Ib5pebluRAfNPJ4O1p80qX9HQ== + dependencies: + "@types/node" "*" + +"@types/chai-as-promised@^7.1.1": + version "7.1.5" + resolved "https://registry.yarnpkg.com/@types/chai-as-promised/-/chai-as-promised-7.1.5.tgz#6e016811f6c7a64f2eed823191c3a6955094e255" + integrity sha512-jStwss93SITGBwt/niYrkf2C+/1KTeZCZl1LaeezTlqppAKeoQC7jxyqYuP72sxBGKCIbw7oHgbYssIRzT5FCQ== + dependencies: + "@types/chai" "*" + +"@types/chai@*", "@types/chai@^4.3.0": + version "4.3.4" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.4.tgz#e913e8175db8307d78b4e8fa690408ba6b65dee4" + integrity sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw== + +"@types/concat-stream@^1.6.0": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@types/concat-stream/-/concat-stream-1.6.1.tgz#24bcfc101ecf68e886aaedce60dfd74b632a1b74" + integrity sha512-eHE4cQPoj6ngxBZMvVf6Hw7Mh4jMW4U9lpGmS5GBPB9RYxlFg+CHaVN7ErNY4W9XfLIEn20b4VDYaIrbq0q4uA== + dependencies: + "@types/node" "*" + +"@types/country-data@^0.0.0": + version "0.0.0" + resolved "https://registry.yarnpkg.com/@types/country-data/-/country-data-0.0.0.tgz#6f5563cae3d148780c5b6539803a29bd93f8f1a1" + integrity sha512-lIxCk6G7AwmUagQ4gIQGxUBnvAq664prFD9nSAz6dgd1XmBXBtZABV/op+QsJsIyaP1GZsf/iXhYKHX3azSRCw== + +"@types/debug@^4.1.5": + version "4.1.7" + resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.7.tgz#7cc0ea761509124709b8b2d1090d8f6c17aadb82" + integrity sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg== + dependencies: + "@types/ms" "*" + +"@types/elliptic@^6.4.9": + version "6.4.14" + resolved "https://registry.yarnpkg.com/@types/elliptic/-/elliptic-6.4.14.tgz#7bbaad60567a588c1f08b10893453e6b9b4de48e" + integrity sha512-z4OBcDAU0GVwDTuwJzQCiL6188QvZMkvoERgcVjq0/mPM8jCfdwZ3x5zQEVoL9WCAru3aG5wl3Z5Ww5wBWn7ZQ== + dependencies: + "@types/bn.js" "*" + +"@types/ethereumjs-util@^5.2.0": + version "5.2.0" + resolved "https://registry.yarnpkg.com/@types/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz#f49fe8114789ec0871721392c09318c3eb56671b" + integrity sha512-qwQgQqXXTRv2h2AlJef+tMEszLFkCB9dWnrJYIdAwqjubERXEc/geB+S3apRw0yQyTVnsBf8r6BhlrE8vx+3WQ== + dependencies: + "@types/bn.js" "*" + "@types/node" "*" + +"@types/form-data@0.0.33": + version "0.0.33" + resolved "https://registry.yarnpkg.com/@types/form-data/-/form-data-0.0.33.tgz#c9ac85b2a5fd18435b8c85d9ecb50e6d6c893ff8" + integrity sha512-8BSvG1kGm83cyJITQMZSulnl6QV8jqAGreJsc5tPu1Jq0vTSOiY/k24Wx82JRpWwZSqrala6sd5rWi6aNXvqcw== + dependencies: + "@types/node" "*" + +"@types/google-libphonenumber@^7.4.17": + version "7.4.23" + resolved "https://registry.yarnpkg.com/@types/google-libphonenumber/-/google-libphonenumber-7.4.23.tgz#c44c9125d45f042943694d605fd8d8d796cafc3b" + integrity sha512-C3ydakLTQa8HxtYf9ge4q6uT9krDX8smSIxmmW3oACFi5g5vv6T068PRExF7UyWbWpuYiDG8Nm24q2X5XhcZWw== + +"@types/http-cache-semantics@*": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812" + integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== + +"@types/json-schema@^7.0.9": + version "7.0.11" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" + integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== + +"@types/json5@^0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" + integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== + +"@types/keyv@^3.1.4": + version "3.1.4" + resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.4.tgz#3ccdb1c6751b0c7e52300bcdacd5bcbf8faa75b6" + integrity sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg== + dependencies: + "@types/node" "*" + +"@types/lodash@^4.14.170": + version "4.14.192" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.192.tgz#5790406361a2852d332d41635d927f1600811285" + integrity sha512-km+Vyn3BYm5ytMO13k9KTp27O75rbQ0NFw+U//g+PX7VZyjCioXaRFisqSIJRECljcTv73G3i6BpglNGHgUQ5A== + +"@types/lru-cache@^5.1.0": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.1.tgz#c48c2e27b65d2a153b19bfc1a317e30872e01eef" + integrity sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw== + +"@types/mkdirp@^0.5.2": + version "0.5.2" + resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.2.tgz#503aacfe5cc2703d5484326b1b27efa67a339c1f" + integrity sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg== + dependencies: + "@types/node" "*" + +"@types/mocha@^9.1.0": + version "9.1.1" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" + integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== + +"@types/ms@*": + version "0.7.31" + resolved "https://registry.yarnpkg.com/@types/ms/-/ms-0.7.31.tgz#31b7ca6407128a3d2bbc27fe2d21b345397f6197" + integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== + +"@types/node-fetch@^2.5.5": + version "2.6.3" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.3.tgz#175d977f5e24d93ad0f57602693c435c57ad7e80" + integrity sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w== + dependencies: + "@types/node" "*" + form-data "^3.0.0" + +"@types/node@*", "@types/node@^18.11.18": + version "18.15.11" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.11.tgz#b3b790f09cb1696cffcec605de025b088fa4225f" + integrity sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q== + +"@types/node@10.12.18": + version "10.12.18" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67" + integrity sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ== + +"@types/node@11.11.6": + version "11.11.6" + resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" + integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== + +"@types/node@^10.0.3", "@types/node@^10.12.18", "@types/node@^10.3.2": + version "10.17.60" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" + integrity sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw== + +"@types/node@^12.11.7", "@types/node@^12.12.6", "@types/node@^12.6.1": + version "12.20.55" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" + integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== + +"@types/node@^8.0.0": + version "8.10.66" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.66.tgz#dd035d409df322acc83dff62a602f12a5783bbb3" + integrity sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw== + +"@types/pbkdf2@^3.0.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@types/pbkdf2/-/pbkdf2-3.1.0.tgz#039a0e9b67da0cdc4ee5dab865caa6b267bb66b1" + integrity sha512-Cf63Rv7jCQ0LaL8tNXmEyqTHuIJxRdlS5vMh1mj5voN4+QFhVZnlZruezqpWYDiJ8UTzhP0VmeLXCmBk66YrMQ== + dependencies: + "@types/node" "*" + +"@types/prettier@^2.1.1": + version "2.7.2" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.2.tgz#6c2324641cc4ba050a8c710b2b251b377581fbf0" + integrity sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg== + +"@types/qs@^6.2.31", "@types/qs@^6.9.7": + version "6.9.7" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" + integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== + +"@types/randombytes@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@types/randombytes/-/randombytes-2.0.0.tgz#0087ff5e60ae68023b9bc4398b406fea7ad18304" + integrity sha512-bz8PhAVlwN72vqefzxa14DKNT8jK/mV66CSjwdVQM/k3Th3EPKfUtdMniwZgMedQTFuywAsfjnZsg+pEnltaMA== + dependencies: + "@types/node" "*" + +"@types/resolve@^0.0.8": + version "0.0.8" + resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194" + integrity sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ== + dependencies: + "@types/node" "*" + +"@types/responselike@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@types/responselike/-/responselike-1.0.0.tgz#251f4fe7d154d2bad125abe1b429b23afd262e29" + integrity sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA== + dependencies: + "@types/node" "*" + +"@types/secp256k1@^4.0.1": + version "4.0.3" + resolved "https://registry.yarnpkg.com/@types/secp256k1/-/secp256k1-4.0.3.tgz#1b8e55d8e00f08ee7220b4d59a6abe89c37a901c" + integrity sha512-Da66lEIFeIz9ltsdMZcpQvmrmmoqrfju8pm1BH8WbYjZSwUgCwXLb9C+9XYogwBITnbsSaMdVPb2ekf7TV+03w== + dependencies: + "@types/node" "*" + +"@types/semver@^7.3.12": + version "7.3.13" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.13.tgz#da4bfd73f49bd541d28920ab0e2bf0ee80f71c91" + integrity sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw== + +"@types/sinon-chai@^3.2.3": + version "3.2.9" + resolved "https://registry.yarnpkg.com/@types/sinon-chai/-/sinon-chai-3.2.9.tgz#71feb938574bbadcb176c68e5ff1a6014c5e69d4" + integrity sha512-/19t63pFYU0ikrdbXKBWj9PCdnKyTd0Qkz0X91Ta081cYsq90OxYdcWwK/dwEoDa6dtXgj2HJfmzgq+QZTHdmQ== + dependencies: + "@types/chai" "*" + "@types/sinon" "*" + +"@types/sinon@*": + version "10.0.13" + resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-10.0.13.tgz#60a7a87a70d9372d0b7b38cc03e825f46981fb83" + integrity sha512-UVjDqJblVNQYvVNUsj0PuYYw0ELRmgt1Nt5Vk0pT5f16ROGfcKJY8o1HVuMOJOpD727RrGB9EGvoaTQE5tgxZQ== + dependencies: + "@types/sinonjs__fake-timers" "*" + +"@types/sinonjs__fake-timers@*": + version "8.1.2" + resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.2.tgz#bf2e02a3dbd4aecaf95942ecd99b7402e03fad5e" + integrity sha512-9GcLXF0/v3t80caGs5p2rRfkB+a8VBGLJZVih6CNFkx8IZ994wiKKLSRs9nuFwk1HevWs/1mnUmkApGrSGsShA== + +"@types/underscore@*": + version "1.11.4" + resolved "https://registry.yarnpkg.com/@types/underscore/-/underscore-1.11.4.tgz#62e393f8bc4bd8a06154d110c7d042a93751def3" + integrity sha512-uO4CD2ELOjw8tasUrAhvnn2W4A0ZECOvMjCivJr4gA9pGgjv+qxKWY9GLTMVEK8ej85BxQOocUyE7hImmSQYcg== + +"@types/utf8@^2.1.6": + version "2.1.6" + resolved "https://registry.yarnpkg.com/@types/utf8/-/utf8-2.1.6.tgz#430cabb71a42d0a3613cce5621324fe4f5a25753" + integrity sha512-pRs2gYF5yoKYrgSaira0DJqVg2tFuF+Qjp838xS7K+mJyY2jJzjsrl6y17GbIa4uMRogMbxs+ghNCvKg6XyNrA== + +"@types/web3@1.0.19": + version "1.0.19" + resolved "https://registry.yarnpkg.com/@types/web3/-/web3-1.0.19.tgz#46b85d91d398ded9ab7c85a5dd57cb33ac558924" + integrity sha512-fhZ9DyvDYDwHZUp5/STa9XW2re0E8GxoioYJ4pEUZ13YHpApSagixj7IAdoYH5uAK+UalGq6Ml8LYzmgRA/q+A== + dependencies: + "@types/bn.js" "*" + "@types/underscore" "*" + +"@typescript-eslint/eslint-plugin@>4.32.0": + version "5.57.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.57.0.tgz#52c8a7a4512f10e7249ca1e2e61f81c62c34365c" + integrity sha512-itag0qpN6q2UMM6Xgk6xoHa0D0/P+M17THnr4SVgqn9Rgam5k/He33MA7/D7QoJcdMxHFyX7U9imaBonAX/6qA== + dependencies: + "@eslint-community/regexpp" "^4.4.0" + "@typescript-eslint/scope-manager" "5.57.0" + "@typescript-eslint/type-utils" "5.57.0" + "@typescript-eslint/utils" "5.57.0" + debug "^4.3.4" + grapheme-splitter "^1.0.4" + ignore "^5.2.0" + natural-compare-lite "^1.4.0" + semver "^7.3.7" + tsutils "^3.21.0" + +"@typescript-eslint/parser@>4.32.0": + version "5.57.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.57.0.tgz#f675bf2cd1a838949fd0de5683834417b757e4fa" + integrity sha512-orrduvpWYkgLCyAdNtR1QIWovcNZlEm6yL8nwH/eTxWLd8gsP+25pdLHYzL2QdkqrieaDwLpytHqycncv0woUQ== + dependencies: + "@typescript-eslint/scope-manager" "5.57.0" + "@typescript-eslint/types" "5.57.0" + "@typescript-eslint/typescript-estree" "5.57.0" + debug "^4.3.4" + +"@typescript-eslint/scope-manager@5.57.0": + version "5.57.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.57.0.tgz#79ccd3fa7bde0758059172d44239e871e087ea36" + integrity sha512-NANBNOQvllPlizl9LatX8+MHi7bx7WGIWYjPHDmQe5Si/0YEYfxSljJpoTyTWFTgRy3X8gLYSE4xQ2U+aCozSw== + dependencies: + "@typescript-eslint/types" "5.57.0" + "@typescript-eslint/visitor-keys" "5.57.0" + +"@typescript-eslint/type-utils@5.57.0": + version "5.57.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.57.0.tgz#98e7531c4e927855d45bd362de922a619b4319f2" + integrity sha512-kxXoq9zOTbvqzLbdNKy1yFrxLC6GDJFE2Yuo3KqSwTmDOFjUGeWSakgoXT864WcK5/NAJkkONCiKb1ddsqhLXQ== + dependencies: + "@typescript-eslint/typescript-estree" "5.57.0" + "@typescript-eslint/utils" "5.57.0" + debug "^4.3.4" + tsutils "^3.21.0" + +"@typescript-eslint/types@5.57.0": + version "5.57.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.57.0.tgz#727bfa2b64c73a4376264379cf1f447998eaa132" + integrity sha512-mxsod+aZRSyLT+jiqHw1KK6xrANm19/+VFALVFP5qa/aiJnlP38qpyaTd0fEKhWvQk6YeNZ5LGwI1pDpBRBhtQ== + +"@typescript-eslint/typescript-estree@5.57.0": + version "5.57.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.57.0.tgz#ebcd0ee3e1d6230e888d88cddf654252d41e2e40" + integrity sha512-LTzQ23TV82KpO8HPnWuxM2V7ieXW8O142I7hQTxWIHDcCEIjtkat6H96PFkYBQqGFLW/G/eVVOB9Z8rcvdY/Vw== + dependencies: + "@typescript-eslint/types" "5.57.0" + "@typescript-eslint/visitor-keys" "5.57.0" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" + +"@typescript-eslint/utils@5.57.0": + version "5.57.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.57.0.tgz#eab8f6563a2ac31f60f3e7024b91bf75f43ecef6" + integrity sha512-ps/4WohXV7C+LTSgAL5CApxvxbMkl9B9AUZRtnEFonpIxZDIT7wC1xfvuJONMidrkB9scs4zhtRyIwHh4+18kw== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@types/json-schema" "^7.0.9" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.57.0" + "@typescript-eslint/types" "5.57.0" + "@typescript-eslint/typescript-estree" "5.57.0" + eslint-scope "^5.1.1" + semver "^7.3.7" + +"@typescript-eslint/visitor-keys@5.57.0": + version "5.57.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.57.0.tgz#e2b2f4174aff1d15eef887ce3d019ecc2d7a8ac1" + integrity sha512-ery2g3k0hv5BLiKpPuwYt9KBkAp2ugT6VvyShXdLOkax895EC55sP0Tx5L0fZaQueiK3fBLvHVvEl3jFS5ia+g== + dependencies: + "@typescript-eslint/types" "5.57.0" + eslint-visitor-keys "^3.3.0" + +"@umpirsky/country-list@git://github.com/umpirsky/country-list#05fda51": + version "1.0.0" + resolved "git://github.com/umpirsky/country-list#05fda51cd97b3294e8175ffed06104c44b3c71d7" + +"@web3-js/scrypt-shim@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@web3-js/scrypt-shim/-/scrypt-shim-0.1.0.tgz#0bf7529ab6788311d3e07586f7d89107c3bea2cc" + integrity sha512-ZtZeWCc/s0nMcdx/+rZwY1EcuRdemOK9ag21ty9UsHkFxsNb/AaoucUz0iPuyGe0Ku+PFuRmWZG7Z7462p9xPw== + dependencies: + scryptsy "^2.1.0" + semver "^6.3.0" + +"@web3-js/websocket@^1.0.29": + version "1.0.30" + resolved "https://registry.yarnpkg.com/@web3-js/websocket/-/websocket-1.0.30.tgz#9ea15b7b582cf3bf3e8bc1f4d3d54c0731a87f87" + integrity sha512-fDwrD47MiDrzcJdSeTLF75aCcxVVt8B1N74rA+vh2XCAvFy4tEWJjtnUtj2QG7/zlQ6g9cQ88bZFBxwd9/FmtA== + dependencies: + debug "^2.2.0" + es5-ext "^0.10.50" + nan "^2.14.0" + typedarray-to-buffer "^3.1.5" + yaeti "^0.0.6" + +"@yarnpkg/lockfile@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31" + integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ== + +abort-controller@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" + integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== + dependencies: + event-target-shim "^5.0.0" + +abstract-level@^1.0.0, abstract-level@^1.0.2, abstract-level@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/abstract-level/-/abstract-level-1.0.3.tgz#78a67d3d84da55ee15201486ab44c09560070741" + integrity sha512-t6jv+xHy+VYwc4xqZMn2Pa9DjcdzvzZmQGRjTFc8spIbRGHgBrEKbPq+rYXc7CCo0lxgYvSgKVg9qZAhpVQSjA== + dependencies: + buffer "^6.0.3" + catering "^2.1.0" + is-buffer "^2.0.5" + level-supports "^4.0.0" + level-transcoder "^1.0.1" + module-error "^1.0.1" + queue-microtask "^1.2.3" + +abstract-leveldown@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-3.0.0.tgz#5cb89f958a44f526779d740d1440e743e0c30a57" + integrity sha512-KUWx9UWGQD12zsmLNj64/pndaz4iJh/Pj7nopgkfDG6RlCcbMZvT6+9l7dchK4idog2Is8VdC/PvNbFuFmalIQ== + dependencies: + xtend "~4.0.0" + +abstract-leveldown@^2.4.1, abstract-leveldown@~2.7.1: + version "2.7.2" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.7.2.tgz#87a44d7ebebc341d59665204834c8b7e0932cc93" + integrity sha512-+OVvxH2rHVEhWLdbudP6p0+dNMXu8JA1CbhP19T8paTYAcX7oJ4OVjT+ZUVpv7mITxXHqDMej+GdqXBmXkw09w== + dependencies: + xtend "~4.0.0" + +abstract-leveldown@^5.0.0, abstract-leveldown@~5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-5.0.0.tgz#f7128e1f86ccabf7d2893077ce5d06d798e386c6" + integrity sha512-5mU5P1gXtsMIXg65/rsYGsi93+MlogXZ9FA8JnwKurHQg64bfXwGYVdVdijNTVNOlAsuIiOwHdvFFD5JqCJQ7A== + dependencies: + xtend "~4.0.0" + +abstract-leveldown@~2.6.0: + version "2.6.3" + resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.6.3.tgz#1c5e8c6a5ef965ae8c35dfb3a8770c476b82c4b8" + integrity sha512-2++wDf/DYqkPR3o5tbfdhF96EfMApo1GpPfzOsR/ZYXdkSmELlvOOEAl9iKkRsktMPHdGjO4rtkBpf2I7TiTeA== + dependencies: + xtend "~4.0.0" + +accepts@~1.3.8: + version "1.3.8" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" + integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== + dependencies: + mime-types "~2.1.34" + negotiator "0.6.3" + +acorn-jsx@^5.0.0, acorn-jsx@^5.3.1: + version "5.3.2" + resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" + integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== + +acorn-walk@^8.1.1: + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + +acorn@^6.0.7: + version "6.4.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.2.tgz#35866fd710528e92de10cf06016498e47e39e1e6" + integrity sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ== + +acorn@^7.4.0: + version "7.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" + integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== + +acorn@^8.4.1: + version "8.8.2" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a" + integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw== + +adm-zip@^0.4.16: + version "0.4.16" + resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.16.tgz#cf4c508fdffab02c269cbc7f471a875f05570365" + integrity sha512-TFi4HBKSGfIKsK5YCkKaaFG2m4PEDyViZmEwof3MTIgzimHLto6muaHVpbrljdIvIrFZzEq/p4nafOeLcYegrg== + +aes-js@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" + integrity sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw== + +aes-js@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.1.2.tgz#db9aabde85d5caabbfc0d4f2a4446960f627146a" + integrity sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ== + +agent-base@6: + version "6.0.2" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" + integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== + dependencies: + debug "4" + +aggregate-error@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" + integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA== + dependencies: + clean-stack "^2.0.0" + indent-string "^4.0.0" + +ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.6.1, ajv@^6.9.1: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ajv@^8.0.1: + version "8.12.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" + integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA== + dependencies: + fast-deep-equal "^3.1.1" + json-schema-traverse "^1.0.0" + require-from-string "^2.0.2" + uri-js "^4.2.2" + +amazon-cognito-identity-js@^6.0.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/amazon-cognito-identity-js/-/amazon-cognito-identity-js-6.3.1.tgz#d9a4c1a92f4b059330df8ea075f65106d2605409" + integrity sha512-PxBdufgS8uZShrcIFAsRjmqNXsh/4fXOWUGQOUhKLHWWK1pcp/y+VeFF48avXIWefM8XwsT3JlN6m9J2eHt4LA== + dependencies: + "@aws-crypto/sha256-js" "1.2.2" + buffer "4.9.2" + fast-base64-decode "^1.0.0" + isomorphic-unfetch "^3.0.0" + js-cookie "^2.2.1" + +ansi-colors@3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" + integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw== + +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + +ansi-colors@^4.1.1: + version "4.1.3" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.3.tgz#37611340eb2243e70cc604cad35d63270d48781b" + integrity sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw== + +ansi-escapes@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" + integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== + +ansi-escapes@^4.3.0: + version "4.3.2" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" + integrity sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ== + dependencies: + type-fest "^0.21.3" + +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + integrity sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA== + +ansi-regex@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.1.tgz#123d6479e92ad45ad897d4054e3c7ca7db4944e1" + integrity sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw== + +ansi-regex@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + integrity sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA== + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +antlr4@4.7.1: + version "4.7.1" + resolved "https://registry.yarnpkg.com/antlr4/-/antlr4-4.7.1.tgz#69984014f096e9e775f53dd9744bf994d8959773" + integrity sha512-haHyTW7Y9joE5MVs37P2lNYfU2RWBLfcRDD8OWldcdZm5TiCE91B5Xl1oWSwiDUSd4rlExpt2pu1fksYQjRBYQ== + +antlr4ts@^0.5.0-alpha.4: + version "0.5.0-alpha.4" + resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a" + integrity sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ== + +any-promise@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== + +anymatch@~3.1.1, anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +arg@^4.1.0: + version "4.1.3" + resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" + integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== + +argparse@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" + integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== + dependencies: + sprintf-js "~1.0.2" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +aria-query@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.1.3.tgz#19db27cd101152773631396f7a95a3b58c22c35e" + integrity sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ== + dependencies: + deep-equal "^2.0.5" + +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + integrity sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA== + +arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + integrity sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q== + +array-back@^1.0.3, array-back@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-1.0.4.tgz#644ba7f095f7ffcf7c43b5f0dc39d3c1f03c063b" + integrity sha512-1WxbZvrmyhkNoeYcizokbmh5oiOCIfyvGtcqbK3Ls1v1fKcquzxnQSceOx6tzq7jmai2kFLWIpGND2cLhH6TPw== + dependencies: + typical "^2.6.0" + +array-back@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-2.0.0.tgz#6877471d51ecc9c9bfa6136fb6c7d5fe69748022" + integrity sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw== + dependencies: + typical "^2.6.1" + +array-back@^3.0.1, array-back@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0" + integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q== + +array-back@^4.0.1, array-back@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.2.tgz#8004e999a6274586beeb27342168652fdb89fa1e" + integrity sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg== + +array-buffer-byte-length@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz#fabe8bc193fea865f317fe7807085ee0dee5aead" + integrity sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A== + dependencies: + call-bind "^1.0.2" + is-array-buffer "^3.0.1" + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== + +array-includes@^3.1.5, array-includes@^3.1.6: + version "3.1.6" + resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.6.tgz#9e9e720e194f198266ba9e18c29e6a9b0e4b225f" + integrity sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + get-intrinsic "^1.1.3" + is-string "^1.0.7" + +array-union@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" + integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== + +array-uniq@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + integrity sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q== + +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + integrity sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ== + +array.prototype.flat@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz#ffc6576a7ca3efc2f46a143b9d1dda9b4b3cf5e2" + integrity sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + es-shim-unscopables "^1.0.0" + +array.prototype.flatmap@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz#1aae7903c2100433cb8261cd4ed310aab5c4a183" + integrity sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + es-shim-unscopables "^1.0.0" + +array.prototype.reduce@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/array.prototype.reduce/-/array.prototype.reduce-1.0.5.tgz#6b20b0daa9d9734dd6bc7ea66b5bbce395471eac" + integrity sha512-kDdugMl7id9COE8R7MHF5jWk7Dqt/fs4Pv+JXoICnYwqpjjjbUurz6w5fT5IG6brLdJhv6/VoHB0H7oyIBXd+Q== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + es-array-method-boxes-properly "^1.0.0" + is-string "^1.0.7" + +array.prototype.tosorted@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array.prototype.tosorted/-/array.prototype.tosorted-1.1.1.tgz#ccf44738aa2b5ac56578ffda97c03fd3e23dd532" + integrity sha512-pZYPXPRl2PqWcsUs6LOMn+1f1532nEoPTYowBtqLwAW+W8vSVhkIGnmOX1t/UQjD6YGI0vcD2B1U7ZFGQH9jnQ== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + es-shim-unscopables "^1.0.0" + get-intrinsic "^1.1.3" + +asap@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" + integrity sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA== + +asn1.js@^5.2.0: + version "5.4.1" + resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" + integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== + dependencies: + bn.js "^4.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + safer-buffer "^2.1.0" + +asn1@~0.2.3: + version "0.2.6" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d" + integrity sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ== + dependencies: + safer-buffer "~2.1.0" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== + +assertion-error@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== + +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + integrity sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw== + +ast-parents@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/ast-parents/-/ast-parents-0.0.1.tgz#508fd0f05d0c48775d9eccda2e174423261e8dd3" + integrity sha512-XHusKxKz3zoYk1ic8Un640joHbFMhbqneyoZfoKnEGtf2ey9Uh/IdpcQplODdO/kENaMIWsD0nJm4+wX3UNLHA== + +ast-types-flow@^0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/ast-types-flow/-/ast-types-flow-0.0.7.tgz#f70b735c6bca1a5c9c22d982c3e39e7feba3bdad" + integrity sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag== + +astral-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9" + integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== + +astral-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" + integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ== + +async-eventemitter@^0.2.2, async-eventemitter@^0.2.4: + version "0.2.4" + resolved "https://registry.yarnpkg.com/async-eventemitter/-/async-eventemitter-0.2.4.tgz#f5e7c8ca7d3e46aab9ec40a292baf686a0bafaca" + integrity sha512-pd20BwL7Yt1zwDFy+8MX8F1+WCT8aQeKj0kQnTrH9WaeRETlRamVhD0JtRPmrV4GfOJ2F9CvdQkZeZhnh2TuHw== + dependencies: + async "^2.4.0" + +async-limiter@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" + integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== + +async-retry@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.3.3.tgz#0e7f36c04d8478e7a58bdbed80cedf977785f280" + integrity sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw== + dependencies: + retry "0.13.1" + +async@2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.2.tgz#18330ea7e6e313887f5d2f2a904bac6fe4dd5381" + integrity sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg== + dependencies: + lodash "^4.17.11" + +async@^1.4.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + integrity sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w== + +async@^2.0.1, async@^2.1.2, async@^2.4.0, async@^2.5.0, async@^2.6.1: + version "2.6.4" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221" + integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA== + dependencies: + lodash "^4.17.14" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + +at-least-node@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2" + integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg== + +atob@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" + integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== + +available-typed-arrays@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" + integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + integrity sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA== + +aws4@^1.8.0: + version "1.12.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.12.0.tgz#ce1c9d143389679e253b314241ea9aa5cec980d3" + integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== + +axe-core@^4.6.2: + version "4.6.3" + resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.6.3.tgz#fc0db6fdb65cc7a80ccf85286d91d64ababa3ece" + integrity sha512-/BQzOX780JhsxDnPpH4ZiyrJAzcd8AfzFPkv+89veFSr1rcMjuq2JDCwypKaPeB6ljHp9KjXhPpjgCvQlWYuqg== + +axios@^0.18.0: + version "0.18.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.18.1.tgz#ff3f0de2e7b5d180e757ad98000f1081b87bcea3" + integrity sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g== + dependencies: + follow-redirects "1.5.10" + is-buffer "^2.0.2" + +axios@^0.21.1, axios@^0.21.2: + version "0.21.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" + integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== + dependencies: + follow-redirects "^1.14.0" + +axios@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f" + integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA== + dependencies: + follow-redirects "^1.15.0" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + +axobject-query@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-3.1.1.tgz#3b6e5c6d4e43ca7ba51c5babf99d22a9c68485e1" + integrity sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg== + dependencies: + deep-equal "^2.0.5" + +babel-code-frame@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" + integrity sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g== + dependencies: + chalk "^1.1.3" + esutils "^2.0.2" + js-tokens "^3.0.2" + +babel-core@^6.0.14, babel-core@^6.26.0: + version "6.26.3" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.3.tgz#b2e2f09e342d0f0c88e2f02e067794125e75c207" + integrity sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA== + dependencies: + babel-code-frame "^6.26.0" + babel-generator "^6.26.0" + babel-helpers "^6.24.1" + babel-messages "^6.23.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + convert-source-map "^1.5.1" + debug "^2.6.9" + json5 "^0.5.1" + lodash "^4.17.4" + minimatch "^3.0.4" + path-is-absolute "^1.0.1" + private "^0.1.8" + slash "^1.0.0" + source-map "^0.5.7" + +babel-generator@^6.26.0: + version "6.26.1" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90" + integrity sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA== + dependencies: + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.17.4" + source-map "^0.5.7" + trim-right "^1.0.1" + +babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" + integrity sha512-gCtfYORSG1fUMX4kKraymq607FWgMWg+j42IFPc18kFQEsmtaibP4UrqsXt8FlEJle25HUd4tsoDR7H2wDhe9Q== + dependencies: + babel-helper-explode-assignable-expression "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-call-delegate@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" + integrity sha512-RL8n2NiEj+kKztlrVJM9JT1cXzzAdvWFh76xh/H1I4nKwunzE4INBXn8ieCZ+wh4zWszZk7NBS1s/8HR5jDkzQ== + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-define-map@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz#a5f56dab41a25f97ecb498c7ebaca9819f95be5f" + integrity sha512-bHkmjcC9lM1kmZcVpA5t2om2nzT/xiZpo6TJq7UlZ3wqKfzia4veeXbIhKvJXAMzhhEBd3cR1IElL5AenWEUpA== + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-helper-explode-assignable-expression@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" + integrity sha512-qe5csbhbvq6ccry9G7tkXbzNtcDiH4r51rrPUbwwoTzZ18AqxWYRZT6AOmxrpxKnQBW0pYlBI/8vh73Z//78nQ== + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-function-name@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" + integrity sha512-Oo6+e2iX+o9eVvJ9Y5eKL5iryeRdsIkwRYheCuhYdVHsdEQysbc2z2QkqCLIYnNxkT5Ss3ggrHdXiDI7Dhrn4Q== + dependencies: + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-get-function-arity@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" + integrity sha512-WfgKFX6swFB1jS2vo+DwivRN4NB8XUdM3ij0Y1gnC21y1tdBoe6xjVnd7NSI6alv+gZXCtJqvrTeMW3fR/c0ng== + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-hoist-variables@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" + integrity sha512-zAYl3tqerLItvG5cKYw7f1SpvIxS9zi7ohyGHaI9cgDUjAT6YcY9jIEH5CstetP5wHIVSceXwNS7Z5BpJg+rOw== + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-optimise-call-expression@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" + integrity sha512-Op9IhEaxhbRT8MDXx2iNuMgciu2V8lDvYCNQbDGjdBNCjaMvyLf4wl4A3b8IgndCyQF8TwfgsQ8T3VD8aX1/pA== + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-regex@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz#325c59f902f82f24b74faceed0363954f6495e72" + integrity sha512-VlPiWmqmGJp0x0oK27Out1D+71nVVCTSdlbhIVoaBAj2lUgrNjBCRR9+llO4lTSb2O4r7PJg+RobRkhBrf6ofg== + dependencies: + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-helper-remap-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" + integrity sha512-RYqaPD0mQyQIFRu7Ho5wE2yvA/5jxqCIj/Lv4BXNq23mHYu/vxikOy2JueLiBxQknwapwrJeNCesvY0ZcfnlHg== + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-replace-supers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" + integrity sha512-sLI+u7sXJh6+ToqDr57Bv973kCepItDhMou0xCP2YPVmR1jkHSCY+p1no8xErbV1Siz5QE8qKT1WIwybSWlqjw== + dependencies: + babel-helper-optimise-call-expression "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" + integrity sha512-n7pFrqQm44TCYvrCDb0MqabAF+JUBq+ijBvNMUxpkLjJaAu32faIexewMumrH5KLLJ1HDyT0PTEqRyAe/GwwuQ== + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-messages@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" + integrity sha512-Bl3ZiA+LjqaMtNYopA9TYE9HP1tQ+E5dLxE0XrAzcIJeK2UqF0/EaqXwBn9esd4UmTfEab+P+UYQ1GnioFIb/w== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-check-es2015-constants@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" + integrity sha512-B1M5KBP29248dViEo1owyY32lk1ZSH2DaNNrXLGt8lyjjHm7pBqAdQ7VKUPR6EEDO323+OvT3MQXbCin8ooWdA== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-syntax-async-functions@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" + integrity sha512-4Zp4unmHgw30A1eWI5EpACji2qMocisdXhAftfhXoSV9j0Tvj6nRFE3tOmRY912E0FMRm/L5xWE7MGVT2FoLnw== + +babel-plugin-syntax-exponentiation-operator@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" + integrity sha512-Z/flU+T9ta0aIEKl1tGEmN/pZiI1uXmCiGFRegKacQfEJzp7iNsKloZmyJlQr+75FCJtiFfGIK03SiCvCt9cPQ== + +babel-plugin-syntax-trailing-function-commas@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" + integrity sha512-Gx9CH3Q/3GKbhs07Bszw5fPTlU+ygrOGfAhEt7W2JICwufpC4SuO0mG0+4NykPBSYPMJhqvVlDBU17qB1D+hMQ== + +babel-plugin-transform-async-to-generator@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" + integrity sha512-7BgYJujNCg0Ti3x0c/DL3tStvnKS6ktIYOmo9wginv/dfZOrbSZ+qG4IRRHMBOzZ5Awb1skTiAsQXg/+IWkZYw== + dependencies: + babel-helper-remap-async-to-generator "^6.24.1" + babel-plugin-syntax-async-functions "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-arrow-functions@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" + integrity sha512-PCqwwzODXW7JMrzu+yZIaYbPQSKjDTAsNNlK2l5Gg9g4rz2VzLnZsStvp/3c46GfXpwkyufb3NCyG9+50FF1Vg== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz#bbc51b49f964d70cb8d8e0b94e820246ce3a6141" + integrity sha512-2+ujAT2UMBzYFm7tidUsYh+ZoIutxJ3pN9IYrF1/H6dCKtECfhmB8UkHVpyxDwkj0CYbQG35ykoz925TUnBc3A== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoping@^6.23.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" + integrity sha512-YiN6sFAQ5lML8JjCmr7uerS5Yc/EMbgg9G8ZNmk2E3nYX4ckHR01wrkeeMijEf5WHNK5TW0Sl0Uu3pv3EdOJWw== + dependencies: + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-plugin-transform-es2015-classes@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" + integrity sha512-5Dy7ZbRinGrNtmWpquZKZ3EGY8sDgIVB4CU8Om8q8tnMLrD/m94cKglVcHps0BCTdZ0TJeeAWOq2TK9MIY6cag== + dependencies: + babel-helper-define-map "^6.24.1" + babel-helper-function-name "^6.24.1" + babel-helper-optimise-call-expression "^6.24.1" + babel-helper-replace-supers "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-computed-properties@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" + integrity sha512-C/uAv4ktFP/Hmh01gMTvYvICrKze0XVX9f2PdIXuriCSvUmV9j+u+BB9f5fJK3+878yMK6dkdcq+Ymr9mrcLzw== + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-destructuring@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" + integrity sha512-aNv/GDAW0j/f4Uy1OEPZn1mqD+Nfy9viFGBfQ5bZyT35YqOiqx7/tXdyfZkJ1sC21NyEsBdfDY6PYmLHF4r5iA== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-duplicate-keys@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" + integrity sha512-ossocTuPOssfxO2h+Z3/Ea1Vo1wWx31Uqy9vIiJusOP4TbF7tPs9U0sJ9pX9OJPf4lXRGj5+6Gkl/HHKiAP5ug== + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-for-of@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" + integrity sha512-DLuRwoygCoXx+YfxHLkVx5/NpeSbVwfoTeBykpJK7JhYWlL/O8hgAK/reforUnZDlxasOrVPPJVI/guE3dCwkw== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-function-name@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" + integrity sha512-iFp5KIcorf11iBqu/y/a7DK3MN5di3pNCzto61FqCNnUX4qeBwcV1SLqe10oXNnCaxBUImX3SckX2/o1nsrTcg== + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-literals@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz#4f54a02d6cd66cf915280019a31d31925377ca2e" + integrity sha512-tjFl0cwMPpDYyoqYA9li1/7mGFit39XiNX5DKC/uCNjBctMxyL1/PT/l4rSlbvBG1pOKI88STRdUsWXB3/Q9hQ== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015-modules-amd@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" + integrity sha512-LnIIdGWIKdw7zwckqx+eGjcS8/cl8D74A3BpJbGjKTFFNJSMrjN4bIh22HY1AlkUbeLG6X6OZj56BDvWD+OeFA== + dependencies: + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-es2015-modules-commonjs@^6.24.1: + version "6.26.2" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3" + integrity sha512-CV9ROOHEdrjcwhIaJNBGMBCodN+1cfkwtM1SbUHmvyy35KGT7fohbpOxkE2uLz1o6odKK2Ck/tz47z+VqQfi9Q== + dependencies: + babel-plugin-transform-strict-mode "^6.24.1" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-types "^6.26.0" + +babel-plugin-transform-es2015-modules-systemjs@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" + integrity sha512-ONFIPsq8y4bls5PPsAWYXH/21Hqv64TBxdje0FvU3MhIV6QM2j5YS7KvAzg/nTIVLot2D2fmFQrFWCbgHlFEjg== + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-umd@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" + integrity sha512-LpVbiT9CLsuAIp3IG0tfbVo81QIhn6pE8xBJ7XSeCtFlMltuar5VuBV6y6Q45tpui9QWcy5i0vLQfCfrnF7Kiw== + dependencies: + babel-plugin-transform-es2015-modules-amd "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-object-super@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" + integrity sha512-8G5hpZMecb53vpD3mjs64NhI1au24TAmokQ4B+TBFBjN9cVoGoOvotdrMMRmHvVZUEvqGUPWL514woru1ChZMA== + dependencies: + babel-helper-replace-supers "^6.24.1" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-parameters@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" + integrity sha512-8HxlW+BB5HqniD+nLkQ4xSAVq3bR/pcYW9IigY+2y0dI+Y7INFeTbfAQr+63T3E4UDsZGjyb+l9txUnABWxlOQ== + dependencies: + babel-helper-call-delegate "^6.24.1" + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-shorthand-properties@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" + integrity sha512-mDdocSfUVm1/7Jw/FIRNw9vPrBQNePy6wZJlR8HAUBLybNp1w/6lr6zZ2pjMShee65t/ybR5pT8ulkLzD1xwiw== + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-spread@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" + integrity sha512-3Ghhi26r4l3d0Js933E5+IhHwk0A1yiutj9gwvzmFbVV0sPMYk2lekhOufHBswX7NCoSeF4Xrl3sCIuSIa+zOg== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-sticky-regex@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" + integrity sha512-CYP359ADryTo3pCsH0oxRo/0yn6UsEZLqYohHmvLQdfS9xkf+MbCzE3/Kolw9OYIY4ZMilH25z/5CbQbwDD+lQ== + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-template-literals@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz#a84b3450f7e9f8f1f6839d6d687da84bb1236d8d" + integrity sha512-x8b9W0ngnKzDMHimVtTfn5ryimars1ByTqsfBDwAqLibmuuQY6pgBQi5z1ErIsUOWBdw1bW9FSz5RZUojM4apg== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-typeof-symbol@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" + integrity sha512-fz6J2Sf4gYN6gWgRZaoFXmq93X+Li/8vf+fb0sGDVtdeWvxC9y5/bTD7bvfWMEq6zetGEHpWjtzRGSugt5kNqw== + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-unicode-regex@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" + integrity sha512-v61Dbbihf5XxnYjtBN04B/JBvsScY37R1cZT5r9permN1cp+b70DY3Ib3fIkgn1DI9U3tGgBJZVD8p/mE/4JbQ== + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + regexpu-core "^2.0.0" + +babel-plugin-transform-exponentiation-operator@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" + integrity sha512-LzXDmbMkklvNhprr20//RStKVcT8Cu+SQtX18eMHLhjHf2yFzwtQ0S2f0jQ+89rokoNdmwoSqYzAhq86FxlLSQ== + dependencies: + babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" + babel-plugin-syntax-exponentiation-operator "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-regenerator@^6.22.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" + integrity sha512-LS+dBkUGlNR15/5WHKe/8Neawx663qttS6AGqoOUhICc9d1KciBvtrQSuc0PI+CxQ2Q/S1aKuJ+u64GtLdcEZg== + dependencies: + regenerator-transform "^0.10.0" + +babel-plugin-transform-strict-mode@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" + integrity sha512-j3KtSpjyLSJxNoCDrhwiJad8kw0gJ9REGj8/CqL0HeRyLnvUNYV9zcqluL6QJSXh3nfsLEmSLvwRfGzrgR96Pw== + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-preset-env@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a" + integrity sha512-9OR2afuKDneX2/q2EurSftUYM0xGu4O2D9adAhVfADDhrYDaxXV0rBbevVYoY9n6nyX1PmQW/0jtpJvUNr9CHg== + dependencies: + babel-plugin-check-es2015-constants "^6.22.0" + babel-plugin-syntax-trailing-function-commas "^6.22.0" + babel-plugin-transform-async-to-generator "^6.22.0" + babel-plugin-transform-es2015-arrow-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoping "^6.23.0" + babel-plugin-transform-es2015-classes "^6.23.0" + babel-plugin-transform-es2015-computed-properties "^6.22.0" + babel-plugin-transform-es2015-destructuring "^6.23.0" + babel-plugin-transform-es2015-duplicate-keys "^6.22.0" + babel-plugin-transform-es2015-for-of "^6.23.0" + babel-plugin-transform-es2015-function-name "^6.22.0" + babel-plugin-transform-es2015-literals "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.22.0" + babel-plugin-transform-es2015-modules-commonjs "^6.23.0" + babel-plugin-transform-es2015-modules-systemjs "^6.23.0" + babel-plugin-transform-es2015-modules-umd "^6.23.0" + babel-plugin-transform-es2015-object-super "^6.22.0" + babel-plugin-transform-es2015-parameters "^6.23.0" + babel-plugin-transform-es2015-shorthand-properties "^6.22.0" + babel-plugin-transform-es2015-spread "^6.22.0" + babel-plugin-transform-es2015-sticky-regex "^6.22.0" + babel-plugin-transform-es2015-template-literals "^6.22.0" + babel-plugin-transform-es2015-typeof-symbol "^6.23.0" + babel-plugin-transform-es2015-unicode-regex "^6.22.0" + babel-plugin-transform-exponentiation-operator "^6.22.0" + babel-plugin-transform-regenerator "^6.22.0" + browserslist "^3.2.6" + invariant "^2.2.2" + semver "^5.3.0" + +babel-register@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" + integrity sha512-veliHlHX06wjaeY8xNITbveXSiI+ASFnOqvne/LaIJIqOWi2Ogmj91KOugEz/hoh/fwMhXNBJPCv8Xaz5CyM4A== + dependencies: + babel-core "^6.26.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" + home-or-tmp "^2.0.0" + lodash "^4.17.4" + mkdirp "^0.5.1" + source-map-support "^0.4.15" + +babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + integrity sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g== + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + +babel-template@^6.24.1, babel-template@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" + integrity sha512-PCOcLFW7/eazGUKIoqH97sO9A2UYMahsn/yRQ7uOk37iutwjq7ODtcTNF+iFDSHNfkctqsLRjLP7URnOx0T1fg== + dependencies: + babel-runtime "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + lodash "^4.17.4" + +babel-traverse@^6.24.1, babel-traverse@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" + integrity sha512-iSxeXx7apsjCHe9c7n8VtRXGzI2Bk1rBSOJgCCjfyXb6v1aCqE1KSEpq/8SXuVN8Ka/Rh1WDTF0MDzkvTA4MIA== + dependencies: + babel-code-frame "^6.26.0" + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + debug "^2.6.8" + globals "^9.18.0" + invariant "^2.2.2" + lodash "^4.17.4" + +babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" + integrity sha512-zhe3V/26rCWsEZK8kZN+HaQj5yQ1CilTObixFzKW1UWjqG7618Twz6YEsCnjfg5gBcJh02DrpCkS9h98ZqDY+g== + dependencies: + babel-runtime "^6.26.0" + esutils "^2.0.2" + lodash "^4.17.4" + to-fast-properties "^1.0.3" + +babelify@^7.3.0: + version "7.3.0" + resolved "https://registry.yarnpkg.com/babelify/-/babelify-7.3.0.tgz#aa56aede7067fd7bd549666ee16dc285087e88e5" + integrity sha512-vID8Fz6pPN5pJMdlUnNFSfrlcx5MUule4k9aKs/zbZPyXxMTcRrB0M4Tarw22L8afr8eYSWxDPYCob3TdrqtlA== + dependencies: + babel-core "^6.0.14" + object-assign "^4.0.0" + +babylon@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" + integrity sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ== + +backoff@^2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/backoff/-/backoff-2.5.0.tgz#f616eda9d3e4b66b8ca7fca79f695722c5f8e26f" + integrity sha512-wC5ihrnUXmR2douXmXLCe5O3zg3GKIyvRi/hi58a/XyRxVI+3/yM0PYueQOZXPXQ9pxBislYkw+sF9b7C/RuMA== + dependencies: + precond "0.2" + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +base-x@^3.0.2, base-x@^3.0.8: + version "3.0.9" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" + integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== + dependencies: + safe-buffer "^5.0.1" + +base64-js@^1.0.2, base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + +bcrypt-pbkdf@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" + integrity sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w== + dependencies: + tweetnacl "^0.14.3" + +bech32@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" + integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== + +big-integer@^1.6.44: + version "1.6.51" + resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" + integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg== + +bigi@^1.1.0: + version "1.4.2" + resolved "https://registry.yarnpkg.com/bigi/-/bigi-1.4.2.tgz#9c665a95f88b8b08fc05cfd731f561859d725825" + integrity sha512-ddkU+dFIuEIW8lE7ZwdIAf2UPoM90eaprg5m3YXAVVTmKlqV/9BX4A2M8BOK2yOq6/VgZFVhK6QAxJebhlbhzw== + +bigint-crypto-utils@^3.0.23: + version "3.1.8" + resolved "https://registry.yarnpkg.com/bigint-crypto-utils/-/bigint-crypto-utils-3.1.8.tgz#e2e0f40cf45488f9d7f0e32ff84152aa73819d5d" + integrity sha512-+VMV9Laq8pXLBKKKK49nOoq9bfR3j7NNQAtbA617a4nw9bVLo8rsqkKMBgM2AJWlNX9fEIyYaYX+d0laqYV4tw== + dependencies: + bigint-mod-arith "^3.1.0" + +bigint-mod-arith@^3.1.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/bigint-mod-arith/-/bigint-mod-arith-3.1.2.tgz#658e416bc593a463d97b59766226d0a3021a76b1" + integrity sha512-nx8J8bBeiRR+NlsROFH9jHswW5HO8mgfOSqW0AmjicMMvaONDa8AO+5ViKDUUNytBPWiwfvZP4/Bj4Y3lUfvgQ== + +bignumber.js@*, bignumber.js@^9.0.0, bignumber.js@^9.0.1: + version "9.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6" + integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig== + +bignumber.js@^7.2.0: + version "7.2.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f" + integrity sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ== + +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + +bindings@^1.3.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + +bip32@2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/bip32/-/bip32-2.0.5.tgz#e3808a9e97a880dbafd0f5f09ca4a1e14ee275d2" + integrity sha512-zVY4VvJV+b2fS0/dcap/5XLlpqtgwyN8oRkuGgAS1uLOeEp0Yo6Tw2yUTozTtlrMJO3G8n4g/KX/XGFHW6Pq3g== + dependencies: + "@types/node" "10.12.18" + bs58check "^2.1.1" + create-hash "^1.2.0" + create-hmac "^1.1.7" + tiny-secp256k1 "^1.1.3" + typeforce "^1.11.5" + wif "^2.0.6" + +bip39@2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/bip39/-/bip39-2.5.0.tgz#51cbd5179460504a63ea3c000db3f787ca051235" + integrity sha512-xwIx/8JKoT2+IPJpFEfXoWdYwP7UVAoUxxLNfGCfVowaJE7yg1Y5B1BVPqlUNsBq5/nGwmFkwRJ8xDW4sX8OdA== + dependencies: + create-hash "^1.1.0" + pbkdf2 "^3.0.9" + randombytes "^2.0.1" + safe-buffer "^5.0.1" + unorm "^1.3.3" + +bip39@3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.0.2.tgz#2baf42ff3071fc9ddd5103de92e8f80d9257ee32" + integrity sha512-J4E1r2N0tUylTKt07ibXvhpT2c5pyAFgvuA5q1H9uDy6dEGpjV8jmymh3MTYJDLCNbIVClSB9FbND49I6N24MQ== + dependencies: + "@types/node" "11.11.6" + create-hash "^1.1.0" + pbkdf2 "^3.0.9" + randombytes "^2.0.1" + +"bip39@https://github.com/bitcoinjs/bip39#d8ea080a18b40f301d4e2219a2991cd2417e83c2": + version "3.0.3" + resolved "https://github.com/bitcoinjs/bip39#d8ea080a18b40f301d4e2219a2991cd2417e83c2" + dependencies: + "@types/node" "11.11.6" + create-hash "^1.1.0" + pbkdf2 "^3.0.9" + randombytes "^2.0.1" + +bl@^1.0.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.3.tgz#1e8dd80142eac80d7158c9dccc047fb620e035e7" + integrity sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww== + dependencies: + readable-stream "^2.3.5" + safe-buffer "^5.1.1" + +blakejs@^1.1.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.2.1.tgz#5057e4206eadb4a97f7c0b6e197a505042fc3814" + integrity sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ== + +"bls12377js@https://github.com/celo-org/bls12377js#400bcaeec9e7620b040bfad833268f5289699cac": + version "0.1.0" + resolved "https://github.com/celo-org/bls12377js#400bcaeec9e7620b040bfad833268f5289699cac" + dependencies: + "@stablelib/blake2xs" "0.10.4" + "@types/node" "^12.11.7" + big-integer "^1.6.44" + chai "^4.2.0" + mocha "^6.2.2" + ts-node "^8.4.1" + typescript "^3.6.4" + +"bls12377js@https://github.com/celo-org/bls12377js#cb38a4cfb643c778619d79b20ca3e5283a2122a6": + version "0.1.0" + resolved "https://github.com/celo-org/bls12377js#cb38a4cfb643c778619d79b20ca3e5283a2122a6" + dependencies: + "@stablelib/blake2xs" "0.10.4" + "@types/node" "^12.11.7" + big-integer "^1.6.44" + chai "^4.2.0" + mocha "^6.2.2" + ts-node "^8.4.1" + typescript "^3.6.4" + +bluebird@^3.5.0, bluebird@^3.5.2: + version "3.7.2" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" + integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== + +bn.js@4.11.6: + version "4.11.6" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" + integrity sha512-XWwnNNFCuuSQ0m3r3C4LE3EiORltHd9M05pq6FOlVeiophzRbMo50Sbz1ehl8K3Z+jw9+vmgnXefY1hz8X+2wA== + +bn.js@4.11.8: + version "4.11.8" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" + integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== + +bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.10.0, bn.js@^4.11.0, bn.js@^4.11.6, bn.js@^4.11.8, bn.js@^4.11.9, bn.js@^4.4.0, bn.js@^4.8.0: + version "4.12.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" + integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== + +bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.1.2, bn.js@^5.2.0, bn.js@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" + integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== + +body-parser@1.20.1: + version "1.20.1" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.1.tgz#b1812a8912c195cd371a3ee5e66faa2338a5c668" + integrity sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw== + dependencies: + bytes "3.1.2" + content-type "~1.0.4" + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + http-errors "2.0.0" + iconv-lite "0.4.24" + on-finished "2.4.1" + qs "6.11.0" + raw-body "2.5.1" + type-is "~1.6.18" + unpipe "1.0.0" + +body-parser@^1.16.0: + version "1.20.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd" + integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA== + dependencies: + bytes "3.1.2" + content-type "~1.0.5" + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + http-errors "2.0.0" + iconv-lite "0.4.24" + on-finished "2.4.1" + qs "6.11.0" + raw-body "2.5.2" + type-is "~1.6.18" + unpipe "1.0.0" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + +braces@^2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + +braces@^3.0.2, braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +brorand@^1.0.1, brorand@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" + integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== + +browser-level@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/browser-level/-/browser-level-1.0.1.tgz#36e8c3183d0fe1c405239792faaab5f315871011" + integrity sha512-XECYKJ+Dbzw0lbydyQuJzwNXtOpbMSq737qxJN11sIRTErOMShvDpbzTlgju7orJKvx4epULolZAuJGLzCmWRQ== + dependencies: + abstract-level "^1.0.2" + catering "^2.1.1" + module-error "^1.0.2" + run-parallel-limit "^1.1.0" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +browserify-aes@^1.0.0, browserify-aes@^1.0.4, browserify-aes@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" + integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== + dependencies: + buffer-xor "^1.0.3" + cipher-base "^1.0.0" + create-hash "^1.1.0" + evp_bytestokey "^1.0.3" + inherits "^2.0.1" + safe-buffer "^5.0.1" + +browserify-cipher@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" + integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== + dependencies: + browserify-aes "^1.0.4" + browserify-des "^1.0.0" + evp_bytestokey "^1.0.0" + +browserify-des@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.2.tgz#3af4f1f59839403572f1c66204375f7a7f703e9c" + integrity sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A== + dependencies: + cipher-base "^1.0.1" + des.js "^1.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.1.0.tgz#b2fd06b5b75ae297f7ce2dc651f918f5be158c8d" + integrity sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog== + dependencies: + bn.js "^5.0.0" + randombytes "^2.0.1" + +browserify-sign@^4.0.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.2.1.tgz#eaf4add46dd54be3bb3b36c0cf15abbeba7956c3" + integrity sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg== + dependencies: + bn.js "^5.1.1" + browserify-rsa "^4.0.1" + create-hash "^1.2.0" + create-hmac "^1.1.7" + elliptic "^6.5.3" + inherits "^2.0.4" + parse-asn1 "^5.1.5" + readable-stream "^3.6.0" + safe-buffer "^5.2.0" + +browserslist@^3.2.6: + version "3.2.8" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.8.tgz#b0005361d6471f0f5952797a76fc985f1f978fc6" + integrity sha512-WHVocJYavUwVgVViC0ORikPHQquXwVh939TaelZ4WDqpWgTX/FsGhl/+P4qBUAGcRvtOgDgC+xftNWWp2RUTAQ== + dependencies: + caniuse-lite "^1.0.30000844" + electron-to-chromium "^1.3.47" + +bs58@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" + integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== + dependencies: + base-x "^3.0.2" + +bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" + integrity sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA== + dependencies: + bs58 "^4.0.0" + create-hash "^1.1.0" + safe-buffer "^5.1.2" + +buffer-alloc-unsafe@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" + integrity sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg== + +buffer-alloc@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/buffer-alloc/-/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec" + integrity sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow== + dependencies: + buffer-alloc-unsafe "^1.1.0" + buffer-fill "^1.0.0" + +buffer-crc32@~0.2.3: + version "0.2.13" + resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" + integrity sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ== + +buffer-fill@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" + integrity sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ== + +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +buffer-reverse@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/buffer-reverse/-/buffer-reverse-1.0.1.tgz#49283c8efa6f901bc01fa3304d06027971ae2f60" + integrity sha512-M87YIUBsZ6N924W57vDwT/aOu8hw7ZgdByz6ijksLjmHJELBASmYTTlNHRgjE+pTsT9oJXGaDSgqqwfdHotDUg== + +buffer-to-arraybuffer@^0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz#6064a40fa76eb43c723aba9ef8f6e1216d10511a" + integrity sha512-3dthu5CYiVB1DEJp61FtApNnNndTckcqe4pFcLdvHtrpG+kcyekCJKg4MRiDcFW7A6AODnXB9U4dwQiCW5kzJQ== + +buffer-xor@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" + integrity sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ== + +buffer-xor@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-2.0.2.tgz#34f7c64f04c777a1f8aac5e661273bb9dd320289" + integrity sha512-eHslX0bin3GB+Lx2p7lEYRShRewuNZL3fUl4qlVJGGiwoPGftmt8JQgk2Y9Ji5/01TnVDo33E5b5O3vUB1HdqQ== + dependencies: + safe-buffer "^5.1.1" + +buffer@4.9.2: + version "4.9.2" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-4.9.2.tgz#230ead344002988644841ab0244af8c44bbe3ef8" + integrity sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg== + dependencies: + base64-js "^1.0.2" + ieee754 "^1.1.4" + isarray "^1.0.0" + +buffer@^5.0.5, buffer@^5.2.1, buffer@^5.5.0, buffer@^5.6.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.1.13" + +buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + +bufferutil@^4.0.1: + version "4.0.7" + resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.7.tgz#60c0d19ba2c992dd8273d3f73772ffc894c153ad" + integrity sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw== + dependencies: + node-gyp-build "^4.3.0" + +busboy@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893" + integrity sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA== + dependencies: + streamsearch "^1.1.0" + +bytes@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" + integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== + +bytewise-core@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/bytewise-core/-/bytewise-core-1.2.3.tgz#3fb410c7e91558eb1ab22a82834577aa6bd61d42" + integrity sha512-nZD//kc78OOxeYtRlVk8/zXqTB4gf/nlguL1ggWA8FuchMyOxcyHR4QPQZMUmA7czC+YnaBrPUCubqAWe50DaA== + dependencies: + typewise-core "^1.2" + +bytewise@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/bytewise/-/bytewise-1.1.0.tgz#1d13cbff717ae7158094aa881b35d081b387253e" + integrity sha512-rHuuseJ9iQ0na6UDhnrRVDh8YnWVlU6xM3VH6q/+yHDeUH2zIhUzP+2/h3LIrhLDBtTqzWpE3p3tP/boefskKQ== + dependencies: + bytewise-core "^1.2.2" + typewise "^1.0.3" + +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + +cacheable-lookup@^5.0.3: + version "5.0.4" + resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005" + integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA== + +cacheable-request@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912" + integrity sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg== + dependencies: + clone-response "^1.0.2" + get-stream "^5.1.0" + http-cache-semantics "^4.0.0" + keyv "^3.0.0" + lowercase-keys "^2.0.0" + normalize-url "^4.1.0" + responselike "^1.0.2" + +cacheable-request@^7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.2.tgz#ea0d0b889364a25854757301ca12b2da77f91d27" + integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew== + dependencies: + clone-response "^1.0.2" + get-stream "^5.1.0" + http-cache-semantics "^4.0.0" + keyv "^4.0.0" + lowercase-keys "^2.0.0" + normalize-url "^6.0.1" + responselike "^2.0.0" + +cachedown@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cachedown/-/cachedown-1.0.0.tgz#d43f036e4510696b31246d7db31ebf0f7ac32d15" + integrity sha512-t+yVk82vQWCJF3PsWHMld+jhhjkkWjcAzz8NbFx1iULOXWl8Tm/FdM4smZNVw3MRr0X+lVTx9PKzvEn4Ng19RQ== + dependencies: + abstract-leveldown "^2.4.1" + lru-cache "^3.2.0" + +call-bind@^1.0.0, call-bind@^1.0.2, call-bind@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" + integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== + dependencies: + function-bind "^1.1.1" + get-intrinsic "^1.0.2" + +caller-callsite@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/caller-callsite/-/caller-callsite-2.0.0.tgz#847e0fce0a223750a9a027c54b33731ad3154134" + integrity sha512-JuG3qI4QOftFsZyOn1qq87fq5grLIyk1JYd5lJmdA+fG7aQ9pA/i3JIJGcO3q0MrRcHlOt1U+ZeHW8Dq9axALQ== + dependencies: + callsites "^2.0.0" + +caller-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-2.0.0.tgz#468f83044e369ab2010fac5f06ceee15bb2cb1f4" + integrity sha512-MCL3sf6nCSXOwCTzvPKhN18TU7AHTvdtam8DAogxcrJ8Rjfbbg7Lgng64H9Iy+vUV6VGFClN/TyxBkAebLRR4A== + dependencies: + caller-callsite "^2.0.0" + +callsites@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50" + integrity sha512-ksWePWBloaWPxJYQ8TL0JHvtci6G5QTKwQ95RcWAa/lzoAKuAOflGdAK92hpHXjkwb8zLxoLNUoNYZgVsaJzvQ== + +callsites@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" + integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ== + +camelcase@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-3.0.0.tgz#32fc4b9fcdaf845fcdf7e73bb97cac2261f0ab0a" + integrity sha512-4nhGqUkc4BqbBBB4Q6zLuD7lzzrHYrjKGeYaEji/3tFR5VdJu9v+LilhGIVe8wxEJPPOeWo7eg8dwY13TZ1BNg== + +camelcase@^5.0.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +camelcase@^6.0.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +caniuse-lite@^1.0.30000844: + version "1.0.30001472" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001472.tgz#3f484885f2a2986c019dc416e65d9d62798cdd64" + integrity sha512-xWC/0+hHHQgj3/vrKYY0AAzeIUgr7L9wlELIcAvZdDUHlhL/kNxMdnQLOSOQfP8R51ZzPhmHdyMkI0MMpmxCfg== + +caseless@^0.12.0, caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== + +catering@^2.1.0, catering@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/catering/-/catering-2.1.1.tgz#66acba06ed5ee28d5286133982a927de9a04b510" + integrity sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w== + +cbor@^4.1.5: + version "4.3.0" + resolved "https://registry.yarnpkg.com/cbor/-/cbor-4.3.0.tgz#0217c1cadd067d9112f44336dca07e72020bb804" + integrity sha512-CvzaxQlaJVa88sdtTWvLJ++MbdtPHtZOBBNjm7h3YKUHILMs9nQyD4AC6hvFZy7GBVB3I6bRibJcxeHydyT2IQ== + dependencies: + bignumber.js "^9.0.0" + commander "^3.0.0" + json-text-sequence "^0.1" + nofilter "^1.0.3" + +cbor@^5.0.2: + version "5.2.0" + resolved "https://registry.yarnpkg.com/cbor/-/cbor-5.2.0.tgz#4cca67783ccd6de7b50ab4ed62636712f287a67c" + integrity sha512-5IMhi9e1QU76ppa5/ajP1BmMWZ2FHkhAhjeVKQ/EFCgYSEaeVaoGtL7cxJskf9oCCk+XjzaIdc3IuU/dbA/o2A== + dependencies: + bignumber.js "^9.0.1" + nofilter "^1.0.4" + +cbor@^8.0.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/cbor/-/cbor-8.1.0.tgz#cfc56437e770b73417a2ecbfc9caf6b771af60d5" + integrity sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg== + dependencies: + nofilter "^3.1.0" + +chai@4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" + integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^3.0.1" + get-func-name "^2.0.0" + pathval "^1.1.1" + type-detect "^4.0.5" + +chai@^4.2.0: + version "4.3.7" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.7.tgz#ec63f6df01829088e8bf55fca839bcd464a8ec51" + integrity sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^4.1.2" + get-func-name "^2.0.0" + loupe "^2.3.1" + pathval "^1.1.1" + type-detect "^4.0.5" + +chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + integrity sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A== + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1, chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chardet@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" + integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA== + +"charenc@>= 0.0.1": + version "0.0.2" + resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" + integrity sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA== + +check-error@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" + integrity sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA== + +checkpoint-store@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/checkpoint-store/-/checkpoint-store-1.1.0.tgz#04e4cb516b91433893581e6d4601a78e9552ea06" + integrity sha512-J/NdY2WvIx654cc6LWSq/IYFFCUf75fFTgwzFnmbqyORH4MwgiQCgswLLKBGzmsyTI5V7i5bp/So6sMbDWhedg== + dependencies: + functional-red-black-tree "^1.0.1" + +chokidar@3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.3.0.tgz#12c0714668c55800f659e262d4962a97faf554a6" + integrity sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A== + dependencies: + anymatch "~3.1.1" + braces "~3.0.2" + glob-parent "~5.1.0" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.2.0" + optionalDependencies: + fsevents "~2.1.1" + +chokidar@3.5.3, chokidar@^3.4.0, chokidar@^3.5.2: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +chownr@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" + integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== + +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + +cids@^0.7.1: + version "0.7.5" + resolved "https://registry.yarnpkg.com/cids/-/cids-0.7.5.tgz#60a08138a99bfb69b6be4ceb63bfef7a396b28b2" + integrity sha512-zT7mPeghoWAu+ppn8+BS1tQ5qGmbMfB4AregnQjA/qHY3GC1m1ptI9GkWNlgeu38r7CuRdXB47uY2XgAYt6QVA== + dependencies: + buffer "^5.5.0" + class-is "^1.1.0" + multibase "~0.6.0" + multicodec "^1.0.0" + multihashes "~0.4.15" + +cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" + integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + +class-is@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/class-is/-/class-is-1.1.0.tgz#9d3c0fba0440d211d843cec3dedfa48055005825" + integrity sha512-rhjH9AG1fvabIDoGRVH587413LPjTZgmDF9fOFCbFJQV4yuocX1mHxxvXI4g3cGwbVY9wAYIoKlg1N79frJKQw== + +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + +classic-level@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/classic-level/-/classic-level-1.2.0.tgz#2d52bdec8e7a27f534e67fdeb890abef3e643c27" + integrity sha512-qw5B31ANxSluWz9xBzklRWTUAJ1SXIdaVKTVS7HcTGKOAmExx65Wo5BUICW+YGORe2FOUaDghoI9ZDxj82QcFg== + dependencies: + abstract-level "^1.0.2" + catering "^2.1.0" + module-error "^1.0.1" + napi-macros "~2.0.0" + node-gyp-build "^4.3.0" + +clean-stack@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" + integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== + +cli-cursor@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" + integrity sha512-8lgKz8LmCRYZZQDpRyT2m5rKJ08TnU4tR9FFFW2rxpxR1FzWi4PQ/NfyODchAatHaUgnSPVcx/R5w6NuTBzFiw== + dependencies: + restore-cursor "^2.0.0" + +cli-cursor@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" + integrity sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw== + dependencies: + restore-cursor "^3.1.0" + +cli-table3@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.5.1.tgz#0252372d94dfc40dbd8df06005f48f31f656f202" + integrity sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw== + dependencies: + object-assign "^4.1.0" + string-width "^2.1.1" + optionalDependencies: + colors "^1.1.2" + +cli-table3@^0.6.0: + version "0.6.3" + resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.3.tgz#61ab765aac156b52f222954ffc607a6f01dbeeb2" + integrity sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg== + dependencies: + string-width "^4.2.0" + optionalDependencies: + "@colors/colors" "1.5.0" + +cli-width@^2.0.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.1.tgz#b0433d0b4e9c847ef18868a4ef16fd5fc8271c48" + integrity sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw== + +cliui@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" + integrity sha512-0yayqDxWQbqk3ojkYqUKqaAQ6AfNKeKWRNA8kR0WXzAsdHpP4BIaOmMAG87JGuO6qcobyW4GjxHd9PmhEd+T9w== + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrap-ansi "^2.0.0" + +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + dependencies: + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" + +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + +clone-response@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.3.tgz#af2032aa47816399cf5f0a1d0db902f517abb8c3" + integrity sha512-ROoL94jJH2dUVML2Y/5PEDNaSHgeOdSDicUyS7izcF63G6sTc/FTjLub4b8Il9S8S0beOfYt0TaA5qvFK+w0wA== + dependencies: + mimic-response "^1.0.0" + +clone@2.1.2, clone@^2.0.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" + integrity sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w== + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + integrity sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA== + +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + integrity sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw== + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +colors@1.4.0, colors@^1.1.2: + version "1.4.0" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" + integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== + +combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + +command-exists@^1.2.8: + version "1.2.9" + resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69" + integrity sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w== + +command-line-args@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-4.0.7.tgz#f8d1916ecb90e9e121eda6428e41300bfb64cc46" + integrity sha512-aUdPvQRAyBvQd2n7jXcsMDz68ckBJELXNzBybCHOibUWEg0mWTnaYCSRU8h9R+aNRSvDihJtssSRCiDRpLaezA== + dependencies: + array-back "^2.0.0" + find-replace "^1.0.3" + typical "^2.6.1" + +command-line-args@^5.1.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.2.1.tgz#c44c32e437a57d7c51157696893c5909e9cec42e" + integrity sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg== + dependencies: + array-back "^3.1.0" + find-replace "^3.0.0" + lodash.camelcase "^4.3.0" + typical "^4.0.0" + +command-line-usage@^6.1.0: + version "6.1.3" + resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.3.tgz#428fa5acde6a838779dfa30e44686f4b6761d957" + integrity sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw== + dependencies: + array-back "^4.0.2" + chalk "^2.4.2" + table-layout "^1.0.2" + typical "^5.2.0" + +commander@2.18.0: + version "2.18.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" + integrity sha512-6CYPa+JP2ftfRU2qkDK+UTVeQYosOg/2GbcjIcKPHfinyOLPVGXu/ovN86RP49Re5ndJK1N0kuiidFFuepc4ZQ== + +commander@3.0.2, commander@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/commander/-/commander-3.0.2.tgz#6837c3fb677ad9933d1cfba42dd14d5117d6b39e" + integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow== + +commander@^2.8.1: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +compare-versions@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-6.0.0.tgz#a3edb527e4487bfab9a8b62ffe70cebc9b87675b" + integrity sha512-s2MzYxfRsE9f/ow8hjn7ysa7pod1xhHdQMsgiJtKx6XSNf4x2N1KG4fjrkUmXcP/e9Y2ZX4zB6sHIso0Lm6evQ== + +component-emitter@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" + integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +concat-stream@^1.5.1, concat-stream@^1.6.0, concat-stream@^1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +confusing-browser-globals@^1.0.10: + version "1.0.11" + resolved "https://registry.yarnpkg.com/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz#ae40e9b57cdd3915408a2805ebd3a5585608dc81" + integrity sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA== + +content-disposition@0.5.4: + version "0.5.4" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" + integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== + dependencies: + safe-buffer "5.2.1" + +content-hash@^2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/content-hash/-/content-hash-2.5.2.tgz#bbc2655e7c21f14fd3bfc7b7d4bfe6e454c9e211" + integrity sha512-FvIQKy0S1JaWV10sMsA7TRx8bpU+pqPkhbsfvOJAdjRXvYxEckAwQWGwtRjiaJfh+E0DvcWUGqcdjwMGFjsSdw== + dependencies: + cids "^0.7.1" + multicodec "^0.5.5" + multihashes "^0.4.15" + +content-type@~1.0.4, content-type@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" + integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== + +convert-source-map@^1.5.1: + version "1.9.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" + integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + integrity sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ== + +cookie@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" + integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== + +cookie@^0.4.1: + version "0.4.2" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" + integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== + +cookiejar@^2.1.1: + version "2.1.4" + resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.4.tgz#ee669c1fea2cf42dc31585469d193fef0d65771b" + integrity sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw== + +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + integrity sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw== + +core-js-pure@^3.0.1: + version "3.29.1" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.29.1.tgz#1be6ca2b8772f6b4df7fc4621743286e676c6162" + integrity sha512-4En6zYVi0i0XlXHVz/bi6l1XDjCqkKRq765NXuX+SnaIatlE96Odt5lMLjdxUiNI1v9OXI5DSLWYPlmTfkTktg== + +core-js@^2.4.0, core-js@^2.5.0: + version "2.6.12" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" + integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== + +core-util-is@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== + +core-util-is@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" + integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== + +cors@^2.8.1: + version "2.8.5" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" + integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== + dependencies: + object-assign "^4" + vary "^1" + +cosmiconfig@^5.0.7: + version "5.2.1" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.2.1.tgz#040f726809c591e77a17c0a3626ca45b4f168b1a" + integrity sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA== + dependencies: + import-fresh "^2.0.0" + is-directory "^0.3.1" + js-yaml "^3.13.1" + parse-json "^4.0.0" + +country-data@^0.0.31: + version "0.0.31" + resolved "https://registry.yarnpkg.com/country-data/-/country-data-0.0.31.tgz#80966b8e1d147fa6d6a589d32933f8793774956d" + integrity sha512-YqlY/i6ikZwoBFfdjK+hJTGaBdTgDpXLI15MCj2UsXZ2cPBb+Kx86AXmDH7PRGt0LUleck0cCgNdWeIhfbcxkQ== + dependencies: + currency-symbol-map "~2" + underscore ">1.4.4" + +crc-32@^1.2.0: + version "1.2.2" + resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff" + integrity sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ== + +create-ecdh@^4.0.0: + version "4.0.4" + resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.4.tgz#d6e7f4bffa66736085a0762fd3a632684dabcc4e" + integrity sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A== + dependencies: + bn.js "^4.1.0" + elliptic "^6.5.3" + +create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" + integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== + dependencies: + cipher-base "^1.0.1" + inherits "^2.0.1" + md5.js "^1.3.4" + ripemd160 "^2.0.1" + sha.js "^2.4.0" + +create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" + integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== + dependencies: + cipher-base "^1.0.3" + create-hash "^1.1.0" + inherits "^2.0.1" + ripemd160 "^2.0.0" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +create-require@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" + integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== + +cross-fetch@3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.0.4.tgz#7bef7020207e684a7638ef5f2f698e24d9eb283c" + integrity sha512-MSHgpjQqgbT/94D4CyADeNoYh52zMkCX4pcJvPP5WqPsLFMKjr2TCMg381ox5qI0ii2dPwaLx/00477knXqXVw== + dependencies: + node-fetch "2.6.0" + whatwg-fetch "3.0.0" + +cross-fetch@^2.1.0, cross-fetch@^2.1.1: + version "2.2.6" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.6.tgz#2ef0bb39a24ac034787965c457368a28730e220a" + integrity sha512-9JZz+vXCmfKUZ68zAptS7k4Nu8e2qcibe7WVZYps7sAgk5R8GYTc+T1WR0v1rlP9HxgARmOX1UTIJZFytajpNA== + dependencies: + node-fetch "^2.6.7" + whatwg-fetch "^2.0.4" + +cross-fetch@^3.0.6: + version "3.1.5" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" + integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== + dependencies: + node-fetch "2.6.7" + +cross-spawn@^6.0.5: + version "6.0.5" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" + integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== + dependencies: + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" + +cross-spawn@^7.0.2: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +"crypt@>= 0.0.1": + version "0.0.2" + resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" + integrity sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow== + +crypto-browserify@3.12.0: + version "3.12.0" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" + integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== + dependencies: + browserify-cipher "^1.0.0" + browserify-sign "^4.0.0" + create-ecdh "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.0" + diffie-hellman "^5.0.0" + inherits "^2.0.1" + pbkdf2 "^3.0.3" + public-encrypt "^4.0.0" + randombytes "^2.0.0" + randomfill "^1.0.3" + +crypto-js@^3.1.9-1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-3.3.0.tgz#846dd1cce2f68aacfa156c8578f926a609b7976b" + integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q== + +currency-symbol-map@~2: + version "2.2.0" + resolved "https://registry.yarnpkg.com/currency-symbol-map/-/currency-symbol-map-2.2.0.tgz#2b3c1872ff1ac2ce595d8273e58e1fff0272aea2" + integrity sha512-fPZJ3jqM68+AAgqQ7UaGbgHL/39rp6l7GyqS2k1HJPu/kpS8D07x/+Uup6a9tCUKIlOFcRrDCf1qxSt8jnI5BA== + +d@1, d@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a" + integrity sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA== + dependencies: + es5-ext "^0.10.50" + type "^1.0.1" + +damerau-levenshtein@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz#b43d286ccbd36bc5b2f7ed41caf2d0aba1f8a6e7" + integrity sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA== + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + integrity sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g== + dependencies: + assert-plus "^1.0.0" + +debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@3.2.6: + version "3.2.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" + integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== + dependencies: + ms "^2.1.1" + +debug@4, debug@4.3.4, debug@^4.0.1, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +debug@=3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + +debug@^3.1.0, debug@^3.2.7: + version "3.2.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" + integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== + dependencies: + ms "^2.1.1" + +decamelize@^1.1.1, decamelize@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA== + +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + +decode-uri-component@^0.2.0: + version "0.2.2" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9" + integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ== + +decompress-response@^3.2.0, decompress-response@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" + integrity sha512-BzRPQuY1ip+qDonAOz42gRm/pg9F768C+npV/4JOsxRC2sq+Rlk+Q4ZCAsOhnIaMrgarILY+RMUIvMmmX1qAEA== + dependencies: + mimic-response "^1.0.0" + +decompress-response@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc" + integrity sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ== + dependencies: + mimic-response "^3.1.0" + +decompress-tar@^4.0.0, decompress-tar@^4.1.0, decompress-tar@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/decompress-tar/-/decompress-tar-4.1.1.tgz#718cbd3fcb16209716e70a26b84e7ba4592e5af1" + integrity sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ== + dependencies: + file-type "^5.2.0" + is-stream "^1.1.0" + tar-stream "^1.5.2" + +decompress-tarbz2@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz#3082a5b880ea4043816349f378b56c516be1a39b" + integrity sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A== + dependencies: + decompress-tar "^4.1.0" + file-type "^6.1.0" + is-stream "^1.1.0" + seek-bzip "^1.0.5" + unbzip2-stream "^1.0.9" + +decompress-targz@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/decompress-targz/-/decompress-targz-4.1.1.tgz#c09bc35c4d11f3de09f2d2da53e9de23e7ce1eee" + integrity sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w== + dependencies: + decompress-tar "^4.1.1" + file-type "^5.2.0" + is-stream "^1.1.0" + +decompress-unzip@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/decompress-unzip/-/decompress-unzip-4.0.1.tgz#deaaccdfd14aeaf85578f733ae8210f9b4848f69" + integrity sha512-1fqeluvxgnn86MOh66u8FjbtJpAFv5wgCT9Iw8rcBqQcCo5tO8eiJw7NNTrvt9n4CRBVq7CstiS922oPgyGLrw== + dependencies: + file-type "^3.8.0" + get-stream "^2.2.0" + pify "^2.3.0" + yauzl "^2.4.2" + +decompress@^4.0.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/decompress/-/decompress-4.2.1.tgz#007f55cc6a62c055afa37c07eb6a4ee1b773f118" + integrity sha512-e48kc2IjU+2Zw8cTb6VZcJQ3lgVbS4uuB1TfCHbiZIP/haNXm+SVyhu+87jts5/3ROpd82GSVCoNs/z8l4ZOaQ== + dependencies: + decompress-tar "^4.0.0" + decompress-tarbz2 "^4.0.0" + decompress-targz "^4.0.0" + decompress-unzip "^4.0.1" + graceful-fs "^4.1.10" + make-dir "^1.0.0" + pify "^2.3.0" + strip-dirs "^2.0.0" + +deep-eql@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" + integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw== + dependencies: + type-detect "^4.0.0" + +deep-eql@^4.1.2: + version "4.1.3" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.3.tgz#7c7775513092f7df98d8df9996dd085eb668cc6d" + integrity sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw== + dependencies: + type-detect "^4.0.0" + +deep-equal@^2.0.5: + version "2.2.0" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.2.0.tgz#5caeace9c781028b9ff459f33b779346637c43e6" + integrity sha512-RdpzE0Hv4lhowpIUKKMJfeH6C1pXdtT1/it80ubgWqwI3qpuxUBpC1S4hnHg+zjnuOoDkzUtUCEEkG+XG5l3Mw== + dependencies: + call-bind "^1.0.2" + es-get-iterator "^1.1.2" + get-intrinsic "^1.1.3" + is-arguments "^1.1.1" + is-array-buffer "^3.0.1" + is-date-object "^1.0.5" + is-regex "^1.1.4" + is-shared-array-buffer "^1.0.2" + isarray "^2.0.5" + object-is "^1.1.5" + object-keys "^1.1.1" + object.assign "^4.1.4" + regexp.prototype.flags "^1.4.3" + side-channel "^1.0.4" + which-boxed-primitive "^1.0.2" + which-collection "^1.0.1" + which-typed-array "^1.1.9" + +deep-equal@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a" + integrity sha512-yd9c5AdiqVcR+JjcwUQb9DkhJc8ngNr0MahEBGvDiJw8puWab2yZlh+nkasOnZP+EGTAP6rRp2JzJhJZzvNF8g== + dependencies: + is-arguments "^1.0.4" + is-date-object "^1.0.1" + is-regex "^1.0.4" + object-is "^1.0.1" + object-keys "^1.1.1" + regexp.prototype.flags "^1.2.0" + +deep-extend@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + +deep-is@^0.1.3, deep-is@~0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" + integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== + +defer-to-connect@^1.0.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" + integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== + +defer-to-connect@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-2.0.1.tgz#8016bdb4143e4632b77a3449c6236277de520587" + integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== + +deferred-leveldown@~1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/deferred-leveldown/-/deferred-leveldown-1.2.2.tgz#3acd2e0b75d1669924bc0a4b642851131173e1eb" + integrity sha512-uukrWD2bguRtXilKt6cAWKyoXrTSMo5m7crUdLfWQmu8kIm88w3QZoUL+6nhpfKVmhHANER6Re3sKoNoZ3IKMA== + dependencies: + abstract-leveldown "~2.6.0" + +deferred-leveldown@~4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/deferred-leveldown/-/deferred-leveldown-4.0.2.tgz#0b0570087827bf480a23494b398f04c128c19a20" + integrity sha512-5fMC8ek8alH16QiV0lTCis610D1Zt1+LA4MS4d63JgS32lrCjTFDUFz2ao09/j2I4Bqb5jL4FZYwu7Jz0XO1ww== + dependencies: + abstract-leveldown "~5.0.0" + inherits "^2.0.3" + +define-properties@^1.1.2, define-properties@^1.1.3, define-properties@^1.1.4: + version "1.2.0" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.0.tgz#52988570670c9eacedd8064f4a990f2405849bd5" + integrity sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA== + dependencies: + has-property-descriptors "^1.0.0" + object-keys "^1.1.1" + +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + integrity sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA== + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + integrity sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA== + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + +defined@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.1.tgz#c0b9db27bfaffd95d6f61399419b893df0f91ebf" + integrity sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q== + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + +delimit-stream@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/delimit-stream/-/delimit-stream-0.1.0.tgz#9b8319477c0e5f8aeb3ce357ae305fc25ea1cd2b" + integrity sha512-a02fiQ7poS5CnjiJBAsjGLPp5EwVoGHNeu9sziBd9huppRfsAFIpv5zNLv0V1gbop53ilngAf5Kf331AwcoRBQ== + +depd@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== + +des.js@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" + integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== + dependencies: + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + +destroy@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== + +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + integrity sha512-BDKtmHlOzwI7iRuEkhzsnPoi5ypEhWAJB5RvHWe1kMr06js3uK5B3734i3ui5Yd+wOJV1cpE4JnivPD283GU/A== + dependencies: + repeating "^2.0.0" + +diff@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== + +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + +diff@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" + integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== + +diffie-hellman@^5.0.0: + version "5.0.3" + resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" + integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== + dependencies: + bn.js "^4.1.0" + miller-rabin "^4.0.0" + randombytes "^2.0.0" + +dir-glob@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" + integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== + dependencies: + path-type "^4.0.0" + +doctrine@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + integrity sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw== + dependencies: + esutils "^2.0.2" + +doctrine@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" + integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== + dependencies: + esutils "^2.0.2" + +dom-walk@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84" + integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w== + +dotenv@^8.2.0: + version "8.6.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.6.0.tgz#061af664d19f7f4d8fc6e4ff9b584ce237adcb8b" + integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g== + +dotignore@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/dotignore/-/dotignore-0.1.2.tgz#f942f2200d28c3a76fbdd6f0ee9f3257c8a2e905" + integrity sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw== + dependencies: + minimatch "^3.0.4" + +duplexer3@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.5.tgz#0b5e4d7bad5de8901ea4440624c8e1d20099217e" + integrity sha512-1A8za6ws41LQgv9HrE/66jyC5yuSjQ3L/KOpFtoBilsAK2iA2wuS5rTt1OCzIvtS2V7nVmedsUU+DGRcjBmOYA== + +ecc-jsbn@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" + integrity sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw== + dependencies: + jsbn "~0.1.0" + safer-buffer "^2.1.0" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== + +electron-to-chromium@^1.3.47: + version "1.4.342" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.342.tgz#3c7e199c3aa89c993df4b6f5223d6d26988f58e6" + integrity sha512-dTei3VResi5bINDENswBxhL+N0Mw5YnfWyTqO75KGsVldurEkhC9+CelJVAse8jycWyP8pv3VSj4BSyP8wTWJA== + +elliptic@6.3.3: + version "6.3.3" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.3.3.tgz#5482d9646d54bcb89fd7d994fc9e2e9568876e3f" + integrity sha512-cIky9SO2H8W2eU1NOLySnhOYJnuEWCq9ZJeHvHd/lXzEL9vyraIMfilZSn57X3aVX+wkfYmqkch2LvmTzkjFpA== + dependencies: + bn.js "^4.4.0" + brorand "^1.0.1" + hash.js "^1.0.0" + inherits "^2.0.1" + +elliptic@6.5.4, elliptic@^6.4.0, elliptic@^6.4.1, elliptic@^6.5.2, elliptic@^6.5.3, elliptic@^6.5.4: + version "6.5.4" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" + integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== + dependencies: + bn.js "^4.11.9" + brorand "^1.1.0" + hash.js "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" + +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + +encode-utf8@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/encode-utf8/-/encode-utf8-1.0.3.tgz#f30fdd31da07fb596f281beb2f6b027851994cda" + integrity sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw== + +encodeurl@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w== + +encoding-down@5.0.4, encoding-down@~5.0.0: + version "5.0.4" + resolved "https://registry.yarnpkg.com/encoding-down/-/encoding-down-5.0.4.tgz#1e477da8e9e9d0f7c8293d320044f8b2cd8e9614" + integrity sha512-8CIZLDcSKxgzT+zX8ZVfgNbu8Md2wq/iqa1Y7zyVR18QBEAc0Nmzuvj/N5ykSKpfGzjM8qxbaFntLPwnVoUhZw== + dependencies: + abstract-leveldown "^5.0.0" + inherits "^2.0.3" + level-codec "^9.0.0" + level-errors "^2.0.0" + xtend "^4.0.1" + +encoding@^0.1.11: + version "0.1.13" + resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9" + integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A== + dependencies: + iconv-lite "^0.6.2" + +end-of-stream@^1.0.0, end-of-stream@^1.1.0: + version "1.4.4" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" + integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== + dependencies: + once "^1.4.0" + +enquirer@^2.3.0, enquirer@^2.3.5, enquirer@^2.3.6: + version "2.3.6" + resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" + integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== + dependencies: + ansi-colors "^4.1.1" + +env-paths@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-2.2.1.tgz#420399d416ce1fbe9bc0a07c62fa68d67fd0f8f2" + integrity sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A== + +errno@~0.1.1: + version "0.1.8" + resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f" + integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A== + dependencies: + prr "~1.0.1" + +error-ex@^1.2.0, error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + +es-abstract@^1.19.0, es-abstract@^1.20.4: + version "1.21.2" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.21.2.tgz#a56b9695322c8a185dc25975aa3b8ec31d0e7eff" + integrity sha512-y/B5POM2iBnIxCiernH1G7rC9qQoM77lLIMQLuob0zhp8C56Po81+2Nj0WFKnd0pNReDTnkYryc+zhOzpEIROg== + dependencies: + array-buffer-byte-length "^1.0.0" + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + es-set-tostringtag "^2.0.1" + es-to-primitive "^1.2.1" + function.prototype.name "^1.1.5" + get-intrinsic "^1.2.0" + get-symbol-description "^1.0.0" + globalthis "^1.0.3" + gopd "^1.0.1" + has "^1.0.3" + has-property-descriptors "^1.0.0" + has-proto "^1.0.1" + has-symbols "^1.0.3" + internal-slot "^1.0.5" + is-array-buffer "^3.0.2" + is-callable "^1.2.7" + is-negative-zero "^2.0.2" + is-regex "^1.1.4" + is-shared-array-buffer "^1.0.2" + is-string "^1.0.7" + is-typed-array "^1.1.10" + is-weakref "^1.0.2" + object-inspect "^1.12.3" + object-keys "^1.1.1" + object.assign "^4.1.4" + regexp.prototype.flags "^1.4.3" + safe-regex-test "^1.0.0" + string.prototype.trim "^1.2.7" + string.prototype.trimend "^1.0.6" + string.prototype.trimstart "^1.0.6" + typed-array-length "^1.0.4" + unbox-primitive "^1.0.2" + which-typed-array "^1.1.9" + +es-array-method-boxes-properly@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz#873f3e84418de4ee19c5be752990b2e44718d09e" + integrity sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA== + +es-get-iterator@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.3.tgz#3ef87523c5d464d41084b2c3c9c214f1199763d6" + integrity sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.3" + has-symbols "^1.0.3" + is-arguments "^1.1.1" + is-map "^2.0.2" + is-set "^2.0.2" + is-string "^1.0.7" + isarray "^2.0.5" + stop-iteration-iterator "^1.0.0" + +es-set-tostringtag@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz#338d502f6f674301d710b80c8592de8a15f09cd8" + integrity sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg== + dependencies: + get-intrinsic "^1.1.3" + has "^1.0.3" + has-tostringtag "^1.0.0" + +es-shim-unscopables@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz#702e632193201e3edf8713635d083d378e510241" + integrity sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w== + dependencies: + has "^1.0.3" + +es-to-primitive@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" + integrity sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA== + dependencies: + is-callable "^1.1.4" + is-date-object "^1.0.1" + is-symbol "^1.0.2" + +es5-ext@^0.10.35, es5-ext@^0.10.50: + version "0.10.62" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.62.tgz#5e6adc19a6da524bf3d1e02bbc8960e5eb49a9a5" + integrity sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA== + dependencies: + es6-iterator "^2.0.3" + es6-symbol "^3.1.3" + next-tick "^1.1.0" + +es6-iterator@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + integrity sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g== + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + +es6-symbol@^3.1.1, es6-symbol@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.3.tgz#bad5d3c1bcdac28269f4cb331e431c78ac705d18" + integrity sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA== + dependencies: + d "^1.0.1" + ext "^1.1.2" + +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== + +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== + +escape-string-regexp@4.0.0, escape-string-regexp@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eslint-config-airbnb-base@^15.0.0: + version "15.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz#6b09add90ac79c2f8d723a2580e07f3925afd236" + integrity sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig== + dependencies: + confusing-browser-globals "^1.0.10" + object.assign "^4.1.2" + object.entries "^1.1.5" + semver "^6.3.0" + +eslint-config-airbnb-typescript@^17.0.0: + version "17.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-typescript/-/eslint-config-airbnb-typescript-17.0.0.tgz#360dbcf810b26bbcf2ff716198465775f1c49a07" + integrity sha512-elNiuzD0kPAPTXjFWg+lE24nMdHMtuxgYoD30OyMD6yrW1AhFZPAg27VX7d3tzOErw+dgJTNWfRSDqEcXb4V0g== + dependencies: + eslint-config-airbnb-base "^15.0.0" + +eslint-config-airbnb@^19.0.0: + version "19.0.4" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb/-/eslint-config-airbnb-19.0.4.tgz#84d4c3490ad70a0ffa571138ebcdea6ab085fdc3" + integrity sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew== + dependencies: + eslint-config-airbnb-base "^15.0.0" + object.assign "^4.1.2" + object.entries "^1.1.5" + +eslint-config-prettier@^8.5.0: + version "8.8.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz#bfda738d412adc917fd7b038857110efe98c9348" + integrity sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA== + +eslint-import-resolver-node@^0.3.7: + version "0.3.7" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.7.tgz#83b375187d412324a1963d84fa664377a23eb4d7" + integrity sha512-gozW2blMLJCeFpBwugLTGyvVjNoeo1knonXAcatC6bjPBZitotxdWf7Gimr25N4c0AAOo4eOUfaG82IJPDpqCA== + dependencies: + debug "^3.2.7" + is-core-module "^2.11.0" + resolve "^1.22.1" + +eslint-module-utils@^2.7.4: + version "2.7.4" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.7.4.tgz#4f3e41116aaf13a20792261e61d3a2e7e0583974" + integrity sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA== + dependencies: + debug "^3.2.7" + +eslint-plugin-import@^2.26.0: + version "2.27.5" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz#876a6d03f52608a3e5bb439c2550588e51dd6c65" + integrity sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow== + dependencies: + array-includes "^3.1.6" + array.prototype.flat "^1.3.1" + array.prototype.flatmap "^1.3.1" + debug "^3.2.7" + doctrine "^2.1.0" + eslint-import-resolver-node "^0.3.7" + eslint-module-utils "^2.7.4" + has "^1.0.3" + is-core-module "^2.11.0" + is-glob "^4.0.3" + minimatch "^3.1.2" + object.values "^1.1.6" + resolve "^1.22.1" + semver "^6.3.0" + tsconfig-paths "^3.14.1" + +eslint-plugin-jsx-a11y@^6.6.1: + version "6.7.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.7.1.tgz#fca5e02d115f48c9a597a6894d5bcec2f7a76976" + integrity sha512-63Bog4iIethyo8smBklORknVjB0T2dwB8Mr/hIC+fBS0uyHdYYpzM/Ed+YC8VxTjlXHEWFOdmgwcDn1U2L9VCA== + dependencies: + "@babel/runtime" "^7.20.7" + aria-query "^5.1.3" + array-includes "^3.1.6" + array.prototype.flatmap "^1.3.1" + ast-types-flow "^0.0.7" + axe-core "^4.6.2" + axobject-query "^3.1.1" + damerau-levenshtein "^1.0.8" + emoji-regex "^9.2.2" + has "^1.0.3" + jsx-ast-utils "^3.3.3" + language-tags "=1.0.5" + minimatch "^3.1.2" + object.entries "^1.1.6" + object.fromentries "^2.0.6" + semver "^6.3.0" + +eslint-plugin-no-only-tests@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-3.1.0.tgz#f38e4935c6c6c4842bf158b64aaa20c366fe171b" + integrity sha512-Lf4YW/bL6Un1R6A76pRZyE1dl1vr31G/ev8UzIc/geCgFWyrKil8hVjYqWVKGB/UIGmb6Slzs9T0wNezdSVegw== + +eslint-plugin-prettier@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz#651cbb88b1dab98bfd42f017a12fa6b2d993f94b" + integrity sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ== + dependencies: + prettier-linter-helpers "^1.0.0" + +eslint-plugin-react-hooks@^4.3.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz#4c3e697ad95b77e93f8646aaa1630c1ba607edd3" + integrity sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g== + +eslint-plugin-react@^7.31.11: + version "7.32.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.32.2.tgz#e71f21c7c265ebce01bcbc9d0955170c55571f10" + integrity sha512-t2fBMa+XzonrrNkyVirzKlvn5RXzzPwRHtMvLAtVZrt8oxgnTQaYbU6SXTOO1mwQgp1y5+toMSKInnzGr0Knqg== + dependencies: + array-includes "^3.1.6" + array.prototype.flatmap "^1.3.1" + array.prototype.tosorted "^1.1.1" + doctrine "^2.1.0" + estraverse "^5.3.0" + jsx-ast-utils "^2.4.1 || ^3.0.0" + minimatch "^3.1.2" + object.entries "^1.1.6" + object.fromentries "^2.0.6" + object.hasown "^1.1.2" + object.values "^1.1.6" + prop-types "^15.8.1" + resolve "^2.0.0-next.4" + semver "^6.3.0" + string.prototype.matchall "^4.0.8" + +eslint-scope@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" + integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint-scope@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== + dependencies: + esrecurse "^4.3.0" + estraverse "^4.1.1" + +eslint-utils@^1.3.1: + version "1.4.3" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f" + integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q== + dependencies: + eslint-visitor-keys "^1.1.0" + +eslint-utils@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" + integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg== + dependencies: + eslint-visitor-keys "^1.1.0" + +eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" + integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== + +eslint-visitor-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" + integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== + +eslint-visitor-keys@^3.3.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz#c7f0f956124ce677047ddbc192a68f999454dedc" + integrity sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ== + +eslint@^5.6.0: + version "5.16.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.16.0.tgz#a1e3ac1aae4a3fbd8296fcf8f7ab7314cbb6abea" + integrity sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg== + dependencies: + "@babel/code-frame" "^7.0.0" + ajv "^6.9.1" + chalk "^2.1.0" + cross-spawn "^6.0.5" + debug "^4.0.1" + doctrine "^3.0.0" + eslint-scope "^4.0.3" + eslint-utils "^1.3.1" + eslint-visitor-keys "^1.0.0" + espree "^5.0.1" + esquery "^1.0.1" + esutils "^2.0.2" + file-entry-cache "^5.0.1" + functional-red-black-tree "^1.0.1" + glob "^7.1.2" + globals "^11.7.0" + ignore "^4.0.6" + import-fresh "^3.0.0" + imurmurhash "^0.1.4" + inquirer "^6.2.2" + js-yaml "^3.13.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.3.0" + lodash "^4.17.11" + minimatch "^3.0.4" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.2" + progress "^2.0.0" + regexpp "^2.0.1" + semver "^5.5.1" + strip-ansi "^4.0.0" + strip-json-comments "^2.0.1" + table "^5.2.3" + text-table "^0.2.0" + +eslint@^7.32.0: + version "7.32.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.32.0.tgz#c6d328a14be3fb08c8d1d21e12c02fdb7a2a812d" + integrity sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA== + dependencies: + "@babel/code-frame" "7.12.11" + "@eslint/eslintrc" "^0.4.3" + "@humanwhocodes/config-array" "^0.5.0" + ajv "^6.10.0" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.0.1" + doctrine "^3.0.0" + enquirer "^2.3.5" + escape-string-regexp "^4.0.0" + eslint-scope "^5.1.1" + eslint-utils "^2.1.0" + eslint-visitor-keys "^2.0.0" + espree "^7.3.1" + esquery "^1.4.0" + esutils "^2.0.2" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + functional-red-black-tree "^1.0.1" + glob-parent "^5.1.2" + globals "^13.6.0" + ignore "^4.0.6" + import-fresh "^3.0.0" + imurmurhash "^0.1.4" + is-glob "^4.0.0" + js-yaml "^3.13.1" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.0.4" + natural-compare "^1.4.0" + optionator "^0.9.1" + progress "^2.0.0" + regexpp "^3.1.0" + semver "^7.2.1" + strip-ansi "^6.0.0" + strip-json-comments "^3.1.0" + table "^6.0.9" + text-table "^0.2.0" + v8-compile-cache "^2.0.3" + +espree@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.1.tgz#5d6526fa4fc7f0788a5cf75b15f30323e2f81f7a" + integrity sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A== + dependencies: + acorn "^6.0.7" + acorn-jsx "^5.0.0" + eslint-visitor-keys "^1.0.0" + +espree@^7.3.0, espree@^7.3.1: + version "7.3.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.1.tgz#f2df330b752c6f55019f8bd89b7660039c1bbbb6" + integrity sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g== + dependencies: + acorn "^7.4.0" + acorn-jsx "^5.3.1" + eslint-visitor-keys "^1.3.0" + +esprima@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + +esquery@^1.0.1, esquery@^1.4.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.5.0.tgz#6ce17738de8577694edd7361c57182ac8cb0db0b" + integrity sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg== + dependencies: + estraverse "^5.1.0" + +esrecurse@^4.1.0, esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^4.1.1: + version "4.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + +estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== + +eth-block-tracker@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/eth-block-tracker/-/eth-block-tracker-3.0.1.tgz#95cd5e763c7293e0b1b2790a2a39ac2ac188a5e1" + integrity sha512-WUVxWLuhMmsfenfZvFO5sbl1qFY2IqUlw/FPVmjjdElpqLsZtSG+wPe9Dz7W/sB6e80HgFKknOmKk2eNlznHug== + dependencies: + eth-query "^2.1.0" + ethereumjs-tx "^1.3.3" + ethereumjs-util "^5.1.3" + ethjs-util "^0.1.3" + json-rpc-engine "^3.6.0" + pify "^2.3.0" + tape "^4.6.3" + +eth-ens-namehash@2.0.8, eth-ens-namehash@^2.0.8: + version "2.0.8" + resolved "https://registry.yarnpkg.com/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz#229ac46eca86d52e0c991e7cb2aef83ff0f68bcf" + integrity sha512-VWEI1+KJfz4Km//dadyvBBoBeSQ0MHTXPvr8UIXiLW6IanxvAV+DmlZAijZwAyggqGUfwQBeHf7tc9wzc1piSw== + dependencies: + idna-uts46-hx "^2.3.1" + js-sha3 "^0.5.7" + +eth-gas-reporter@^0.2.25: + version "0.2.25" + resolved "https://registry.yarnpkg.com/eth-gas-reporter/-/eth-gas-reporter-0.2.25.tgz#546dfa946c1acee93cb1a94c2a1162292d6ff566" + integrity sha512-1fRgyE4xUB8SoqLgN3eDfpDfwEfRxh2Sz1b7wzFbyQA+9TekMmvSjjoRu9SKcSVyK+vLkLIsVbJDsTWjw195OQ== + dependencies: + "@ethersproject/abi" "^5.0.0-beta.146" + "@solidity-parser/parser" "^0.14.0" + cli-table3 "^0.5.0" + colors "1.4.0" + ethereum-cryptography "^1.0.3" + ethers "^4.0.40" + fs-readdir-recursive "^1.1.0" + lodash "^4.17.14" + markdown-table "^1.1.3" + mocha "^7.1.1" + req-cwd "^2.0.0" + request "^2.88.0" + request-promise-native "^1.0.5" + sha1 "^1.1.1" + sync-request "^6.0.0" + +eth-json-rpc-infura@^3.1.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/eth-json-rpc-infura/-/eth-json-rpc-infura-3.2.1.tgz#26702a821067862b72d979c016fd611502c6057f" + integrity sha512-W7zR4DZvyTn23Bxc0EWsq4XGDdD63+XPUCEhV2zQvQGavDVC4ZpFDK4k99qN7bd7/fjj37+rxmuBOBeIqCA5Mw== + dependencies: + cross-fetch "^2.1.1" + eth-json-rpc-middleware "^1.5.0" + json-rpc-engine "^3.4.0" + json-rpc-error "^2.0.0" + +eth-json-rpc-middleware@^1.5.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/eth-json-rpc-middleware/-/eth-json-rpc-middleware-1.6.0.tgz#5c9d4c28f745ccb01630f0300ba945f4bef9593f" + integrity sha512-tDVCTlrUvdqHKqivYMjtFZsdD7TtpNLBCfKAcOpaVs7orBMS/A8HWro6dIzNtTZIR05FAbJ3bioFOnZpuCew9Q== + dependencies: + async "^2.5.0" + eth-query "^2.1.2" + eth-tx-summary "^3.1.2" + ethereumjs-block "^1.6.0" + ethereumjs-tx "^1.3.3" + ethereumjs-util "^5.1.2" + ethereumjs-vm "^2.1.0" + fetch-ponyfill "^4.0.0" + json-rpc-engine "^3.6.0" + json-rpc-error "^2.0.0" + json-stable-stringify "^1.0.1" + promise-to-callback "^1.0.0" + tape "^4.6.3" + +eth-lib@0.2.7: + version "0.2.7" + resolved "https://registry.yarnpkg.com/eth-lib/-/eth-lib-0.2.7.tgz#2f93f17b1e23aec3759cd4a3fe20c1286a3fc1ca" + integrity sha512-VqEBQKH92jNsaE8lG9CTq8M/bc12gdAfb5MY8Ro1hVyXkh7rOtY3m5tRHK3Hus5HqIAAwU2ivcUjTLVwsvf/kw== + dependencies: + bn.js "^4.11.6" + elliptic "^6.4.0" + xhr-request-promise "^0.1.2" + +eth-lib@0.2.8, eth-lib@^0.2.8: + version "0.2.8" + resolved "https://registry.yarnpkg.com/eth-lib/-/eth-lib-0.2.8.tgz#b194058bef4b220ad12ea497431d6cb6aa0623c8" + integrity sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw== + dependencies: + bn.js "^4.11.6" + elliptic "^6.4.0" + xhr-request-promise "^0.1.2" + +eth-lib@^0.1.26: + version "0.1.29" + resolved "https://registry.yarnpkg.com/eth-lib/-/eth-lib-0.1.29.tgz#0c11f5060d42da9f931eab6199084734f4dbd1d9" + integrity sha512-bfttrr3/7gG4E02HoWTDUcDDslN003OlOoBxk9virpAZQ1ja/jDgwkWB8QfJF7ojuEowrqy+lzp9VcJG7/k5bQ== + dependencies: + bn.js "^4.11.6" + elliptic "^6.4.0" + nano-json-stream-parser "^0.1.2" + servify "^0.1.12" + ws "^3.0.0" + xhr-request-promise "^0.1.2" + +eth-query@^2.0.2, eth-query@^2.1.0, eth-query@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/eth-query/-/eth-query-2.1.2.tgz#d6741d9000106b51510c72db92d6365456a6da5e" + integrity sha512-srES0ZcvwkR/wd5OQBRA1bIJMww1skfGS0s8wlwK3/oNP4+wnds60krvu5R1QbpRQjMmpG5OMIWro5s7gvDPsA== + dependencies: + json-rpc-random-id "^1.0.0" + xtend "^4.0.1" + +eth-sig-util@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/eth-sig-util/-/eth-sig-util-3.0.0.tgz#75133b3d7c20a5731af0690c385e184ab942b97e" + integrity sha512-4eFkMOhpGbTxBQ3AMzVf0haUX2uTur7DpWiHzWyTURa28BVJJtOkcb9Ok5TV0YvEPG61DODPW7ZUATbJTslioQ== + dependencies: + buffer "^5.2.1" + elliptic "^6.4.0" + ethereumjs-abi "0.6.5" + ethereumjs-util "^5.1.1" + tweetnacl "^1.0.0" + tweetnacl-util "^0.15.0" + +eth-sig-util@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/eth-sig-util/-/eth-sig-util-1.4.2.tgz#8d958202c7edbaae839707fba6f09ff327606210" + integrity sha512-iNZ576iTOGcfllftB73cPB5AN+XUQAT/T8xzsILsghXC1o8gJUqe3RHlcDqagu+biFpYQ61KQrZZJza8eRSYqw== + dependencies: + ethereumjs-abi "git+https://github.com/ethereumjs/ethereumjs-abi.git" + ethereumjs-util "^5.1.1" + +eth-tx-summary@^3.1.2: + version "3.2.4" + resolved "https://registry.yarnpkg.com/eth-tx-summary/-/eth-tx-summary-3.2.4.tgz#e10eb95eb57cdfe549bf29f97f1e4f1db679035c" + integrity sha512-NtlDnaVZah146Rm8HMRUNMgIwG/ED4jiqk0TME9zFheMl1jOp6jL1m0NKGjJwehXQ6ZKCPr16MTr+qspKpEXNg== + dependencies: + async "^2.1.2" + clone "^2.0.0" + concat-stream "^1.5.1" + end-of-stream "^1.1.0" + eth-query "^2.0.2" + ethereumjs-block "^1.4.1" + ethereumjs-tx "^1.1.1" + ethereumjs-util "^5.0.1" + ethereumjs-vm "^2.6.0" + through2 "^2.0.3" + +ethashjs@~0.0.7: + version "0.0.8" + resolved "https://registry.yarnpkg.com/ethashjs/-/ethashjs-0.0.8.tgz#227442f1bdee409a548fb04136e24c874f3aa6f9" + integrity sha512-/MSbf/r2/Ld8o0l15AymjOTlPqpN8Cr4ByUEA9GtR4x0yAh3TdtDzEg29zMjXCNPI7u6E5fOQdj/Cf9Tc7oVNw== + dependencies: + async "^2.1.2" + buffer-xor "^2.0.1" + ethereumjs-util "^7.0.2" + miller-rabin "^4.0.0" + +ethereum-bloom-filters@^1.0.6: + version "1.0.10" + resolved "https://registry.yarnpkg.com/ethereum-bloom-filters/-/ethereum-bloom-filters-1.0.10.tgz#3ca07f4aed698e75bd134584850260246a5fed8a" + integrity sha512-rxJ5OFN3RwjQxDcFP2Z5+Q9ho4eIdEmSc2ht0fCu8Se9nbXjZ7/031uXoUYJ87KHCOdVeiUuwSnoS7hmYAGVHA== + dependencies: + js-sha3 "^0.8.0" + +ethereum-common@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/ethereum-common/-/ethereum-common-0.2.0.tgz#13bf966131cce1eeade62a1b434249bb4cb120ca" + integrity sha512-XOnAR/3rntJgbCdGhqdaLIxDLWKLmsZOGhHdBKadEr6gEnJLH52k93Ou+TUdFaPN3hJc3isBZBal3U/XZ15abA== + +ethereum-common@^0.0.18: + version "0.0.18" + resolved "https://registry.yarnpkg.com/ethereum-common/-/ethereum-common-0.0.18.tgz#2fdc3576f232903358976eb39da783213ff9523f" + integrity sha512-EoltVQTRNg2Uy4o84qpa2aXymXDJhxm7eos/ACOg0DG4baAbMjhbdAEsx9GeE8sC3XCxnYvrrzZDH8D8MtA2iQ== + +ethereum-cryptography@0.1.3, ethereum-cryptography@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz#8d6143cfc3d74bf79bbd8edecdf29e4ae20dd191" + integrity sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ== + dependencies: + "@types/pbkdf2" "^3.0.0" + "@types/secp256k1" "^4.0.1" + blakejs "^1.1.0" + browserify-aes "^1.2.0" + bs58check "^2.1.2" + create-hash "^1.2.0" + create-hmac "^1.1.7" + hash.js "^1.1.7" + keccak "^3.0.0" + pbkdf2 "^3.0.17" + randombytes "^2.1.0" + safe-buffer "^5.1.2" + scrypt-js "^3.0.0" + secp256k1 "^4.0.1" + setimmediate "^1.0.5" + +ethereum-cryptography@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-1.2.0.tgz#5ccfa183e85fdaf9f9b299a79430c044268c9b3a" + integrity sha512-6yFQC9b5ug6/17CQpCyE3k9eKBMdhyVjzUy1WkiuY/E4vj/SXDBbCw8QEIaXqf0Mf2SnY6RmpDcwlUmBSS0EJw== + dependencies: + "@noble/hashes" "1.2.0" + "@noble/secp256k1" "1.7.1" + "@scure/bip32" "1.1.5" + "@scure/bip39" "1.1.1" + +ethereum-waffle@3.4.0: + version "3.4.0" + resolved "https://registry.yarnpkg.com/ethereum-waffle/-/ethereum-waffle-3.4.0.tgz#990b3c6c26db9c2dd943bf26750a496f60c04720" + integrity sha512-ADBqZCkoSA5Isk486ntKJVjFEawIiC+3HxNqpJqONvh3YXBTNiRfXvJtGuAFLXPG91QaqkGqILEHANAo7j/olQ== + dependencies: + "@ethereum-waffle/chai" "^3.4.0" + "@ethereum-waffle/compiler" "^3.4.0" + "@ethereum-waffle/mock-contract" "^3.3.0" + "@ethereum-waffle/provider" "^3.4.0" + ethers "^5.0.1" + +ethereumjs-abi@0.6.5: + version "0.6.5" + resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.5.tgz#5a637ef16ab43473fa72a29ad90871405b3f5241" + integrity sha512-rCjJZ/AE96c/AAZc6O3kaog4FhOsAViaysBxqJNy2+LHP0ttH0zkZ7nXdVHOAyt6lFwLO0nlCwWszysG/ao1+g== + dependencies: + bn.js "^4.10.0" + ethereumjs-util "^4.3.0" + +ethereumjs-abi@0.6.8, ethereumjs-abi@^0.6.8: + version "0.6.8" + resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz#71bc152db099f70e62f108b7cdfca1b362c6fcae" + integrity sha512-Tx0r/iXI6r+lRsdvkFDlut0N08jWMnKRZ6Gkq+Nmw75lZe4e6o3EkSnkaBP5NF6+m5PTGAr9JP43N3LyeoglsA== + dependencies: + bn.js "^4.11.8" + ethereumjs-util "^6.0.0" + +"ethereumjs-abi@git+https://github.com/ethereumjs/ethereumjs-abi.git": + version "0.6.8" + resolved "git+https://github.com/ethereumjs/ethereumjs-abi.git#ee3994657fa7a427238e6ba92a84d0b529bbcde0" + dependencies: + bn.js "^4.11.8" + ethereumjs-util "^6.0.0" + +ethereumjs-account@3.0.0, ethereumjs-account@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ethereumjs-account/-/ethereumjs-account-3.0.0.tgz#728f060c8e0c6e87f1e987f751d3da25422570a9" + integrity sha512-WP6BdscjiiPkQfF9PVfMcwx/rDvfZTjFKY0Uwc09zSQr9JfIVH87dYIJu0gNhBhpmovV4yq295fdllS925fnBA== + dependencies: + ethereumjs-util "^6.0.0" + rlp "^2.2.1" + safe-buffer "^5.1.1" + +ethereumjs-account@^2.0.3: + version "2.0.5" + resolved "https://registry.yarnpkg.com/ethereumjs-account/-/ethereumjs-account-2.0.5.tgz#eeafc62de544cb07b0ee44b10f572c9c49e00a84" + integrity sha512-bgDojnXGjhMwo6eXQC0bY6UK2liSFUSMwwylOmQvZbSl/D7NXQ3+vrGO46ZeOgjGfxXmgIeVNDIiHw7fNZM4VA== + dependencies: + ethereumjs-util "^5.0.0" + rlp "^2.0.0" + safe-buffer "^5.1.1" + +ethereumjs-block@2.2.2, ethereumjs-block@^2.2.2, ethereumjs-block@~2.2.0, ethereumjs-block@~2.2.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/ethereumjs-block/-/ethereumjs-block-2.2.2.tgz#c7654be7e22df489fda206139ecd63e2e9c04965" + integrity sha512-2p49ifhek3h2zeg/+da6XpdFR3GlqY3BIEiqxGF8j9aSRIgkb7M1Ky+yULBKJOu8PAZxfhsYA+HxUk2aCQp3vg== + dependencies: + async "^2.0.1" + ethereumjs-common "^1.5.0" + ethereumjs-tx "^2.1.1" + ethereumjs-util "^5.0.0" + merkle-patricia-tree "^2.1.2" + +ethereumjs-block@^1.2.2, ethereumjs-block@^1.4.1, ethereumjs-block@^1.6.0: + version "1.7.1" + resolved "https://registry.yarnpkg.com/ethereumjs-block/-/ethereumjs-block-1.7.1.tgz#78b88e6cc56de29a6b4884ee75379b6860333c3f" + integrity sha512-B+sSdtqm78fmKkBq78/QLKJbu/4Ts4P2KFISdgcuZUPDm9x+N7qgBPIIFUGbaakQh8bzuquiRVbdmvPKqbILRg== + dependencies: + async "^2.0.1" + ethereum-common "0.2.0" + ethereumjs-tx "^1.2.2" + ethereumjs-util "^5.0.0" + merkle-patricia-tree "^2.1.2" + +ethereumjs-blockchain@^4.0.3: + version "4.0.4" + resolved "https://registry.yarnpkg.com/ethereumjs-blockchain/-/ethereumjs-blockchain-4.0.4.tgz#30f2228dc35f6dcf94423692a6902604ae34960f" + integrity sha512-zCxaRMUOzzjvX78DTGiKjA+4h2/sF0OYL1QuPux0DHpyq8XiNoF5GYHtb++GUxVlMsMfZV7AVyzbtgcRdIcEPQ== + dependencies: + async "^2.6.1" + ethashjs "~0.0.7" + ethereumjs-block "~2.2.2" + ethereumjs-common "^1.5.0" + ethereumjs-util "^6.1.0" + flow-stoplight "^1.0.0" + level-mem "^3.0.1" + lru-cache "^5.1.1" + rlp "^2.2.2" + semaphore "^1.1.0" + +ethereumjs-common@1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/ethereumjs-common/-/ethereumjs-common-1.5.0.tgz#d3e82fc7c47c0cef95047f431a99485abc9bb1cd" + integrity sha512-SZOjgK1356hIY7MRj3/ma5qtfr/4B5BL+G4rP/XSMYr2z1H5el4RX5GReYCKmQmYI/nSBmRnwrZ17IfHuG0viQ== + +ethereumjs-common@^1.1.0, ethereumjs-common@^1.3.2, ethereumjs-common@^1.5.0: + version "1.5.2" + resolved "https://registry.yarnpkg.com/ethereumjs-common/-/ethereumjs-common-1.5.2.tgz#2065dbe9214e850f2e955a80e650cb6999066979" + integrity sha512-hTfZjwGX52GS2jcVO6E2sx4YuFnf0Fhp5ylo4pEPhEffNln7vS59Hr5sLnp3/QCazFLluuBZ+FZ6J5HTp0EqCA== + +ethereumjs-tx@2.1.2, ethereumjs-tx@^2.1.1, ethereumjs-tx@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-2.1.2.tgz#5dfe7688bf177b45c9a23f86cf9104d47ea35fed" + integrity sha512-zZEK1onCeiORb0wyCXUvg94Ve5It/K6GD1K+26KfFKodiBiS6d9lfCXlUKGBBdQ+bv7Day+JK0tj1K+BeNFRAw== + dependencies: + ethereumjs-common "^1.5.0" + ethereumjs-util "^6.0.0" + +ethereumjs-tx@^1.1.1, ethereumjs-tx@^1.2.0, ethereumjs-tx@^1.2.2, ethereumjs-tx@^1.3.3: + version "1.3.7" + resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-1.3.7.tgz#88323a2d875b10549b8347e09f4862b546f3d89a" + integrity sha512-wvLMxzt1RPhAQ9Yi3/HKZTn0FZYpnsmQdbKYfUUpi4j1SEIcbkd9tndVjcPrufY3V7j2IebOpC00Zp2P/Ay2kA== + dependencies: + ethereum-common "^0.0.18" + ethereumjs-util "^5.0.0" + +ethereumjs-util@6.2.1, ethereumjs-util@^6.0.0, ethereumjs-util@^6.1.0, ethereumjs-util@^6.2.0, ethereumjs-util@^6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz#fcb4e4dd5ceacb9d2305426ab1a5cd93e3163b69" + integrity sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw== + dependencies: + "@types/bn.js" "^4.11.3" + bn.js "^4.11.0" + create-hash "^1.1.2" + elliptic "^6.5.2" + ethereum-cryptography "^0.1.3" + ethjs-util "0.1.6" + rlp "^2.2.3" + +ethereumjs-util@^4.3.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-4.5.1.tgz#f4bf9b3b515a484e3cc8781d61d9d980f7c83bd0" + integrity sha512-WrckOZ7uBnei4+AKimpuF1B3Fv25OmoRgmYCpGsP7u8PFxXAmAgiJSYT2kRWnt6fVIlKaQlZvuwXp7PIrmn3/w== + dependencies: + bn.js "^4.8.0" + create-hash "^1.1.2" + elliptic "^6.5.2" + ethereum-cryptography "^0.1.3" + rlp "^2.0.0" + +ethereumjs-util@^5.0.0, ethereumjs-util@^5.0.1, ethereumjs-util@^5.1.1, ethereumjs-util@^5.1.2, ethereumjs-util@^5.1.3, ethereumjs-util@^5.1.5, ethereumjs-util@^5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.2.1.tgz#a833f0e5fca7e5b361384dc76301a721f537bf65" + integrity sha512-v3kT+7zdyCm1HIqWlLNrHGqHGLpGYIhjeHxQjnDXjLT2FyGJDsd3LWMYUo7pAFRrk86CR3nUJfhC81CCoJNNGQ== + dependencies: + bn.js "^4.11.0" + create-hash "^1.1.2" + elliptic "^6.5.2" + ethereum-cryptography "^0.1.3" + ethjs-util "^0.1.3" + rlp "^2.0.0" + safe-buffer "^5.1.1" + +ethereumjs-util@^7.0.2, ethereumjs-util@^7.0.3, ethereumjs-util@^7.1.0: + version "7.1.5" + resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz#9ecf04861e4fbbeed7465ece5f23317ad1129181" + integrity sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg== + dependencies: + "@types/bn.js" "^5.1.0" + bn.js "^5.1.2" + create-hash "^1.1.2" + ethereum-cryptography "^0.1.3" + rlp "^2.2.4" + +ethereumjs-vm@4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/ethereumjs-vm/-/ethereumjs-vm-4.2.0.tgz#e885e861424e373dbc556278f7259ff3fca5edab" + integrity sha512-X6qqZbsY33p5FTuZqCnQ4+lo957iUJMM6Mpa6bL4UW0dxM6WmDSHuI4j/zOp1E2TDKImBGCJA9QPfc08PaNubA== + dependencies: + async "^2.1.2" + async-eventemitter "^0.2.2" + core-js-pure "^3.0.1" + ethereumjs-account "^3.0.0" + ethereumjs-block "^2.2.2" + ethereumjs-blockchain "^4.0.3" + ethereumjs-common "^1.5.0" + ethereumjs-tx "^2.1.2" + ethereumjs-util "^6.2.0" + fake-merkle-patricia-tree "^1.0.1" + functional-red-black-tree "^1.0.1" + merkle-patricia-tree "^2.3.2" + rustbn.js "~0.2.0" + safe-buffer "^5.1.1" + util.promisify "^1.0.0" + +ethereumjs-vm@^2.1.0, ethereumjs-vm@^2.3.4, ethereumjs-vm@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/ethereumjs-vm/-/ethereumjs-vm-2.6.0.tgz#76243ed8de031b408793ac33907fb3407fe400c6" + integrity sha512-r/XIUik/ynGbxS3y+mvGnbOKnuLo40V5Mj1J25+HEO63aWYREIqvWeRO/hnROlMBE5WoniQmPmhiaN0ctiHaXw== + dependencies: + async "^2.1.2" + async-eventemitter "^0.2.2" + ethereumjs-account "^2.0.3" + ethereumjs-block "~2.2.0" + ethereumjs-common "^1.1.0" + ethereumjs-util "^6.0.0" + fake-merkle-patricia-tree "^1.0.1" + functional-red-black-tree "^1.0.1" + merkle-patricia-tree "^2.3.2" + rustbn.js "~0.2.0" + safe-buffer "^5.1.1" + +ethereumjs-wallet@0.6.5: + version "0.6.5" + resolved "https://registry.yarnpkg.com/ethereumjs-wallet/-/ethereumjs-wallet-0.6.5.tgz#685e9091645cee230ad125c007658833991ed474" + integrity sha512-MDwjwB9VQVnpp/Dc1XzA6J1a3wgHQ4hSvA1uWNatdpOrtCbPVuQSKSyRnjLvS0a+KKMw2pvQ9Ybqpb3+eW8oNA== + dependencies: + aes-js "^3.1.1" + bs58check "^2.1.2" + ethereum-cryptography "^0.1.3" + ethereumjs-util "^6.0.0" + randombytes "^2.0.6" + safe-buffer "^5.1.2" + scryptsy "^1.2.1" + utf8 "^3.0.0" + uuid "^3.3.2" + +ethers@4.0.0-beta.3: + version "4.0.0-beta.3" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.0-beta.3.tgz#15bef14e57e94ecbeb7f9b39dd0a4bd435bc9066" + integrity sha512-YYPogooSknTwvHg3+Mv71gM/3Wcrx+ZpCzarBj3mqs9njjRkrOo2/eufzhHloOCo3JSoNI4TQJJ6yU5ABm3Uog== + dependencies: + "@types/node" "^10.3.2" + aes-js "3.0.0" + bn.js "^4.4.0" + elliptic "6.3.3" + hash.js "1.1.3" + js-sha3 "0.5.7" + scrypt-js "2.0.3" + setimmediate "1.0.4" + uuid "2.0.1" + xmlhttprequest "1.8.0" + +ethers@^4.0.20, ethers@^4.0.40: + version "4.0.49" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-4.0.49.tgz#0eb0e9161a0c8b4761be547396bbe2fb121a8894" + integrity sha512-kPltTvWiyu+OktYy1IStSO16i2e7cS9D9OxZ81q2UUaiNPVrm/RTcbxamCXF9VUSKzJIdJV68EAIhTEVBalRWg== + dependencies: + aes-js "3.0.0" + bn.js "^4.11.9" + elliptic "6.5.4" + hash.js "1.1.3" + js-sha3 "0.5.7" + scrypt-js "2.0.4" + setimmediate "1.0.4" + uuid "2.0.1" + xmlhttprequest "1.8.0" + +ethers@^5.0.1, ethers@^5.0.2, ethers@^5.2.0, ethers@^5.5.2, ethers@^5.5.3: + version "5.7.2" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-5.7.2.tgz#3a7deeabbb8c030d4126b24f84e525466145872e" + integrity sha512-wswUsmWo1aOK8rR7DIKiWSw9DbLWe6x98Jrn8wcTflTVvaXhAMaB5zGAXy0GYQEQp9iO1iSHWVyARQm11zUtyg== + dependencies: + "@ethersproject/abi" "5.7.0" + "@ethersproject/abstract-provider" "5.7.0" + "@ethersproject/abstract-signer" "5.7.0" + "@ethersproject/address" "5.7.0" + "@ethersproject/base64" "5.7.0" + "@ethersproject/basex" "5.7.0" + "@ethersproject/bignumber" "5.7.0" + "@ethersproject/bytes" "5.7.0" + "@ethersproject/constants" "5.7.0" + "@ethersproject/contracts" "5.7.0" + "@ethersproject/hash" "5.7.0" + "@ethersproject/hdnode" "5.7.0" + "@ethersproject/json-wallets" "5.7.0" + "@ethersproject/keccak256" "5.7.0" + "@ethersproject/logger" "5.7.0" + "@ethersproject/networks" "5.7.1" + "@ethersproject/pbkdf2" "5.7.0" + "@ethersproject/properties" "5.7.0" + "@ethersproject/providers" "5.7.2" + "@ethersproject/random" "5.7.0" + "@ethersproject/rlp" "5.7.0" + "@ethersproject/sha2" "5.7.0" + "@ethersproject/signing-key" "5.7.0" + "@ethersproject/solidity" "5.7.0" + "@ethersproject/strings" "5.7.0" + "@ethersproject/transactions" "5.7.0" + "@ethersproject/units" "5.7.0" + "@ethersproject/wallet" "5.7.0" + "@ethersproject/web" "5.7.1" + "@ethersproject/wordlists" "5.7.0" + +ethjs-unit@0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/ethjs-unit/-/ethjs-unit-0.1.6.tgz#c665921e476e87bce2a9d588a6fe0405b2c41699" + integrity sha512-/Sn9Y0oKl0uqQuvgFk/zQgR7aw1g36qX/jzSQ5lSwlO0GigPymk4eGQfeNTD03w1dPOqfz8V77Cy43jH56pagw== + dependencies: + bn.js "4.11.6" + number-to-bn "1.7.0" + +ethjs-util@0.1.6, ethjs-util@^0.1.3, ethjs-util@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" + integrity sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w== + dependencies: + is-hex-prefixed "1.0.0" + strip-hex-prefix "1.0.0" + +event-target-shim@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" + integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== + +eventemitter3@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7" + integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q== + +eventemitter3@4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384" + integrity sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ== + +events@^3.0.0, events@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + +evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" + integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== + dependencies: + md5.js "^1.3.4" + safe-buffer "^5.1.1" + +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + integrity sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA== + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +express@^4.14.0: + version "4.18.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.18.2.tgz#3fabe08296e930c796c19e3c516979386ba9fd59" + integrity sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ== + dependencies: + accepts "~1.3.8" + array-flatten "1.1.1" + body-parser "1.20.1" + content-disposition "0.5.4" + content-type "~1.0.4" + cookie "0.5.0" + cookie-signature "1.0.6" + debug "2.6.9" + depd "2.0.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.2.0" + fresh "0.5.2" + http-errors "2.0.0" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "2.4.1" + parseurl "~1.3.3" + path-to-regexp "0.1.7" + proxy-addr "~2.0.7" + qs "6.11.0" + range-parser "~1.2.1" + safe-buffer "5.2.1" + send "0.18.0" + serve-static "1.15.0" + setprototypeof "1.2.0" + statuses "2.0.1" + type-is "~1.6.18" + utils-merge "1.0.1" + vary "~1.1.2" + +ext@^1.1.2: + version "1.7.0" + resolved "https://registry.yarnpkg.com/ext/-/ext-1.7.0.tgz#0ea4383c0103d60e70be99e9a7f11027a33c4f5f" + integrity sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw== + dependencies: + type "^2.7.2" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug== + dependencies: + is-extendable "^0.1.0" + +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + integrity sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q== + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + +extend@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + +external-editor@^3.0.3: + version "3.1.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" + integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew== + dependencies: + chardet "^0.7.0" + iconv-lite "^0.4.24" + tmp "^0.0.33" + +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + integrity sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g== + +extsprintf@^1.2.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.1.tgz#8d172c064867f235c0c84a596806d279bf4bcc07" + integrity sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA== + +fake-merkle-patricia-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fake-merkle-patricia-tree/-/fake-merkle-patricia-tree-1.0.1.tgz#4b8c3acfb520afadf9860b1f14cd8ce3402cddd3" + integrity sha512-Tgq37lkc9pUIgIKw5uitNUKcgcYL3R6JvXtKQbOf/ZSavXbidsksgp/pAY6p//uhw0I4yoMsvTSovvVIsk/qxA== + dependencies: + checkpoint-store "^1.1.0" + +fast-base64-decode@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fast-base64-decode/-/fast-base64-decode-1.0.0.tgz#b434a0dd7d92b12b43f26819300d2dafb83ee418" + integrity sha512-qwaScUgUGBYeDNRnbc/KyllVU88Jk1pRHPStuF/lO7B0/RTRLj7U0lkdTAutlBblY08rwZDff6tNU9cjv6j//Q== + +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-diff@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== + +fast-glob@^3.2.9: + version "3.2.12" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" + integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" + integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== + +fastq@^1.6.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.15.0.tgz#d04d07c6a2a68fe4599fea8d2e103a937fae6b3a" + integrity sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw== + dependencies: + reusify "^1.0.4" + +fd-slicer@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e" + integrity sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g== + dependencies: + pend "~1.2.0" + +fetch-ponyfill@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/fetch-ponyfill/-/fetch-ponyfill-4.1.0.tgz#ae3ce5f732c645eab87e4ae8793414709b239893" + integrity sha512-knK9sGskIg2T7OnYLdZ2hZXn0CtDrAIBxYQLpmEf0BqfdWnwmM1weccUl5+4EdA44tzNSFAuxITPbXtPehUB3g== + dependencies: + node-fetch "~1.7.1" + +figures@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" + integrity sha512-Oa2M9atig69ZkfwiApY8F2Yy+tzMbazyvqv21R0NsSC8floSOC09BbT1ITWAdoMGQvJ/aZnR1KMwdx9tvHnTNA== + dependencies: + escape-string-regexp "^1.0.5" + +file-entry-cache@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" + integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== + dependencies: + flat-cache "^2.0.1" + +file-entry-cache@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" + integrity sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg== + dependencies: + flat-cache "^3.0.4" + +file-type@^3.8.0: + version "3.9.0" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9" + integrity sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA== + +file-type@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-5.2.0.tgz#2ddbea7c73ffe36368dfae49dc338c058c2b8ad6" + integrity sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ== + +file-type@^6.1.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-6.2.0.tgz#e50cd75d356ffed4e306dc4f5bcf52a79903a919" + integrity sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg== + +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + integrity sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ== + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +finalhandler@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.2.0.tgz#7d23fe5731b207b4640e4fcd00aec1f9207a7b32" + integrity sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg== + dependencies: + debug "2.6.9" + encodeurl "~1.0.2" + escape-html "~1.0.3" + on-finished "2.4.1" + parseurl "~1.3.3" + statuses "2.0.1" + unpipe "~1.0.0" + +find-replace@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-1.0.3.tgz#b88e7364d2d9c959559f388c66670d6130441fa0" + integrity sha512-KrUnjzDCD9426YnCP56zGYy/eieTnhtK6Vn++j+JJzmlsWWwEkDnsyVF575spT6HJ6Ow9tlbT3TQTDsa+O4UWA== + dependencies: + array-back "^1.0.4" + test-value "^2.1.0" + +find-replace@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38" + integrity sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ== + dependencies: + array-back "^3.0.1" + +find-up@3.0.0, find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + integrity sha512-jvElSjyuo4EMQGoTwo1uJU5pQMwTW5lS1x05zzfJuTIyLR3zwO27LYrxNg+dlvKpGOuGy/MzBdXh80g0ve5+HA== + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + integrity sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ== + dependencies: + locate-path "^2.0.0" + +find-yarn-workspace-root@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-1.2.1.tgz#40eb8e6e7c2502ddfaa2577c176f221422f860db" + integrity sha512-dVtfb0WuQG+8Ag2uWkbG79hOUzEsRrhBzgfn86g2sJPkzmcpGdghbNTfUKGTxymFrY/tLIodDzLoW9nOJ4FY8Q== + dependencies: + fs-extra "^4.0.3" + micromatch "^3.1.4" + +find-yarn-workspace-root@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd" + integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ== + dependencies: + micromatch "^4.0.2" + +flat-cache@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" + integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== + dependencies: + flatted "^2.0.0" + rimraf "2.6.3" + write "1.0.3" + +flat-cache@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.0.4.tgz#61b0338302b2fe9f957dcc32fc2a87f1c3048b11" + integrity sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg== + dependencies: + flatted "^3.1.0" + rimraf "^3.0.2" + +flat@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/flat/-/flat-4.1.1.tgz#a392059cc382881ff98642f5da4dde0a959f309b" + integrity sha512-FmTtBsHskrU6FJ2VxCnsDb84wu9zhmO3cUX2kGFb5tuwhfXxGciiT0oRY+cck35QmG+NmGh5eLz6lLCpWTqwpA== + dependencies: + is-buffer "~2.0.3" + +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + +flatted@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" + integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== + +flatted@^3.1.0: + version "3.2.7" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" + integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== + +flow-stoplight@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/flow-stoplight/-/flow-stoplight-1.0.0.tgz#4a292c5bcff8b39fa6cc0cb1a853d86f27eeff7b" + integrity sha512-rDjbZUKpN8OYhB0IE/vY/I8UWO/602IIJEU/76Tv4LvYnwHCk0BCsvz4eRr9n+FQcri7L5cyaXOo0+/Kh4HisA== + +fmix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/fmix/-/fmix-0.1.0.tgz#c7bbf124dec42c9d191cfb947d0a9778dd986c0c" + integrity sha512-Y6hyofImk9JdzU8k5INtTXX1cu8LDlePWDFU5sftm9H+zKCr5SGrVjdhkvsim646cw5zD0nADj8oHyXMZmCZ9w== + dependencies: + imul "^1.0.0" + +follow-redirects@1.5.10: + version "1.5.10" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" + integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ== + dependencies: + debug "=3.1.0" + +follow-redirects@^1.12.1, follow-redirects@^1.14.0, follow-redirects@^1.15.0: + version "1.15.2" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" + integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== + +for-each@^0.3.3, for-each@~0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" + integrity sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw== + dependencies: + is-callable "^1.1.3" + +for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + integrity sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ== + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + integrity sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw== + +form-data@^2.2.0: + version "2.5.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.5.1.tgz#f2cbec57b5e59e23716e128fe44d4e5dd23895f4" + integrity sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" + +form-data@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f" + integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + +form-data@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" + integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" + +forwarded@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" + integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== + +fp-ts@1.19.3: + version "1.19.3" + resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-1.19.3.tgz#261a60d1088fbff01f91256f91d21d0caaaaa96f" + integrity sha512-H5KQDspykdHuztLTg+ajGN0Z2qUjcEf3Ybxc6hLt0k7/zPkn29XnKnxlBPyW2XIddWrGaJBzBl4VLYOtk39yZg== + +fp-ts@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-2.1.1.tgz#c910544499d7c959351bb4260ee7c44a544084c1" + integrity sha512-YcWhMdDCFCja0MmaDroTgNu+NWWrrnUEn92nvDgrtVy9Z71YFnhNVIghoHPt8gs82ijoMzFGeWKvArbyICiJgw== + +fp-ts@^1.0.0: + version "1.19.5" + resolved "https://registry.yarnpkg.com/fp-ts/-/fp-ts-1.19.5.tgz#3da865e585dfa1fdfd51785417357ac50afc520a" + integrity sha512-wDNqTimnzs8QqpldiId9OavWK2NptormjXnRJTQecNjzwfyp6P/8s/zG8e4h3ja3oqkKaY72UlTjQYt/1yXf9A== + +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + integrity sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA== + dependencies: + map-cache "^0.2.2" + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== + +fs-constants@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" + integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== + +fs-extra@^0.30.0: + version "0.30.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.30.0.tgz#f233ffcc08d4da7d432daa449776989db1df93f0" + integrity sha512-UvSPKyhMn6LEd/WpUaV9C9t3zATuqoqfWc3QdPhPLb58prN9tqYPlPWi8Krxi44loBoUzlobqZ3+8tGpxxSzwA== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + klaw "^1.0.0" + path-is-absolute "^1.0.0" + rimraf "^2.2.8" + +fs-extra@^10.0.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" + integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + +fs-extra@^4.0.2, fs-extra@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94" + integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs-extra@^7.0.0, fs-extra@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs-extra@^9.0.0, fs-extra@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" + integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ== + dependencies: + at-least-node "^1.0.0" + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + +fs-minipass@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" + integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== + dependencies: + minipass "^2.6.0" + +fs-readdir-recursive@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" + integrity sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA== + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@~2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.3.tgz#fb738703ae8d2f9fe900c33836ddebee8b97f23e" + integrity sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ== + +fsevents@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + +function.prototype.name@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.5.tgz#cce0505fe1ffb80503e6f9e46cc64e46a12a9621" + integrity sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.19.0" + functions-have-names "^1.2.2" + +functional-red-black-tree@^1.0.1, functional-red-black-tree@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" + integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== + +functions-have-names@^1.2.2: + version "1.2.3" + resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" + integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== + +futoin-hkdf@^1.0.3: + version "1.5.2" + resolved "https://registry.yarnpkg.com/futoin-hkdf/-/futoin-hkdf-1.5.2.tgz#d316623d29f45fe5e6f136f435eccd74096bf676" + integrity sha512-Bnytx8kQJQoEAPGgTZw3kVPy8e/n9CDftPzc0okgaujmbdF1x7w8wg+u2xS0CML233HgruNk6VQW28CzuUFMKw== + +ganache-core@^2.13.2: + version "2.13.2" + resolved "https://registry.yarnpkg.com/ganache-core/-/ganache-core-2.13.2.tgz#27e6fc5417c10e6e76e2e646671869d7665814a3" + integrity sha512-tIF5cR+ANQz0+3pHWxHjIwHqFXcVo0Mb+kcsNhglNFALcYo49aQpnS9dqHartqPfMFjiHh/qFoD3mYK0d/qGgw== + dependencies: + abstract-leveldown "3.0.0" + async "2.6.2" + bip39 "2.5.0" + cachedown "1.0.0" + clone "2.1.2" + debug "3.2.6" + encoding-down "5.0.4" + eth-sig-util "3.0.0" + ethereumjs-abi "0.6.8" + ethereumjs-account "3.0.0" + ethereumjs-block "2.2.2" + ethereumjs-common "1.5.0" + ethereumjs-tx "2.1.2" + ethereumjs-util "6.2.1" + ethereumjs-vm "4.2.0" + heap "0.2.6" + keccak "3.0.1" + level-sublevel "6.6.4" + levelup "3.1.1" + lodash "4.17.20" + lru-cache "5.1.1" + merkle-patricia-tree "3.0.0" + patch-package "6.2.2" + seedrandom "3.0.1" + source-map-support "0.5.12" + tmp "0.1.0" + web3-provider-engine "14.2.1" + websocket "1.0.32" + optionalDependencies: + ethereumjs-wallet "0.6.5" + web3 "1.2.11" + +get-caller-file@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" + integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== + +get-caller-file@^2.0.1, get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-func-name@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" + integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig== + +get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f" + integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q== + dependencies: + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.3" + +get-port@^3.1.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/get-port/-/get-port-3.2.0.tgz#dd7ce7de187c06c8bf353796ac71e099f0980ebc" + integrity sha512-x5UJKlgeUiNT8nyo/AcnwLnZuZNcSjSw0kogRB+Whd1fjjFq4B1hySFxSFWWSn4mIBzg3sRNUDFYc4g5gjPoLg== + +get-stream@^2.2.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de" + integrity sha512-AUGhbbemXxrZJRD5cDvKtQxLuYaIbNtDTK8YqupCI393Q2KSTreEsLUN3ZxAWFGiKTzL6nKuzfcIvieflUX9qA== + dependencies: + object-assign "^4.0.1" + pinkie-promise "^2.0.0" + +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + integrity sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ== + +get-stream@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" + integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== + dependencies: + pump "^3.0.0" + +get-stream@^5.1.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" + integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== + dependencies: + pump "^3.0.0" + +get-symbol-description@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.0.0.tgz#7fdb81c900101fbd564dd5f1a30af5aadc1e58d6" + integrity sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.1" + +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + integrity sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA== + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + integrity sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng== + dependencies: + assert-plus "^1.0.0" + +glob-parent@^5.1.2, glob-parent@~5.1.0, glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob@7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" + integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@^7.1.2, glob@^7.1.3, glob@^7.1.6, glob@~7.2.3: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +global@~4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/global/-/global-4.4.0.tgz#3e7b105179006a323ed71aafca3e9c57a5cc6406" + integrity sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w== + dependencies: + min-document "^2.19.0" + process "^0.11.10" + +globals@^11.7.0: + version "11.12.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" + integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== + +globals@^13.6.0, globals@^13.9.0: + version "13.20.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.20.0.tgz#ea276a1e508ffd4f1612888f9d1bad1e2717bf82" + integrity sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ== + dependencies: + type-fest "^0.20.2" + +globals@^9.18.0: + version "9.18.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" + integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== + +globalthis@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf" + integrity sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA== + dependencies: + define-properties "^1.1.3" + +globby@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" + slash "^3.0.0" + +google-libphonenumber@^3.2.15, google-libphonenumber@^3.2.4: + version "3.2.32" + resolved "https://registry.yarnpkg.com/google-libphonenumber/-/google-libphonenumber-3.2.32.tgz#63c48a9c247b64a3bc2eec21bdf3fcfbf2e148c0" + integrity sha512-mcNgakausov/B/eTgVeX8qc8IwWjRrupk9UzZZ/QDEvdh5fAjE7Aa211bkZpZj42zKkeS6MTT8avHUwjcLxuGQ== + +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + +got@9.6.0: + version "9.6.0" + resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" + integrity sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q== + dependencies: + "@sindresorhus/is" "^0.14.0" + "@szmarczak/http-timer" "^1.1.2" + cacheable-request "^6.0.0" + decompress-response "^3.3.0" + duplexer3 "^0.1.4" + get-stream "^4.1.0" + lowercase-keys "^1.0.1" + mimic-response "^1.0.1" + p-cancelable "^1.0.0" + to-readable-stream "^1.0.0" + url-parse-lax "^3.0.0" + +got@^11.8.5: + version "11.8.6" + resolved "https://registry.yarnpkg.com/got/-/got-11.8.6.tgz#276e827ead8772eddbcfc97170590b841823233a" + integrity sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g== + dependencies: + "@sindresorhus/is" "^4.0.0" + "@szmarczak/http-timer" "^4.0.5" + "@types/cacheable-request" "^6.0.1" + "@types/responselike" "^1.0.0" + cacheable-lookup "^5.0.3" + cacheable-request "^7.0.2" + decompress-response "^6.0.0" + http2-wrapper "^1.0.0-beta.5.2" + lowercase-keys "^2.0.0" + p-cancelable "^2.0.0" + responselike "^2.0.0" + +got@^7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/got/-/got-7.1.0.tgz#05450fd84094e6bbea56f451a43a9c289166385a" + integrity sha512-Y5WMo7xKKq1muPsxD+KmrR8DH5auG7fBdDVueZwETwV6VytKyU9OX/ddpq2/1hp1vIPvVb4T81dKQz3BivkNLw== + dependencies: + decompress-response "^3.2.0" + duplexer3 "^0.1.4" + get-stream "^3.0.0" + is-plain-obj "^1.1.0" + is-retry-allowed "^1.0.0" + is-stream "^1.0.0" + isurl "^1.0.0-alpha5" + lowercase-keys "^1.0.0" + p-cancelable "^0.3.0" + p-timeout "^1.1.1" + safe-buffer "^5.0.1" + timed-out "^4.0.0" + url-parse-lax "^1.0.0" + url-to-options "^1.0.1" + +graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.4: + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + +grapheme-splitter@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e" + integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ== + +growl@1.10.5: + version "1.10.5" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" + integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + integrity sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q== + +har-validator@~5.1.3: + version "5.1.5" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" + integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== + dependencies: + ajv "^6.12.3" + har-schema "^2.0.0" + +hardhat-contract-sizer@^2.5.0: + version "2.8.0" + resolved "https://registry.yarnpkg.com/hardhat-contract-sizer/-/hardhat-contract-sizer-2.8.0.tgz#730a9bf35ed200ba57b6865bd3f459a91c90f205" + integrity sha512-jXt2Si3uIDx5z99J+gvKa0yvIw156pE4dpH9X/PvTQv652BUd+qGj7WT93PXnHXGh5qhQLkjDYeZMYNOThfjFg== + dependencies: + chalk "^4.0.0" + cli-table3 "^0.6.0" + strip-ansi "^6.0.0" + +hardhat-dependency-compiler@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/hardhat-dependency-compiler/-/hardhat-dependency-compiler-1.1.3.tgz#1e49e23f68878bd713f860c66648a711bc4a4a79" + integrity sha512-bCDqsOxGST6WkbMvj4lPchYWidNSSBm5CFnkyAex1T11cGmr9otZTGl81W6f9pmrtBXbKCvr3OSuNJ6Q394sAw== + +hardhat-deploy@^0.11.11: + version "0.11.25" + resolved "https://registry.yarnpkg.com/hardhat-deploy/-/hardhat-deploy-0.11.25.tgz#bd6f2310ad9232a5d73f6e5dfff4112220a392e8" + integrity sha512-ppSgrVE9A13YgTmf2PQGoyIs9o/jgJOMORrUP/rblU5K8mQ2YHWlPvkzZmP4h+SBW+tNmlnvSrf5K5DmMmExhw== + dependencies: + "@types/qs" "^6.9.7" + axios "^0.21.1" + chalk "^4.1.2" + chokidar "^3.5.2" + debug "^4.3.2" + enquirer "^2.3.6" + ethers "^5.5.3" + form-data "^4.0.0" + fs-extra "^10.0.0" + match-all "^1.2.6" + murmur-128 "^0.2.1" + qs "^6.9.4" + zksync-web3 "^0.8.1" + +hardhat-gas-reporter@^1.0.8: + version "1.0.9" + resolved "https://registry.yarnpkg.com/hardhat-gas-reporter/-/hardhat-gas-reporter-1.0.9.tgz#9a2afb354bc3b6346aab55b1c02ca556d0e16450" + integrity sha512-INN26G3EW43adGKBNzYWOlI3+rlLnasXTwW79YNnUhXPDa+yHESgt639dJEs37gCjhkbNKcRRJnomXEuMFBXJg== + dependencies: + array-uniq "1.0.3" + eth-gas-reporter "^0.2.25" + sha1 "^1.1.1" + +hardhat@^2.10.0: + version "2.13.0" + resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.13.0.tgz#d52a0ec9b733a651687e5b1c1b0ee9a11a30f3d0" + integrity sha512-ZlzBOLML1QGlm6JWyVAG8lVTEAoOaVm1in/RU2zoGAnYEoD1Rp4T+ZMvrLNhHaaeS9hfjJ1gJUBfiDr4cx+htQ== + dependencies: + "@ethersproject/abi" "^5.1.2" + "@metamask/eth-sig-util" "^4.0.0" + "@nomicfoundation/ethereumjs-block" "^4.0.0" + "@nomicfoundation/ethereumjs-blockchain" "^6.0.0" + "@nomicfoundation/ethereumjs-common" "^3.0.0" + "@nomicfoundation/ethereumjs-evm" "^1.0.0" + "@nomicfoundation/ethereumjs-rlp" "^4.0.0" + "@nomicfoundation/ethereumjs-statemanager" "^1.0.0" + "@nomicfoundation/ethereumjs-trie" "^5.0.0" + "@nomicfoundation/ethereumjs-tx" "^4.0.0" + "@nomicfoundation/ethereumjs-util" "^8.0.0" + "@nomicfoundation/ethereumjs-vm" "^6.0.0" + "@nomicfoundation/solidity-analyzer" "^0.1.0" + "@sentry/node" "^5.18.1" + "@types/bn.js" "^5.1.0" + "@types/lru-cache" "^5.1.0" + abort-controller "^3.0.0" + adm-zip "^0.4.16" + aggregate-error "^3.0.0" + ansi-escapes "^4.3.0" + chalk "^2.4.2" + chokidar "^3.4.0" + ci-info "^2.0.0" + debug "^4.1.1" + enquirer "^2.3.0" + env-paths "^2.2.0" + ethereum-cryptography "^1.0.3" + ethereumjs-abi "^0.6.8" + find-up "^2.1.0" + fp-ts "1.19.3" + fs-extra "^7.0.1" + glob "7.2.0" + immutable "^4.0.0-rc.12" + io-ts "1.10.4" + keccak "^3.0.2" + lodash "^4.17.11" + mnemonist "^0.38.0" + mocha "^10.0.0" + p-map "^4.0.0" + qs "^6.7.0" + raw-body "^2.4.1" + resolve "1.17.0" + semver "^6.3.0" + solc "0.7.3" + source-map-support "^0.5.13" + stacktrace-parser "^0.1.10" + tsort "0.0.1" + undici "^5.14.0" + uuid "^8.3.2" + ws "^7.4.6" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + integrity sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg== + dependencies: + ansi-regex "^2.0.0" + +has-bigints@^1.0.1, has-bigints@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa" + integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-property-descriptors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" + integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== + dependencies: + get-intrinsic "^1.1.1" + +has-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.1.tgz#1885c1305538958aff469fef37937c22795408e0" + integrity sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg== + +has-symbol-support-x@^1.4.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455" + integrity sha512-3ToOva++HaW+eCpgqZrCfN51IPB+7bJNVT6CUATzueB5Heb8o6Nam0V3HG5dlDvZU1Gn5QLcbahiKw/XVk5JJw== + +has-symbols@^1.0.0, has-symbols@^1.0.1, has-symbols@^1.0.2, has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +has-to-string-tag-x@^1.2.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" + integrity sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw== + dependencies: + has-symbol-support-x "^1.4.1" + +has-tostringtag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-tostringtag/-/has-tostringtag-1.0.0.tgz#7e133818a7d394734f941e73c3d3f9291e658b25" + integrity sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ== + dependencies: + has-symbols "^1.0.2" + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + integrity sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q== + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + integrity sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw== + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + integrity sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ== + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + integrity sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ== + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +has@^1.0.3, has@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== + dependencies: + function-bind "^1.1.1" + +hash-base@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" + integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== + dependencies: + inherits "^2.0.4" + readable-stream "^3.6.0" + safe-buffer "^5.2.0" + +hash.js@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.3.tgz#340dedbe6290187151c1ea1d777a3448935df846" + integrity sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA== + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.0" + +hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3, hash.js@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" + integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.1" + +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + +heap@0.2.6: + version "0.2.6" + resolved "https://registry.yarnpkg.com/heap/-/heap-0.2.6.tgz#087e1f10b046932fc8594dd9e6d378afc9d1e5ac" + integrity sha512-MzzWcnfB1e4EG2vHi3dXHoBupmuXNZzx6pY6HldVS55JKKBoq3xOyzfSaZRkJp37HIhEYC78knabHff3zc4dQQ== + +hmac-drbg@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" + integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg== + dependencies: + hash.js "^1.0.3" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.1" + +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + integrity sha512-ycURW7oUxE2sNiPVw1HVEFsW+ecOpJ5zaj7eC0RlwhibhRBod20muUN8qu/gzx956YrLolVvs1MTXwKgC2rVEg== + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + +hosted-git-info@^2.1.4, hosted-git-info@^2.6.0: + version "2.8.9" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" + integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== + +http-basic@^8.1.1: + version "8.1.3" + resolved "https://registry.yarnpkg.com/http-basic/-/http-basic-8.1.3.tgz#a7cabee7526869b9b710136970805b1004261bbf" + integrity sha512-/EcDMwJZh3mABI2NhGfHOGOeOZITqfkEO4p/xK+l3NpyncIHUQBoMvCSF/b5GqvKtySC2srL/GGG3+EtlqlmCw== + dependencies: + caseless "^0.12.0" + concat-stream "^1.6.2" + http-response-object "^3.0.1" + parse-cache-control "^1.0.1" + +http-cache-semantics@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" + integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== + +http-errors@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" + integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== + dependencies: + depd "2.0.0" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses "2.0.1" + toidentifier "1.0.1" + +http-https@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/http-https/-/http-https-1.0.0.tgz#2f908dd5f1db4068c058cd6e6d4ce392c913389b" + integrity sha512-o0PWwVCSp3O0wS6FvNr6xfBCHgt0m1tvPLFOCc2iFDKTRAXhB7m8klDf7ErowFH8POa6dVdGatKU5I1YYwzUyg== + +http-response-object@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/http-response-object/-/http-response-object-3.0.2.tgz#7f435bb210454e4360d074ef1f989d5ea8aa9810" + integrity sha512-bqX0XTF6fnXSQcEJ2Iuyr75yVakyjIDCqroJQ/aHfSdlM743Cwqoi2nDYMzLGWUcuTWGWy8AAvOKXTfiv6q9RA== + dependencies: + "@types/node" "^10.0.3" + +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +http2-wrapper@^1.0.0-beta.5.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-1.0.3.tgz#b8f55e0c1f25d4ebd08b3b0c2c079f9590800b3d" + integrity sha512-V+23sDMr12Wnz7iTcDeJr3O6AIxlnvT/bmaAAAP/Xda35C90p9599p0F1eHR/N1KILWSoWVAiOMFjBBXaXSMxg== + dependencies: + quick-lru "^5.1.1" + resolve-alpn "^1.0.0" + +https-proxy-agent@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" + integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== + dependencies: + agent-base "6" + debug "4" + +iconv-lite@0.4.24, iconv-lite@^0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +iconv-lite@^0.6.2: + version "0.6.3" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" + integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + +idna-uts46-hx@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/idna-uts46-hx/-/idna-uts46-hx-2.3.1.tgz#a1dc5c4df37eee522bf66d969cc980e00e8711f9" + integrity sha512-PWoF9Keq6laYdIRwwCdhTPl60xRqAloYNMQLiyUnG42VjT53oW07BXIRM+NK7eQjzXjAk2gUvX9caRxlnF9TAA== + dependencies: + punycode "2.1.0" + +ieee754@^1.1.13, ieee754@^1.1.4, ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +ignore@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" + integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== + +ignore@^5.2.0: + version "5.2.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" + integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== + +immediate@^3.2.3: + version "3.3.0" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.3.0.tgz#1aef225517836bcdf7f2a2de2600c79ff0269266" + integrity sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q== + +immediate@~3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.2.3.tgz#d140fa8f614659bd6541233097ddaac25cdd991c" + integrity sha512-RrGCXRm/fRVqMIhqXrGEX9rRADavPiDFSoMb/k64i9XMk8uH4r/Omi5Ctierj6XzNecwDbO4WuFbDD1zmpl3Tg== + +immutable@^4.0.0-rc.12: + version "4.3.0" + resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.3.0.tgz#eb1738f14ffb39fd068b1dbe1296117484dd34be" + integrity sha512-0AOCmOip+xgJwEVTQj1EfiDDOkPmuyllDuTuEX+DDXUgapLAsBIfkg3sxCYyCEA8mQqZrrxPUGjcOQ2JS3WLkg== + +import-fresh@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-2.0.0.tgz#d81355c15612d386c61f9ddd3922d4304822a546" + integrity sha512-eZ5H8rcgYazHbKC3PG4ClHNykCSxtAhxSSEM+2mb+7evD2CKF5V7c0dNum7AdpDh0ZdICwZY9sRSn8f+KH96sg== + dependencies: + caller-path "^2.0.0" + resolve-from "^3.0.0" + +import-fresh@^3.0.0, import-fresh@^3.2.1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.3.0.tgz#37162c25fcb9ebaa2e6e53d5b4d88ce17d9e0c2b" + integrity sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== + dependencies: + parent-module "^1.0.0" + resolve-from "^4.0.0" + +imul@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/imul/-/imul-1.0.1.tgz#9d5867161e8b3de96c2c38d5dc7cb102f35e2ac9" + integrity sha512-WFAgfwPLAjU66EKt6vRdTlKj4nAgIDQzh29JonLa4Bqtl6D8JrIMvWjCnx7xEjVNmP3U0fM5o8ZObk7d0f62bA== + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== + +indent-string@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" + integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3, inherits@~2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +inquirer@^6.2.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.2.tgz#ad50942375d036d327ff528c08bd5fab089928ca" + integrity sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ== + dependencies: + ansi-escapes "^3.2.0" + chalk "^2.4.2" + cli-cursor "^2.1.0" + cli-width "^2.0.0" + external-editor "^3.0.3" + figures "^2.0.0" + lodash "^4.17.12" + mute-stream "0.0.7" + run-async "^2.2.0" + rxjs "^6.4.0" + string-width "^2.1.0" + strip-ansi "^5.1.0" + through "^2.3.6" + +internal-slot@^1.0.3, internal-slot@^1.0.4, internal-slot@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.5.tgz#f2a2ee21f668f8627a4667f309dc0f4fb6674986" + integrity sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ== + dependencies: + get-intrinsic "^1.2.0" + has "^1.0.3" + side-channel "^1.0.4" + +invariant@2, invariant@^2.2.2: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + integrity sha512-xgs2NH9AE66ucSq4cNG1nhSFghr5l6tdL15Pk+jl46bmmBapgoaY/AacXyaDznAqmGL99TiLSQgO/XazFSKYeQ== + +io-ts@1.10.4: + version "1.10.4" + resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-1.10.4.tgz#cd5401b138de88e4f920adbcb7026e2d1967e6e2" + integrity sha512-b23PteSnYXSONJ6JQXRAlvJhuw8KOtkqa87W4wDtvMrud/DTJd5X+NpOOI+O/zZwVq6v0VLAaJ+1EDViKEuN9g== + dependencies: + fp-ts "^1.0.0" + +io-ts@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-2.0.1.tgz#1261c12f915c2f48d16393a36966636b48a45aa1" + integrity sha512-RezD+WcCfW4VkMkEcQWL/Nmy/nqsWTvTYg7oUmTGzglvSSV2P9h2z1PVeREPFf0GWNzruYleAt1XCMQZSg1xxQ== + +ipaddr.js@1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" + integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== + +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + integrity sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A== + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== + dependencies: + kind-of "^6.0.0" + +is-arguments@^1.0.4, is-arguments@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" + integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== + dependencies: + call-bind "^1.0.2" + has-tostringtag "^1.0.0" + +is-array-buffer@^3.0.1, is-array-buffer@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz#f2653ced8412081638ecb0ebbd0c41c6e0aecbbe" + integrity sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.2.0" + is-typed-array "^1.1.10" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== + +is-bigint@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.4.tgz#08147a1875bc2b32005d41ccd8291dffc6691df3" + integrity sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg== + dependencies: + has-bigints "^1.0.1" + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-boolean-object@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.1.2.tgz#5c6dc200246dd9321ae4b885a114bb1f75f63719" + integrity sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA== + dependencies: + call-bind "^1.0.2" + has-tostringtag "^1.0.0" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== + +is-buffer@^2.0.2, is-buffer@^2.0.5, is-buffer@~2.0.3: + version "2.0.5" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.5.tgz#ebc252e400d22ff8d77fa09888821a24a658c191" + integrity sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ== + +is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" + integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== + +is-ci@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== + dependencies: + ci-info "^2.0.0" + +is-core-module@^2.11.0, is-core-module@^2.9.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" + integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== + dependencies: + has "^1.0.3" + +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + integrity sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg== + dependencies: + kind-of "^3.0.2" + +is-data-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== + dependencies: + kind-of "^6.0.0" + +is-date-object@^1.0.1, is-date-object@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.5.tgz#0841d5536e724c25597bf6ea62e1bd38298df31f" + integrity sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ== + dependencies: + has-tostringtag "^1.0.0" + +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== + dependencies: + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== + dependencies: + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" + +is-directory@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1" + integrity sha512-yVChGzahRFvbkscn2MlwGismPO12i9+znNruC5gVEntG3qu0xQMzsGg/JFbrsqDOHtHFPci+V5aP5T9I+yeKqw== + +is-docker@^2.0.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" + integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw== + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== + dependencies: + is-plain-object "^2.0.4" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-finite@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" + integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w== + +is-fn@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fn/-/is-fn-1.0.0.tgz#9543d5de7bcf5b08a22ec8a20bae6e286d510d8c" + integrity sha512-XoFPJQmsAShb3jEQRfzf2rqXavq7fIqF/jOekp308JlThqrODnMpweVSGilKTCXELfLhltGP2AGgbQGVP8F1dg== + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + integrity sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw== + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-function@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.2.tgz#4f097f30abf6efadac9833b17ca5dc03f8144e08" + integrity sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ== + +is-generator-function@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.10.tgz#f1558baf1ac17e0deea7c0415c438351ff2b3c72" + integrity sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A== + dependencies: + has-tostringtag "^1.0.0" + +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-hex-prefixed@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz#7d8d37e6ad77e5d127148913c573e082d777f554" + integrity sha512-WvtOiug1VFrE9v1Cydwm+FnXd3+w9GaeVUss5W4v/SLy3UW00vP+6iNF2SdnfiBoLy4bTqVdkftNGTUeOFVsbA== + +is-map@^2.0.1, is-map@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.2.tgz#00922db8c9bf73e81b7a335827bc2a43f2b91127" + integrity sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg== + +is-natural-number@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-natural-number/-/is-natural-number-4.0.1.tgz#ab9d76e1db4ced51e35de0c72ebecf09f734cde8" + integrity sha512-Y4LTamMe0DDQIIAlaer9eKebAlDSV6huy+TWhJVPlzZh2o4tRP5SQWFlLn5N0To4mDD22/qdOq+veo1cSISLgQ== + +is-negative-zero@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" + integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== + +is-number-object@^1.0.4: + version "1.0.7" + resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.7.tgz#59d50ada4c45251784e9904f5246c742f07a42fc" + integrity sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ== + dependencies: + has-tostringtag "^1.0.0" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + integrity sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg== + dependencies: + kind-of "^3.0.2" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-object@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.2.tgz#a56552e1c665c9e950b4a025461da87e72f86fcf" + integrity sha512-2rRIahhZr2UWb45fIOuvZGpFtz0TyOZLf32KxBbSoUCeZR495zCKlWUKKUByk3geS2eAs7ZAABt0Y/Rx0GiQGA== + +is-plain-obj@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" + integrity sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg== + +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + +is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-regex@^1.0.4, is-regex@^1.1.4, is-regex@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.4.tgz#eef5663cd59fa4c0ae339505323df6854bb15958" + integrity sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg== + dependencies: + call-bind "^1.0.2" + has-tostringtag "^1.0.0" + +is-retry-allowed@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.2.0.tgz#d778488bd0a4666a3be8a1482b9f2baafedea8b4" + integrity sha512-RUbUeKwvm3XG2VYamhJL1xFktgjvPzL0Hq8C+6yrWIswDy3BIXGqCxhxkc30N9jqK311gVU137K8Ei55/zVJRg== + +is-set@^2.0.1, is-set@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.2.tgz#90755fa4c2562dc1c5d4024760d6119b94ca18ec" + integrity sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g== + +is-shared-array-buffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" + integrity sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA== + dependencies: + call-bind "^1.0.2" + +is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + integrity sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ== + +is-string@^1.0.5, is-string@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.7.tgz#0dd12bf2006f255bb58f695110eff7491eebc0fd" + integrity sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg== + dependencies: + has-tostringtag "^1.0.0" + +is-symbol@^1.0.2, is-symbol@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.4.tgz#a6dac93b635b063ca6872236de88910a57af139c" + integrity sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg== + dependencies: + has-symbols "^1.0.2" + +is-typed-array@^1.1.10, is-typed-array@^1.1.3, is-typed-array@^1.1.9: + version "1.1.10" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.10.tgz#36a5b5cb4189b575d1a3e4b08536bfb485801e3f" + integrity sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + gopd "^1.0.1" + has-tostringtag "^1.0.0" + +is-typedarray@^1.0.0, is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== + +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + +is-url@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52" + integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww== + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + integrity sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q== + +is-weakmap@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.1.tgz#5008b59bdc43b698201d18f62b37b2ca243e8cf2" + integrity sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA== + +is-weakref@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" + integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== + dependencies: + call-bind "^1.0.2" + +is-weakset@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-weakset/-/is-weakset-2.0.2.tgz#4569d67a747a1ce5a994dfd4ef6dcea76e7c0a1d" + integrity sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.1" + +is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== + +is-wsl@^2.1.1: + version "2.2.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" + integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== + dependencies: + is-docker "^2.0.0" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + integrity sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ== + +isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== + +isarray@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" + integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + integrity sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA== + dependencies: + isarray "1.0.0" + +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== + +isomorphic-unfetch@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz#87341d5f4f7b63843d468438128cb087b7c3e98f" + integrity sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q== + dependencies: + node-fetch "^2.6.1" + unfetch "^4.2.0" + +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + integrity sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g== + +isurl@^1.0.0-alpha5: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isurl/-/isurl-1.0.0.tgz#b27f4f49f3cdaa3ea44a0a5b7f3462e6edc39d67" + integrity sha512-1P/yWsxPlDtn7QeRD+ULKQPaIaN6yF368GZ2vDfv0AL0NwpStafjWCDDdn0k8wgFMWpVAqG7oJhxHnlud42i9w== + dependencies: + has-to-string-tag-x "^1.2.0" + is-object "^1.0.1" + +js-cookie@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8" + integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ== + +js-sha3@0.5.7, js-sha3@^0.5.7: + version "0.5.7" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.7.tgz#0d4ffd8002d5333aabaf4a23eed2f6374c9f28e7" + integrity sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g== + +js-sha3@0.8.0, js-sha3@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" + integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== + +"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +js-tokens@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" + integrity sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg== + +js-yaml@3.13.1: + version "3.13.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" + integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +js-yaml@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +js-yaml@^3.12.0, js-yaml@^3.13.0, js-yaml@^3.13.1: + version "3.14.1" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" + integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + integrity sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg== + +jsesc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + integrity sha512-Mke0DA0QjUWuJlhsE0ZPPhYiJkRap642SmI/4ztCFaUs6V2AiH1sfecc+57NgaryfAA2VR3v6O+CSjC1jZJKOA== + +jsesc@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + integrity sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA== + +json-buffer@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" + integrity sha512-CuUqjv0FUZIdXkHPI8MezCnFCdaTAacej1TZYulLoAg1h/PhwkdXFN4V/gzY4g+fMBCOV2xF+rp7t2XD2ns/NQ== + +json-buffer@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" + integrity sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ== + +json-parse-better-errors@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" + integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== + +json-rpc-engine@^3.4.0, json-rpc-engine@^3.6.0: + version "3.8.0" + resolved "https://registry.yarnpkg.com/json-rpc-engine/-/json-rpc-engine-3.8.0.tgz#9d4ff447241792e1d0a232f6ef927302bb0c62a9" + integrity sha512-6QNcvm2gFuuK4TKU1uwfH0Qd/cOSb9c1lls0gbnIhciktIUQJwz6NQNAW4B1KiGPenv7IKu97V222Yo1bNhGuA== + dependencies: + async "^2.0.1" + babel-preset-env "^1.7.0" + babelify "^7.3.0" + json-rpc-error "^2.0.0" + promise-to-callback "^1.0.0" + safe-event-emitter "^1.0.1" + +json-rpc-error@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/json-rpc-error/-/json-rpc-error-2.0.0.tgz#a7af9c202838b5e905c7250e547f1aff77258a02" + integrity sha512-EwUeWP+KgAZ/xqFpaP6YDAXMtCJi+o/QQpCQFIYyxr01AdADi2y413eM8hSqJcoQym9WMePAJWoaODEJufC4Ug== + dependencies: + inherits "^2.0.1" + +json-rpc-random-id@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-rpc-random-id/-/json-rpc-random-id-1.0.1.tgz#ba49d96aded1444dbb8da3d203748acbbcdec8c8" + integrity sha512-RJ9YYNCkhVDBuP4zN5BBtYAzEl03yq/jIIsyif0JY9qyJuQQZNeDK7anAPKKlyEtLSj2s8h6hNh2F8zO5q7ScA== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-schema-traverse@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" + integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== + +json-schema@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" + integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== + +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== + +json-stable-stringify@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.2.tgz#e06f23128e0bbe342dc996ed5a19e28b57b580e0" + integrity sha512-eunSSaEnxV12z+Z73y/j5N37/In40GK4GmsSy+tEHJMxknvqnA7/djeYtAgW0GsWHUfg+847WJjKaEylk2y09g== + dependencies: + jsonify "^0.0.1" + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== + +json-text-sequence@^0.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/json-text-sequence/-/json-text-sequence-0.1.1.tgz#a72f217dc4afc4629fff5feb304dc1bd51a2f3d2" + integrity sha512-L3mEegEWHRekSHjc7+sc8eJhba9Clq1PZ8kMkzf8OxElhXc8O4TS5MwcVlj9aEbm5dr81N90WHC5nAz3UO971w== + dependencies: + delimit-stream "0.1.0" + +json5@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + integrity sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw== + +json5@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" + integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== + dependencies: + minimist "^1.2.0" + +jsonfile@^2.1.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" + integrity sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw== + optionalDependencies: + graceful-fs "^4.1.6" + +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== + optionalDependencies: + graceful-fs "^4.1.6" + +jsonfile@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" + integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + +jsonify@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.1.tgz#2aa3111dae3d34a0f151c63f3a45d995d9420978" + integrity sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg== + +jsprim@^1.2.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.2.tgz#712c65533a15c878ba59e9ed5f0e26d5b77c5feb" + integrity sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw== + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.4.0" + verror "1.10.0" + +"jsx-ast-utils@^2.4.1 || ^3.0.0", jsx-ast-utils@^3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz#76b3e6e6cece5c69d49a5792c3d01bd1a0cdc7ea" + integrity sha512-fYQHZTZ8jSfmWZ0iyzfwiU4WDX4HpHbMCZ3gPlWYiCl3BoeOTsqKBqnTVfH2rYT7eP5c3sVbeSPHnnJOaTrWiw== + dependencies: + array-includes "^3.1.5" + object.assign "^4.1.3" + +keccak256@^1.0.0: + version "1.0.6" + resolved "https://registry.yarnpkg.com/keccak256/-/keccak256-1.0.6.tgz#dd32fb771558fed51ce4e45a035ae7515573da58" + integrity sha512-8GLiM01PkdJVGUhR1e6M/AvWnSqYS0HaERI+K/QtStGDGlSTx2B1zTqZk4Zlqu5TxHJNTxWAdP9Y+WI50OApUw== + dependencies: + bn.js "^5.2.0" + buffer "^6.0.3" + keccak "^3.0.2" + +keccak@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.1.tgz#ae30a0e94dbe43414f741375cff6d64c8bea0bff" + integrity sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA== + dependencies: + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + +keccak@^3.0.0, keccak@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.3.tgz#4bc35ad917be1ef54ff246f904c2bbbf9ac61276" + integrity sha512-JZrLIAJWuZxKbCilMpNz5Vj7Vtb4scDG3dMXLOsbzBmQGyjwE61BbW7bJkfKKCShXiQZt3T6sBgALRtmd+nZaQ== + dependencies: + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + readable-stream "^3.6.0" + +keyv@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" + integrity sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA== + dependencies: + json-buffer "3.0.0" + +keyv@^4.0.0: + version "4.5.2" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.2.tgz#0e310ce73bf7851ec702f2eaf46ec4e3805cce56" + integrity sha512-5MHbFaKn8cNSmVW7BYnijeAVlE4cYA/SVkifVgrh7yotnfhKmjuXpDKjrABLnT0SfHWV21P8ow07OGfRrNDg8g== + dependencies: + json-buffer "3.0.1" + +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + integrity sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ== + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + integrity sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw== + dependencies: + is-buffer "^1.1.5" + +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +klaw-sync@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c" + integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ== + dependencies: + graceful-fs "^4.1.11" + +klaw@^1.0.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" + integrity sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw== + optionalDependencies: + graceful-fs "^4.1.9" + +language-subtag-registry@~0.3.2: + version "0.3.22" + resolved "https://registry.yarnpkg.com/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz#2e1500861b2e457eba7e7ae86877cbd08fa1fd1d" + integrity sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w== + +language-tags@=1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/language-tags/-/language-tags-1.0.5.tgz#d321dbc4da30ba8bf3024e040fa5c14661f9193a" + integrity sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ== + dependencies: + language-subtag-registry "~0.3.2" + +lcid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + integrity sha512-YiGkH6EnGrDGqLMITnGjXtGmNtjoXw9SVUzcaos8RBi7Ps0VBylkq+vOcY9QE5poLasPCR849ucFUkl0UzUyOw== + dependencies: + invert-kv "^1.0.0" + +level-codec@^9.0.0: + version "9.0.2" + resolved "https://registry.yarnpkg.com/level-codec/-/level-codec-9.0.2.tgz#fd60df8c64786a80d44e63423096ffead63d8cbc" + integrity sha512-UyIwNb1lJBChJnGfjmO0OR+ezh2iVu1Kas3nvBS/BzGnx79dv6g7unpKIDNPMhfdTEGoc7mC8uAu51XEtX+FHQ== + dependencies: + buffer "^5.6.0" + +level-codec@~7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/level-codec/-/level-codec-7.0.1.tgz#341f22f907ce0f16763f24bddd681e395a0fb8a7" + integrity sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ== + +level-errors@^1.0.3: + version "1.1.2" + resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-1.1.2.tgz#4399c2f3d3ab87d0625f7e3676e2d807deff404d" + integrity sha512-Sw/IJwWbPKF5Ai4Wz60B52yj0zYeqzObLh8k1Tk88jVmD51cJSKWSYpRyhVIvFzZdvsPqlH5wfhp/yxdsaQH4w== + dependencies: + errno "~0.1.1" + +level-errors@^2.0.0, level-errors@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-2.0.1.tgz#2132a677bf4e679ce029f517c2f17432800c05c8" + integrity sha512-UVprBJXite4gPS+3VznfgDSU8PTRuVX0NXwoWW50KLxd2yw4Y1t2JUR5In1itQnudZqRMT9DlAM3Q//9NCjCFw== + dependencies: + errno "~0.1.1" + +level-errors@~1.0.3: + version "1.0.5" + resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-1.0.5.tgz#83dbfb12f0b8a2516bdc9a31c4876038e227b859" + integrity sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig== + dependencies: + errno "~0.1.1" + +level-iterator-stream@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-2.0.3.tgz#ccfff7c046dcf47955ae9a86f46dfa06a31688b4" + integrity sha512-I6Heg70nfF+e5Y3/qfthJFexhRw/Gi3bIymCoXAlijZdAcLaPuWSJs3KXyTYf23ID6g0o2QF62Yh+grOXY3Rig== + dependencies: + inherits "^2.0.1" + readable-stream "^2.0.5" + xtend "^4.0.0" + +level-iterator-stream@~1.3.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-1.3.1.tgz#e43b78b1a8143e6fa97a4f485eb8ea530352f2ed" + integrity sha512-1qua0RHNtr4nrZBgYlpV0qHHeHpcRRWTxEZJ8xsemoHAXNL5tbooh4tPEEqIqsbWCAJBmUmkwYK/sW5OrFjWWw== + dependencies: + inherits "^2.0.1" + level-errors "^1.0.3" + readable-stream "^1.0.33" + xtend "^4.0.0" + +level-iterator-stream@~3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-3.0.1.tgz#2c98a4f8820d87cdacab3132506815419077c730" + integrity sha512-nEIQvxEED9yRThxvOrq8Aqziy4EGzrxSZK+QzEFAVuJvQ8glfyZ96GB6BoI4sBbLfjMXm2w4vu3Tkcm9obcY0g== + dependencies: + inherits "^2.0.1" + readable-stream "^2.3.6" + xtend "^4.0.0" + +level-mem@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/level-mem/-/level-mem-3.0.1.tgz#7ce8cf256eac40f716eb6489654726247f5a89e5" + integrity sha512-LbtfK9+3Ug1UmvvhR2DqLqXiPW1OJ5jEh0a3m9ZgAipiwpSxGj/qaVVy54RG5vAQN1nCuXqjvprCuKSCxcJHBg== + dependencies: + level-packager "~4.0.0" + memdown "~3.0.0" + +level-packager@~4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/level-packager/-/level-packager-4.0.1.tgz#7e7d3016af005be0869bc5fa8de93d2a7f56ffe6" + integrity sha512-svCRKfYLn9/4CoFfi+d8krOtrp6RoX8+xm0Na5cgXMqSyRru0AnDYdLl+YI8u1FyS6gGZ94ILLZDE5dh2but3Q== + dependencies: + encoding-down "~5.0.0" + levelup "^3.0.0" + +level-post@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/level-post/-/level-post-1.0.7.tgz#19ccca9441a7cc527879a0635000f06d5e8f27d0" + integrity sha512-PWYqG4Q00asOrLhX7BejSajByB4EmG2GaKHfj3h5UmmZ2duciXLPGYWIjBzLECFWUGOZWlm5B20h/n3Gs3HKew== + dependencies: + ltgt "^2.1.2" + +level-sublevel@6.6.4: + version "6.6.4" + resolved "https://registry.yarnpkg.com/level-sublevel/-/level-sublevel-6.6.4.tgz#f7844ae893919cd9d69ae19d7159499afd5352ba" + integrity sha512-pcCrTUOiO48+Kp6F1+UAzF/OtWqLcQVTVF39HLdZ3RO8XBoXt+XVPKZO1vVr1aUoxHZA9OtD2e1v7G+3S5KFDA== + dependencies: + bytewise "~1.1.0" + level-codec "^9.0.0" + level-errors "^2.0.0" + level-iterator-stream "^2.0.3" + ltgt "~2.1.1" + pull-defer "^0.2.2" + pull-level "^2.0.3" + pull-stream "^3.6.8" + typewiselite "~1.0.0" + xtend "~4.0.0" + +level-supports@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/level-supports/-/level-supports-4.0.1.tgz#431546f9d81f10ff0fea0e74533a0e875c08c66a" + integrity sha512-PbXpve8rKeNcZ9C1mUicC9auIYFyGpkV9/i6g76tLgANwWhtG2v7I4xNBUlkn3lE2/dZF3Pi0ygYGtLc4RXXdA== + +level-transcoder@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/level-transcoder/-/level-transcoder-1.0.1.tgz#f8cef5990c4f1283d4c86d949e73631b0bc8ba9c" + integrity sha512-t7bFwFtsQeD8cl8NIoQ2iwxA0CL/9IFw7/9gAjOonH0PWTTiRfY7Hq+Ejbsxh86tXobDQ6IOiddjNYIfOBs06w== + dependencies: + buffer "^6.0.3" + module-error "^1.0.1" + +level-ws@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/level-ws/-/level-ws-0.0.0.tgz#372e512177924a00424b0b43aef2bb42496d228b" + integrity sha512-XUTaO/+Db51Uiyp/t7fCMGVFOTdtLS/NIACxE/GHsij15mKzxksZifKVjlXDF41JMUP/oM1Oc4YNGdKnc3dVLw== + dependencies: + readable-stream "~1.0.15" + xtend "~2.1.1" + +level-ws@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/level-ws/-/level-ws-1.0.0.tgz#19a22d2d4ac57b18cc7c6ecc4bd23d899d8f603b" + integrity sha512-RXEfCmkd6WWFlArh3X8ONvQPm8jNpfA0s/36M4QzLqrLEIt1iJE9WBHLZ5vZJK6haMjJPJGJCQWfjMNnRcq/9Q== + dependencies: + inherits "^2.0.3" + readable-stream "^2.2.8" + xtend "^4.0.1" + +level@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/level/-/level-8.0.0.tgz#41b4c515dabe28212a3e881b61c161ffead14394" + integrity sha512-ypf0jjAk2BWI33yzEaaotpq7fkOPALKAgDBxggO6Q9HGX2MRXn0wbP1Jn/tJv1gtL867+YOjOB49WaUF3UoJNQ== + dependencies: + browser-level "^1.0.1" + classic-level "^1.2.0" + +levelup@3.1.1, levelup@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/levelup/-/levelup-3.1.1.tgz#c2c0b3be2b4dc316647c53b42e2f559e232d2189" + integrity sha512-9N10xRkUU4dShSRRFTBdNaBxofz+PGaIZO962ckboJZiNmLuhVT6FZ6ZKAsICKfUBO76ySaYU6fJWX/jnj3Lcg== + dependencies: + deferred-leveldown "~4.0.0" + level-errors "~2.0.0" + level-iterator-stream "~3.0.0" + xtend "~4.0.0" + +levelup@^1.2.1: + version "1.3.9" + resolved "https://registry.yarnpkg.com/levelup/-/levelup-1.3.9.tgz#2dbcae845b2bb2b6bea84df334c475533bbd82ab" + integrity sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ== + dependencies: + deferred-leveldown "~1.2.1" + level-codec "~7.0.0" + level-errors "~1.0.3" + level-iterator-stream "~1.3.0" + prr "~1.0.1" + semver "~5.4.1" + xtend "~4.0.0" + +levn@^0.3.0, levn@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" + integrity sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA== + dependencies: + prelude-ls "~1.1.2" + type-check "~0.3.2" + +levn@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade" + integrity sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ== + dependencies: + prelude-ls "^1.2.1" + type-check "~0.4.0" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + integrity sha512-cy7ZdNRXdablkXYNI049pthVeXFurRyb9+hA/dZzerZ0pGTx42z+y+ssxBaVV2l70t1muq5IdKhn4UtcoGUY9A== + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + integrity sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA== + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash.assign@^4.0.3, lodash.assign@^4.0.6: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7" + integrity sha512-hFuH8TY+Yji7Eja3mGiuAxBqLagejScbG8GbG0j6o9vzn0YL14My+ktnqtZgFTosKymC9/44wP6s7xyuLfnClw== + +lodash.camelcase@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" + integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA== + +lodash.merge@^4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" + integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== + +lodash.truncate@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193" + integrity sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw== + +lodash@4.17.20: + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== + +lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.16, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.4: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + +log-symbols@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a" + integrity sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg== + dependencies: + chalk "^2.0.1" + +log-symbols@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-3.0.0.tgz#f3a08516a5dea893336a7dee14d18a1cfdab77c4" + integrity sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ== + dependencies: + chalk "^2.4.2" + +log-symbols@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + +looper@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/looper/-/looper-2.0.0.tgz#66cd0c774af3d4fedac53794f742db56da8f09ec" + integrity sha512-6DzMHJcjbQX/UPHc1rRCBfKlLwDkvuGZ715cIR36wSdYqWXFT35uLXq5P/2orl3tz+t+VOVPxw4yPinQlUDGDQ== + +looper@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/looper/-/looper-3.0.0.tgz#2efa54c3b1cbaba9b94aee2e5914b0be57fbb749" + integrity sha512-LJ9wplN/uSn72oJRsXTx+snxPet5c8XiZmOKCm906NVYu+ag6SB6vUcnJcWxgnl2NfbIyeobAn7Bwv6xRj2XJg== + +loose-envify@^1.0.0, loose-envify@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== + dependencies: + js-tokens "^3.0.0 || ^4.0.0" + +loupe@^2.3.1: + version "2.3.6" + resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.6.tgz#76e4af498103c532d1ecc9be102036a21f787b53" + integrity sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA== + dependencies: + get-func-name "^2.0.0" + +lowercase-keys@^1.0.0, lowercase-keys@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" + integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== + +lowercase-keys@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" + integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== + +lru-cache@5.1.1, lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + dependencies: + yallist "^3.0.2" + +lru-cache@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-3.2.0.tgz#71789b3b7f5399bec8565dda38aa30d2a097efee" + integrity sha512-91gyOKTc2k66UG6kHiH4h3S2eltcPwE1STVfMYC/NG+nZwf8IIuiamfmpGZjpbbxzSyEJaLC0tNSmhjlQUTJow== + dependencies: + pseudomap "^1.0.1" + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +lru_map@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd" + integrity sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ== + +ltgt@^2.1.2, ltgt@~2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" + integrity sha512-AI2r85+4MquTw9ZYqabu4nMwy9Oftlfa/e/52t9IjtfG+mGBbTNdAoZ3RQKLHR6r0wQnwZnPIEh/Ya6XTWAKNA== + +ltgt@~2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.1.3.tgz#10851a06d9964b971178441c23c9e52698eece34" + integrity sha512-5VjHC5GsENtIi5rbJd+feEpDKhfr7j0odoUR2Uh978g+2p93nd5o34cTjQWohXsPsCZeqoDnIqEf88mPCe0Pfw== + +make-dir@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" + integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== + dependencies: + pify "^3.0.0" + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + integrity sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg== + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + integrity sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w== + dependencies: + object-visit "^1.0.0" + +markdown-table@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.3.tgz#9fcb69bcfdb8717bfd0398c6ec2d93036ef8de60" + integrity sha512-1RUZVgQlpJSPWYbFSpmudq5nHY1doEIv89gBtF0s4gW1GF2XorxcA/70M5vq7rLv0a6mhOUccRsqkwhwLCIQ2Q== + +match-all@^1.2.6: + version "1.2.6" + resolved "https://registry.yarnpkg.com/match-all/-/match-all-1.2.6.tgz#66d276ad6b49655551e63d3a6ee53e8be0566f8d" + integrity sha512-0EESkXiTkWzrQQntBu2uzKvLu6vVkUGz40nGPbSZuegcfE5UuSzNjLaIu76zJWuaT/2I3Z/8M06OlUOZLGwLlQ== + +mcl-wasm@^0.7.1: + version "0.7.9" + resolved "https://registry.yarnpkg.com/mcl-wasm/-/mcl-wasm-0.7.9.tgz#c1588ce90042a8700c3b60e40efb339fc07ab87f" + integrity sha512-iJIUcQWA88IJB/5L15GnJVnSQJmf/YaxxV6zRavv83HILHaJQb6y0iFyDMdDO0gN8X37tdxmAOrH/P8B6RB8sQ== + +md5.js@^1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" + integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ== + +memdown@^1.0.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/memdown/-/memdown-1.4.1.tgz#b4e4e192174664ffbae41361aa500f3119efe215" + integrity sha512-iVrGHZB8i4OQfM155xx8akvG9FIj+ht14DX5CQkCTG4EHzZ3d3sgckIf/Lm9ivZalEsFuEVnWv2B2WZvbrro2w== + dependencies: + abstract-leveldown "~2.7.1" + functional-red-black-tree "^1.0.1" + immediate "^3.2.3" + inherits "~2.0.1" + ltgt "~2.2.0" + safe-buffer "~5.1.1" + +memdown@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/memdown/-/memdown-3.0.0.tgz#93aca055d743b20efc37492e9e399784f2958309" + integrity sha512-tbV02LfZMWLcHcq4tw++NuqMO+FZX8tNJEiD2aNRm48ZZusVg5N8NART+dmBkepJVye986oixErf7jfXboMGMA== + dependencies: + abstract-leveldown "~5.0.0" + functional-red-black-tree "~1.0.1" + immediate "~3.2.3" + inherits "~2.0.1" + ltgt "~2.2.0" + safe-buffer "~5.1.1" + +memory-level@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/memory-level/-/memory-level-1.0.0.tgz#7323c3fd368f9af2f71c3cd76ba403a17ac41692" + integrity sha512-UXzwewuWeHBz5krr7EvehKcmLFNoXxGcvuYhC41tRnkrTbJohtS7kVn9akmgirtRygg+f7Yjsfi8Uu5SGSQ4Og== + dependencies: + abstract-level "^1.0.0" + functional-red-black-tree "^1.0.1" + module-error "^1.0.1" + +memorystream@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2" + integrity sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw== + +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w== + +merge2@^1.3.0, merge2@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" + integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== + +merkle-patricia-tree@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-3.0.0.tgz#448d85415565df72febc33ca362b8b614f5a58f8" + integrity sha512-soRaMuNf/ILmw3KWbybaCjhx86EYeBbD8ph0edQCTed0JN/rxDt1EBN52Ajre3VyGo+91f8+/rfPIRQnnGMqmQ== + dependencies: + async "^2.6.1" + ethereumjs-util "^5.2.0" + level-mem "^3.0.1" + level-ws "^1.0.0" + readable-stream "^3.0.6" + rlp "^2.0.0" + semaphore ">=1.0.1" + +merkle-patricia-tree@^2.1.2, merkle-patricia-tree@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz#982ca1b5a0fde00eed2f6aeed1f9152860b8208a" + integrity sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g== + dependencies: + async "^1.4.2" + ethereumjs-util "^5.0.0" + level-ws "0.0.0" + levelup "^1.2.1" + memdown "^1.0.0" + readable-stream "^2.0.0" + rlp "^2.0.0" + semaphore ">=1.0.1" + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== + +micromatch@^3.1.4: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + +micromatch@^4.0.2, micromatch@^4.0.4: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + +miller-rabin@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" + integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== + dependencies: + bn.js "^4.0.0" + brorand "^1.0.1" + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12, mime-types@^2.1.16, mime-types@~2.1.19, mime-types@~2.1.24, mime-types@~2.1.34: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +mime@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== + +mimic-fn@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" + integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== + +mimic-fn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +mimic-response@^1.0.0, mimic-response@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" + integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== + +mimic-response@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9" + integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ== + +min-document@^2.19.0: + version "2.19.0" + resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685" + integrity sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ== + dependencies: + dom-walk "^0.1.0" + +minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== + +minimalistic-crypto-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" + integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== + +minimatch@3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + dependencies: + brace-expansion "^1.1.7" + +minimatch@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" + integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^3.0.4, minimatch@^3.1.1, minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6, minimist@^1.2.7, minimist@~1.2.7: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== + +minipass@^2.6.0, minipass@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" + integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== + dependencies: + safe-buffer "^5.1.2" + yallist "^3.0.0" + +minizlib@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" + integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== + dependencies: + minipass "^2.9.0" + +mixin-deep@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + +mkdirp-promise@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/mkdirp-promise/-/mkdirp-promise-5.0.1.tgz#e9b8f68e552c68a9c1713b84883f7a1dd039b8a1" + integrity sha512-Hepn5kb1lJPtVW84RFT40YG1OddBNTOVUZR2bzQUHc+Z03en8/3uX0+060JDhcEzyO08HmipsN9DcnFMxhIL9w== + dependencies: + mkdirp "*" + +mkdirp@*: + version "2.1.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19" + integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A== + +mkdirp@0.5.4: + version "0.5.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.4.tgz#fd01504a6797ec5c9be81ff43d204961ed64a512" + integrity sha512-iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw== + dependencies: + minimist "^1.2.5" + +mkdirp@0.5.5: + version "0.5.5" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" + integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== + dependencies: + minimist "^1.2.5" + +mkdirp@^0.5.1, mkdirp@^0.5.5: + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + +mnemonist@^0.38.0: + version "0.38.5" + resolved "https://registry.yarnpkg.com/mnemonist/-/mnemonist-0.38.5.tgz#4adc7f4200491237fe0fa689ac0b86539685cade" + integrity sha512-bZTFT5rrPKtPJxj8KSV0WkPyNxl72vQepqqVUAW2ARUpUSF2qXMB6jZj7hW5/k7C1rtpzqbD/IIbJwLXUjCHeg== + dependencies: + obliterator "^2.0.0" + +mocha@^10.0.0: + version "10.2.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.2.0.tgz#1fd4a7c32ba5ac372e03a17eef435bd00e5c68b8" + integrity sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg== + dependencies: + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.3" + debug "4.3.4" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "7.2.0" + he "1.2.0" + js-yaml "4.1.0" + log-symbols "4.1.0" + minimatch "5.0.1" + ms "2.1.3" + nanoid "3.3.3" + serialize-javascript "6.0.0" + strip-json-comments "3.1.1" + supports-color "8.1.1" + workerpool "6.2.1" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + +mocha@^6.2.2: + version "6.2.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-6.2.3.tgz#e648432181d8b99393410212664450a4c1e31912" + integrity sha512-0R/3FvjIGH3eEuG17ccFPk117XL2rWxatr81a57D+r/x2uTYZRbdZ4oVidEUMh2W2TJDa7MdAb12Lm2/qrKajg== + dependencies: + ansi-colors "3.2.3" + browser-stdout "1.3.1" + debug "3.2.6" + diff "3.5.0" + escape-string-regexp "1.0.5" + find-up "3.0.0" + glob "7.1.3" + growl "1.10.5" + he "1.2.0" + js-yaml "3.13.1" + log-symbols "2.2.0" + minimatch "3.0.4" + mkdirp "0.5.4" + ms "2.1.1" + node-environment-flags "1.0.5" + object.assign "4.1.0" + strip-json-comments "2.0.1" + supports-color "6.0.0" + which "1.3.1" + wide-align "1.1.3" + yargs "13.3.2" + yargs-parser "13.1.2" + yargs-unparser "1.6.0" + +mocha@^7.1.1: + version "7.2.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-7.2.0.tgz#01cc227b00d875ab1eed03a75106689cfed5a604" + integrity sha512-O9CIypScywTVpNaRrCAgoUnJgozpIofjKUYmJhiCIJMiuYnLI6otcb1/kpW9/n/tJODHGZ7i8aLQoDVsMtOKQQ== + dependencies: + ansi-colors "3.2.3" + browser-stdout "1.3.1" + chokidar "3.3.0" + debug "3.2.6" + diff "3.5.0" + escape-string-regexp "1.0.5" + find-up "3.0.0" + glob "7.1.3" + growl "1.10.5" + he "1.2.0" + js-yaml "3.13.1" + log-symbols "3.0.0" + minimatch "3.0.4" + mkdirp "0.5.5" + ms "2.1.1" + node-environment-flags "1.0.6" + object.assign "4.1.0" + strip-json-comments "2.0.1" + supports-color "6.0.0" + which "1.3.1" + wide-align "1.1.3" + yargs "13.3.2" + yargs-parser "13.1.2" + yargs-unparser "1.6.0" + +mock-fs@^4.1.0: + version "4.14.0" + resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.14.0.tgz#ce5124d2c601421255985e6e94da80a7357b1b18" + integrity sha512-qYvlv/exQ4+svI3UOvPUpLDF0OMX5euvUH0Ny4N5QyRyhNdgAgUrVH3iUINSzEPLvx0kbo/Bp28GJKIqvE7URw== + +module-error@^1.0.1, module-error@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/module-error/-/module-error-1.0.2.tgz#8d1a48897ca883f47a45816d4fb3e3c6ba404d86" + integrity sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA== + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== + +ms@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@2.1.3, ms@^2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +multibase@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/multibase/-/multibase-0.7.0.tgz#1adfc1c50abe05eefeb5091ac0c2728d6b84581b" + integrity sha512-TW8q03O0f6PNFTQDvh3xxH03c8CjGaaYrjkl9UQPG6rz53TQzzxJVCIWVjzcbN/Q5Y53Zd0IBQBMVktVgNx4Fg== + dependencies: + base-x "^3.0.8" + buffer "^5.5.0" + +multibase@~0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/multibase/-/multibase-0.6.1.tgz#b76df6298536cc17b9f6a6db53ec88f85f8cc12b" + integrity sha512-pFfAwyTjbbQgNc3G7D48JkJxWtoJoBMaR4xQUOuB8RnCgRqaYmWNFeJTTvrJ2w51bjLq2zTby6Rqj9TQ9elSUw== + dependencies: + base-x "^3.0.8" + buffer "^5.5.0" + +multicodec@^0.5.5: + version "0.5.7" + resolved "https://registry.yarnpkg.com/multicodec/-/multicodec-0.5.7.tgz#1fb3f9dd866a10a55d226e194abba2dcc1ee9ffd" + integrity sha512-PscoRxm3f+88fAtELwUnZxGDkduE2HD9Q6GHUOywQLjOGT/HAdhjLDYNZ1e7VR0s0TP0EwZ16LNUTFpoBGivOA== + dependencies: + varint "^5.0.0" + +multicodec@^1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/multicodec/-/multicodec-1.0.4.tgz#46ac064657c40380c28367c90304d8ed175a714f" + integrity sha512-NDd7FeS3QamVtbgfvu5h7fd1IlbaC4EQ0/pgU4zqE2vdHCmBGsUa0TiM8/TdSeG6BMPC92OOCf8F1ocE/Wkrrg== + dependencies: + buffer "^5.6.0" + varint "^5.0.0" + +multihashes@^0.4.15, multihashes@~0.4.15: + version "0.4.21" + resolved "https://registry.yarnpkg.com/multihashes/-/multihashes-0.4.21.tgz#dc02d525579f334a7909ade8a122dabb58ccfcb5" + integrity sha512-uVSvmeCWf36pU2nB4/1kzYZjsXD9vofZKpgudqkceYY5g2aZZXJ5r9lxuzoRLl1OAp28XljXsEJ/X/85ZsKmKw== + dependencies: + buffer "^5.5.0" + multibase "^0.7.0" + varint "^5.0.0" + +murmur-128@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/murmur-128/-/murmur-128-0.2.1.tgz#a9f6568781d2350ecb1bf80c14968cadbeaa4b4d" + integrity sha512-WseEgiRkI6aMFBbj8Cg9yBj/y+OdipwVC7zUo3W2W1JAJITwouUOtpqsmGSg67EQmwwSyod7hsVsWY5LsrfQVg== + dependencies: + encode-utf8 "^1.0.2" + fmix "^0.1.0" + imul "^1.0.0" + +mute-stream@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" + integrity sha512-r65nCZhrbXXb6dXOACihYApHw2Q6pV0M3V0PSxd74N0+D8nzAdEAITq2oAjA1jVnKI+tGvEBUpqiMh0+rW6zDQ== + +mvdan-sh@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/mvdan-sh/-/mvdan-sh-0.5.0.tgz#fa76f611a103595ad0f04f5d18e582892c46e87c" + integrity sha512-UWbdl4LHd2fUnaEcOUFVWRdWGLkNoV12cKVIPiirYd8qM5VkCoCTXErlDubevrkEG7kGohvjRxAlTQmOqG80tw== + +nan@^2.13.2, nan@^2.14.0: + version "2.17.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb" + integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ== + +nano-json-stream-parser@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz#0cc8f6d0e2b622b479c40d499c46d64b755c6f5f" + integrity sha512-9MqxMH/BSJC7dnLsEMPyfN5Dvoo49IsPFYMcHw3Bcfc2kN0lpHRBSzlMSVx4HGyJ7s9B31CyBTVehWJoQ8Ctew== + +nanoid@3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25" + integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w== + +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" + integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +napi-macros@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/napi-macros/-/napi-macros-2.0.0.tgz#2b6bae421e7b96eb687aa6c77a7858640670001b" + integrity sha512-A0xLykHtARfueITVDernsAWdtIMbOJgKgcluwENp3AlsKN/PloyO10HtmoqnFAQAcxPkgZN7wdfPfEd0zNGxbg== + +natural-compare-lite@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" + integrity sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g== + +natural-compare@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== + +negotiator@0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== + +next-tick@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" + integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== + +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + +node-addon-api@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" + integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== + +node-environment-flags@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.5.tgz#fa930275f5bf5dae188d6192b24b4c8bbac3d76a" + integrity sha512-VNYPRfGfmZLx0Ye20jWzHUjyTW/c+6Wq+iLhDzUI4XmhrDd9l/FozXV3F2xOaXjvp0co0+v1YSR3CMP6g+VvLQ== + dependencies: + object.getownpropertydescriptors "^2.0.3" + semver "^5.7.0" + +node-environment-flags@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.6.tgz#a30ac13621f6f7d674260a54dede048c3982c088" + integrity sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw== + dependencies: + object.getownpropertydescriptors "^2.0.3" + semver "^5.7.0" + +node-fetch@2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" + integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== + +node-fetch@2.6.7: + version "2.6.7" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== + dependencies: + whatwg-url "^5.0.0" + +node-fetch@^2.6.0: + version "2.6.12" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" + integrity sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g== + dependencies: + whatwg-url "^5.0.0" + +node-fetch@^2.6.1, node-fetch@^2.6.7: + version "2.6.9" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.9.tgz#7c7f744b5cc6eb5fd404e0c7a9fec630a55657e6" + integrity sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg== + dependencies: + whatwg-url "^5.0.0" + +node-fetch@~1.7.1: + version "1.7.3" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef" + integrity sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ== + dependencies: + encoding "^0.1.11" + is-stream "^1.0.1" + +node-gyp-build@^4.2.0, node-gyp-build@^4.3.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.0.tgz#0c52e4cbf54bbd28b709820ef7b6a3c2d6209055" + integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ== + +nofilter@^1.0.3, nofilter@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-1.0.4.tgz#78d6f4b6a613e7ced8b015cec534625f7667006e" + integrity sha512-N8lidFp+fCz+TD51+haYdbDGrcBWwuHX40F5+z0qkUjMJ5Tp+rdSuAkMJ9N9eoolDlEVTf6u5icM+cNKkKW2mA== + +nofilter@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/nofilter/-/nofilter-3.1.0.tgz#c757ba68801d41ff930ba2ec55bab52ca184aa66" + integrity sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g== + +normalize-package-data@^2.3.2: + version "2.5.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" + integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== + dependencies: + hosted-git-info "^2.1.4" + resolve "^1.10.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +normalize-url@^4.1.0: + version "4.5.1" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.1.tgz#0dd90cf1288ee1d1313b87081c9a5932ee48518a" + integrity sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA== + +normalize-url@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" + integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A== + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + integrity sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ== + +number-to-bn@1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/number-to-bn/-/number-to-bn-1.7.0.tgz#bb3623592f7e5f9e0030b1977bd41a0c53fe1ea0" + integrity sha512-wsJ9gfSz1/s4ZsJN01lyonwuxA1tml6X1yBDnfpMglypcBRFZZkus26EdPSlqS5GJfYddVZa22p3VNb3z5m5Ig== + dependencies: + bn.js "4.11.6" + strip-hex-prefix "1.0.0" + +numeral@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/numeral/-/numeral-2.0.6.tgz#4ad080936d443c2561aed9f2197efffe25f4e506" + integrity sha512-qaKRmtYPZ5qdw4jWJD6bxEf1FJEqllJrwxCLIm0sQU/A7v2/czigzOb+C2uSiFsa9lBUzeH7M1oK+Q+OLxL3kA== + +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== + +object-assign@^4, object-assign@^4.0.0, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== + +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + integrity sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ== + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + +object-inspect@^1.12.3, object-inspect@^1.9.0, object-inspect@~1.12.3: + version "1.12.3" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" + integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== + +object-is@^1.0.1, object-is@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.5.tgz#b9deeaa5fc7f1846a0faecdceec138e5778f53ac" + integrity sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + +object-keys@^1.0.11, object-keys@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" + integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== + +object-keys@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336" + integrity sha512-ncrLw+X55z7bkl5PnUvHwFK9FcGuFYo9gtjws2XtSzL+aZ8tm830P60WJ0dSmFVaSalWieW5MD7kEdnXda9yJw== + +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + integrity sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA== + dependencies: + isobject "^3.0.0" + +object.assign@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" + integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w== + dependencies: + define-properties "^1.1.2" + function-bind "^1.1.1" + has-symbols "^1.0.0" + object-keys "^1.0.11" + +object.assign@^4.1.2, object.assign@^4.1.3, object.assign@^4.1.4: + version "4.1.4" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" + integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + has-symbols "^1.0.3" + object-keys "^1.1.1" + +object.entries@^1.1.5, object.entries@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.6.tgz#9737d0e5b8291edd340a3e3264bb8a3b00d5fa23" + integrity sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + +object.fromentries@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.6.tgz#cdb04da08c539cffa912dcd368b886e0904bfa73" + integrity sha512-VciD13dswC4j1Xt5394WR4MzmAQmlgN72phd/riNp9vtD7tp4QQWJ0R4wvclXcafgcYK8veHRed2W6XeGBvcfg== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + +object.getownpropertydescriptors@^2.0.3, object.getownpropertydescriptors@^2.1.1: + version "2.1.5" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.5.tgz#db5a9002489b64eef903df81d6623c07e5b4b4d3" + integrity sha512-yDNzckpM6ntyQiGTik1fKV1DcVDRS+w8bvpWNCBanvH5LfRX9O8WTHqQzG4RZwRAM4I0oU7TV11Lj5v0g20ibw== + dependencies: + array.prototype.reduce "^1.0.5" + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + +object.hasown@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/object.hasown/-/object.hasown-1.1.2.tgz#f919e21fad4eb38a57bc6345b3afd496515c3f92" + integrity sha512-B5UIT3J1W+WuWIU55h0mjlwaqxiE5vYENJXIXZ4VFe05pNYrkKuK0U/6aFcb0pKywYJh7IhfoqUfKVmrJJHZHw== + dependencies: + define-properties "^1.1.4" + es-abstract "^1.20.4" + +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + integrity sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ== + dependencies: + isobject "^3.0.1" + +object.values@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.6.tgz#4abbaa71eba47d63589d402856f908243eea9b1d" + integrity sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + +obliterator@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/obliterator/-/obliterator-2.0.4.tgz#fa650e019b2d075d745e44f1effeb13a2adbe816" + integrity sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ== + +oboe@2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/oboe/-/oboe-2.1.4.tgz#20c88cdb0c15371bb04119257d4fdd34b0aa49f6" + integrity sha512-ymBJ4xSC6GBXLT9Y7lirj+xbqBLa+jADGJldGEYG7u8sZbS9GyG+u1Xk9c5cbriKwSpCg41qUhPjvU5xOpvIyQ== + dependencies: + http-https "^1.0.0" + +oboe@2.1.5: + version "2.1.5" + resolved "https://registry.yarnpkg.com/oboe/-/oboe-2.1.5.tgz#5554284c543a2266d7a38f17e073821fbde393cd" + integrity sha512-zRFWiF+FoicxEs3jNI/WYUrVEgA7DeET/InK0XQuudGHRg8iIob3cNPrJTKaz4004uaA9Pbe+Dwa8iluhjLZWA== + dependencies: + http-https "^1.0.0" + +on-finished@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" + integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== + dependencies: + ee-first "1.1.1" + +once@^1.3.0, once@^1.3.1, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +onetime@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" + integrity sha512-oyyPpiMaKARvvcgip+JV+7zci5L8D1W9RZIz2l1o08AM3pfspitVWnPt3mzHcBPp12oYMTy0pqrFs/C+m3EwsQ== + dependencies: + mimic-fn "^1.0.0" + +onetime@^5.1.0: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + +open@^7.4.2: + version "7.4.2" + resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321" + integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q== + dependencies: + is-docker "^2.0.0" + is-wsl "^2.1.1" + +openzeppelin-solidity@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/openzeppelin-solidity/-/openzeppelin-solidity-2.3.0.tgz#1ab7b4cc3782a5472ed61eb740c56a8bfdd74119" + integrity sha512-QYeiPLvB1oSbDt6lDQvvpx7k8ODczvE474hb2kLXZBPKMsxKT1WxTCHBYrCU7kS7hfAku4DcJ0jqOyL+jvjwQw== + +openzeppelin-solidity@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/openzeppelin-solidity/-/openzeppelin-solidity-2.4.0.tgz#5f0a7b30571c45493449166e57b947203415349d" + integrity sha512-533gc5jkspxW5YT0qJo02Za5q1LHwXK9CJCc48jNj/22ncNM/3M/3JfWLqfpB90uqLwOKOovpl0JfaMQTR+gXQ== + +optionator@^0.8.2: + version "0.8.3" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" + integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== + dependencies: + deep-is "~0.1.3" + fast-levenshtein "~2.0.6" + levn "~0.3.0" + prelude-ls "~1.1.2" + type-check "~0.3.2" + word-wrap "~1.2.3" + +optionator@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.1.tgz#4f236a6373dae0566a6d43e1326674f50c291499" + integrity sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw== + dependencies: + deep-is "^0.1.3" + fast-levenshtein "^2.0.6" + levn "^0.4.1" + prelude-ls "^1.2.1" + type-check "^0.4.0" + word-wrap "^1.2.3" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + integrity sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ== + +os-locale@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-1.4.0.tgz#20f9f17ae29ed345e8bde583b13d2009803c14d9" + integrity sha512-PRT7ZORmwu2MEFt4/fv3Q+mEfN4zetKxufQrkShY2oGvUms9r8otu5HfdyIFHkYXjO7laNsoVGmM2MANfuTA8g== + dependencies: + lcid "^1.0.0" + +os-tmpdir@^1.0.1, os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g== + +p-cancelable@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-0.3.0.tgz#b9e123800bcebb7ac13a479be195b507b98d30fa" + integrity sha512-RVbZPLso8+jFeq1MfNvgXtCRED2raz/dKpacfTNxsx6pLEpEomM7gah6VeHSYV3+vo0OAi4MkArtQcWWXuQoyw== + +p-cancelable@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc" + integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw== + +p-cancelable@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.1.1.tgz#aab7fbd416582fa32a3db49859c122487c5ed2cf" + integrity sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg== + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + integrity sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow== + +p-limit@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== + dependencies: + p-try "^1.0.0" + +p-limit@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + integrity sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg== + dependencies: + p-limit "^1.1.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +p-map@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b" + integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ== + dependencies: + aggregate-error "^3.0.0" + +p-timeout@^1.1.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/p-timeout/-/p-timeout-1.2.1.tgz#5eb3b353b7fce99f101a1038880bb054ebbea386" + integrity sha512-gb0ryzr+K2qFqFv6qi3khoeqMZF/+ajxQipEF6NteZVnvz9tzdsfAVj3lYtn1gAXvH5lfLwfxEII799gt/mRIA== + dependencies: + p-finally "^1.0.0" + +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + integrity sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww== + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +parent-module@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" + integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g== + dependencies: + callsites "^3.0.0" + +parse-asn1@^5.0.0, parse-asn1@^5.1.5: + version "5.1.6" + resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.6.tgz#385080a3ec13cb62a62d39409cb3e88844cdaed4" + integrity sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw== + dependencies: + asn1.js "^5.2.0" + browserify-aes "^1.0.0" + evp_bytestokey "^1.0.0" + pbkdf2 "^3.0.3" + safe-buffer "^5.1.1" + +parse-cache-control@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parse-cache-control/-/parse-cache-control-1.0.1.tgz#8eeab3e54fa56920fe16ba38f77fa21aacc2d74e" + integrity sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg== + +parse-headers@^2.0.0: + version "2.0.5" + resolved "https://registry.yarnpkg.com/parse-headers/-/parse-headers-2.0.5.tgz#069793f9356a54008571eb7f9761153e6c770da9" + integrity sha512-ft3iAoLOB/MlwbNXgzy43SWGP6sQki2jQvAyBg/zDFAgr9bfNWZIUj42Kw2eJIl8kEi4PbgE6U1Zau/HwI75HA== + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + integrity sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ== + dependencies: + error-ex "^1.2.0" + +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + integrity sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw== + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + +parseurl@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" + integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== + +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + integrity sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw== + +patch-package@6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.2.2.tgz#71d170d650c65c26556f0d0fbbb48d92b6cc5f39" + integrity sha512-YqScVYkVcClUY0v8fF0kWOjDYopzIM8e3bj/RU1DPeEF14+dCGm6UeOYm4jvCyxqIEQ5/eJzmbWfDWnUleFNMg== + dependencies: + "@yarnpkg/lockfile" "^1.1.0" + chalk "^2.4.2" + cross-spawn "^6.0.5" + find-yarn-workspace-root "^1.2.1" + fs-extra "^7.0.1" + is-ci "^2.0.0" + klaw-sync "^6.0.0" + minimist "^1.2.0" + rimraf "^2.6.3" + semver "^5.6.0" + slash "^2.0.0" + tmp "^0.0.33" + +patch-package@^6.2.2: + version "6.5.1" + resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.5.1.tgz#3e5d00c16997e6160291fee06a521c42ac99b621" + integrity sha512-I/4Zsalfhc6bphmJTlrLoOcAF87jcxko4q0qsv4bGcurbr8IskEOtdnt9iCmsQVGL1B+iUhSQqweyTLJfCF9rA== + dependencies: + "@yarnpkg/lockfile" "^1.1.0" + chalk "^4.1.2" + cross-spawn "^6.0.5" + find-yarn-workspace-root "^2.0.0" + fs-extra "^9.0.0" + is-ci "^2.0.0" + klaw-sync "^6.0.0" + minimist "^1.2.6" + open "^7.4.2" + rimraf "^2.6.3" + semver "^5.6.0" + slash "^2.0.0" + tmp "^0.0.33" + yaml "^1.10.2" + +path-browserify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" + integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + integrity sha512-yTltuKuhtNeFJKa1PiRzfLAU5182q1y4Eb4XCJ3PBqyzEDkAZRzBrKKBct682ls9reBVHf9udYLN5Nd+K1B9BQ== + dependencies: + pinkie-promise "^2.0.0" + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ== + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-is-inside@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" + integrity sha512-DUWJr3+ULp4zXmol/SZkFf3JGsS9/SIv+Y3Rt93/UjPpDpklB5f1er4O3POIbUuUJ3FXgqte2Q7SrU6zAqwk8w== + +path-key@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== + +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +path-parse@^1.0.6, path-parse@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== + +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + integrity sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ== + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + integrity sha512-S4eENJz1pkiQn9Znv33Q+deTOKmbl+jj1Fl+qiP/vYezj+S8x+J3Uo0ISrx/QoEvIlOaDWJhPaRd1flJ9HXZqg== + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +path-type@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" + integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== + +pathval@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" + integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== + +pbkdf2@^3.0.17, pbkdf2@^3.0.3, pbkdf2@^3.0.9: + version "3.1.2" + resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.1.2.tgz#dd822aa0887580e52f1a039dc3eda108efae3075" + integrity sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA== + dependencies: + create-hash "^1.1.2" + create-hmac "^1.1.4" + ripemd160 "^2.0.1" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +pend@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" + integrity sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg== + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== + +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +pify@^2.0.0, pify@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + integrity sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog== + +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + integrity sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg== + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + integrity sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw== + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + integrity sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg== + +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + integrity sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg== + +postinstall-postinstall@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/postinstall-postinstall/-/postinstall-postinstall-2.1.0.tgz#4f7f77441ef539d1512c40bd04c71b06a4704ca3" + integrity sha512-7hQX6ZlZXIoRiWNrbMQaLzUUfH+sSx39u8EJ9HYuDc1kLo9IXKWjM5RSquZN1ad5GnH8CGFM78fsAAQi3OKEEQ== + +precond@0.2: + version "0.2.3" + resolved "https://registry.yarnpkg.com/precond/-/precond-0.2.3.tgz#aa9591bcaa24923f1e0f4849d240f47efc1075ac" + integrity sha512-QCYG84SgGyGzqJ/vlMsxeXd/pgL/I94ixdNFyh1PusWmTCyVfPJjZ1K1jvHtsbfnXQs2TSkEP2fR7QiMZAnKFQ== + +prelude-ls@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" + integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== + +prelude-ls@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" + integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== + +prepend-http@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" + integrity sha512-PhmXi5XmoyKw1Un4E+opM2KcsJInDvKyuOumcjjw3waw86ZNjHwVUOOWLc4bCzLdcKNaWBH9e99sbWzDQsVaYg== + +prepend-http@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" + integrity sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA== + +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prettier-plugin-sh@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/prettier-plugin-sh/-/prettier-plugin-sh-0.8.2.tgz#ea0690e87385bcdc1cc22df63e8f182a36cb6eea" + integrity sha512-M8D4G5OqgZtoVKx+U/J/B/gVA4xUKmWflOjayxiDjCQbxz3HOv0zlpYeb6DXd5xMFl7jW2UY1fJjmDzI9pDBFA== + dependencies: + mvdan-sh "^0.5.0" + +prettier-plugin-solidity@^1.0.0-beta.19: + version "1.1.3" + resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.1.3.tgz#9a35124f578404caf617634a8cab80862d726cba" + integrity sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg== + dependencies: + "@solidity-parser/parser" "^0.16.0" + semver "^7.3.8" + solidity-comments-extractor "^0.0.7" + +prettier@^1.14.3: + version "1.19.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" + integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + +prettier@^2.1.2, prettier@^2.5.1: + version "2.8.7" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.7.tgz#bb79fc8729308549d28fe3a98fce73d2c0656450" + integrity sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw== + +private@^0.1.6, private@^0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" + integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== + +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + +process@^0.11.10: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== + +progress@^2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" + integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== + +promise-to-callback@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/promise-to-callback/-/promise-to-callback-1.0.0.tgz#5d2a749010bfb67d963598fcd3960746a68feef7" + integrity sha512-uhMIZmKM5ZteDMfLgJnoSq9GCwsNKrYau73Awf1jIy6/eUcuuZ3P+CD9zUv0kJsIUbU+x6uLNIhXhLHDs1pNPA== + dependencies: + is-fn "^1.0.0" + set-immediate-shim "^1.0.1" + +promise@^8.0.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/promise/-/promise-8.3.0.tgz#8cb333d1edeb61ef23869fbb8a4ea0279ab60e0a" + integrity sha512-rZPNPKTOYVNEEKFaq1HqTgOwZD+4/YHS5ukLzQCypkj+OkYx7iv0mA91lJlpPPZ8vMau3IIGj5Qlwrx+8iiSmg== + dependencies: + asap "~2.0.6" + +prop-types@^15.8.1: + version "15.8.1" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" + integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== + dependencies: + loose-envify "^1.4.0" + object-assign "^4.1.1" + react-is "^16.13.1" + +proper-lockfile@^4.1.1: + version "4.1.2" + resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-4.1.2.tgz#c8b9de2af6b2f1601067f98e01ac66baa223141f" + integrity sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA== + dependencies: + graceful-fs "^4.2.4" + retry "^0.12.0" + signal-exit "^3.0.2" + +proxy-addr@~2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" + integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== + dependencies: + forwarded "0.2.0" + ipaddr.js "1.9.1" + +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + +prr@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" + integrity sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw== + +pseudomap@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ== + +psl@^1.1.28: + version "1.9.0" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" + integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== + +public-encrypt@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" + integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== + dependencies: + bn.js "^4.1.0" + browserify-rsa "^4.0.0" + create-hash "^1.1.0" + parse-asn1 "^5.0.0" + randombytes "^2.0.1" + safe-buffer "^5.1.2" + +pull-cat@^1.1.9: + version "1.1.11" + resolved "https://registry.yarnpkg.com/pull-cat/-/pull-cat-1.1.11.tgz#b642dd1255da376a706b6db4fa962f5fdb74c31b" + integrity sha512-i3w+xZ3DCtTVz8S62hBOuNLRHqVDsHMNZmgrZsjPnsxXUgbWtXEee84lo1XswE7W2a3WHyqsNuDJTjVLAQR8xg== + +pull-defer@^0.2.2: + version "0.2.3" + resolved "https://registry.yarnpkg.com/pull-defer/-/pull-defer-0.2.3.tgz#4ee09c6d9e227bede9938db80391c3dac489d113" + integrity sha512-/An3KE7mVjZCqNhZsr22k1Tx8MACnUnHZZNPSJ0S62td8JtYr/AiRG42Vz7Syu31SoTLUzVIe61jtT/pNdjVYA== + +pull-level@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pull-level/-/pull-level-2.0.4.tgz#4822e61757c10bdcc7cf4a03af04c92734c9afac" + integrity sha512-fW6pljDeUThpq5KXwKbRG3X7Ogk3vc75d5OQU/TvXXui65ykm+Bn+fiktg+MOx2jJ85cd+sheufPL+rw9QSVZg== + dependencies: + level-post "^1.0.7" + pull-cat "^1.1.9" + pull-live "^1.0.1" + pull-pushable "^2.0.0" + pull-stream "^3.4.0" + pull-window "^2.1.4" + stream-to-pull-stream "^1.7.1" + +pull-live@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/pull-live/-/pull-live-1.0.1.tgz#a4ecee01e330155e9124bbbcf4761f21b38f51f5" + integrity sha512-tkNz1QT5gId8aPhV5+dmwoIiA1nmfDOzJDlOOUpU5DNusj6neNd3EePybJ5+sITr2FwyCs/FVpx74YMCfc8YeA== + dependencies: + pull-cat "^1.1.9" + pull-stream "^3.4.0" + +pull-pushable@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/pull-pushable/-/pull-pushable-2.2.0.tgz#5f2f3aed47ad86919f01b12a2e99d6f1bd776581" + integrity sha512-M7dp95enQ2kaHvfCt2+DJfyzgCSpWVR2h2kWYnVsW6ZpxQBx5wOu0QWOvQPVoPnBLUZYitYP2y7HyHkLQNeGXg== + +pull-stream@^3.2.3, pull-stream@^3.4.0, pull-stream@^3.6.8: + version "3.7.0" + resolved "https://registry.yarnpkg.com/pull-stream/-/pull-stream-3.7.0.tgz#85de0e44ff38a4d2ad08cc43fc458e1922f9bf0b" + integrity sha512-Eco+/R004UaCK2qEDE8vGklcTG2OeZSVm1kTUQNrykEjDwcFXDZhygFDsW49DbXyJMEhHeRL3z5cRVqPAhXlIw== + +pull-window@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/pull-window/-/pull-window-2.1.4.tgz#fc3b86feebd1920c7ae297691e23f705f88552f0" + integrity sha512-cbDzN76BMlcGG46OImrgpkMf/VkCnupj8JhsrpBw3aWBM9ye345aYnqitmZCgauBkc0HbbRRn9hCnsa3k2FNUg== + dependencies: + looper "^2.0.0" + +pump@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" + integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +punycode@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + integrity sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw== + +punycode@2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d" + integrity sha512-Yxz2kRwT90aPiWEMHVYnEf4+rhwF1tBmmZ4KepCP+Wkium9JxtWnUm1nqGwpiAHr/tnTSeHqr3wb++jgSkXjhA== + +punycode@^2.1.0, punycode@^2.1.1: + version "2.3.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" + integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== + +qs@6.11.0: + version "6.11.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" + integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== + dependencies: + side-channel "^1.0.4" + +qs@^6.4.0, qs@^6.7.0, qs@^6.9.4: + version "6.11.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.1.tgz#6c29dff97f0c0060765911ba65cbc9764186109f" + integrity sha512-0wsrzgTz/kAVIeuxSjnpGC56rzYtr6JT/2BwEvMaPhFIoYa1aGO8LbzuU1R0uUYQkLpWBTOj0l/CLAJB64J6nQ== + dependencies: + side-channel "^1.0.4" + +qs@~6.5.2: + version "6.5.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" + integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== + +query-string@^5.0.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb" + integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw== + dependencies: + decode-uri-component "^0.2.0" + object-assign "^4.1.0" + strict-uri-encode "^1.0.0" + +querystring@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + integrity sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g== + +queue-microtask@^1.2.2, queue-microtask@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" + integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== + +quick-lru@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-5.1.1.tgz#366493e6b3e42a3a6885e2e99d18f80fb7a8c932" + integrity sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA== + +randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.0.6, randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +randomfill@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" + integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== + dependencies: + randombytes "^2.0.5" + safe-buffer "^5.1.0" + +range-parser@~1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" + integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== + +raw-body@2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.1.tgz#fe1b1628b181b700215e5fd42389f98b71392857" + integrity sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig== + dependencies: + bytes "3.1.2" + http-errors "2.0.0" + iconv-lite "0.4.24" + unpipe "1.0.0" + +raw-body@2.5.2, raw-body@^2.4.1: + version "2.5.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a" + integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA== + dependencies: + bytes "3.1.2" + http-errors "2.0.0" + iconv-lite "0.4.24" + unpipe "1.0.0" + +react-is@^16.13.1: + version "16.13.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" + integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + integrity sha512-WD9MTlNtI55IwYUS27iHh9tK3YoIVhxis8yKhLpTqWtml739uXc9NWTpxoHkfZf3+DkCCsXox94/VWZniuZm6A== + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + integrity sha512-7BGwRHqt4s/uVbuyoeejRn4YmFnYZiFl4AuaeXHlgZf3sONF0SOGlxs2Pw8g6hCKupo08RafIO5YXFNOKTfwsQ== + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +readable-stream@^1.0.33: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + integrity sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@^2.0.0, readable-stream@^2.0.5, readable-stream@^2.2.2, readable-stream@^2.2.8, readable-stream@^2.2.9, readable-stream@^2.3.0, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.6: + version "2.3.8" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" + integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +readable-stream@^3.0.6, readable-stream@^3.6.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readable-stream@~1.0.15: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + integrity sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readdirp@~3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.2.0.tgz#c30c33352b12c96dfb4b895421a49fd5a9593839" + integrity sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ== + dependencies: + picomatch "^2.0.4" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +reduce-flatten@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27" + integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w== + +regenerate@^1.2.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.2.tgz#b9346d8827e8f5a32f7ba29637d398b69014848a" + integrity sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A== + +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== + +regenerator-runtime@^0.13.11: + version "0.13.11" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" + integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== + +regenerator-transform@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd" + integrity sha512-PJepbvDbuK1xgIgnau7Y90cwaAmO/LCLMI2mPvaXq2heGMR3aWW5/BQvYrhJ8jgmQjXewXvBjzfqKcVOmhjZ6Q== + dependencies: + babel-runtime "^6.18.0" + babel-types "^6.19.0" + private "^0.1.6" + +regex-not@^1.0.0, regex-not@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + +regexp.prototype.flags@^1.2.0, regexp.prototype.flags@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac" + integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + functions-have-names "^1.2.2" + +regexpp@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" + integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw== + +regexpp@^3.1.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" + integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== + +regexpu-core@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" + integrity sha512-tJ9+S4oKjxY8IZ9jmjnp/mtytu1u3iyIQAfmI51IKWH6bFf7XR1ybtaO6j7INhZKXOTYADk7V5qxaqLkmNxiZQ== + dependencies: + regenerate "^1.2.1" + regjsgen "^0.2.0" + regjsparser "^0.1.4" + +regjsgen@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" + integrity sha512-x+Y3yA24uF68m5GA+tBjbGYo64xXVJpbToBaWCoSNSc1hdk6dfctaRWrNFTVJZIIhL5GxW8zwjoixbnifnK59g== + +regjsparser@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" + integrity sha512-jlQ9gYLfk2p3V5Ag5fYhA7fv7OHzd1KUH0PRP46xc3TgwjwgROIW572AfYg/X9kaNq/LJnu6oJcFRXlIrGoTRw== + dependencies: + jsesc "~0.5.0" + +repeat-element@^1.1.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.4.tgz#be681520847ab58c7568ac75fbfad28ed42d39e9" + integrity sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ== + +repeat-string@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + integrity sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w== + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + integrity sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A== + dependencies: + is-finite "^1.0.0" + +req-cwd@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/req-cwd/-/req-cwd-2.0.0.tgz#d4082b4d44598036640fb73ddea01ed53db49ebc" + integrity sha512-ueoIoLo1OfB6b05COxAA9UpeoscNpYyM+BqYlA7H6LVF4hKGPXQQSSaD2YmvDVJMkk4UDpAHIeU1zG53IqjvlQ== + dependencies: + req-from "^2.0.0" + +req-from@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/req-from/-/req-from-2.0.0.tgz#d74188e47f93796f4aa71df6ee35ae689f3e0e70" + integrity sha512-LzTfEVDVQHBRfjOUMgNBA+V6DWsSnoeKzf42J7l0xa/B4jyPOuuF5MlNSmomLNGemWTnV2TIdjSSLnEn95fOQA== + dependencies: + resolve-from "^3.0.0" + +request-promise-core@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.4.tgz#3eedd4223208d419867b78ce815167d10593a22f" + integrity sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw== + dependencies: + lodash "^4.17.19" + +request-promise-native@^1.0.5: + version "1.0.9" + resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.9.tgz#e407120526a5efdc9a39b28a5679bf47b9d9dc28" + integrity sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g== + dependencies: + request-promise-core "1.1.4" + stealthy-require "^1.1.1" + tough-cookie "^2.3.3" + +request@^2.79.0, request@^2.85.0, request@^2.88.0: + version "2.88.2" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" + integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.3" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.5.0" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +require-from-string@^1.1.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-1.2.1.tgz#529c9ccef27380adfec9a2f965b649bbee636418" + integrity sha512-H7AkJWMobeskkttHyhTVtS0fxpFLjxhbfMa6Bk3wimP7sdPRGL3EyCg3sAQenFfAe+xQ+oAc85Nmtvq0ROM83Q== + +require-from-string@^2.0.0, require-from-string@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" + integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== + +require-main-filename@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" + integrity sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug== + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + +resolve-alpn@^1.0.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/resolve-alpn/-/resolve-alpn-1.2.1.tgz#b7adbdac3546aaaec20b45e7d8265927072726f9" + integrity sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g== + +resolve-from@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" + integrity sha512-GnlH6vxLymXJNMBo7XP1fJIzBFbdYt49CuTwmB/6N53t+kMPRMFKz783LlQ4tv28XoQfMWinAJX6WCGf2IlaIw== + +resolve-from@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" + integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== + +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + integrity sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg== + +resolve@1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + +resolve@^1.10.0, resolve@^1.22.1, resolve@^1.8.1, resolve@~1.22.1: + version "1.22.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" + integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== + dependencies: + is-core-module "^2.9.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + +resolve@^2.0.0-next.4: + version "2.0.0-next.4" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.4.tgz#3d37a113d6429f496ec4752d2a2e58efb1fd4660" + integrity sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ== + dependencies: + is-core-module "^2.9.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + +responselike@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" + integrity sha512-/Fpe5guzJk1gPqdJLJR5u7eG/gNY4nImjbRDaVWVMRhne55TCmj2i9Q+54PBRfatRC8v/rIiv9BN0pMd9OV5EQ== + dependencies: + lowercase-keys "^1.0.0" + +responselike@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/responselike/-/responselike-2.0.1.tgz#9a0bc8fdc252f3fb1cca68b016591059ba1422bc" + integrity sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw== + dependencies: + lowercase-keys "^2.0.0" + +restore-cursor@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" + integrity sha512-6IzJLuGi4+R14vwagDHX+JrXmPVtPpn4mffDJ1UdR7/Edm87fl6yi8mMBIVvFtJaNTUvjughmW4hwLhRG7gC1Q== + dependencies: + onetime "^2.0.0" + signal-exit "^3.0.2" + +restore-cursor@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" + integrity sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA== + dependencies: + onetime "^5.1.0" + signal-exit "^3.0.2" + +resumer@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/resumer/-/resumer-0.0.0.tgz#f1e8f461e4064ba39e82af3cdc2a8c893d076759" + integrity sha512-Fn9X8rX8yYF4m81rZCK/5VmrmsSbqS/i3rDLl6ZZHAXgC2nTAx3dhwG8q8odP/RmdLa2YrybDJaAMg+X1ajY3w== + dependencies: + through "~2.3.4" + +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== + +retry@0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" + integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== + +retry@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" + integrity sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow== + +reusify@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" + integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== + +rimraf@2.6.3: + version "2.6.3" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" + integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== + dependencies: + glob "^7.1.3" + +rimraf@^2.2.8, rimraf@^2.6.3: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob "^7.1.3" + +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + +ripemd160@^2.0.0, ripemd160@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" + integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + +rlp@^2.0.0, rlp@^2.2.1, rlp@^2.2.2, rlp@^2.2.3, rlp@^2.2.4: + version "2.2.7" + resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.2.7.tgz#33f31c4afac81124ac4b283e2bd4d9720b30beaf" + integrity sha512-d5gdPmgQ0Z+AklL2NVXr/IoSjNZFfTVvQWzL/AM2AOcSzYP2xjlb0AC8YyCLc41MSNf6P6QVtjgPdmVtzb+4lQ== + dependencies: + bn.js "^5.2.0" + +run-async@^2.2.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" + integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== + +run-parallel-limit@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/run-parallel-limit/-/run-parallel-limit-1.1.0.tgz#be80e936f5768623a38a963262d6bef8ff11e7ba" + integrity sha512-jJA7irRNM91jaKc3Hcl1npHsFLOXOoTkPCUL1JEa1R82O2miplXXRaGdjW/KM/98YQWDhJLiSs793CnXfblJUw== + dependencies: + queue-microtask "^1.2.2" + +run-parallel@^1.1.9: + version "1.2.0" + resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" + integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== + dependencies: + queue-microtask "^1.2.2" + +rustbn.js@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/rustbn.js/-/rustbn.js-0.2.0.tgz#8082cb886e707155fd1cb6f23bd591ab8d55d0ca" + integrity sha512-4VlvkRUuCJvr2J6Y0ImW7NvTCriMi7ErOAqWk1y69vAdoNIzCF3yPmgeNzx+RQTLEDFq5sHfscn1MwHxP9hNfA== + +rxjs@6, rxjs@^6.4.0: + version "6.6.7" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.7.tgz#90ac018acabf491bf65044235d5863c4dab804c9" + integrity sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ== + dependencies: + tslib "^1.9.0" + +safe-buffer@5.2.1, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@^5.2.1, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +safe-event-emitter@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/safe-event-emitter/-/safe-event-emitter-1.0.1.tgz#5b692ef22329ed8f69fdce607e50ca734f6f20af" + integrity sha512-e1wFe99A91XYYxoQbcq2ZJUWurxEyP8vfz7A7vuUe1s95q8r5ebraVaA1BukYJcpM6V16ugWoD9vngi8Ccu5fg== + dependencies: + events "^3.0.0" + +safe-regex-test@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295" + integrity sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.3" + is-regex "^1.1.4" + +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + integrity sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg== + dependencies: + ret "~0.1.10" + +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +scrypt-js@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-2.0.3.tgz#bb0040be03043da9a012a2cea9fc9f852cfc87d4" + integrity sha512-d8DzQxNivoNDogyYmb/9RD5mEQE/Q7vG2dLDUgvfPmKL9xCVzgqUntOdS0me9Cq9Sh9VxIZuoNEFcsfyXRnyUw== + +scrypt-js@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-2.0.4.tgz#32f8c5149f0797672e551c07e230f834b6af5f16" + integrity sha512-4KsaGcPnuhtCZQCxFxN3GVYIhKFPTdLd8PLC552XwbMndtD0cjRFAhDuuydXQ0h08ZfPgzqe6EKHozpuH74iDw== + +scrypt-js@3.0.1, scrypt-js@^3.0.0, scrypt-js@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/scrypt-js/-/scrypt-js-3.0.1.tgz#d314a57c2aef69d1ad98a138a21fe9eafa9ee312" + integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== + +"scrypt-shim@github:web3-js/scrypt-shim": + version "0.1.0" + resolved "https://codeload.github.com/web3-js/scrypt-shim/tar.gz/aafdadda13e660e25e1c525d1f5b2443f5eb1ebb" + dependencies: + scryptsy "^2.1.0" + semver "^6.3.0" + +scryptsy@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/scryptsy/-/scryptsy-1.2.1.tgz#a3225fa4b2524f802700761e2855bdf3b2d92163" + integrity sha512-aldIRgMozSJ/Gl6K6qmJZysRP82lz83Wb42vl4PWN8SaLFHIaOzLPc9nUUW2jQN88CuGm5q5HefJ9jZ3nWSmTw== + dependencies: + pbkdf2 "^3.0.3" + +scryptsy@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/scryptsy/-/scryptsy-2.1.0.tgz#8d1e8d0c025b58fdd25b6fa9a0dc905ee8faa790" + integrity sha512-1CdSqHQowJBnMAFyPEBRfqag/YP9OF394FV+4YREIJX4ljD7OxvQRDayyoyyCk+senRjSkP6VnUNQmVQqB6g7w== + +secp256k1@^4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/secp256k1/-/secp256k1-4.0.3.tgz#c4559ecd1b8d3c1827ed2d1b94190d69ce267303" + integrity sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA== + dependencies: + elliptic "^6.5.4" + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + +seedrandom@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.1.tgz#eb3dde015bcf55df05a233514e5df44ef9dce083" + integrity sha512-1/02Y/rUeU1CJBAGLebiC5Lbo5FnB22gQbIFFYTLkwvp1xdABZJH1sn4ZT1MzXmPpzv+Rf/Lu2NcsLJiK4rcDg== + +seek-bzip@^1.0.5: + version "1.0.6" + resolved "https://registry.yarnpkg.com/seek-bzip/-/seek-bzip-1.0.6.tgz#35c4171f55a680916b52a07859ecf3b5857f21c4" + integrity sha512-e1QtP3YL5tWww8uKaOCQ18UxIT2laNBXHjV/S2WYCiK4udiv8lkG89KRIoCjUagnAmCBurjF4zEVX2ByBbnCjQ== + dependencies: + commander "^2.8.1" + +semaphore@>=1.0.1, semaphore@^1.0.3, semaphore@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/semaphore/-/semaphore-1.1.0.tgz#aaad8b86b20fe8e9b32b16dc2ee682a8cd26a8aa" + integrity sha512-O4OZEaNtkMd/K0i6js9SL+gqy0ZCBMgUvlSqHKi4IBdjhe7wB8pwztUk1BbZ1fmrvpwFrPbHzqd2w5pTcJH6LA== + +"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + +semver@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" + integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + +semver@^7.2.1, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8: + version "7.3.8" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" + integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== + dependencies: + lru-cache "^6.0.0" + +semver@~5.4.1: + version "5.4.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" + integrity sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg== + +send@0.18.0: + version "0.18.0" + resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" + integrity sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg== + dependencies: + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "2.0.0" + mime "1.6.0" + ms "2.1.3" + on-finished "2.4.1" + range-parser "~1.2.1" + statuses "2.0.1" + +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" + +serve-static@1.15.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.15.0.tgz#faaef08cffe0a1a62f60cad0c4e513cff0ac9540" + integrity sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g== + dependencies: + encodeurl "~1.0.2" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.18.0" + +servify@^0.1.12: + version "0.1.12" + resolved "https://registry.yarnpkg.com/servify/-/servify-0.1.12.tgz#142ab7bee1f1d033b66d0707086085b17c06db95" + integrity sha512-/xE6GvsKKqyo1BAY+KxOWXcLpPsUUyji7Qg3bVD7hh1eRze5bR1uYiuDA/k3Gof1s9BTzQZEJK8sNcNGFIzeWw== + dependencies: + body-parser "^1.16.0" + cors "^2.8.1" + express "^4.14.0" + request "^2.79.0" + xhr "^2.3.3" + +set-blocking@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== + +set-immediate-shim@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + integrity sha512-Li5AOqrZWCVA2n5kryzEmqai6bKSIvpz5oUJHPVj6+dsbD3X1ixtsY5tEnsaNpH3pFAHmG8eIHUrtEtohrg+UQ== + +set-value@^2.0.0, set-value@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" + integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + +setimmediate@1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.4.tgz#20e81de622d4a02588ce0c8da8973cbcf1d3138f" + integrity sha512-/TjEmXQVEzdod/FFskf3o7oOAsGhHf2j1dZqRFbDzq4F3mvvxflIIi4Hd3bLQE9y/CpwqfSQam5JakI/mi3Pog== + +setimmediate@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA== + +setprototypeof@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== + +sha.js@^2.4.0, sha.js@^2.4.8: + version "2.4.11" + resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" + integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + +sha1@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/sha1/-/sha1-1.1.1.tgz#addaa7a93168f393f19eb2b15091618e2700f848" + integrity sha512-dZBS6OrMjtgVkopB1Gmo4RQCDKiZsqcpAQpkV/aaj+FCrCg8r4I4qMkDPQjBgLIxlmu9k4nUbWq6ohXahOneYA== + dependencies: + charenc ">= 0.0.1" + crypt ">= 0.0.1" + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg== + dependencies: + shebang-regex "^1.0.0" + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +side-channel@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" + integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== + dependencies: + call-bind "^1.0.0" + get-intrinsic "^1.0.2" + object-inspect "^1.9.0" + +signal-exit@^3.0.2: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +simple-concat@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/simple-concat/-/simple-concat-1.0.1.tgz#f46976082ba35c2263f1c8ab5edfe26c41c9552f" + integrity sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q== + +simple-get@^2.7.0: + version "2.8.2" + resolved "https://registry.yarnpkg.com/simple-get/-/simple-get-2.8.2.tgz#5708fb0919d440657326cd5fe7d2599d07705019" + integrity sha512-Ijd/rV5o+mSBBs4F/x9oDPtTx9Zb6X9brmnXvMW4J7IR15ngi9q5xxqWBKU744jTZiaXtxaPL7uHG6vtN8kUkw== + dependencies: + decompress-response "^3.3.0" + once "^1.3.1" + simple-concat "^1.0.0" + +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + integrity sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg== + +slash@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44" + integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A== + +slash@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" + integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== + +slice-ansi@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" + integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== + dependencies: + ansi-styles "^3.2.0" + astral-regex "^1.0.0" + is-fullwidth-code-point "^2.0.0" + +slice-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-4.0.0.tgz#500e8dd0fd55b05815086255b3195adf2a45fe6b" + integrity sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ== + dependencies: + ansi-styles "^4.0.0" + astral-regex "^2.0.0" + is-fullwidth-code-point "^3.0.0" + +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" + integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + +solc@0.7.3: + version "0.7.3" + resolved "https://registry.yarnpkg.com/solc/-/solc-0.7.3.tgz#04646961bd867a744f63d2b4e3c0701ffdc7d78a" + integrity sha512-GAsWNAjGzIDg7VxzP6mPjdurby3IkGCjQcM8GFYZT6RyaoUZKmMU6Y7YwG+tFGhv7dwZ8rmR4iwFDrrD99JwqA== + dependencies: + command-exists "^1.2.8" + commander "3.0.2" + follow-redirects "^1.12.1" + fs-extra "^0.30.0" + js-sha3 "0.8.0" + memorystream "^0.3.1" + require-from-string "^2.0.0" + semver "^5.5.0" + tmp "0.0.33" + +solc@^0.4.20: + version "0.4.26" + resolved "https://registry.yarnpkg.com/solc/-/solc-0.4.26.tgz#5390a62a99f40806b86258c737c1cf653cc35cb5" + integrity sha512-o+c6FpkiHd+HPjmjEVpQgH7fqZ14tJpXhho+/bQXlXbliLIS/xjXb42Vxh+qQY1WCSTMQ0+a5vR9vi0MfhU6mA== + dependencies: + fs-extra "^0.30.0" + memorystream "^0.3.1" + require-from-string "^1.1.0" + semver "^5.3.0" + yargs "^4.7.1" + +solc@^0.6.3: + version "0.6.12" + resolved "https://registry.yarnpkg.com/solc/-/solc-0.6.12.tgz#48ac854e0c729361b22a7483645077f58cba080e" + integrity sha512-Lm0Ql2G9Qc7yPP2Ba+WNmzw2jwsrd3u4PobHYlSOxaut3TtUbj9+5ZrT6f4DUpNPEoBaFUOEg9Op9C0mk7ge9g== + dependencies: + command-exists "^1.2.8" + commander "3.0.2" + fs-extra "^0.30.0" + js-sha3 "0.8.0" + memorystream "^0.3.1" + require-from-string "^2.0.0" + semver "^5.5.0" + tmp "0.0.33" + +"solhint-config-keep@github:keep-network/solhint-config-keep": + version "0.1.0" + resolved "https://codeload.github.com/keep-network/solhint-config-keep/tar.gz/5e1751e58c0f1c507305ffc8c7f6c58047657ada" + +solhint@3.3.6: + version "3.3.6" + resolved "https://registry.yarnpkg.com/solhint/-/solhint-3.3.6.tgz#abe9af185a9a7defefba480047b3e42cbe9a1210" + integrity sha512-HWUxTAv2h7hx3s3hAab3ifnlwb02ZWhwFU/wSudUHqteMS3ll9c+m1FlGn9V8ztE2rf3Z82fQZA005Wv7KpcFA== + dependencies: + "@solidity-parser/parser" "^0.13.2" + ajv "^6.6.1" + antlr4 "4.7.1" + ast-parents "0.0.1" + chalk "^2.4.2" + commander "2.18.0" + cosmiconfig "^5.0.7" + eslint "^5.6.0" + fast-diff "^1.1.2" + glob "^7.1.3" + ignore "^4.0.6" + js-yaml "^3.12.0" + lodash "^4.17.11" + semver "^6.3.0" + optionalDependencies: + prettier "^1.14.3" + +solidity-ast@^0.4.15: + version "0.4.46" + resolved "https://registry.yarnpkg.com/solidity-ast/-/solidity-ast-0.4.46.tgz#d0745172dced937741d07464043564e35b147c59" + integrity sha512-MlPZQfPhjWXqh7YxWcBGDXaPZIfMYCOHYoLEhGDWulNwEPIQQZuB7mA9eP17CU0jY/bGR4avCEUVVpvHtT2gbA== + +solidity-comments-extractor@^0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19" + integrity sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw== + +source-map-resolve@^0.5.0: + version "0.5.3" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" + integrity sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw== + dependencies: + atob "^2.1.2" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + +source-map-support@0.5.12: + version "0.5.12" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.12.tgz#b4f3b10d51857a5af0138d3ce8003b201613d599" + integrity sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map-support@^0.4.15: + version "0.4.18" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" + integrity sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA== + dependencies: + source-map "^0.5.6" + +source-map-support@^0.5.13, source-map-support@^0.5.17: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map-url@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.1.tgz#0af66605a745a5a2f91cf1bbf8a7afbc283dec56" + integrity sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw== + +source-map@^0.5.6, source-map@^0.5.7: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ== + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +spdx-correct@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.2.0.tgz#4f5ab0668f0059e34f9c00dce331784a12de4e9c" + integrity sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA== + dependencies: + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" + +spdx-exceptions@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== + +spdx-expression-parse@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.13" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.13.tgz#7189a474c46f8d47c7b0da4b987bb45e908bd2d5" + integrity sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w== + +spinnies@^0.4.2: + version "0.4.3" + resolved "https://registry.yarnpkg.com/spinnies/-/spinnies-0.4.3.tgz#2ea0ad148e78353ddf621dec3951a6f4c3cbf66e" + integrity sha512-TTA2vWXrXJpfThWAl2t2hchBnCMI1JM5Wmb2uyI7Zkefdw/xO98LDy6/SBYwQPiYXL3swx3Eb44ZxgoS8X5wpA== + dependencies: + chalk "^2.4.2" + cli-cursor "^3.0.0" + strip-ansi "^5.2.0" + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== + dependencies: + extend-shallow "^3.0.0" + +sprintf-js@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== + +sshpk@^1.7.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.17.0.tgz#578082d92d4fe612b13007496e543fa0fbcbe4c5" + integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + bcrypt-pbkdf "^1.0.0" + dashdash "^1.12.0" + ecc-jsbn "~0.1.1" + getpass "^0.1.1" + jsbn "~0.1.0" + safer-buffer "^2.0.2" + tweetnacl "~0.14.0" + +stacktrace-parser@^0.1.10: + version "0.1.10" + resolved "https://registry.yarnpkg.com/stacktrace-parser/-/stacktrace-parser-0.1.10.tgz#29fb0cae4e0d0b85155879402857a1639eb6051a" + integrity sha512-KJP1OCML99+8fhOHxwwzyWrlUuVX5GQ0ZpJTd1DFXhdkrvg1szxfHhawXUZ3g9TkXORQd4/WG68jMlQZ2p8wlg== + dependencies: + type-fest "^0.7.1" + +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + integrity sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g== + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + +statuses@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" + integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== + +stealthy-require@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" + integrity sha512-ZnWpYnYugiOVEY5GkcuJK1io5V8QmNYChG62gSit9pQVGErXtrKuPC55ITaVSukmMta5qpMU7vqLt2Lnni4f/g== + +stop-iteration-iterator@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz#6a60be0b4ee757d1ed5254858ec66b10c49285e4" + integrity sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ== + dependencies: + internal-slot "^1.0.4" + +stream-to-pull-stream@^1.7.1: + version "1.7.3" + resolved "https://registry.yarnpkg.com/stream-to-pull-stream/-/stream-to-pull-stream-1.7.3.tgz#4161aa2d2eb9964de60bfa1af7feaf917e874ece" + integrity sha512-6sNyqJpr5dIOQdgNy/xcDWwDuzAsAwVzhzrWlAPAQ7Lkjx/rv0wgvxEyKwTq6FmNd5rjTrELt/CLmaSw7crMGg== + dependencies: + looper "^3.0.0" + pull-stream "^3.2.3" + +streamsearch@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-1.1.0.tgz#404dd1e2247ca94af554e841a8ef0eaa238da764" + integrity sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg== + +strict-uri-encode@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713" + integrity sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ== + +string-format@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/string-format/-/string-format-2.0.0.tgz#f2df2e7097440d3b65de31b6d40d54c96eaffb9b" + integrity sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA== + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + integrity sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw== + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +"string-width@^1.0.2 || 2", string-width@^2.1.0, string-width@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string-width@^3.0.0, string-width@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string.prototype.matchall@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz#3bf85722021816dcd1bf38bb714915887ca79fd3" + integrity sha512-6zOCOcJ+RJAQshcTvXPHoxoQGONa3e/Lqx90wUA+wEzX78sg5Bo+1tQo4N0pohS0erG9qtCqJDjNCQBjeWVxyg== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + get-intrinsic "^1.1.3" + has-symbols "^1.0.3" + internal-slot "^1.0.3" + regexp.prototype.flags "^1.4.3" + side-channel "^1.0.4" + +string.prototype.trim@^1.2.7, string.prototype.trim@~1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz#a68352740859f6893f14ce3ef1bb3037f7a90533" + integrity sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + +string.prototype.trimend@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz#c4a27fa026d979d79c04f17397f250a462944533" + integrity sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + +string.prototype.trimstart@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz#e90ab66aa8e4007d92ef591bbf3cd422c56bdcf4" + integrity sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + integrity sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ== + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + integrity sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg== + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + integrity sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow== + dependencies: + ansi-regex "^3.0.0" + +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + integrity sha512-kwrX1y7czp1E69n2ajbG65mIo9dqvJ+8aBQXOGVxqwvNbsXdFM6Lq37dLAY3mknUwru8CfcCbfOLL/gMo+fi3g== + dependencies: + is-utf8 "^0.2.0" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== + +strip-dirs@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/strip-dirs/-/strip-dirs-2.1.0.tgz#4987736264fc344cf20f6c34aca9d13d1d4ed6c5" + integrity sha512-JOCxOeKLm2CAS73y/U4ZeZPTkE+gNVCzKt7Eox84Iej1LT/2pTWYpZKJuxwQpvX1LiZb1xokNR7RLfuBAa7T3g== + dependencies: + is-natural-number "^4.0.1" + +strip-hex-prefix@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz#0c5f155fef1151373377de9dbb588da05500e36f" + integrity sha512-q8d4ue7JGEiVcypji1bALTos+0pWtyGlivAWyPuTkHzuTCJqrK9sWxYQZUq6Nq3cuyv3bm734IhHvHtGGURU6A== + dependencies: + is-hex-prefixed "1.0.0" + +strip-json-comments@2.0.1, strip-json-comments@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ== + +strip-json-comments@3.1.1, strip-json-comments@^3.1.0, strip-json-comments@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +supports-color@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a" + integrity sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg== + dependencies: + has-flag "^3.0.0" + +supports-color@8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + integrity sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g== + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + +swarm-js@0.1.39: + version "0.1.39" + resolved "https://registry.yarnpkg.com/swarm-js/-/swarm-js-0.1.39.tgz#79becb07f291d4b2a178c50fee7aa6e10342c0e8" + integrity sha512-QLMqL2rzF6n5s50BptyD6Oi0R1aWlJC5Y17SRIVXRj6OR1DRIPM7nepvrxxkjA1zNzFz6mUOMjfeqeDaWB7OOg== + dependencies: + bluebird "^3.5.0" + buffer "^5.0.5" + decompress "^4.0.0" + eth-lib "^0.1.26" + fs-extra "^4.0.2" + got "^7.1.0" + mime-types "^2.1.16" + mkdirp-promise "^5.0.1" + mock-fs "^4.1.0" + setimmediate "^1.0.5" + tar "^4.0.2" + xhr-request-promise "^0.1.2" + +swarm-js@^0.1.40: + version "0.1.42" + resolved "https://registry.yarnpkg.com/swarm-js/-/swarm-js-0.1.42.tgz#497995c62df6696f6e22372f457120e43e727979" + integrity sha512-BV7c/dVlA3R6ya1lMlSSNPLYrntt0LUq4YMgy3iwpCIc6rZnS5W2wUoctarZ5pXlpKtxDDf9hNziEkcfrxdhqQ== + dependencies: + bluebird "^3.5.0" + buffer "^5.0.5" + eth-lib "^0.1.26" + fs-extra "^4.0.2" + got "^11.8.5" + mime-types "^2.1.16" + mkdirp-promise "^5.0.1" + mock-fs "^4.1.0" + setimmediate "^1.0.5" + tar "^4.0.2" + xhr-request "^1.0.1" + +sync-request@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/sync-request/-/sync-request-6.1.0.tgz#e96217565b5e50bbffe179868ba75532fb597e68" + integrity sha512-8fjNkrNlNCrVc/av+Jn+xxqfCjYaBoHqCsDz6mt030UMxJGr+GSfCV1dQt2gRtlL63+VPidwDVLr7V2OcTSdRw== + dependencies: + http-response-object "^3.0.1" + sync-rpc "^1.2.1" + then-request "^6.0.0" + +sync-rpc@^1.2.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/sync-rpc/-/sync-rpc-1.3.6.tgz#b2e8b2550a12ccbc71df8644810529deb68665a7" + integrity sha512-J8jTXuZzRlvU7HemDgHi3pGnh/rkoqR/OZSjhTyyZrEkkYQbk7Z33AXp37mkPfPpfdOuj7Ex3H/TJM1z48uPQw== + dependencies: + get-port "^3.1.0" + +table-layout@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.2.tgz#c4038a1853b0136d63365a734b6931cf4fad4a04" + integrity sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A== + dependencies: + array-back "^4.0.1" + deep-extend "~0.6.0" + typical "^5.2.0" + wordwrapjs "^4.0.0" + +table@^5.2.3: + version "5.4.6" + resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e" + integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug== + dependencies: + ajv "^6.10.2" + lodash "^4.17.14" + slice-ansi "^2.1.0" + string-width "^3.0.0" + +table@^6.0.9, table@^6.8.0: + version "6.8.1" + resolved "https://registry.yarnpkg.com/table/-/table-6.8.1.tgz#ea2b71359fe03b017a5fbc296204471158080bdf" + integrity sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA== + dependencies: + ajv "^8.0.1" + lodash.truncate "^4.4.2" + slice-ansi "^4.0.0" + string-width "^4.2.3" + strip-ansi "^6.0.1" + +tape@^4.6.3: + version "4.16.2" + resolved "https://registry.yarnpkg.com/tape/-/tape-4.16.2.tgz#7565e6af20426565557266e9dda7215869b297b6" + integrity sha512-TUChV+q0GxBBCEbfCYkGLkv8hDJYjMdSWdE0/Lr331sB389dsvFUHNV9ph5iQqKzt8Ss9drzcda/YeexclBFqg== + dependencies: + call-bind "~1.0.2" + deep-equal "~1.1.1" + defined "~1.0.1" + dotignore "~0.1.2" + for-each "~0.3.3" + glob "~7.2.3" + has "~1.0.3" + inherits "~2.0.4" + is-regex "~1.1.4" + minimist "~1.2.7" + object-inspect "~1.12.3" + resolve "~1.22.1" + resumer "~0.0.0" + string.prototype.trim "~1.2.7" + through "~2.3.8" + +tar-stream@^1.5.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.6.2.tgz#8ea55dab37972253d9a9af90fdcd559ae435c555" + integrity sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A== + dependencies: + bl "^1.0.0" + buffer-alloc "^1.2.0" + end-of-stream "^1.0.0" + fs-constants "^1.0.0" + readable-stream "^2.3.0" + to-buffer "^1.1.1" + xtend "^4.0.0" + +tar@^4.0.2: + version "4.4.19" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3" + integrity sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA== + dependencies: + chownr "^1.1.4" + fs-minipass "^1.2.7" + minipass "^2.9.0" + minizlib "^1.3.3" + mkdirp "^0.5.5" + safe-buffer "^5.2.1" + yallist "^3.1.1" + +test-value@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/test-value/-/test-value-2.1.0.tgz#11da6ff670f3471a73b625ca4f3fdcf7bb748291" + integrity sha512-+1epbAxtKeXttkGFMTX9H42oqzOTufR1ceCF+GYA5aOmvaPq9wd4PUS8329fn2RRLGNeUkgRLnVpycjx8DsO2w== + dependencies: + array-back "^1.0.3" + typical "^2.6.0" + +testrpc@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/testrpc/-/testrpc-0.0.1.tgz#83e2195b1f5873aec7be1af8cbe6dcf39edb7aed" + integrity sha512-afH1hO+SQ/VPlmaLUFj2636QMeDvPCeQMc/9RBMW0IfjNe9gFD9Ra3ShqYkB7py0do1ZcCna/9acHyzTJ+GcNA== + +text-table@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" + integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== + +then-request@^6.0.0: + version "6.0.2" + resolved "https://registry.yarnpkg.com/then-request/-/then-request-6.0.2.tgz#ec18dd8b5ca43aaee5cb92f7e4c1630e950d4f0c" + integrity sha512-3ZBiG7JvP3wbDzA9iNY5zJQcHL4jn/0BWtXIkagfz7QgOL/LqjCEOBQuJNZfu0XYnv5JhKh+cDxCPM4ILrqruA== + dependencies: + "@types/concat-stream" "^1.6.0" + "@types/form-data" "0.0.33" + "@types/node" "^8.0.0" + "@types/qs" "^6.2.31" + caseless "~0.12.0" + concat-stream "^1.6.0" + form-data "^2.2.0" + http-basic "^8.1.1" + http-response-object "^3.0.1" + promise "^8.0.0" + qs "^6.4.0" + +through2@^2.0.3: + version "2.0.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" + integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== + dependencies: + readable-stream "~2.3.6" + xtend "~4.0.1" + +through@^2.3.6, through@^2.3.8, through@~2.3.4, through@~2.3.8: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== + +timed-out@^4.0.0, timed-out@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" + integrity sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA== + +tiny-secp256k1@^1.1.3: + version "1.1.6" + resolved "https://registry.yarnpkg.com/tiny-secp256k1/-/tiny-secp256k1-1.1.6.tgz#7e224d2bee8ab8283f284e40e6b4acb74ffe047c" + integrity sha512-FmqJZGduTyvsr2cF3375fqGHUovSwDi/QytexX1Se4BPuPZpTE5Ftp5fg+EFSuEf3lhZqgCRjEG3ydUQ/aNiwA== + dependencies: + bindings "^1.3.0" + bn.js "^4.11.8" + create-hmac "^1.1.7" + elliptic "^6.4.0" + nan "^2.13.2" + +tmp@0.0.33, tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== + dependencies: + os-tmpdir "~1.0.2" + +tmp@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.1.0.tgz#ee434a4e22543082e294ba6201dcc6eafefa2877" + integrity sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw== + dependencies: + rimraf "^2.6.3" + +to-buffer@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/to-buffer/-/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80" + integrity sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg== + +to-fast-properties@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" + integrity sha512-lxrWP8ejsq+7E3nNjwYmUBMAgjMTZoTI+sdBOpvNyijeDLa29LUn9QaoXAHv4+Z578hbmHHJKZknzxVtvo77og== + +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + integrity sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg== + dependencies: + kind-of "^3.0.2" + +to-readable-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771" + integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q== + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + integrity sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg== + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + +tough-cookie@^2.3.3, tough-cookie@~2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" + integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== + dependencies: + psl "^1.1.28" + punycode "^2.1.1" + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + +trim-right@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + integrity sha512-WZGXGstmCWgeevgTL54hrCuw1dyMQIzWy7ZfqRJfSmJZBwklI15egmQytFP6bPidmw3M8d5yEowl1niq4vmqZw== + +truffle-flattener@^1.4.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/truffle-flattener/-/truffle-flattener-1.6.0.tgz#abb64488b711e6cca0a9d3e449f6a85e35964c5d" + integrity sha512-scS5Bsi4CZyvlrmD4iQcLHTiG2RQFUXVheTgWeH6PuafmI+Lk5U87Es98loM3w3ImqC9/fPHq+3QIXbcPuoJ1Q== + dependencies: + "@resolver-engine/imports-fs" "^0.2.2" + "@solidity-parser/parser" "^0.14.1" + find-up "^2.1.0" + mkdirp "^1.0.4" + tsort "0.0.1" + +ts-command-line-args@^2.2.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/ts-command-line-args/-/ts-command-line-args-2.4.2.tgz#b4815b23c35f8a0159d4e69e01012d95690bc448" + integrity sha512-mJLQQBOdyD4XI/ZWQY44PIdYde47JhV2xl380O7twPkTQ+Y5vFDHsk8LOeXKuz7dVY5aDCfAzRarNfSqtKOkQQ== + dependencies: + "@morgan-stanley/ts-mocking-bird" "^0.6.2" + chalk "^4.1.0" + command-line-args "^5.1.1" + command-line-usage "^6.1.0" + string-format "^2.0.0" + +ts-essentials@^1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-1.0.4.tgz#ce3b5dade5f5d97cf69889c11bf7d2da8555b15a" + integrity sha512-q3N1xS4vZpRouhYHDPwO0bDW3EZ6SK9CrrDHxi/D6BPReSjpVgWIOpLS2o0gSBZm+7q/wyKp6RVM1AeeW7uyfQ== + +ts-essentials@^6.0.3: + version "6.0.7" + resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-6.0.7.tgz#5f4880911b7581a873783740ce8b94da163d18a6" + integrity sha512-2E4HIIj4tQJlIHuATRHayv0EfMGK3ris/GRk1E3CFnsZzeNV+hUmelbaTZHLtXaZppM5oLhHRtO04gINC4Jusw== + +ts-essentials@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-7.0.3.tgz#686fd155a02133eedcc5362dc8b5056cde3e5a38" + integrity sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ== + +ts-generator@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ts-generator/-/ts-generator-0.1.1.tgz#af46f2fb88a6db1f9785977e9590e7bcd79220ab" + integrity sha512-N+ahhZxTLYu1HNTQetwWcx3so8hcYbkKBHTr4b4/YgObFTIKkOSSsaa+nal12w8mfrJAyzJfETXawbNjSfP2gQ== + dependencies: + "@types/mkdirp" "^0.5.2" + "@types/prettier" "^2.1.1" + "@types/resolve" "^0.0.8" + chalk "^2.4.1" + glob "^7.1.2" + mkdirp "^0.5.1" + prettier "^2.1.2" + resolve "^1.8.1" + ts-essentials "^1.0.0" + +ts-node@^10.4.0: + version "10.9.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" + integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== + dependencies: + "@cspotcode/source-map-support" "^0.8.0" + "@tsconfig/node10" "^1.0.7" + "@tsconfig/node12" "^1.0.7" + "@tsconfig/node14" "^1.0.0" + "@tsconfig/node16" "^1.0.2" + acorn "^8.4.1" + acorn-walk "^8.1.1" + arg "^4.1.0" + create-require "^1.1.0" + diff "^4.0.1" + make-error "^1.1.1" + v8-compile-cache-lib "^3.0.1" + yn "3.1.1" + +ts-node@^8.4.1: + version "8.10.2" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d" + integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA== + dependencies: + arg "^4.1.0" + diff "^4.0.1" + make-error "^1.1.1" + source-map-support "^0.5.17" + yn "3.1.1" + +tsconfig-paths@^3.14.1: + version "3.14.2" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" + integrity sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g== + dependencies: + "@types/json5" "^0.0.29" + json5 "^1.0.2" + minimist "^1.2.6" + strip-bom "^3.0.0" + +tslib@^1.11.1, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: + version "1.14.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" + integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== + +tslib@^2.3.1, tslib@^2.5.0: + version "2.6.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" + integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== + +tsort@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/tsort/-/tsort-0.0.1.tgz#e2280f5e817f8bf4275657fd0f9aebd44f5a2786" + integrity sha512-Tyrf5mxF8Ofs1tNoxA13lFeZ2Zrbd6cKbuH3V+MQ5sb6DtBj5FjrXVsRWT8YvNAQTqNoz66dz1WsbigI22aEnw== + +tsutils@^3.21.0: + version "3.21.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" + integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== + dependencies: + tslib "^1.8.1" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + integrity sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w== + dependencies: + safe-buffer "^5.0.1" + +tweetnacl-util@^0.15.0, tweetnacl-util@^0.15.1: + version "0.15.1" + resolved "https://registry.yarnpkg.com/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz#b80fcdb5c97bcc508be18c44a4be50f022eea00b" + integrity sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw== + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + integrity sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA== + +tweetnacl@^1.0.0, tweetnacl@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" + integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== + +type-check@^0.4.0, type-check@~0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" + integrity sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew== + dependencies: + prelude-ls "^1.2.1" + +type-check@~0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" + integrity sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg== + dependencies: + prelude-ls "~1.1.2" + +type-detect@^4.0.0, type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== + +type-fest@^0.20.2: + version "0.20.2" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" + integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== + +type-fest@^0.21.3: + version "0.21.3" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37" + integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w== + +type-fest@^0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.7.1.tgz#8dda65feaf03ed78f0a3f9678f1869147f7c5c48" + integrity sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg== + +type-is@~1.6.18: + version "1.6.18" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" + integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== + dependencies: + media-typer "0.3.0" + mime-types "~2.1.24" + +type@^1.0.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0" + integrity sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg== + +type@^2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/type/-/type-2.7.2.tgz#2376a15a3a28b1efa0f5350dcf72d24df6ef98d0" + integrity sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw== + +typechain@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/typechain/-/typechain-3.0.0.tgz#d5a47700831f238e43f7429b987b4bb54849b92e" + integrity sha512-ft4KVmiN3zH4JUFu2WJBrwfHeDf772Tt2d8bssDTo/YcckKW2D+OwFrHXRC6hJvO3mHjFQTihoMV6fJOi0Hngg== + dependencies: + command-line-args "^4.0.7" + debug "^4.1.1" + fs-extra "^7.0.0" + js-sha3 "^0.8.0" + lodash "^4.17.15" + ts-essentials "^6.0.3" + ts-generator "^0.1.1" + +typechain@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/typechain/-/typechain-6.1.0.tgz#462a35f555accf870689d1ba5698749108d0ce81" + integrity sha512-GGfkK0p3fUgz8kYxjSS4nKcWXE0Lo+teHTetghousIK5njbNoYNDlwn91QIyD181L3fVqlTvBE0a/q3AZmjNfw== + dependencies: + "@types/prettier" "^2.1.1" + debug "^4.1.1" + fs-extra "^7.0.0" + glob "^7.1.6" + js-sha3 "^0.8.0" + lodash "^4.17.15" + mkdirp "^1.0.4" + prettier "^2.1.2" + ts-command-line-args "^2.2.0" + ts-essentials "^7.0.1" + +typed-array-length@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.4.tgz#89d83785e5c4098bec72e08b319651f0eac9c1bb" + integrity sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng== + dependencies: + call-bind "^1.0.2" + for-each "^0.3.3" + is-typed-array "^1.1.9" + +typedarray-to-buffer@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" + integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q== + dependencies: + is-typedarray "^1.0.0" + +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== + +typeforce@^1.11.5: + version "1.18.0" + resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc" + integrity sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g== + +typescript@^3.6.4: + version "3.9.10" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.10.tgz#70f3910ac7a51ed6bef79da7800690b19bf778b8" + integrity sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q== + +typescript@^4.5.4: + version "4.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" + integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== + +typewise-core@^1.2, typewise-core@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/typewise-core/-/typewise-core-1.2.0.tgz#97eb91805c7f55d2f941748fa50d315d991ef195" + integrity sha512-2SCC/WLzj2SbUwzFOzqMCkz5amXLlxtJqDKTICqg30x+2DZxcfZN2MvQZmGfXWKNWaKK9pBPsvkcwv8bF/gxKg== + +typewise@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/typewise/-/typewise-1.0.3.tgz#1067936540af97937cc5dcf9922486e9fa284651" + integrity sha512-aXofE06xGhaQSPzt8hlTY+/YWQhm9P0jYUp1f2XtmW/3Bk0qzXcyFWAtPoo2uTGQj1ZwbDuSyuxicq+aDo8lCQ== + dependencies: + typewise-core "^1.2.0" + +typewiselite@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typewiselite/-/typewiselite-1.0.0.tgz#c8882fa1bb1092c06005a97f34ef5c8508e3664e" + integrity sha512-J9alhjVHupW3Wfz6qFRGgQw0N3gr8hOkw6zm7FZ6UR1Cse/oD9/JVok7DNE9TT9IbciDHX2Ex9+ksE6cRmtymw== + +typical@^2.6.0, typical@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d" + integrity sha512-ofhi8kjIje6npGozTip9Fr8iecmYfEbS06i0JnIg+rh51KakryWF4+jX8lLKZVhy6N+ID45WYSFCxPOdTWCzNg== + +typical@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4" + integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw== + +typical@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" + integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== + +ultron@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" + integrity sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og== + +unbox-primitive@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" + integrity sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw== + dependencies: + call-bind "^1.0.2" + has-bigints "^1.0.2" + has-symbols "^1.0.3" + which-boxed-primitive "^1.0.2" + +unbzip2-stream@^1.0.9: + version "1.4.3" + resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz#b0da04c4371311df771cdc215e87f2130991ace7" + integrity sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg== + dependencies: + buffer "^5.2.1" + through "^2.3.8" + +underscore@1.12.1: + version "1.12.1" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.12.1.tgz#7bb8cc9b3d397e201cf8553336d262544ead829e" + integrity sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw== + +underscore@1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961" + integrity sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg== + +underscore@>1.4.4: + version "1.13.6" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441" + integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A== + +undici@^5.14.0: + version "5.21.0" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.21.0.tgz#b00dfc381f202565ab7f52023222ab862bb2494f" + integrity sha512-HOjK8l6a57b2ZGXOcUsI5NLfoTrfmbOl90ixJDl0AEFG4wgHNDQxtZy15/ZQp7HhjkpaGlp/eneMgtsu1dIlUA== + dependencies: + busboy "^1.6.0" + +undici@^5.4.0: + version "5.22.1" + resolved "https://registry.yarnpkg.com/undici/-/undici-5.22.1.tgz#877d512effef2ac8be65e695f3586922e1a57d7b" + integrity sha512-Ji2IJhFXZY0x/0tVBXeQwgPlLWw13GVzpsWPQ3rV50IFMMof2I55PZZxtm4P6iNq+L5znYN9nSTAq0ZyE6lSJw== + dependencies: + busboy "^1.6.0" + +unfetch@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.2.0.tgz#7e21b0ef7d363d8d9af0fb929a5555f6ef97a3be" + integrity sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA== + +union-value@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847" + integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg== + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^2.0.1" + +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + +universalify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" + integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== + +unorm@^1.3.3: + version "1.6.0" + resolved "https://registry.yarnpkg.com/unorm/-/unorm-1.6.0.tgz#029b289661fba714f1a9af439eb51d9b16c205af" + integrity sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA== + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + integrity sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ== + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +uri-js@^4.2.2: + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + integrity sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg== + +url-parse-lax@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" + integrity sha512-BVA4lR5PIviy2PMseNd2jbFQ+jwSwQGdJejf5ctd1rEXt0Ypd7yanUK9+lYechVlN5VaTJGsu2U/3MDDu6KgBA== + dependencies: + prepend-http "^1.0.1" + +url-parse-lax@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c" + integrity sha512-NjFKA0DidqPa5ciFcSrXnAltTtzz84ogy+NebPvfEgAck0+TNg4UJ4IN+fB7zRZfbgUf0syOo9MDxFkDSMuFaQ== + dependencies: + prepend-http "^2.0.0" + +url-set-query@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/url-set-query/-/url-set-query-1.0.0.tgz#016e8cfd7c20ee05cafe7795e892bd0702faa339" + integrity sha512-3AChu4NiXquPfeckE5R5cGdiHCMWJx1dwCWOmWIL4KHAziJNOFIYJlpGFeKDvwLPHovZRCxK3cYlwzqI9Vp+Gg== + +url-to-options@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/url-to-options/-/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9" + integrity sha512-0kQLIzG4fdk/G5NONku64rSH/x32NOA39LVQqlK8Le6lvTF6GGRJpqaQFGgU+CLwySIqBSMdwYM0sYcW9f6P4A== + +url@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" + integrity sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ== + dependencies: + punycode "1.3.2" + querystring "0.2.0" + +use@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" + integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== + +utf-8-validate@^5.0.2: + version "5.0.10" + resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2" + integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ== + dependencies: + node-gyp-build "^4.3.0" + +utf8@3.0.0, utf8@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/utf8/-/utf8-3.0.0.tgz#f052eed1364d696e769ef058b183df88c87f69d1" + integrity sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ== + +util-deprecate@^1.0.1, util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + +util.promisify@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.1.1.tgz#77832f57ced2c9478174149cae9b96e9918cd54b" + integrity sha512-/s3UsZUrIfa6xDhr7zZhnE9SLQ5RIXyYfiVnMMyMDzOc8WhWN4Nbh36H842OyurKbCDAesZOJaVyvmSl6fhGQw== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + for-each "^0.3.3" + has-symbols "^1.0.1" + object.getownpropertydescriptors "^2.1.1" + +util@^0.12.0: + version "0.12.5" + resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc" + integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA== + dependencies: + inherits "^2.0.3" + is-arguments "^1.0.4" + is-generator-function "^1.0.7" + is-typed-array "^1.1.3" + which-typed-array "^1.1.2" + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== + +uuid@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.1.tgz#c2a30dedb3e535d72ccf82e343941a50ba8533ac" + integrity sha512-nWg9+Oa3qD2CQzHIP4qKUqwNfzKn8P0LtFhotaCTFchsV7ZfDhAybeip/HZVeMIpZi9JgY1E3nUlwaCmZT1sEg== + +uuid@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== + +uuid@^3.3.2: + version "3.4.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" + integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== + +uuid@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-7.0.3.tgz#c5c9f2c8cf25dc0a372c4df1441c41f5bd0c680b" + integrity sha512-DPSke0pXhTZgoF/d+WSt2QaKMCFSfx7QegxEWT+JOuHF5aWrKEn0G+ztjuJg/gG8/ItK+rbPCD/yNv8yyih6Cg== + +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + +v8-compile-cache-lib@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" + integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== + +v8-compile-cache@^2.0.3: + version "2.3.0" + resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" + integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== + +validate-npm-package-license@^3.0.1: + version "3.0.4" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== + dependencies: + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" + +varint@^5.0.0: + version "5.0.2" + resolved "https://registry.yarnpkg.com/varint/-/varint-5.0.2.tgz#5b47f8a947eb668b848e034dcfa87d0ff8a7f7a4" + integrity sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow== + +vary@^1, vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" + integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + integrity sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw== + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +web3-bzz@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.2.11.tgz#41bc19a77444bd5365744596d778b811880f707f" + integrity sha512-XGpWUEElGypBjeFyUhTkiPXFbDVD6Nr/S5jznE3t8cWUA0FxRf1n3n/NuIZeb0H9RkN2Ctd/jNma/k8XGa3YKg== + dependencies: + "@types/node" "^12.12.6" + got "9.6.0" + swarm-js "^0.1.40" + underscore "1.9.1" + +web3-bzz@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.2.2.tgz#a3b9f613c49fd3e120e0997088a73557d5adb724" + integrity sha512-b1O2ObsqUN1lJxmFSjvnEC4TsaCbmh7Owj3IAIWTKqL9qhVgx7Qsu5O9cD13pBiSPNZJ68uJPaKq380QB4NWeA== + dependencies: + "@types/node" "^10.12.18" + got "9.6.0" + swarm-js "0.1.39" + underscore "1.9.1" + +web3-bzz@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.2.4.tgz#a4adb7a8cba3d260de649bdb1f14ed359bfb3821" + integrity sha512-MqhAo/+0iQSMBtt3/QI1rU83uvF08sYq8r25+OUZ+4VtihnYsmkkca+rdU0QbRyrXY2/yGIpI46PFdh0khD53A== + dependencies: + "@types/node" "^10.12.18" + got "9.6.0" + swarm-js "0.1.39" + underscore "1.9.1" + +web3-bzz@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.3.6.tgz#95f370aecc3ff6ad07f057e6c0c916ef09b04dde" + integrity sha512-ibHdx1wkseujFejrtY7ZyC0QxQ4ATXjzcNUpaLrvM6AEae8prUiyT/OloG9FWDgFD2CPLwzKwfSQezYQlANNlw== + dependencies: + "@types/node" "^12.12.6" + got "9.6.0" + swarm-js "^0.1.40" + underscore "1.12.1" + +web3-core-helpers@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-1.2.11.tgz#84c681ed0b942c0203f3b324a245a127e8c67a99" + integrity sha512-PEPoAoZd5ME7UfbnCZBdzIerpe74GEvlwT4AjOmHeCVZoIFk7EqvOZDejJHt+feJA6kMVTdd0xzRNN295UhC1A== + dependencies: + underscore "1.9.1" + web3-eth-iban "1.2.11" + web3-utils "1.2.11" + +web3-core-helpers@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-1.2.2.tgz#484974f4bd4a487217b85b0d7cfe841af0907619" + integrity sha512-HJrRsIGgZa1jGUIhvGz4S5Yh6wtOIo/TMIsSLe+Xay+KVnbseJpPprDI5W3s7H2ODhMQTbogmmUFquZweW2ImQ== + dependencies: + underscore "1.9.1" + web3-eth-iban "1.2.2" + web3-utils "1.2.2" + +web3-core-helpers@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-1.2.4.tgz#ffd425861f4d66b3f38df032afdb39ea0971fc0f" + integrity sha512-U7wbsK8IbZvF3B7S+QMSNP0tni/6VipnJkB0tZVEpHEIV2WWeBHYmZDnULWcsS/x/jn9yKhJlXIxWGsEAMkjiw== + dependencies: + underscore "1.9.1" + web3-eth-iban "1.2.4" + web3-utils "1.2.4" + +web3-core-helpers@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-core-helpers/-/web3-core-helpers-1.3.6.tgz#c478246a9abe4e5456acf42657dac2f7c330be74" + integrity sha512-nhtjA2ZbkppjlxTSwG0Ttu6FcPkVu1rCN5IFAOVpF/L0SEt+jy+O5l90+cjDq0jAYvlBwUwnbh2mR9hwDEJCNA== + dependencies: + underscore "1.12.1" + web3-eth-iban "1.3.6" + web3-utils "1.3.6" + +web3-core-method@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-1.2.11.tgz#f880137d1507a0124912bf052534f168b8d8fbb6" + integrity sha512-ff0q76Cde94HAxLDZ6DbdmKniYCQVtvuaYh+rtOUMB6kssa5FX0q3vPmixi7NPooFnbKmmZCM6NvXg4IreTPIw== + dependencies: + "@ethersproject/transactions" "^5.0.0-beta.135" + underscore "1.9.1" + web3-core-helpers "1.2.11" + web3-core-promievent "1.2.11" + web3-core-subscriptions "1.2.11" + web3-utils "1.2.11" + +web3-core-method@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-1.2.2.tgz#d4fe2bb1945b7152e5f08e4ea568b171132a1e56" + integrity sha512-szR4fDSBxNHaF1DFqE+j6sFR/afv9Aa36OW93saHZnrh+iXSrYeUUDfugeNcRlugEKeUCkd4CZylfgbK2SKYJA== + dependencies: + underscore "1.9.1" + web3-core-helpers "1.2.2" + web3-core-promievent "1.2.2" + web3-core-subscriptions "1.2.2" + web3-utils "1.2.2" + +web3-core-method@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-1.2.4.tgz#a0fbc50b8ff5fd214021435cc2c6d1e115807aed" + integrity sha512-8p9kpL7di2qOVPWgcM08kb+yKom0rxRCMv6m/K+H+yLSxev9TgMbCgMSbPWAHlyiF3SJHw7APFKahK5Z+8XT5A== + dependencies: + underscore "1.9.1" + web3-core-helpers "1.2.4" + web3-core-promievent "1.2.4" + web3-core-subscriptions "1.2.4" + web3-utils "1.2.4" + +web3-core-method@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-core-method/-/web3-core-method-1.3.6.tgz#4b0334edd94b03dfec729d113c69a4eb6ebc68ae" + integrity sha512-RyegqVGxn0cyYW5yzAwkPlsSEynkdPiegd7RxgB4ak1eKk2Cv1q2x4C7D2sZjeeCEF+q6fOkVmo2OZNqS2iQxg== + dependencies: + "@ethersproject/transactions" "^5.0.0-beta.135" + underscore "1.12.1" + web3-core-helpers "1.3.6" + web3-core-promievent "1.3.6" + web3-core-subscriptions "1.3.6" + web3-utils "1.3.6" + +web3-core-promievent@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-promievent/-/web3-core-promievent-1.2.11.tgz#51fe97ca0ddec2f99bf8c3306a7a8e4b094ea3cf" + integrity sha512-il4McoDa/Ox9Agh4kyfQ8Ak/9ABYpnF8poBLL33R/EnxLsJOGQG2nZhkJa3I067hocrPSjEdlPt/0bHXsln4qA== + dependencies: + eventemitter3 "4.0.4" + +web3-core-promievent@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-core-promievent/-/web3-core-promievent-1.2.2.tgz#3b60e3f2a0c96db8a891c927899d29d39e66ab1c" + integrity sha512-tKvYeT8bkUfKABcQswK6/X79blKTKYGk949urZKcLvLDEaWrM3uuzDwdQT3BNKzQ3vIvTggFPX9BwYh0F1WwqQ== + dependencies: + any-promise "1.3.0" + eventemitter3 "3.1.2" + +web3-core-promievent@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-core-promievent/-/web3-core-promievent-1.2.4.tgz#75e5c0f2940028722cdd21ba503ebd65272df6cb" + integrity sha512-gEUlm27DewUsfUgC3T8AxkKi8Ecx+e+ZCaunB7X4Qk3i9F4C+5PSMGguolrShZ7Zb6717k79Y86f3A00O0VAZw== + dependencies: + any-promise "1.3.0" + eventemitter3 "3.1.2" + +web3-core-promievent@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-core-promievent/-/web3-core-promievent-1.3.6.tgz#6c27dc79de8f71b74f5d17acaf9aaf593d3cb0c9" + integrity sha512-Z+QzfyYDTXD5wJmZO5wwnRO8bAAHEItT1XNSPVb4J1CToV/I/SbF7CuF8Uzh2jns0Cm1109o666H7StFFvzVKw== + dependencies: + eventemitter3 "4.0.4" + +web3-core-requestmanager@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-requestmanager/-/web3-core-requestmanager-1.2.11.tgz#fe6eb603fbaee18530293a91f8cf26d8ae28c45a" + integrity sha512-oFhBtLfOiIbmfl6T6gYjjj9igOvtyxJ+fjS+byRxiwFJyJ5BQOz4/9/17gWR1Cq74paTlI7vDGxYfuvfE/mKvA== + dependencies: + underscore "1.9.1" + web3-core-helpers "1.2.11" + web3-providers-http "1.2.11" + web3-providers-ipc "1.2.11" + web3-providers-ws "1.2.11" + +web3-core-requestmanager@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-core-requestmanager/-/web3-core-requestmanager-1.2.2.tgz#667ba9ac724c9c76fa8965ae8a3c61f66e68d8d6" + integrity sha512-a+gSbiBRHtHvkp78U2bsntMGYGF2eCb6219aMufuZWeAZGXJ63Wc2321PCbA8hF9cQrZI4EoZ4kVLRI4OF15Hw== + dependencies: + underscore "1.9.1" + web3-core-helpers "1.2.2" + web3-providers-http "1.2.2" + web3-providers-ipc "1.2.2" + web3-providers-ws "1.2.2" + +web3-core-requestmanager@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-core-requestmanager/-/web3-core-requestmanager-1.2.4.tgz#0a7020a23fb91c6913c611dfd3d8c398d1e4b4a8" + integrity sha512-eZJDjyNTDtmSmzd3S488nR/SMJtNnn/GuwxnMh3AzYCqG3ZMfOylqTad2eYJPvc2PM5/Gj1wAMQcRpwOjjLuPg== + dependencies: + underscore "1.9.1" + web3-core-helpers "1.2.4" + web3-providers-http "1.2.4" + web3-providers-ipc "1.2.4" + web3-providers-ws "1.2.4" + +web3-core-requestmanager@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-core-requestmanager/-/web3-core-requestmanager-1.3.6.tgz#4fea269fe913fd4fca464b4f7c65cb94857b5b2a" + integrity sha512-2rIaeuqeo7QN1Eex7aXP0ZqeteJEPWXYFS/M3r3LXMiV8R4STQBKE+//dnHJXoo2ctzEB5cgd+7NaJM8S3gPyA== + dependencies: + underscore "1.12.1" + util "^0.12.0" + web3-core-helpers "1.3.6" + web3-providers-http "1.3.6" + web3-providers-ipc "1.3.6" + web3-providers-ws "1.3.6" + +web3-core-subscriptions@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-1.2.11.tgz#beca908fbfcb050c16f45f3f0f4c205e8505accd" + integrity sha512-qEF/OVqkCvQ7MPs1JylIZCZkin0aKK9lDxpAtQ1F8niEDGFqn7DT8E/vzbIa0GsOjL2fZjDhWJsaW+BSoAW1gg== + dependencies: + eventemitter3 "4.0.4" + underscore "1.9.1" + web3-core-helpers "1.2.11" + +web3-core-subscriptions@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-1.2.2.tgz#bf4ba23a653a003bdc3551649958cc0b080b068e" + integrity sha512-QbTgigNuT4eicAWWr7ahVpJyM8GbICsR1Ys9mJqzBEwpqS+RXTRVSkwZ2IsxO+iqv6liMNwGregbJLq4urMFcQ== + dependencies: + eventemitter3 "3.1.2" + underscore "1.9.1" + web3-core-helpers "1.2.2" + +web3-core-subscriptions@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-1.2.4.tgz#0dc095b5cfd82baa527a39796e3515a846b21b99" + integrity sha512-3D607J2M8ymY9V+/WZq4MLlBulwCkwEjjC2U+cXqgVO1rCyVqbxZNCmHyNYHjDDCxSEbks9Ju5xqJxDSxnyXEw== + dependencies: + eventemitter3 "3.1.2" + underscore "1.9.1" + web3-core-helpers "1.2.4" + +web3-core-subscriptions@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-core-subscriptions/-/web3-core-subscriptions-1.3.6.tgz#ee24e7974d1d72ff6c992c599deba4ef9b308415" + integrity sha512-wi9Z9X5X75OKvxAg42GGIf81ttbNR2TxzkAsp1g+nnp5K8mBwgZvXrIsDuj7Z7gx72Y45mWJADCWjk/2vqNu8g== + dependencies: + eventemitter3 "4.0.4" + underscore "1.12.1" + web3-core-helpers "1.3.6" + +web3-core@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-1.2.11.tgz#1043cacc1becb80638453cc5b2a14be9050288a7" + integrity sha512-CN7MEYOY5ryo5iVleIWRE3a3cZqVaLlIbIzDPsvQRUfzYnvzZQRZBm9Mq+ttDi2STOOzc1MKylspz/o3yq/LjQ== + dependencies: + "@types/bn.js" "^4.11.5" + "@types/node" "^12.12.6" + bignumber.js "^9.0.0" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-core-requestmanager "1.2.11" + web3-utils "1.2.11" + +web3-core@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-1.2.2.tgz#334b99c8222ef9cfd0339e27352f0b58ea789a2f" + integrity sha512-miHAX3qUgxV+KYfaOY93Hlc3kLW2j5fH8FJy6kSxAv+d4d5aH0wwrU2IIoJylQdT+FeenQ38sgsCnFu9iZ1hCQ== + dependencies: + "@types/bn.js" "^4.11.4" + "@types/node" "^12.6.1" + web3-core-helpers "1.2.2" + web3-core-method "1.2.2" + web3-core-requestmanager "1.2.2" + web3-utils "1.2.2" + +web3-core@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-1.2.4.tgz#2df13b978dcfc59c2abaa887d27f88f21ad9a9d6" + integrity sha512-CHc27sMuET2cs1IKrkz7xzmTdMfZpYswe7f0HcuyneTwS1yTlTnHyqjAaTy0ZygAb/x4iaVox+Gvr4oSAqSI+A== + dependencies: + "@types/bignumber.js" "^5.0.0" + "@types/bn.js" "^4.11.4" + "@types/node" "^12.6.1" + web3-core-helpers "1.2.4" + web3-core-method "1.2.4" + web3-core-requestmanager "1.2.4" + web3-utils "1.2.4" + +web3-core@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-core/-/web3-core-1.3.6.tgz#a6a761d1ff2f3ee462b8dab679229d2f8e267504" + integrity sha512-gkLDM4T1Sc0T+HZIwxrNrwPg0IfWI0oABSglP2X5ZbBAYVUeEATA0o92LWV8BeF+okvKXLK1Fek/p6axwM/h3Q== + dependencies: + "@types/bn.js" "^4.11.5" + "@types/node" "^12.12.6" + bignumber.js "^9.0.0" + web3-core-helpers "1.3.6" + web3-core-method "1.3.6" + web3-core-requestmanager "1.3.6" + web3-utils "1.3.6" + +web3-eth-abi@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-abi/-/web3-eth-abi-1.2.11.tgz#a887494e5d447c2926d557a3834edd66e17af9b0" + integrity sha512-PkRYc0+MjuLSgg03QVWqWlQivJqRwKItKtEpRUaxUAeLE7i/uU39gmzm2keHGcQXo3POXAbOnMqkDvOep89Crg== + dependencies: + "@ethersproject/abi" "5.0.0-beta.153" + underscore "1.9.1" + web3-utils "1.2.11" + +web3-eth-abi@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-eth-abi/-/web3-eth-abi-1.2.2.tgz#d5616d88a90020f894763423a9769f2da11fe37a" + integrity sha512-Yn/ZMgoOLxhTVxIYtPJ0eS6pnAnkTAaJgUJh1JhZS4ekzgswMfEYXOwpMaD5eiqPJLpuxmZFnXnBZlnQ1JMXsw== + dependencies: + ethers "4.0.0-beta.3" + underscore "1.9.1" + web3-utils "1.2.2" + +web3-eth-abi@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-eth-abi/-/web3-eth-abi-1.2.4.tgz#5b73e5ef70b03999227066d5d1310b168845e2b8" + integrity sha512-8eLIY4xZKoU3DSVu1pORluAw9Ru0/v4CGdw5so31nn+7fR8zgHMgwbFe0aOqWQ5VU42PzMMXeIJwt4AEi2buFg== + dependencies: + ethers "4.0.0-beta.3" + underscore "1.9.1" + web3-utils "1.2.4" + +web3-eth-abi@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-eth-abi/-/web3-eth-abi-1.3.6.tgz#4272ca48d817aa651bbf97b269f5ff10abc2b8a9" + integrity sha512-Or5cRnZu6WzgScpmbkvC6bfNxR26hqiKK4i8sMPFeTUABQcb/FU3pBj7huBLYbp9dH+P5W79D2MqwbWwjj9DoQ== + dependencies: + "@ethersproject/abi" "5.0.7" + underscore "1.12.1" + web3-utils "1.3.6" + +web3-eth-accounts@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-accounts/-/web3-eth-accounts-1.2.11.tgz#a9e3044da442d31903a7ce035a86d8fa33f90520" + integrity sha512-6FwPqEpCfKIh3nSSGeo3uBm2iFSnFJDfwL3oS9pyegRBXNsGRVpgiW63yhNzL0796StsvjHWwQnQHsZNxWAkGw== + dependencies: + crypto-browserify "3.12.0" + eth-lib "0.2.8" + ethereumjs-common "^1.3.2" + ethereumjs-tx "^2.1.1" + scrypt-js "^3.0.1" + underscore "1.9.1" + uuid "3.3.2" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-utils "1.2.11" + +web3-eth-accounts@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-eth-accounts/-/web3-eth-accounts-1.2.2.tgz#c187e14bff6baa698ac352220290222dbfd332e5" + integrity sha512-KzHOEyXOEZ13ZOkWN3skZKqSo5f4Z1ogPFNn9uZbKCz+kSp+gCAEKxyfbOsB/JMAp5h7o7pb6eYsPCUBJmFFiA== + dependencies: + any-promise "1.3.0" + crypto-browserify "3.12.0" + eth-lib "0.2.7" + ethereumjs-common "^1.3.2" + ethereumjs-tx "^2.1.1" + scrypt-shim "github:web3-js/scrypt-shim" + underscore "1.9.1" + uuid "3.3.2" + web3-core "1.2.2" + web3-core-helpers "1.2.2" + web3-core-method "1.2.2" + web3-utils "1.2.2" + +web3-eth-accounts@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-eth-accounts/-/web3-eth-accounts-1.2.4.tgz#ada6edc49542354328a85cafab067acd7f88c288" + integrity sha512-04LzT/UtWmRFmi4hHRewP5Zz43fWhuHiK5XimP86sUQodk/ByOkXQ3RoXyGXFMNoRxdcAeRNxSfA2DpIBc9xUw== + dependencies: + "@web3-js/scrypt-shim" "^0.1.0" + any-promise "1.3.0" + crypto-browserify "3.12.0" + eth-lib "0.2.7" + ethereumjs-common "^1.3.2" + ethereumjs-tx "^2.1.1" + underscore "1.9.1" + uuid "3.3.2" + web3-core "1.2.4" + web3-core-helpers "1.2.4" + web3-core-method "1.2.4" + web3-utils "1.2.4" + +web3-eth-accounts@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-eth-accounts/-/web3-eth-accounts-1.3.6.tgz#f9fcb50b28ee58090ab292a10d996155caa2b474" + integrity sha512-Ilr0hG6ONbCdSlVKffasCmNwftD5HsNpwyQASevocIQwHdTlvlwO0tb3oGYuajbKOaDzNTwXfz25bttAEoFCGA== + dependencies: + crypto-browserify "3.12.0" + eth-lib "0.2.8" + ethereumjs-common "^1.3.2" + ethereumjs-tx "^2.1.1" + scrypt-js "^3.0.1" + underscore "1.12.1" + uuid "3.3.2" + web3-core "1.3.6" + web3-core-helpers "1.3.6" + web3-core-method "1.3.6" + web3-utils "1.3.6" + +web3-eth-contract@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-1.2.11.tgz#917065902bc27ce89da9a1da26e62ef663663b90" + integrity sha512-MzYuI/Rq2o6gn7vCGcnQgco63isPNK5lMAan2E51AJLknjSLnOxwNY3gM8BcKoy4Z+v5Dv00a03Xuk78JowFow== + dependencies: + "@types/bn.js" "^4.11.5" + underscore "1.9.1" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-core-promievent "1.2.11" + web3-core-subscriptions "1.2.11" + web3-eth-abi "1.2.11" + web3-utils "1.2.11" + +web3-eth-contract@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-1.2.2.tgz#84e92714918a29e1028ee7718f0712536e14e9a1" + integrity sha512-EKT2yVFws3FEdotDQoNsXTYL798+ogJqR2//CaGwx3p0/RvQIgfzEwp8nbgA6dMxCsn9KOQi7OtklzpnJMkjtA== + dependencies: + "@types/bn.js" "^4.11.4" + underscore "1.9.1" + web3-core "1.2.2" + web3-core-helpers "1.2.2" + web3-core-method "1.2.2" + web3-core-promievent "1.2.2" + web3-core-subscriptions "1.2.2" + web3-eth-abi "1.2.2" + web3-utils "1.2.2" + +web3-eth-contract@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-1.2.4.tgz#68ef7cc633232779b0a2c506a810fbe903575886" + integrity sha512-b/9zC0qjVetEYnzRA1oZ8gF1OSSUkwSYi5LGr4GeckLkzXP7osEnp9lkO/AQcE4GpG+l+STnKPnASXJGZPgBRQ== + dependencies: + "@types/bn.js" "^4.11.4" + underscore "1.9.1" + web3-core "1.2.4" + web3-core-helpers "1.2.4" + web3-core-method "1.2.4" + web3-core-promievent "1.2.4" + web3-core-subscriptions "1.2.4" + web3-eth-abi "1.2.4" + web3-utils "1.2.4" + +web3-eth-contract@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-eth-contract/-/web3-eth-contract-1.3.6.tgz#cccf4d32dc56917fb6923e778498a9ba2a5ba866" + integrity sha512-8gDaRrLF2HCg+YEZN1ov0zN35vmtPnGf3h1DxmJQK5Wm2lRMLomz9rsWsuvig3UJMHqZAQKD7tOl3ocJocQsmA== + dependencies: + "@types/bn.js" "^4.11.5" + underscore "1.12.1" + web3-core "1.3.6" + web3-core-helpers "1.3.6" + web3-core-method "1.3.6" + web3-core-promievent "1.3.6" + web3-core-subscriptions "1.3.6" + web3-eth-abi "1.3.6" + web3-utils "1.3.6" + +web3-eth-ens@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-ens/-/web3-eth-ens-1.2.11.tgz#26d4d7f16d6cbcfff918e39832b939edc3162532" + integrity sha512-dbW7dXP6HqT1EAPvnniZVnmw6TmQEKF6/1KgAxbo8iBBYrVTMDGFQUUnZ+C4VETGrwwaqtX4L9d/FrQhZ6SUiA== + dependencies: + content-hash "^2.5.2" + eth-ens-namehash "2.0.8" + underscore "1.9.1" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-promievent "1.2.11" + web3-eth-abi "1.2.11" + web3-eth-contract "1.2.11" + web3-utils "1.2.11" + +web3-eth-ens@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-eth-ens/-/web3-eth-ens-1.2.2.tgz#0a4abed1d4cbdacbf5e1ab06e502d806d1192bc6" + integrity sha512-CFjkr2HnuyMoMFBoNUWojyguD4Ef+NkyovcnUc/iAb9GP4LHohKrODG4pl76R5u61TkJGobC2ij6TyibtsyVYg== + dependencies: + eth-ens-namehash "2.0.8" + underscore "1.9.1" + web3-core "1.2.2" + web3-core-helpers "1.2.2" + web3-core-promievent "1.2.2" + web3-eth-abi "1.2.2" + web3-eth-contract "1.2.2" + web3-utils "1.2.2" + +web3-eth-ens@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-eth-ens/-/web3-eth-ens-1.2.4.tgz#b95b3aa99fb1e35c802b9e02a44c3046a3fa065e" + integrity sha512-g8+JxnZlhdsCzCS38Zm6R/ngXhXzvc3h7bXlxgKU4coTzLLoMpgOAEz71GxyIJinWTFbLXk/WjNY0dazi9NwVw== + dependencies: + eth-ens-namehash "2.0.8" + underscore "1.9.1" + web3-core "1.2.4" + web3-core-helpers "1.2.4" + web3-core-promievent "1.2.4" + web3-eth-abi "1.2.4" + web3-eth-contract "1.2.4" + web3-utils "1.2.4" + +web3-eth-ens@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-eth-ens/-/web3-eth-ens-1.3.6.tgz#0d28c5d4ea7b4462ef6c077545a77956a6cdf175" + integrity sha512-n27HNj7lpSkRxTgSx+Zo7cmKAgyg2ElFilaFlUu/X2CNH23lXfcPm2bWssivH9z0ndhg0OyR4AYFZqPaqDHkJA== + dependencies: + content-hash "^2.5.2" + eth-ens-namehash "2.0.8" + underscore "1.12.1" + web3-core "1.3.6" + web3-core-helpers "1.3.6" + web3-core-promievent "1.3.6" + web3-eth-abi "1.3.6" + web3-eth-contract "1.3.6" + web3-utils "1.3.6" + +web3-eth-iban@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-1.2.11.tgz#f5f73298305bc7392e2f188bf38a7362b42144ef" + integrity sha512-ozuVlZ5jwFC2hJY4+fH9pIcuH1xP0HEFhtWsR69u9uDIANHLPQQtWYmdj7xQ3p2YT4bQLq/axKhZi7EZVetmxQ== + dependencies: + bn.js "^4.11.9" + web3-utils "1.2.11" + +web3-eth-iban@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-1.2.2.tgz#76bec73bad214df7c4192388979a59fc98b96c5a" + integrity sha512-gxKXBoUhaTFHr0vJB/5sd4i8ejF/7gIsbM/VvemHT3tF5smnmY6hcwSMmn7sl5Gs+83XVb/BngnnGkf+I/rsrQ== + dependencies: + bn.js "4.11.8" + web3-utils "1.2.2" + +web3-eth-iban@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-1.2.4.tgz#8e0550fd3fd8e47a39357d87fe27dee9483ee476" + integrity sha512-D9HIyctru/FLRpXakRwmwdjb5bWU2O6UE/3AXvRm6DCOf2e+7Ve11qQrPtaubHfpdW3KWjDKvlxV9iaFv/oTMQ== + dependencies: + bn.js "4.11.8" + web3-utils "1.2.4" + +web3-eth-iban@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-eth-iban/-/web3-eth-iban-1.3.6.tgz#0d6ba21fe78f190af8919e9cd5453882457209e0" + integrity sha512-nfMQaaLA/zsg5W4Oy/EJQbs8rSs1vBAX6b/35xzjYoutXlpHMQadujDx2RerTKhSHqFXSJeQAfE+2f6mdhYkRQ== + dependencies: + bn.js "^4.11.9" + web3-utils "1.3.6" + +web3-eth-personal@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-1.2.11.tgz#a38b3942a1d87a62070ce0622a941553c3d5aa70" + integrity sha512-42IzUtKq9iHZ8K9VN0vAI50iSU9tOA1V7XU2BhF/tb7We2iKBVdkley2fg26TxlOcKNEHm7o6HRtiiFsVK4Ifw== + dependencies: + "@types/node" "^12.12.6" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-net "1.2.11" + web3-utils "1.2.11" + +web3-eth-personal@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-1.2.2.tgz#eee1c86a8132fa16b5e34c6d421ca92e684f0be6" + integrity sha512-4w+GLvTlFqW3+q4xDUXvCEMU7kRZ+xm/iJC8gm1Li1nXxwwFbs+Y+KBK6ZYtoN1qqAnHR+plYpIoVo27ixI5Rg== + dependencies: + "@types/node" "^12.6.1" + web3-core "1.2.2" + web3-core-helpers "1.2.2" + web3-core-method "1.2.2" + web3-net "1.2.2" + web3-utils "1.2.2" + +web3-eth-personal@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-1.2.4.tgz#3224cca6851c96347d9799b12c1b67b2a6eb232b" + integrity sha512-5Russ7ZECwHaZXcN3DLuLS7390Vzgrzepl4D87SD6Sn1DHsCZtvfdPIYwoTmKNp69LG3mORl7U23Ga5YxqkICw== + dependencies: + "@types/node" "^12.6.1" + web3-core "1.2.4" + web3-core-helpers "1.2.4" + web3-core-method "1.2.4" + web3-net "1.2.4" + web3-utils "1.2.4" + +web3-eth-personal@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-eth-personal/-/web3-eth-personal-1.3.6.tgz#226137916754c498f0284f22c55924c87a2efcf0" + integrity sha512-pOHU0+/h1RFRYoh1ehYBehRbcKWP4OSzd4F7mDljhHngv6W8ewMHrAN8O1ol9uysN2MuCdRE19qkRg5eNgvzFQ== + dependencies: + "@types/node" "^12.12.6" + web3-core "1.3.6" + web3-core-helpers "1.3.6" + web3-core-method "1.3.6" + web3-net "1.3.6" + web3-utils "1.3.6" + +web3-eth@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-1.2.11.tgz#4c81fcb6285b8caf544058fba3ae802968fdc793" + integrity sha512-REvxW1wJ58AgHPcXPJOL49d1K/dPmuw4LjPLBPStOVkQjzDTVmJEIsiLwn2YeuNDd4pfakBwT8L3bz1G1/wVsQ== + dependencies: + underscore "1.9.1" + web3-core "1.2.11" + web3-core-helpers "1.2.11" + web3-core-method "1.2.11" + web3-core-subscriptions "1.2.11" + web3-eth-abi "1.2.11" + web3-eth-accounts "1.2.11" + web3-eth-contract "1.2.11" + web3-eth-ens "1.2.11" + web3-eth-iban "1.2.11" + web3-eth-personal "1.2.11" + web3-net "1.2.11" + web3-utils "1.2.11" + +web3-eth@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-1.2.2.tgz#65a1564634a23b990efd1655bf94ad513904286c" + integrity sha512-UXpC74mBQvZzd4b+baD4Ocp7g+BlwxhBHumy9seyE/LMIcMlePXwCKzxve9yReNpjaU16Mmyya6ZYlyiKKV8UA== + dependencies: + underscore "1.9.1" + web3-core "1.2.2" + web3-core-helpers "1.2.2" + web3-core-method "1.2.2" + web3-core-subscriptions "1.2.2" + web3-eth-abi "1.2.2" + web3-eth-accounts "1.2.2" + web3-eth-contract "1.2.2" + web3-eth-ens "1.2.2" + web3-eth-iban "1.2.2" + web3-eth-personal "1.2.2" + web3-net "1.2.2" + web3-utils "1.2.2" + +web3-eth@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-1.2.4.tgz#24c3b1f1ac79351bbfb808b2ab5c585fa57cdd00" + integrity sha512-+j+kbfmZsbc3+KJpvHM16j1xRFHe2jBAniMo1BHKc3lho6A8Sn9Buyut6odubguX2AxoRArCdIDCkT9hjUERpA== + dependencies: + underscore "1.9.1" + web3-core "1.2.4" + web3-core-helpers "1.2.4" + web3-core-method "1.2.4" + web3-core-subscriptions "1.2.4" + web3-eth-abi "1.2.4" + web3-eth-accounts "1.2.4" + web3-eth-contract "1.2.4" + web3-eth-ens "1.2.4" + web3-eth-iban "1.2.4" + web3-eth-personal "1.2.4" + web3-net "1.2.4" + web3-utils "1.2.4" + +web3-eth@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-eth/-/web3-eth-1.3.6.tgz#2c650893d540a7a0eb1365dd5b2dca24ac919b7c" + integrity sha512-9+rnywRRpyX3C4hfsAQXPQh6vHh9XzQkgLxo3gyeXfbhbShUoq2gFVuy42vsRs//6JlsKdyZS7Z3hHPHz2wreA== + dependencies: + underscore "1.12.1" + web3-core "1.3.6" + web3-core-helpers "1.3.6" + web3-core-method "1.3.6" + web3-core-subscriptions "1.3.6" + web3-eth-abi "1.3.6" + web3-eth-accounts "1.3.6" + web3-eth-contract "1.3.6" + web3-eth-ens "1.3.6" + web3-eth-iban "1.3.6" + web3-eth-personal "1.3.6" + web3-net "1.3.6" + web3-utils "1.3.6" + +web3-net@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-net/-/web3-net-1.2.11.tgz#eda68ef25e5cdb64c96c39085cdb74669aabbe1b" + integrity sha512-sjrSDj0pTfZouR5BSTItCuZ5K/oZPVdVciPQ6981PPPIwJJkCMeVjD7I4zO3qDPCnBjBSbWvVnLdwqUBPtHxyg== + dependencies: + web3-core "1.2.11" + web3-core-method "1.2.11" + web3-utils "1.2.11" + +web3-net@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-net/-/web3-net-1.2.2.tgz#5c3226ca72df7c591422440ce6f1203fd42ddad9" + integrity sha512-K07j2DXq0x4UOJgae65rWZKraOznhk8v5EGSTdFqASTx7vWE/m+NqBijBYGEsQY1lSMlVaAY9UEQlcXK5HzXTw== + dependencies: + web3-core "1.2.2" + web3-core-method "1.2.2" + web3-utils "1.2.2" + +web3-net@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-net/-/web3-net-1.2.4.tgz#1d246406d3aaffbf39c030e4e98bce0ca5f25458" + integrity sha512-wKOsqhyXWPSYTGbp7ofVvni17yfRptpqoUdp3SC8RAhDmGkX6irsiT9pON79m6b3HUHfLoBilFQyt/fTUZOf7A== + dependencies: + web3-core "1.2.4" + web3-core-method "1.2.4" + web3-utils "1.2.4" + +web3-net@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-net/-/web3-net-1.3.6.tgz#a56492e2227475e38db29394f8bac305a2446e41" + integrity sha512-KhzU3wMQY/YYjyMiQzbaLPt2kut88Ncx2iqjy3nw28vRux3gVX0WOCk9EL/KVJBiAA/fK7VklTXvgy9dZnnipw== + dependencies: + web3-core "1.3.6" + web3-core-method "1.3.6" + web3-utils "1.3.6" + +web3-provider-engine@14.2.1: + version "14.2.1" + resolved "https://registry.yarnpkg.com/web3-provider-engine/-/web3-provider-engine-14.2.1.tgz#ef351578797bf170e08d529cb5b02f8751329b95" + integrity sha512-iSv31h2qXkr9vrL6UZDm4leZMc32SjWJFGOp/D92JXfcEboCqraZyuExDkpxKw8ziTufXieNM7LSXNHzszYdJw== + dependencies: + async "^2.5.0" + backoff "^2.5.0" + clone "^2.0.0" + cross-fetch "^2.1.0" + eth-block-tracker "^3.0.0" + eth-json-rpc-infura "^3.1.0" + eth-sig-util "^1.4.2" + ethereumjs-block "^1.2.2" + ethereumjs-tx "^1.2.0" + ethereumjs-util "^5.1.5" + ethereumjs-vm "^2.3.4" + json-rpc-error "^2.0.0" + json-stable-stringify "^1.0.1" + promise-to-callback "^1.0.0" + readable-stream "^2.2.9" + request "^2.85.0" + semaphore "^1.0.3" + ws "^5.1.1" + xhr "^2.2.0" + xtend "^4.0.1" + +web3-providers-http@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-providers-http/-/web3-providers-http-1.2.11.tgz#1cd03442c61670572d40e4dcdf1faff8bd91e7c6" + integrity sha512-psh4hYGb1+ijWywfwpB2cvvOIMISlR44F/rJtYkRmQ5jMvG4FOCPlQJPiHQZo+2cc3HbktvvSJzIhkWQJdmvrA== + dependencies: + web3-core-helpers "1.2.11" + xhr2-cookies "1.1.0" + +web3-providers-http@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-providers-http/-/web3-providers-http-1.2.2.tgz#155e55c1d69f4c5cc0b411ede40dea3d06720956" + integrity sha512-BNZ7Hguy3eBszsarH5gqr9SIZNvqk9eKwqwmGH1LQS1FL3NdoOn7tgPPdddrXec4fL94CwgNk4rCU+OjjZRNDg== + dependencies: + web3-core-helpers "1.2.2" + xhr2-cookies "1.1.0" + +web3-providers-http@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-providers-http/-/web3-providers-http-1.2.4.tgz#514fcad71ae77832c2c15574296282fbbc5f4a67" + integrity sha512-dzVCkRrR/cqlIrcrWNiPt9gyt0AZTE0J+MfAu9rR6CyIgtnm1wFUVVGaxYRxuTGQRO4Dlo49gtoGwaGcyxqiTw== + dependencies: + web3-core-helpers "1.2.4" + xhr2-cookies "1.1.0" + +web3-providers-http@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-providers-http/-/web3-providers-http-1.3.6.tgz#36e8724a7424d52827819d53fd75dbf31f5422c2" + integrity sha512-OQkT32O1A06dISIdazpGLveZcOXhEo5cEX6QyiSQkiPk/cjzDrXMw4SKZOGQbbS1+0Vjizm1Hrp7O8Vp2D1M5Q== + dependencies: + web3-core-helpers "1.3.6" + xhr2-cookies "1.1.0" + +web3-providers-ipc@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-providers-ipc/-/web3-providers-ipc-1.2.11.tgz#d16d6c9be1be6e0b4f4536c4acc16b0f4f27ef21" + integrity sha512-yhc7Y/k8hBV/KlELxynWjJDzmgDEDjIjBzXK+e0rHBsYEhdCNdIH5Psa456c+l0qTEU2YzycF8VAjYpWfPnBpQ== + dependencies: + oboe "2.1.4" + underscore "1.9.1" + web3-core-helpers "1.2.11" + +web3-providers-ipc@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-providers-ipc/-/web3-providers-ipc-1.2.2.tgz#c6d165a12bc68674b4cdd543ea18aec79cafc2e8" + integrity sha512-t97w3zi5Kn/LEWGA6D9qxoO0LBOG+lK2FjlEdCwDQatffB/+vYrzZ/CLYVQSoyFZAlsDoBasVoYSWZK1n39aHA== + dependencies: + oboe "2.1.4" + underscore "1.9.1" + web3-core-helpers "1.2.2" + +web3-providers-ipc@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-providers-ipc/-/web3-providers-ipc-1.2.4.tgz#9d6659f8d44943fb369b739f48df09092be459bd" + integrity sha512-8J3Dguffin51gckTaNrO3oMBo7g+j0UNk6hXmdmQMMNEtrYqw4ctT6t06YOf9GgtOMjSAc1YEh3LPrvgIsR7og== + dependencies: + oboe "2.1.4" + underscore "1.9.1" + web3-core-helpers "1.2.4" + +web3-providers-ipc@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-providers-ipc/-/web3-providers-ipc-1.3.6.tgz#cef8d12c1ebb47adce5ebf597f553c623362cb4a" + integrity sha512-+TVsSd2sSVvVgHG4s6FXwwYPPT91boKKcRuEFXqEfAbUC5t52XOgmyc2LNiD9LzPhed65FbV4LqICpeYGUvSwA== + dependencies: + oboe "2.1.5" + underscore "1.12.1" + web3-core-helpers "1.3.6" + +web3-providers-ws@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-1.2.11.tgz#a1dfd6d9778d840561d9ec13dd453046451a96bb" + integrity sha512-ZxnjIY1Er8Ty+cE4migzr43zA/+72AF1myzsLaU5eVgdsfV7Jqx7Dix1hbevNZDKFlSoEyq/3j/jYalh3So1Zg== + dependencies: + eventemitter3 "4.0.4" + underscore "1.9.1" + web3-core-helpers "1.2.11" + websocket "^1.0.31" + +web3-providers-ws@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-1.2.2.tgz#d2c05c68598cea5ad3fa6ef076c3bcb3ca300d29" + integrity sha512-Wb1mrWTGMTXOpJkL0yGvL/WYLt8fUIXx8k/l52QB2IiKzvyd42dTWn4+j8IKXGSYYzOm7NMqv6nhA5VDk12VfA== + dependencies: + underscore "1.9.1" + web3-core-helpers "1.2.2" + websocket "github:web3-js/WebSocket-Node#polyfill/globalThis" + +web3-providers-ws@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-1.2.4.tgz#099ee271ee03f6ea4f5df9cfe969e83f4ce0e36f" + integrity sha512-F/vQpDzeK+++oeeNROl1IVTufFCwCR2hpWe5yRXN0ApLwHqXrMI7UwQNdJ9iyibcWjJf/ECbauEEQ8CHgE+MYQ== + dependencies: + "@web3-js/websocket" "^1.0.29" + underscore "1.9.1" + web3-core-helpers "1.2.4" + +web3-providers-ws@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-providers-ws/-/web3-providers-ws-1.3.6.tgz#e1df617bc89d66165abdf2191da0014c505bfaac" + integrity sha512-bk7MnJf5or0Re2zKyhR3L3CjGululLCHXx4vlbc/drnaTARUVvi559OI5uLytc/1k5HKUUyENAxLvetz2G1dnQ== + dependencies: + eventemitter3 "4.0.4" + underscore "1.12.1" + web3-core-helpers "1.3.6" + websocket "^1.0.32" + +web3-shh@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-shh/-/web3-shh-1.2.11.tgz#f5d086f9621c9a47e98d438010385b5f059fd88f" + integrity sha512-B3OrO3oG1L+bv3E1sTwCx66injW1A8hhwpknDUbV+sw3fehFazA06z9SGXUefuFI1kVs4q2vRi0n4oCcI4dZDg== + dependencies: + web3-core "1.2.11" + web3-core-method "1.2.11" + web3-core-subscriptions "1.2.11" + web3-net "1.2.11" + +web3-shh@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-shh/-/web3-shh-1.2.2.tgz#44ed998f2a6ba0ec5cb9d455184a0f647826a49c" + integrity sha512-og258NPhlBn8yYrDWjoWBBb6zo1OlBgoWGT+LL5/LPqRbjPe09hlOYHgscAAr9zZGtohTOty7RrxYw6Z6oDWCg== + dependencies: + web3-core "1.2.2" + web3-core-method "1.2.2" + web3-core-subscriptions "1.2.2" + web3-net "1.2.2" + +web3-shh@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-shh/-/web3-shh-1.2.4.tgz#5c8ff5ab624a3b14f08af0d24d2b16c10e9f70dd" + integrity sha512-z+9SCw0dE+69Z/Hv8809XDbLj7lTfEv9Sgu8eKEIdGntZf4v7ewj5rzN5bZZSz8aCvfK7Y6ovz1PBAu4QzS4IQ== + dependencies: + web3-core "1.2.4" + web3-core-method "1.2.4" + web3-core-subscriptions "1.2.4" + web3-net "1.2.4" + +web3-shh@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-shh/-/web3-shh-1.3.6.tgz#4e3486c7eca5cbdb87f88910948223a5b7ea6c20" + integrity sha512-9zRo415O0iBslxBnmu9OzYjNErzLnzOsy+IOvSpIreLYbbAw0XkDWxv3SfcpKnTIWIACBR4AYMIxmmyi5iB3jw== + dependencies: + web3-core "1.3.6" + web3-core-method "1.3.6" + web3-core-subscriptions "1.3.6" + web3-net "1.3.6" + +web3-utils@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.2.11.tgz#af1942aead3fb166ae851a985bed8ef2c2d95a82" + integrity sha512-3Tq09izhD+ThqHEaWYX4VOT7dNPdZiO+c/1QMA0s5X2lDFKK/xHJb7cyTRRVzN2LvlHbR7baS1tmQhSua51TcQ== + dependencies: + bn.js "^4.11.9" + eth-lib "0.2.8" + ethereum-bloom-filters "^1.0.6" + ethjs-unit "0.1.6" + number-to-bn "1.7.0" + randombytes "^2.1.0" + underscore "1.9.1" + utf8 "3.0.0" + +web3-utils@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.2.2.tgz#b53a08c40d2c3f31d3c4a28e7d749405df99c8c0" + integrity sha512-joF+s3243TY5cL7Z7y4h1JsJpUCf/kmFmj+eJar7Y2yNIGVcW961VyrAms75tjUysSuHaUQ3eQXjBEUJueT52A== + dependencies: + bn.js "4.11.8" + eth-lib "0.2.7" + ethereum-bloom-filters "^1.0.6" + ethjs-unit "0.1.6" + number-to-bn "1.7.0" + randombytes "^2.1.0" + underscore "1.9.1" + utf8 "3.0.0" + +web3-utils@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.2.4.tgz#96832a39a66b05bf8862a5b0bdad2799d709d951" + integrity sha512-+S86Ip+jqfIPQWvw2N/xBQq5JNqCO0dyvukGdJm8fEWHZbckT4WxSpHbx+9KLEWY4H4x9pUwnoRkK87pYyHfgQ== + dependencies: + bn.js "4.11.8" + eth-lib "0.2.7" + ethereum-bloom-filters "^1.0.6" + ethjs-unit "0.1.6" + number-to-bn "1.7.0" + randombytes "^2.1.0" + underscore "1.9.1" + utf8 "3.0.0" + +web3-utils@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.3.6.tgz#390bc9fa3a7179746963cfaca55bb80ac4d8dc10" + integrity sha512-hHatFaQpkQgjGVER17gNx8u1qMyaXFZtM0y0XLGH1bzsjMPlkMPLRcYOrZ00rOPfTEuYFOdrpGOqZXVmGrMZRg== + dependencies: + bn.js "^4.11.9" + eth-lib "0.2.8" + ethereum-bloom-filters "^1.0.6" + ethjs-unit "0.1.6" + number-to-bn "1.7.0" + randombytes "^2.1.0" + underscore "1.12.1" + utf8 "3.0.0" + +web3-utils@^1.0.0-beta.31: + version "1.9.0" + resolved "https://registry.yarnpkg.com/web3-utils/-/web3-utils-1.9.0.tgz#7c5775a47586cefb4ad488831be8f6627be9283d" + integrity sha512-p++69rCNNfu2jM9n5+VD/g26l+qkEOQ1m6cfRQCbH8ZRrtquTmrirJMgTmyOoax5a5XRYOuws14aypCOs51pdQ== + dependencies: + bn.js "^5.2.1" + ethereum-bloom-filters "^1.0.6" + ethereumjs-util "^7.1.0" + ethjs-unit "0.1.6" + number-to-bn "1.7.0" + randombytes "^2.1.0" + utf8 "3.0.0" + +web3@1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/web3/-/web3-1.2.11.tgz#50f458b2e8b11aa37302071c170ed61cff332975" + integrity sha512-mjQ8HeU41G6hgOYm1pmeH0mRAeNKJGnJEUzDMoerkpw7QUQT4exVREgF1MYPvL/z6vAshOXei25LE/t/Bxl8yQ== + dependencies: + web3-bzz "1.2.11" + web3-core "1.2.11" + web3-eth "1.2.11" + web3-eth-personal "1.2.11" + web3-net "1.2.11" + web3-shh "1.2.11" + web3-utils "1.2.11" + +web3@1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/web3/-/web3-1.2.2.tgz#b1b8b69aafdf94cbaeadbb68a8aa1df2ef266aec" + integrity sha512-/ChbmB6qZpfGx6eNpczt5YSUBHEA5V2+iUCbn85EVb3Zv6FVxrOo5Tv7Lw0gE2tW7EEjASbCyp3mZeiZaCCngg== + dependencies: + "@types/node" "^12.6.1" + web3-bzz "1.2.2" + web3-core "1.2.2" + web3-eth "1.2.2" + web3-eth-personal "1.2.2" + web3-net "1.2.2" + web3-shh "1.2.2" + web3-utils "1.2.2" + +web3@1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/web3/-/web3-1.2.4.tgz#6e7ab799eefc9b4648c2dab63003f704a1d5e7d9" + integrity sha512-xPXGe+w0x0t88Wj+s/dmAdASr3O9wmA9mpZRtixGZxmBexAF0MjfqYM+MS4tVl5s11hMTN3AZb8cDD4VLfC57A== + dependencies: + "@types/node" "^12.6.1" + web3-bzz "1.2.4" + web3-core "1.2.4" + web3-eth "1.2.4" + web3-eth-personal "1.2.4" + web3-net "1.2.4" + web3-shh "1.2.4" + web3-utils "1.2.4" + +web3@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/web3/-/web3-1.3.6.tgz#599425461c3f9a8cbbefa70616438995f4a064cc" + integrity sha512-jEpPhnL6GDteifdVh7ulzlPrtVQeA30V9vnki9liYlUvLV82ZM7BNOQJiuzlDePuE+jZETZSP/0G/JlUVt6pOA== + dependencies: + web3-bzz "1.3.6" + web3-core "1.3.6" + web3-eth "1.3.6" + web3-eth-personal "1.3.6" + web3-net "1.3.6" + web3-shh "1.3.6" + web3-utils "1.3.6" + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +websocket@1.0.32: + version "1.0.32" + resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.32.tgz#1f16ddab3a21a2d929dec1687ab21cfdc6d3dbb1" + integrity sha512-i4yhcllSP4wrpoPMU2N0TQ/q0O94LRG/eUQjEAamRltjQ1oT1PFFKOG4i877OlJgCG8rw6LrrowJp+TYCEWF7Q== + dependencies: + bufferutil "^4.0.1" + debug "^2.2.0" + es5-ext "^0.10.50" + typedarray-to-buffer "^3.1.5" + utf-8-validate "^5.0.2" + yaeti "^0.0.6" + +websocket@^1.0.31, websocket@^1.0.32: + version "1.0.34" + resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.34.tgz#2bdc2602c08bf2c82253b730655c0ef7dcab3111" + integrity sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ== + dependencies: + bufferutil "^4.0.1" + debug "^2.2.0" + es5-ext "^0.10.50" + typedarray-to-buffer "^3.1.5" + utf-8-validate "^5.0.2" + yaeti "^0.0.6" + +"websocket@github:web3-js/WebSocket-Node#polyfill/globalThis": + version "1.0.29" + resolved "https://codeload.github.com/web3-js/WebSocket-Node/tar.gz/ef5ea2f41daf4a2113b80c9223df884b4d56c400" + dependencies: + debug "^2.2.0" + es5-ext "^0.10.50" + nan "^2.14.0" + typedarray-to-buffer "^3.1.5" + yaeti "^0.0.6" + +whatwg-fetch@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb" + integrity sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q== + +whatwg-fetch@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" + integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + +which-boxed-primitive@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6" + integrity sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg== + dependencies: + is-bigint "^1.0.1" + is-boolean-object "^1.1.0" + is-number-object "^1.0.4" + is-string "^1.0.5" + is-symbol "^1.0.3" + +which-collection@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/which-collection/-/which-collection-1.0.1.tgz#70eab71ebbbd2aefaf32f917082fc62cdcb70906" + integrity sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A== + dependencies: + is-map "^2.0.1" + is-set "^2.0.1" + is-weakmap "^2.0.1" + is-weakset "^2.0.1" + +which-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f" + integrity sha512-F6+WgncZi/mJDrammbTuHe1q0R5hOXv/mBaiNA2TCNT/LTHusX0V+CJnj9XT8ki5ln2UZyyddDgHfCzyrOH7MQ== + +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + integrity sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q== + +which-typed-array@^1.1.2, which-typed-array@^1.1.9: + version "1.1.9" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.9.tgz#307cf898025848cf995e795e8423c7f337efbde6" + integrity sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + gopd "^1.0.1" + has-tostringtag "^1.0.0" + is-typed-array "^1.1.10" + +which@1.3.1, which@^1.2.9: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +wide-align@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" + integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== + dependencies: + string-width "^1.0.2 || 2" + +wif@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/wif/-/wif-2.0.6.tgz#08d3f52056c66679299726fade0d432ae74b4704" + integrity sha512-HIanZn1zmduSF+BQhkE+YXIbEiH0xPr1012QbFEGB0xsKqJii0/SqJjyn8dFv6y36kOznMgMB+LGcbZTJ1xACQ== + dependencies: + bs58check "<3.0.0" + +window-size@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.2.0.tgz#b4315bb4214a3d7058ebeee892e13fa24d98b075" + integrity sha512-UD7d8HFA2+PZsbKyaOCEy8gMh1oDtHgJh1LfgjQ4zVXmYjAT/kvz3PueITKuqDiIXQe7yzpPnxX3lNc+AhQMyw== + +word-wrap@^1.2.3, word-wrap@~1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" + integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== + +wordwrapjs@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.1.tgz#d9790bccfb110a0fc7836b5ebce0937b37a8b98f" + integrity sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA== + dependencies: + reduce-flatten "^2.0.0" + typical "^5.2.0" + +workerpool@6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" + integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== + +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + integrity sha512-vAaEaDM946gbNpH5pLVNR+vX2ht6n0Bt3GXwVB1AuAqZosOvHNF3P7wDnh8KLkSqgUh0uh77le7Owgoz+Z9XBw== + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + dependencies: + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +write@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" + integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== + dependencies: + mkdirp "^0.5.1" + +ws@7.4.6: + version "7.4.6" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" + integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== + +ws@^3.0.0: + version "3.3.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" + integrity sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA== + dependencies: + async-limiter "~1.0.0" + safe-buffer "~5.1.0" + ultron "~1.1.0" + +ws@^5.1.1: + version "5.2.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-5.2.3.tgz#05541053414921bc29c63bee14b8b0dd50b07b3d" + integrity sha512-jZArVERrMsKUatIdnLzqvcfydI85dvd/Fp1u/VOpfdDWQ4c9qWXe+VIeAbQ5FrDwciAkr+lzofXLz3Kuf26AOA== + dependencies: + async-limiter "~1.0.0" + +ws@^7.4.6: + version "7.5.9" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" + integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q== + +xhr-request-promise@^0.1.2: + version "0.1.3" + resolved "https://registry.yarnpkg.com/xhr-request-promise/-/xhr-request-promise-0.1.3.tgz#2d5f4b16d8c6c893be97f1a62b0ed4cf3ca5f96c" + integrity sha512-YUBytBsuwgitWtdRzXDDkWAXzhdGB8bYm0sSzMPZT7Z2MBjMSTHFsyCT1yCRATY+XC69DUrQraRAEgcoCRaIPg== + dependencies: + xhr-request "^1.1.0" + +xhr-request@^1.0.1, xhr-request@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/xhr-request/-/xhr-request-1.1.0.tgz#f4a7c1868b9f198723444d82dcae317643f2e2ed" + integrity sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA== + dependencies: + buffer-to-arraybuffer "^0.0.5" + object-assign "^4.1.1" + query-string "^5.0.1" + simple-get "^2.7.0" + timed-out "^4.0.1" + url-set-query "^1.0.0" + xhr "^2.0.4" + +xhr2-cookies@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/xhr2-cookies/-/xhr2-cookies-1.1.0.tgz#7d77449d0999197f155cb73b23df72505ed89d48" + integrity sha512-hjXUA6q+jl/bd8ADHcVfFsSPIf+tyLIjuO9TwJC9WI6JP2zKcS7C+p56I9kCLLsaCiNT035iYvEUUzdEFj/8+g== + dependencies: + cookiejar "^2.1.1" + +xhr@^2.0.4, xhr@^2.2.0, xhr@^2.3.3: + version "2.6.0" + resolved "https://registry.yarnpkg.com/xhr/-/xhr-2.6.0.tgz#b69d4395e792b4173d6b7df077f0fc5e4e2b249d" + integrity sha512-/eCGLb5rxjx5e3mF1A7s+pLlR6CGyqWN91fv1JgER5mVWg1MZmlhBvy9kjcsOdRk8RrIujotWyJamfyrp+WIcA== + dependencies: + global "~4.4.0" + is-function "^1.0.1" + parse-headers "^2.0.0" + xtend "^4.0.0" + +xmlhttprequest@1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc" + integrity sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA== + +xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.0, xtend@~4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + +xtend@~2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-2.1.2.tgz#6efecc2a4dad8e6962c4901b337ce7ba87b5d28b" + integrity sha512-vMNKzr2rHP9Dp/e1NQFnLQlwlhp9L/LfvnsVdHxN1f+uggyVI3i08uD14GPvCToPkdsRfyPqIyYGmIk58V98ZQ== + dependencies: + object-keys "~0.4.0" + +y18n@^3.2.1: + version "3.2.2" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.2.tgz#85c901bd6470ce71fc4bb723ad209b70f7f28696" + integrity sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ== + +y18n@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.3.tgz#b5f259c82cd6e336921efd7bfd8bf560de9eeedf" + integrity sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ== + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yaeti@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/yaeti/-/yaeti-0.0.6.tgz#f26f484d72684cf42bedfb76970aa1608fbf9577" + integrity sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug== + +yallist@^3.0.0, yallist@^3.0.2, yallist@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yaml@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" + integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== + +yargs-parser@13.1.2, yargs-parser@^13.1.2: + version "13.1.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-2.4.1.tgz#85568de3cf150ff49fa51825f03a8c880ddcc5c4" + integrity sha512-9pIKIJhnI5tonzG6OnCFlz/yln8xHYcGl+pn3xR0Vzff0vzN1PbNRaelgfgRUwZ3s4i3jvxT9WhmUGL4whnasA== + dependencies: + camelcase "^3.0.0" + lodash.assign "^4.0.6" + +yargs-parser@^20.2.2: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + +yargs-unparser@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.6.0.tgz#ef25c2c769ff6bd09e4b0f9d7c605fb27846ea9f" + integrity sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw== + dependencies: + flat "^4.1.0" + lodash "^4.17.15" + yargs "^13.3.0" + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@13.3.2, yargs@^13.3.0: + version "13.3.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.3.2.tgz#ad7ffefec1aa59565ac915f82dccb38a9c31a2dd" + integrity sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.2" + +yargs@16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yargs@^4.7.1: + version "4.8.1" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-4.8.1.tgz#c0c42924ca4aaa6b0e6da1739dfb216439f9ddc0" + integrity sha512-LqodLrnIDM3IFT+Hf/5sxBnEGECrfdC1uIbgZeJmESCSo4HoCAaKEus8MylXHAkdacGc0ye+Qa+dpkuom8uVYA== + dependencies: + cliui "^3.2.0" + decamelize "^1.1.1" + get-caller-file "^1.0.1" + lodash.assign "^4.0.3" + os-locale "^1.4.0" + read-pkg-up "^1.0.1" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^1.0.1" + which-module "^1.0.0" + window-size "^0.2.0" + y18n "^3.2.1" + yargs-parser "^2.4.1" + +yauzl@^2.4.2: + version "2.10.0" + resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9" + integrity sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g== + dependencies: + buffer-crc32 "~0.2.3" + fd-slicer "~1.1.0" + +yn@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" + integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + +zksync-web3@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/zksync-web3/-/zksync-web3-0.8.1.tgz#db289d8f6caf61f4d5ddc471fa3448d93208dc14" + integrity sha512-1A4aHPQ3MyuGjpv5X/8pVEN+MdZqMjfVmiweQSRjOlklXYu65wT9BGEOtCmMs5d3gIvLp4ssfTeuR5OCKOD2kw== From ee212eff395b3a1c3c1b977700a79ead4094289c Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 27 Jul 2023 20:13:49 +0200 Subject: [PATCH 019/205] Setting baseWormholeTBTC address after it was registered in Portal --- cross-chain/base/external/baseGoerli/BaseWormholeTBTC.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-chain/base/external/baseGoerli/BaseWormholeTBTC.json b/cross-chain/base/external/baseGoerli/BaseWormholeTBTC.json index d8483e704..646be6e84 100644 --- a/cross-chain/base/external/baseGoerli/BaseWormholeTBTC.json +++ b/cross-chain/base/external/baseGoerli/BaseWormholeTBTC.json @@ -1,3 +1,3 @@ { - "address": "0x5D89a5BcB86F15a2CCAb05e7E3bEE23fDF246a64" + "address": "0x0219441240d89fac3fd708d06d8fd3a072c02fb6" } From 05e0f2be7a6c891461e4cf4d28d071480c7da122 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 28 Jul 2023 17:04:40 +0200 Subject: [PATCH 020/205] Updating README and seeting dependency tags --- cross-chain/base/README.adoc | 4 ++-- .../13_update_with_arbitrum_in_wormhole_gateway_mapping.ts | 2 +- .../14_update_with_polygon_in_wormhole_gateway_mapping.ts | 2 +- .../15_update_with_optimism_in_wormhole_gateway_mapping.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cross-chain/base/README.adoc b/cross-chain/base/README.adoc index bb33b7545..cc95d56a3 100644 --- a/cross-chain/base/README.adoc +++ b/cross-chain/base/README.adoc @@ -27,7 +27,7 @@ Wormhole-specific tBTC representation into the canonical `BaseTBTC` token. The deployment scripts are responsible for managing updates of the tBTC gateway addresses across various chains. These addresses are stored in the `external/` -directory for a specific network, such as `arbitrumGoerli/ArbitrumWormholeGateway.json.` +directory for a specific network. It is important to note that these addresses should remain constant for the mainnet network. However, there may be instances where a new version of a cross-chain module is deployed to the testing network, which would require a @@ -54,6 +54,6 @@ the contracts before running the deployment script. This command produces an `export.json` file containing contract deployment info. Note that for the chains other than `hardhat` the following environment variables are needed: -- `L2_CHAIN_API_URL` - URL to access blockchain services, e.g. `https://opt-goerli.g.alchemy.com/v2/` +- `L2_CHAIN_API_URL` - URL to access blockchain services, e.g. `https://goerli.base.org` - `L2_ACCOUNTS_PRIVATE_KEYS` - Private keys for the deployer and council `<0xOwnerPrivKey,0xCouncilPrivKey>` - `BASESCAN_API_KEY` - Base Etherscan API key diff --git a/cross-chain/base/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts index fd7788645..e80738989 100644 --- a/cross-chain/base/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts +++ b/cross-chain/base/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts @@ -38,4 +38,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { export default func func.tags = ["SetArbitrumGatewayAddress"] -func.dependencies = ["BaseWormholeGateway"] +func.dependencies = ["BaseWormholeGateway", "ArbitrumWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/14_update_with_polygon_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/14_update_with_polygon_in_wormhole_gateway_mapping.ts index 69f4659df..7d4f38a70 100644 --- a/cross-chain/base/deploy_l2/14_update_with_polygon_in_wormhole_gateway_mapping.ts +++ b/cross-chain/base/deploy_l2/14_update_with_polygon_in_wormhole_gateway_mapping.ts @@ -36,4 +36,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { export default func func.tags = ["SetPolygonGatewayAddress"] -func.dependencies = ["BaseWormholeGateway"] +func.dependencies = ["BaseWormholeGateway", "PolygonWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/15_update_with_optimism_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/15_update_with_optimism_in_wormhole_gateway_mapping.ts index fb2b61d9f..09dd489ff 100644 --- a/cross-chain/base/deploy_l2/15_update_with_optimism_in_wormhole_gateway_mapping.ts +++ b/cross-chain/base/deploy_l2/15_update_with_optimism_in_wormhole_gateway_mapping.ts @@ -38,4 +38,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { export default func func.tags = ["SetOptimismGatewayAddress"] -func.dependencies = ["BaseWormholeGateway"] +func.dependencies = ["BaseWormholeGateway", "OptimismWormholeGateway"] From 765c5d6d11c8958f892d7a767ac2218fa193379a Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 28 Jul 2023 17:05:23 +0200 Subject: [PATCH 021/205] Setting 0x0 as a placeholder for baseWormholeTBTC once it is deployed --- cross-chain/base/external/base/BaseWormholeTBTC.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-chain/base/external/base/BaseWormholeTBTC.json b/cross-chain/base/external/base/BaseWormholeTBTC.json index b13fbf0fc..27a670f17 100644 --- a/cross-chain/base/external/base/BaseWormholeTBTC.json +++ b/cross-chain/base/external/base/BaseWormholeTBTC.json @@ -1,3 +1,3 @@ { - "address": "0xeC0a755664271b87002dDa33CA2484B24aF68912" + "address": "0x0" } From 7976e64530c2145f99656798b575ecd1e85462d6 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Mon, 31 Jul 2023 14:39:22 +0200 Subject: [PATCH 022/205] Don't pass constructor params for BaseWormholeGateway verification The implementation contract was failing basescan verification unless the constructor params were empty. --- cross-chain/base/deploy_l2/02_deploy_base_wormhole_gateway.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-chain/base/deploy_l2/02_deploy_base_wormhole_gateway.ts b/cross-chain/base/deploy_l2/02_deploy_base_wormhole_gateway.ts index 2cb5e2548..7d5e64147 100644 --- a/cross-chain/base/deploy_l2/02_deploy_base_wormhole_gateway.ts +++ b/cross-chain/base/deploy_l2/02_deploy_base_wormhole_gateway.ts @@ -56,7 +56,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // link the proxy to the implementation contract’s ABI on (Ether)scan. await hre.run("verify", { address: proxyDeployment.address, - constructorArgsParams: proxyDeployment.args, + constructorArgsParams: [], }) } } From ffe38186aae1d9bec664d63d6a04d83eafa2a23d Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Mon, 31 Jul 2023 14:40:34 +0200 Subject: [PATCH 023/205] Remove upgrade script We don't use this script currently so there is no need to push it. --- .../31_upgrade_base_wormhole_gateway.ts | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 cross-chain/base/deploy_l2/31_upgrade_base_wormhole_gateway.ts diff --git a/cross-chain/base/deploy_l2/31_upgrade_base_wormhole_gateway.ts b/cross-chain/base/deploy_l2/31_upgrade_base_wormhole_gateway.ts deleted file mode 100644 index d5a09751b..000000000 --- a/cross-chain/base/deploy_l2/31_upgrade_base_wormhole_gateway.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { HardhatRuntimeEnvironment } from "hardhat/types" -import type { DeployFunction } from "hardhat-deploy/types" - -const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { ethers, getNamedAccounts, helpers, deployments } = hre - const { deployer } = await getNamedAccounts() - - const BaseTokenBridge = await deployments.get("BaseTokenBridge") - const BaseWormholeTBTC = await deployments.get("BaseWormholeTBTC") - const BaseTBTC = await deployments.get("BaseTBTC") - - const [, proxyDeployment] = await helpers.upgrades.upgradeProxy( - "BaseWormholeGateway", - "BaseWormholeGateway", - { - contractName: - "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:L2WormholeGateway", - initializerArgs: [ - BaseTokenBridge.address, - BaseWormholeTBTC.address, - BaseTBTC.address, - ], - factoryOpts: { signer: await ethers.getSigner(deployer) }, - proxyOpts: { - kind: "transparent", - }, - } - ) - - // Contracts can be verified on L2 Base Etherscan in a similar way as we do - // it on L1 Etherscan - if (hre.network.tags.basescan) { - // We use `verify` instead of `verify:verify` as the `verify` task is defined - // in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation - // contract, the proxy itself and any proxy-related contracts, as well as - // link the proxy to the implementation contract’s ABI on (Ether)scan. - await hre.run("verify", { - address: proxyDeployment.address, - constructorArgsParams: proxyDeployment.args, - }) - } -} - -export default func - -func.tags = ["UpgradeBaseWormholeGateway"] - -// Comment this line when running an upgrade. -// yarn deploy --tags UpgradeBaseWormholeGateway --network -func.skip = async () => true From 1a8fa10b1f4ab299ef1bee46599beaf700f0b955 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Mon, 31 Jul 2023 14:51:48 +0200 Subject: [PATCH 024/205] Comment out hardcoded gasPrice Most of the transactions pass without gasPrice parameter. We need to set it in case we have problems. --- cross-chain/base/hardhat.config.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cross-chain/base/hardhat.config.ts b/cross-chain/base/hardhat.config.ts index 5778ad859..8cd0291db 100644 --- a/cross-chain/base/hardhat.config.ts +++ b/cross-chain/base/hardhat.config.ts @@ -61,7 +61,9 @@ const config: HardhatUserConfig = { ? process.env.L2_ACCOUNTS_PRIVATE_KEYS.split(",") : undefined, tags: ["basescan"], - gasPrice: 1000000000, + // In case of deployment failing with underpriced transaction error set + // the `gasPrice` parameter. + // gasPrice: 1000000000, // companionNetworks: { // l1: "goerli", // }, @@ -74,7 +76,9 @@ const config: HardhatUserConfig = { ? process.env.L2_ACCOUNTS_PRIVATE_KEYS.split(",") : undefined, tags: ["basescan"], - gasPrice: 1000000000, + // In case of deployment failing with underpriced transaction error set + // the `gasPrice` parameter. + // gasPrice: 1000000000, // companionNetworks: { // l1: "mainnet", // }, From 642e60a3c504eff74caaa04b506ccb623e2a5878 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Mon, 31 Jul 2023 16:06:36 +0100 Subject: [PATCH 025/205] Restructure solana files --- cross-chain/solana/.yarnrc.yml | 1 + cross-chain/solana/package-lock.json | 1947 +++++++++++++++++ cross-chain/solana/programs/tbtc/Cargo.toml | 2 +- .../solana/programs/tbtc/src/constants.rs | 4 + cross-chain/solana/programs/tbtc/src/error.rs | 8 + cross-chain/solana/programs/tbtc/src/event.rs | 21 + cross-chain/solana/programs/tbtc/src/lib.rs | 379 +--- .../tbtc/src/processor/admin/add_guardian.rs | 36 + .../tbtc/src/processor/admin/add_minter.rs | 36 + .../src/processor/admin/change_authority.rs | 23 + .../tbtc/src/processor/admin/initialize.rs | 47 + .../programs/tbtc/src/processor/admin/mod.rs | 17 + .../tbtc/src/processor/admin/pause.rs | 26 + .../src/processor/admin/remove_guardian.rs | 29 + .../tbtc/src/processor/admin/remove_minter.rs | 29 + .../tbtc/src/processor/admin/unpause.rs | 21 + .../programs/tbtc/src/processor/mint/mint.rs | 78 + .../programs/tbtc/src/processor/mint/mod.rs | 3 + .../solana/programs/tbtc/src/processor/mod.rs | 5 + .../programs/tbtc/src/state/guardian_info.rs | 17 + .../programs/tbtc/src/state/minter_info.rs | 17 + .../solana/programs/tbtc/src/state/mod.rs | 7 + .../solana/programs/tbtc/src/state/tbtc.rs | 24 + cross-chain/solana/tests/tbtc.ts | 73 +- cross-chain/solana/yarn.lock | 51 +- 25 files changed, 2506 insertions(+), 395 deletions(-) create mode 100644 cross-chain/solana/.yarnrc.yml create mode 100644 cross-chain/solana/package-lock.json create mode 100644 cross-chain/solana/programs/tbtc/src/constants.rs create mode 100644 cross-chain/solana/programs/tbtc/src/error.rs create mode 100644 cross-chain/solana/programs/tbtc/src/event.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/mod.rs create mode 100644 cross-chain/solana/programs/tbtc/src/state/guardian_info.rs create mode 100644 cross-chain/solana/programs/tbtc/src/state/minter_info.rs create mode 100644 cross-chain/solana/programs/tbtc/src/state/mod.rs create mode 100644 cross-chain/solana/programs/tbtc/src/state/tbtc.rs diff --git a/cross-chain/solana/.yarnrc.yml b/cross-chain/solana/.yarnrc.yml new file mode 100644 index 000000000..3186f3f07 --- /dev/null +++ b/cross-chain/solana/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/cross-chain/solana/package-lock.json b/cross-chain/solana/package-lock.json new file mode 100644 index 000000000..b524a8dc3 --- /dev/null +++ b/cross-chain/solana/package-lock.json @@ -0,0 +1,1947 @@ +{ + "name": "solana", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@solana/spl-token": "^0.3.8", + "@solana/web3.js": "^1.77.3", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "prettier": "^2.6.2", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } + }, + "node_modules/@babel/runtime": { + "version": "7.22.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz", + "integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==", + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@coral-xyz/anchor": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.28.0.tgz", + "integrity": "sha512-kQ02Hv2ZqxtWP30WN1d4xxT4QqlOXYDxmEd3k/bbneqhV3X5QMO4LAtoUFs7otxyivOgoqam5Il5qx81FuI4vw==", + "dependencies": { + "@coral-xyz/borsh": "^0.28.0", + "@solana/web3.js": "^1.68.0", + "base64-js": "^1.5.1", + "bn.js": "^5.1.2", + "bs58": "^4.0.1", + "buffer-layout": "^1.2.2", + "camelcase": "^6.3.0", + "cross-fetch": "^3.1.5", + "crypto-hash": "^1.3.0", + "eventemitter3": "^4.0.7", + "js-sha256": "^0.9.0", + "pako": "^2.0.3", + "snake-case": "^3.0.4", + "superstruct": "^0.15.4", + "toml": "^3.0.0" + }, + "engines": { + "node": ">=11" + } + }, + "node_modules/@coral-xyz/borsh": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.28.0.tgz", + "integrity": "sha512-/u1VTzw7XooK7rqeD7JLUSwOyRSesPUk0U37BV9zK0axJc1q0nRbKFGFLYCQ16OtdOJTTwGfGp11Lx9B45bRCQ==", + "dependencies": { + "bn.js": "^5.1.2", + "buffer-layout": "^1.2.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@solana/web3.js": "^1.68.0" + } + }, + "node_modules/@noble/curves": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", + "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", + "dependencies": { + "@noble/hashes": "1.3.1" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", + "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@solana/buffer-layout": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz", + "integrity": "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==", + "dependencies": { + "buffer": "~6.0.3" + }, + "engines": { + "node": ">=5.10" + } + }, + "node_modules/@solana/buffer-layout-utils": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz", + "integrity": "sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g==", + "dev": true, + "dependencies": { + "@solana/buffer-layout": "^4.0.0", + "@solana/web3.js": "^1.32.0", + "bigint-buffer": "^1.1.5", + "bignumber.js": "^9.0.1" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@solana/spl-token": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.8.tgz", + "integrity": "sha512-ogwGDcunP9Lkj+9CODOWMiVJEdRtqHAtX2rWF62KxnnSWtMZtV9rDhTrZFshiyJmxDnRL/1nKE1yJHg4jjs3gg==", + "dev": true, + "dependencies": { + "@solana/buffer-layout": "^4.0.0", + "@solana/buffer-layout-utils": "^0.2.0", + "buffer": "^6.0.3" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.47.4" + } + }, + "node_modules/@solana/web3.js": { + "version": "1.78.1", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.78.1.tgz", + "integrity": "sha512-r0WZAYwCfVElfONP/dmWkEfw6wufL+u7lWojEsNecn9PyIIYq+r4eb0h2MRiJ3xkctvTN76G0T6FTGcTJhXh3Q==", + "dependencies": { + "@babel/runtime": "^7.22.6", + "@noble/curves": "^1.0.0", + "@noble/hashes": "^1.3.0", + "@solana/buffer-layout": "^4.0.0", + "agentkeepalive": "^4.2.1", + "bigint-buffer": "^1.1.5", + "bn.js": "^5.0.0", + "borsh": "^0.7.0", + "bs58": "^4.0.1", + "buffer": "6.0.3", + "fast-stable-stringify": "^1.0.0", + "jayson": "^4.1.0", + "node-fetch": "^2.6.12", + "rpc-websockets": "^7.5.1", + "superstruct": "^0.14.2" + } + }, + "node_modules/@solana/web3.js/node_modules/superstruct": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.14.2.tgz", + "integrity": "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==" + }, + "node_modules/@types/bn.js": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", + "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/chai": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", + "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==", + "dev": true + }, + "node_modules/@types/connect": { + "version": "3.4.35", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", + "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", + "dev": true, + "optional": true + }, + "node_modules/@types/mocha": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.1.tgz", + "integrity": "sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==", + "dev": true + }, + "node_modules/@types/node": { + "version": "20.4.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.5.tgz", + "integrity": "sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg==" + }, + "node_modules/@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@ungap/promise-all-settled": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", + "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", + "dev": true + }, + "node_modules/agentkeepalive": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.3.0.tgz", + "integrity": "sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg==", + "dependencies": { + "debug": "^4.1.0", + "depd": "^2.0.0", + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/base-x": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", + "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bigint-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz", + "integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==", + "hasInstallScript": true, + "dependencies": { + "bindings": "^1.3.0" + }, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/bignumber.js": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz", + "integrity": "sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, + "node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" + }, + "node_modules/borsh": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", + "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", + "dependencies": { + "bn.js": "^5.2.0", + "bs58": "^4.0.0", + "text-encoding-utf-8": "^1.0.2" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "node_modules/bs58": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", + "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", + "dependencies": { + "base-x": "^3.0.2" + } + }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/buffer-layout": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/buffer-layout/-/buffer-layout-1.2.2.tgz", + "integrity": "sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==", + "engines": { + "node": ">=4.5" + } + }, + "node_modules/bufferutil": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", + "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/chai": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", + "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", + "dev": true, + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/cross-fetch": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", + "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", + "dependencies": { + "node-fetch": "^2.6.12" + } + }, + "node_modules/crypto-hash": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/crypto-hash/-/crypto-hash-1.3.0.tgz", + "integrity": "sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", + "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", + "dev": true, + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/delay": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", + "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, + "node_modules/es6-promisify": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", + "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", + "dependencies": { + "es6-promise": "^4.0.3" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" + }, + "node_modules/eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==", + "engines": { + "node": "> 0.1.90" + } + }, + "node_modules/fast-stable-stringify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", + "integrity": "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==" + }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "bin": { + "flat": "cli.js" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", + "dev": true, + "engines": { + "node": ">=4.x" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", + "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", + "dependencies": { + "ms": "^2.0.0" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", + "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/isomorphic-ws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", + "peerDependencies": { + "ws": "*" + } + }, + "node_modules/jayson": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/jayson/-/jayson-4.1.0.tgz", + "integrity": "sha512-R6JlbyLN53Mjku329XoRT2zJAE6ZgOQ8f91ucYdMCD4nkGCF9kZSrcGXpHIU4jeKj58zUZke2p+cdQchU7Ly7A==", + "dependencies": { + "@types/connect": "^3.4.33", + "@types/node": "^12.12.54", + "@types/ws": "^7.4.4", + "commander": "^2.20.3", + "delay": "^5.0.0", + "es6-promisify": "^5.0.0", + "eyes": "^0.1.8", + "isomorphic-ws": "^4.0.1", + "json-stringify-safe": "^5.0.1", + "JSONStream": "^1.3.5", + "uuid": "^8.3.2", + "ws": "^7.4.5" + }, + "bin": { + "jayson": "bin/jayson.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jayson/node_modules/@types/node": { + "version": "12.20.55", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", + "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" + }, + "node_modules/js-sha256": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", + "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" + }, + "node_modules/json5": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "dev": true, + "optional": true, + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", + "engines": [ + "node >= 0.2.0" + ] + }, + "node_modules/JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", + "dependencies": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + }, + "bin": { + "JSONStream": "bin.js" + }, + "engines": { + "node": "*" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", + "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/loupe": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", + "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", + "dev": true, + "dependencies": { + "get-func-name": "^2.0.0" + } + }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/minimatch": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", + "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mocha": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", + "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==", + "dev": true, + "dependencies": { + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.3", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "4.2.1", + "ms": "2.1.3", + "nanoid": "3.3.1", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", + "workerpool": "6.2.0", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/mocha/node_modules/debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mocha/node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/mocha/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/nanoid": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", + "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", + "dev": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, + "node_modules/node-fetch": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", + "integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-gyp-build": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz", + "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", + "optional": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pako": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pathval": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", + "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "dev": true, + "engines": { + "node": "*" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rpc-websockets": { + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-7.5.1.tgz", + "integrity": "sha512-kGFkeTsmd37pHPMaHIgN1LVKXMi0JD782v4Ds9ZKtLlwdTKjn+CxM9A9/gLT2LaOuEcEFGL98h1QWQtlOIdW0w==", + "dependencies": { + "@babel/runtime": "^7.17.2", + "eventemitter3": "^4.0.7", + "uuid": "^8.3.2", + "ws": "^8.5.0" + }, + "funding": { + "type": "paypal", + "url": "https://paypal.me/kozjak" + }, + "optionalDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + } + }, + "node_modules/rpc-websockets/node_modules/ws": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/snake-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", + "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "optional": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/superstruct": { + "version": "0.15.5", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz", + "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==" + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/text-encoding-utf-8": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", + "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toml": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", + "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/ts-mocha": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-10.0.0.tgz", + "integrity": "sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw==", + "dev": true, + "dependencies": { + "ts-node": "7.0.1" + }, + "bin": { + "ts-mocha": "bin/ts-mocha" + }, + "engines": { + "node": ">= 6.X.X" + }, + "optionalDependencies": { + "tsconfig-paths": "^3.5.0" + }, + "peerDependencies": { + "mocha": "^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X" + } + }, + "node_modules/ts-node": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", + "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", + "dev": true, + "dependencies": { + "arrify": "^1.0.0", + "buffer-from": "^1.1.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.5.6", + "yn": "^2.0.0" + }, + "bin": { + "ts-node": "dist/bin.js" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/tsconfig-paths": { + "version": "3.14.2", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", + "integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==", + "dev": true, + "optional": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tslib": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.1.tgz", + "integrity": "sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==" + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/typescript": { + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/utf-8-validate": { + "version": "5.0.10", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", + "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/workerpool": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", + "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", + "dev": true + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/cross-chain/solana/programs/tbtc/Cargo.toml b/cross-chain/solana/programs/tbtc/Cargo.toml index 9aa4c8db8..25ef87264 100644 --- a/cross-chain/solana/programs/tbtc/Cargo.toml +++ b/cross-chain/solana/programs/tbtc/Cargo.toml @@ -16,5 +16,5 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -anchor-lang = "0.28.0" +anchor-lang = { version = "0.28.0", features = ["init-if-needed"] } anchor-spl = "0.28.0" \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/constants.rs b/cross-chain/solana/programs/tbtc/src/constants.rs new file mode 100644 index 000000000..fb63dab07 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/constants.rs @@ -0,0 +1,4 @@ +use anchor_lang::prelude::constant; + +#[constant] +pub const SEED_PREFIX_TBTC_MINT: &[u8] = b"tbtc-mint"; \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/error.rs b/cross-chain/solana/programs/tbtc/src/error.rs new file mode 100644 index 000000000..434c27b05 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/error.rs @@ -0,0 +1,8 @@ +use anchor_lang::prelude::error_code; + +#[error_code] +pub enum TbtcError { + IsPaused, + IsNotPaused, + IsNotAuthority, +} diff --git a/cross-chain/solana/programs/tbtc/src/event.rs b/cross-chain/solana/programs/tbtc/src/event.rs new file mode 100644 index 000000000..6a385a50a --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/event.rs @@ -0,0 +1,21 @@ +use anchor_lang::prelude::*; + +#[event] +pub struct MinterAdded { + pub minter: Pubkey, +} + +#[event] +pub struct MinterRemoved { + pub minter: Pubkey, +} + +#[event] +pub struct GuardianAdded { + pub guardian: Pubkey, +} + +#[event] +pub struct GuardianRemoved { + pub guardian: Pubkey, +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/lib.rs b/cross-chain/solana/programs/tbtc/src/lib.rs index 9200f3d83..eb784c05c 100644 --- a/cross-chain/solana/programs/tbtc/src/lib.rs +++ b/cross-chain/solana/programs/tbtc/src/lib.rs @@ -1,9 +1,14 @@ use anchor_lang::prelude::*; -use anchor_spl::{ - associated_token::AssociatedToken, - // mint, - token::{mint_to, TokenAccount, Mint as SplMint, MintTo as SplMintTo, Token as SplToken}, -}; + +pub use constants::*; +pub use error::*; +pub(crate) use processor::*; +pub use state::*; + +pub mod constants; +pub mod error; +mod processor; +pub mod state; declare_id!("HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG"); @@ -11,347 +16,61 @@ declare_id!("HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG"); pub mod tbtc { use super::*; - pub fn initialize(ctx: Context) -> Result<()> { - let tbtc = &mut ctx.accounts.tbtc; - tbtc.authority = ctx.accounts.authority.key(); - tbtc.token_mint = ctx.accounts.tbtc_mint.key(); - tbtc.token_bump = *ctx.bumps.get("tbtc_mint").unwrap(); - tbtc.minters = 0; - tbtc.guardians = 0; - tbtc.paused = false; - Ok(()) + pub fn initialize( + ctx: Context, + ) -> Result<()> { + processor::initialize(ctx) } - pub fn add_minter(ctx: Context) -> Result<()> { - let minter_info = &mut ctx.accounts.minter_info; - minter_info.minter = ctx.accounts.minter.key(); - minter_info.bump = *ctx.bumps.get("minter_info").unwrap(); - - ctx.accounts.tbtc.minters += 1; - emit!(MinterAdded { minter: ctx.accounts.minter.key() }); - Ok(()) + pub fn change_authority( + ctx: Context, + ) -> Result<()> { + processor::change_authority(ctx) } - pub fn remove_minter(ctx: Context, minter: Pubkey) -> Result<()> { - // require!(ctx.accounts.tbtc.minters > 0, TbtcError::NoMinters); - ctx.accounts.tbtc.minters -= 1; - emit!(MinterRemoved { minter: minter }); - Ok(()) + pub fn add_minter( + ctx: Context, + ) -> Result<()> { + processor::add_minter(ctx) } - pub fn add_guardian(ctx: Context) -> Result<()> { - let guardian_info = &mut ctx.accounts.guardian_info; - guardian_info.guardian = ctx.accounts.guardian.key(); - guardian_info.bump = *ctx.bumps.get("guardian_info").unwrap(); - - ctx.accounts.tbtc.guardians += 1; - emit!(GuardianAdded { guardian: ctx.accounts.guardian.key() }); - Ok(()) + pub fn remove_minter( + ctx: Context, + minter: Pubkey, + ) -> Result<()> { + processor::remove_minter(ctx, minter) } - pub fn remove_guardian(ctx: Context, guardian: Pubkey) -> Result<()> { - // require!(ctx.accounts.tbtc.guardians > 0, TbtcError::NoGuardians); - ctx.accounts.tbtc.guardians -= 1; - emit!(GuardianRemoved { guardian: guardian }); - Ok(()) + pub fn add_guardian( + ctx: Context, + ) -> Result<()> { + processor::add_guardian(ctx) } - pub fn setup_mint(_ctx: Context) -> Result<()> { - msg!("setup mint complete\n\n\n"); - Ok(()) + pub fn remove_guardian( + ctx: Context, + guardian: Pubkey, + ) -> Result<()> { + processor::remove_guardian(ctx, guardian) } - pub fn mint(ctx: Context, amount: u64) -> Result<()> { - msg!("start mint\n\n\n"); - let seed = b"tbtc-mint"; - let key_seed = ctx.accounts.tbtc.key(); - let mint_bump = ctx.accounts.tbtc.token_bump; - let signer: &[&[&[u8]]] = &[&[seed, key_seed.as_ref(), &[mint_bump]]]; - - let cpi_ctx = CpiContext::new_with_signer( - ctx.accounts.token_program.to_account_info(), - SplMintTo { - mint: ctx.accounts.tbtc_mint.to_account_info(), - to: ctx.accounts.recipient_account.to_account_info(), - authority: ctx.accounts.tbtc_mint.to_account_info(), - }, - signer, - ); - mint_to(cpi_ctx, amount)?; - - Ok(()) + pub fn pause( + ctx: Context, + ) -> Result<()> { + processor::pause(ctx) } - pub fn pause(ctx: Context) -> Result<()> { - ctx.accounts.tbtc.paused = true; - Ok(()) + pub fn unpause( + ctx: Context, + ) -> Result<()> { + processor::unpause(ctx) } - pub fn unpause(ctx: Context) -> Result<()> { - ctx.accounts.tbtc.paused = false; - Ok(()) + pub fn mint( + ctx: Context, + amount: u64, + ) -> Result<()> { + processor::mint(ctx, amount) } } -#[account] -#[derive(Default)] -pub struct Tbtc { - authority: Pubkey, - token_mint: Pubkey, - token_bump: u8, - minters: u8, - guardians: u8, - paused: bool, -} - -#[account] -#[derive(Default)] -pub struct MinterInfo { - minter: Pubkey, - bump: u8, -} - -#[account] -#[derive(Default)] -pub struct GuardianInfo { - guardian: Pubkey, - bump: u8, -} - -#[derive(Accounts)] -pub struct Initialize<'info> { - // Use PDA for the mint address - // so we can sign for it from the program - #[account( - init, - seeds = [b"tbtc-mint", tbtc.key().as_ref()], - bump, - payer = authority, - mint::decimals = 9, - mint::authority = tbtc_mint, - )] - pub tbtc_mint: Account<'info, SplMint>, - - #[account(init, payer = authority, space = 8 + Tbtc::MAXIMUM_SIZE)] - pub tbtc: Account<'info, Tbtc>, - - #[account(mut)] - pub authority: Signer<'info>, - - pub token_program: Program<'info, SplToken>, - pub system_program: Program<'info, System> -} - -#[derive(Accounts)] -pub struct AddMinter<'info> { - #[account( - mut, - has_one = authority @ TbtcError::IsNotAuthority - )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, - pub minter: Signer<'info>, - #[account(mut)] - pub payer: Signer<'info>, - #[account( - init, - payer = payer, - space = 8 + 32 + 1, - seeds = [b"minter-info", tbtc.key().as_ref(), minter.key().as_ref()], bump - )] - pub minter_info: Account<'info, MinterInfo>, - pub system_program: Program<'info, System>, -} - -#[derive(Accounts)] -#[instruction(minter: Pubkey)] -pub struct RemoveMinter<'info> { - #[account( - mut, - has_one = authority @ TbtcError::IsNotAuthority - )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, - #[account( - mut, - constraint = minter_info.minter == minter, - close = authority, - seeds = [b"minter-info", tbtc.key().as_ref(), minter.as_ref()], - bump = minter_info.bump, - )] - pub minter_info: Account<'info, MinterInfo>, -} - -#[derive(Accounts)] -pub struct AddGuardian<'info> { - #[account( - mut, - has_one = authority @ TbtcError::IsNotAuthority - )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, - pub guardian: Signer<'info>, - #[account(mut)] - pub payer: Signer<'info>, - #[account( - init, - payer = payer, - space = 8 + 32 + 1, - seeds = [b"guardian-info", tbtc.key().as_ref(), guardian.key().as_ref()], bump - )] - pub guardian_info: Account<'info, GuardianInfo>, - pub system_program: Program<'info, System>, -} - -#[derive(Accounts)] -#[instruction(guardian: Pubkey)] -pub struct RemoveGuardian<'info> { - #[account( - mut, - has_one = authority @ TbtcError::IsNotAuthority, - )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, - #[account( - mut, - constraint = guardian_info.guardian == guardian, - close = authority, - seeds = [b"guardian-info", tbtc.key().as_ref(), guardian.as_ref()], - bump = guardian_info.bump, - )] - pub guardian_info: Account<'info, GuardianInfo>, -} - -#[derive(Accounts)] -pub struct Pause<'info> { - #[account( - mut, - constraint = !tbtc.paused @ TbtcError::IsPaused - )] - pub tbtc: Account<'info, Tbtc>, - #[account( - has_one = guardian, - seeds = [b"guardian-info", tbtc.key().as_ref(), guardian.key().as_ref()], - bump = guardian_info.bump - )] - pub guardian_info: Account<'info, GuardianInfo>, - pub guardian: Signer<'info>, -} - -#[derive(Accounts)] -pub struct Unpause<'info> { - #[account( - mut, - constraint = tbtc.paused @ TbtcError::IsNotPaused, - has_one = authority @ TbtcError::IsNotAuthority - )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, -} - -#[derive(Accounts)] -pub struct SetupMint<'info> { - // Use the correct token mint for the program. - #[account( - mut, - seeds = [b"tbtc-mint", tbtc.key().as_ref()], - bump = tbtc.token_bump, - mint::decimals = 9, - mint::authority = tbtc_mint, - )] - pub tbtc_mint: Account<'info, SplMint>, - pub tbtc: Account<'info, Tbtc>, - - // Set up the recipient's token account. - #[account( - init, - payer = payer, - associated_token::mint = tbtc_mint, - associated_token::authority = recipient, - )] - pub recipient_account: Account<'info, TokenAccount>, - /// CHECK: the recipient doesn't need to sign the mint, - /// and it doesn't conform to any specific rules. - /// Validating the recipient is the minter's responsibility. - pub recipient: UncheckedAccount<'info>, - #[account(mut)] - pub payer: Signer<'info>, - - pub token_program: Program<'info, SplToken>, - pub associated_token_program: Program<'info, AssociatedToken>, - pub system_program: Program<'info, System> -} - -#[derive(Accounts)] -pub struct Mint<'info> { - // Use the correct token mint for the program. - #[account( - mut, - seeds = [b"tbtc-mint", tbtc.key().as_ref()], - bump = tbtc.token_bump, - mint::decimals = 9, - mint::authority = tbtc_mint, - )] - pub tbtc_mint: Account<'info, SplMint>, - - // Can not mint when paused. - #[account( - constraint = !tbtc.paused @ TbtcError::IsPaused - )] - pub tbtc: Account<'info, Tbtc>, - - // Require the signing minter to match a valid minter info. - #[account( - has_one = minter, - seeds = [b"minter-info", tbtc.key().as_ref(), minter.key().as_ref()], - bump = minter_info.bump, - )] - pub minter_info: Account<'info, MinterInfo>, - pub minter: Signer<'info>, - - // Use the associated token account for the recipient. - // This account needs to be initialised first. - #[account( - mut, - associated_token::mint = tbtc_mint, - associated_token::authority = recipient, - )] - pub recipient_account: Account<'info, TokenAccount>, - /// CHECK: the recipient doesn't need to sign the mint, - /// and it doesn't conform to any specific rules. - /// Validating the recipient is the minter's responsibility. - pub recipient: UncheckedAccount<'info>, - - pub token_program: Program<'info, SplToken>, -} - -impl Tbtc { - pub const MAXIMUM_SIZE: usize = 32 + 32 + 1 + 1 + 1 + 1; -} - -#[error_code] -pub enum TbtcError { - IsPaused, - IsNotPaused, - IsNotAuthority, -} - -#[event] -pub struct MinterAdded { - pub minter: Pubkey, -} - -#[event] -pub struct MinterRemoved { - pub minter: Pubkey, -} - -#[event] -pub struct GuardianAdded { - pub guardian: Pubkey, -} - -#[event] -pub struct GuardianRemoved { - pub guardian: Pubkey, -} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs new file mode 100644 index 000000000..f0dab2236 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs @@ -0,0 +1,36 @@ +use crate::{ + error::TbtcError, + state::{Tbtc, GuardianInfo}, +}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct AddGuardian<'info> { + #[account( + mut, + has_one = authority @ TbtcError::IsNotAuthority + )] + pub tbtc: Account<'info, Tbtc>, + pub authority: Signer<'info>, + pub guardian: Signer<'info>, + #[account(mut)] + pub payer: Signer<'info>, + #[account( + init, + payer = payer, + space = GuardianInfo::MAXIMUM_SIZE, + seeds = [GuardianInfo::SEED_PREFIX, tbtc.key().as_ref(), guardian.key().as_ref()], bump + )] + pub guardian_info: Account<'info, GuardianInfo>, + pub system_program: Program<'info, System>, +} + +pub fn add_guardian(ctx: Context) -> Result<()> { + ctx.accounts.guardian_info.set_inner(GuardianInfo { + guardian: ctx.accounts.guardian.key(), + bump: *ctx.bumps.get("guardian_info").unwrap(), + }); + + ctx.accounts.tbtc.guardians += 1; + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs new file mode 100644 index 000000000..cb3e4fe92 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs @@ -0,0 +1,36 @@ +use crate::{ + error::TbtcError, + state::{Tbtc, MinterInfo}, +}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct AddMinter<'info> { + #[account( + mut, + has_one = authority @ TbtcError::IsNotAuthority + )] + pub tbtc: Account<'info, Tbtc>, + pub authority: Signer<'info>, + pub minter: Signer<'info>, + #[account(mut)] + pub payer: Signer<'info>, + #[account( + init, + payer = payer, + space = MinterInfo::MAXIMUM_SIZE, + seeds = [MinterInfo::SEED_PREFIX, tbtc.key().as_ref(), minter.key().as_ref()], bump + )] + pub minter_info: Account<'info, MinterInfo>, + pub system_program: Program<'info, System>, +} + +pub fn add_minter(ctx: Context) -> Result<()> { + ctx.accounts.minter_info.set_inner(MinterInfo { + minter: ctx.accounts.minter.key(), + bump: *ctx.bumps.get("minter_info").unwrap(), + }); + + ctx.accounts.tbtc.minters += 1; + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs new file mode 100644 index 000000000..6ce176d6d --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs @@ -0,0 +1,23 @@ +use crate::{ + error::TbtcError, + state::{Tbtc}, +}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct ChangeAuthority<'info> { + #[account( + mut, + has_one = authority @ TbtcError::IsNotAuthority + )] + pub tbtc: Account<'info, Tbtc>, + pub authority: Signer<'info>, + #[account(mut)] + pub payer: Signer<'info>, + pub new_authority: Signer<'info>, +} + +pub fn change_authority(ctx: Context) -> Result<()> { + ctx.accounts.tbtc.authority = ctx.accounts.new_authority.key(); + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs new file mode 100644 index 000000000..0fcb7b980 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs @@ -0,0 +1,47 @@ +use crate::{ + constants::SEED_PREFIX_TBTC_MINT, + state::{Tbtc}, +}; +use anchor_lang::prelude::*; +use anchor_spl::{ + token, +}; + + + + +#[derive(Accounts)] +pub struct Initialize<'info> { + // Use PDA for the mint address + // so we can sign for it from the program + #[account( + init, + seeds = [SEED_PREFIX_TBTC_MINT, tbtc.key().as_ref()], + bump, + payer = authority, + mint::decimals = 9, + mint::authority = tbtc_mint, + )] + pub tbtc_mint: Account<'info, token::Mint>, + + #[account(init, payer = authority, space = Tbtc::MAXIMUM_SIZE)] + pub tbtc: Account<'info, Tbtc>, + + #[account(mut)] + pub authority: Signer<'info>, + + pub token_program: Program<'info, token::Token>, + pub system_program: Program<'info, System> +} + +pub fn initialize(ctx: Context) -> Result<()> { + ctx.accounts.tbtc.set_inner(Tbtc { + authority: ctx.accounts.authority.key(), + token_mint: ctx.accounts.tbtc_mint.key(), + token_bump: *ctx.bumps.get("tbtc_mint").unwrap(), + minters: 0, + guardians: 0, + paused: false, + }); + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs new file mode 100644 index 000000000..8e6c69a39 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs @@ -0,0 +1,17 @@ +mod add_guardian; +mod add_minter; +mod change_authority; +mod initialize; +mod pause; +mod remove_guardian; +mod remove_minter; +mod unpause; + +pub use add_guardian::*; +pub use add_minter::*; +pub use change_authority::*; +pub use initialize::*; +pub use pause::*; +pub use remove_guardian::*; +pub use remove_minter::*; +pub use unpause::*; \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs new file mode 100644 index 000000000..11b078d85 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs @@ -0,0 +1,26 @@ +use crate::{ + error::TbtcError, + state::{Tbtc, GuardianInfo}, +}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct Pause<'info> { + #[account( + mut, + constraint = !tbtc.paused @ TbtcError::IsPaused + )] + pub tbtc: Account<'info, Tbtc>, + #[account( + has_one = guardian, + seeds = [GuardianInfo::SEED_PREFIX, tbtc.key().as_ref(), guardian.key().as_ref()], + bump = guardian_info.bump + )] + pub guardian_info: Account<'info, GuardianInfo>, + pub guardian: Signer<'info>, +} + +pub fn pause(ctx: Context) -> Result<()> { + ctx.accounts.tbtc.paused = true; + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs new file mode 100644 index 000000000..17dda7d85 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs @@ -0,0 +1,29 @@ +use crate::{ + error::TbtcError, + state::{Tbtc, GuardianInfo}, +}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +#[instruction(guardian: Pubkey)] +pub struct RemoveGuardian<'info> { + #[account( + mut, + has_one = authority @ TbtcError::IsNotAuthority, + )] + pub tbtc: Account<'info, Tbtc>, + pub authority: Signer<'info>, + #[account( + mut, + has_one = guardian, + close = authority, + seeds = [GuardianInfo::SEED_PREFIX, tbtc.key().as_ref(), guardian.as_ref()], + bump = guardian_info.bump, + )] + pub guardian_info: Account<'info, GuardianInfo>, +} + +pub fn remove_guardian(ctx: Context, _guardian: Pubkey) -> Result<()> { + ctx.accounts.tbtc.guardians -= 1; + Ok(()) +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs new file mode 100644 index 000000000..7b0183d79 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs @@ -0,0 +1,29 @@ +use crate::{ + error::TbtcError, + state::{Tbtc, MinterInfo}, +}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +#[instruction(minter: Pubkey)] +pub struct RemoveMinter<'info> { + #[account( + mut, + has_one = authority @ TbtcError::IsNotAuthority + )] + pub tbtc: Account<'info, Tbtc>, + pub authority: Signer<'info>, + #[account( + mut, + constraint = minter_info.minter == minter, + close = authority, + seeds = [MinterInfo::SEED_PREFIX, tbtc.key().as_ref(), minter.as_ref()], + bump = minter_info.bump, + )] + pub minter_info: Account<'info, MinterInfo>, +} + +pub fn remove_minter(ctx: Context, _minter: Pubkey) -> Result<()> { + ctx.accounts.tbtc.minters -= 1; + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs new file mode 100644 index 000000000..c1c594243 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs @@ -0,0 +1,21 @@ +use crate::{ + error::TbtcError, + state::Tbtc, +}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct Unpause<'info> { + #[account( + mut, + constraint = tbtc.paused @ TbtcError::IsNotPaused, + has_one = authority @ TbtcError::IsNotAuthority + )] + pub tbtc: Account<'info, Tbtc>, + pub authority: Signer<'info>, +} + +pub fn unpause(ctx: Context) -> Result<()> { + ctx.accounts.tbtc.paused = false; + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs b/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs new file mode 100644 index 000000000..089e0a914 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs @@ -0,0 +1,78 @@ +use crate::{ + constants::SEED_PREFIX_TBTC_MINT, + error::TbtcError, + state::{Tbtc, MinterInfo}, +}; +use anchor_lang::prelude::*; +use anchor_spl::{ + associated_token::AssociatedToken, + token, +}; + +#[derive(Accounts)] +pub struct Mint<'info> { + // Use the correct token mint for the program. + #[account( + mut, + seeds = [SEED_PREFIX_TBTC_MINT, tbtc.key().as_ref()], + bump = tbtc.token_bump, + mint::decimals = 9, + mint::authority = tbtc_mint, + )] + pub tbtc_mint: Account<'info, token::Mint>, + + // Can not mint when paused. + #[account( + constraint = !tbtc.paused @ TbtcError::IsPaused + )] + pub tbtc: Account<'info, Tbtc>, + + // Require the signing minter to match a valid minter info. + #[account( + has_one = minter, + seeds = [MinterInfo::SEED_PREFIX, tbtc.key().as_ref(), minter.key().as_ref()], + bump = minter_info.bump, + )] + pub minter_info: Account<'info, MinterInfo>, + pub minter: Signer<'info>, + + // Use the associated token account for the recipient. + #[account( + init_if_needed, + payer = payer, + associated_token::mint = tbtc_mint, + associated_token::authority = recipient, + )] + pub recipient_account: Account<'info, token::TokenAccount>, + /// CHECK: the recipient doesn't need to sign the mint, + /// and it doesn't conform to any specific rules. + /// Validating the recipient is the minter's responsibility. + pub recipient: UncheckedAccount<'info>, + + #[account( + mut, + )] + pub payer: Signer<'info>, + + pub token_program: Program<'info, token::Token>, + pub associated_token_program: Program<'info, AssociatedToken>, + pub system_program: Program<'info, System>, +} + +pub fn mint(ctx: Context, amount: u64) -> Result<()> { + let seed_prefix = SEED_PREFIX_TBTC_MINT; + let key_seed = ctx.accounts.tbtc.key(); + let mint_bump = ctx.accounts.tbtc.token_bump; + let signer: &[&[&[u8]]] = &[&[seed_prefix, key_seed.as_ref(), &[mint_bump]]]; + + let cpi_ctx = CpiContext::new_with_signer( + ctx.accounts.token_program.to_account_info(), + token::MintTo { + mint: ctx.accounts.tbtc_mint.to_account_info(), + to: ctx.accounts.recipient_account.to_account_info(), + authority: ctx.accounts.tbtc_mint.to_account_info(), + }, + signer, + ); + token::mint_to(cpi_ctx, amount) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs b/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs new file mode 100644 index 000000000..6eac15698 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs @@ -0,0 +1,3 @@ +mod mint; + +pub use mint::*; \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/processor/mod.rs b/cross-chain/solana/programs/tbtc/src/processor/mod.rs new file mode 100644 index 000000000..3e7105fef --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/mod.rs @@ -0,0 +1,5 @@ +mod admin; +mod mint; + +pub use admin::*; +pub use mint::*; \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs new file mode 100644 index 000000000..385d4c1d7 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs @@ -0,0 +1,17 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Default)] +pub struct GuardianInfo { + pub guardian: Pubkey, + pub bump: u8, +} + +impl GuardianInfo { + pub fn is_guardian(&self, key: &Pubkey) -> bool { + self.guardian == *key + } + + pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; // discriminator + pubkey + bump + pub const SEED_PREFIX: &'static [u8; 13] = b"guardian-info"; +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/state/minter_info.rs b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs new file mode 100644 index 000000000..b287c2514 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs @@ -0,0 +1,17 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Default)] +pub struct MinterInfo { + pub minter: Pubkey, + pub bump: u8, +} + +impl MinterInfo { + pub fn is_minter(&self, key: &Pubkey) -> bool { + self.minter == *key + } + + pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; // discriminator + pubkey + bump + pub const SEED_PREFIX: &'static [u8; 11] = b"minter-info"; +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/state/mod.rs b/cross-chain/solana/programs/tbtc/src/state/mod.rs new file mode 100644 index 000000000..234adb0d0 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/state/mod.rs @@ -0,0 +1,7 @@ +pub use guardian_info::*; +pub use minter_info::*; +pub use tbtc::*; + +pub mod guardian_info; +pub mod minter_info; +pub mod tbtc; \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/state/tbtc.rs b/cross-chain/solana/programs/tbtc/src/state/tbtc.rs new file mode 100644 index 000000000..3254e0b81 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/state/tbtc.rs @@ -0,0 +1,24 @@ +use anchor_lang::prelude::*; + + +#[account] +#[derive(Default)] +pub struct Tbtc { + pub authority: Pubkey, + pub token_mint: Pubkey, + pub token_bump: u8, + pub minters: u8, + pub guardians: u8, + pub paused: bool, +} + +impl Tbtc { + // 8 discriminator + // 32 pubkey + // 32 pubkey + // 1 u8 + // 1 u8 + // 1 u8 + // 1 bool + pub const MAXIMUM_SIZE: usize = 8 + 32 + 32 + 1 + 1 + 1 + 1; +} \ No newline at end of file diff --git a/cross-chain/solana/tests/tbtc.ts b/cross-chain/solana/tests/tbtc.ts index 53dff9b49..53e71e1da 100644 --- a/cross-chain/solana/tests/tbtc.ts +++ b/cross-chain/solana/tests/tbtc.ts @@ -51,6 +51,23 @@ async function checkState( expect(mintState.supply == expectedTokensSupply).to.be.true; } +async function changeAuthority( + program: Program, + tbtc, + authority, + newAuthority, +) { + await program.methods + .changeAuthority() + .accounts({ + tbtc: tbtc.publicKey, + authority: authority.publicKey, + newAuthority: newAuthority.publicKey, + }) + .signers(maybeAuthorityAnd(authority, [newAuthority])) + .rpc(); +} + async function checkPaused( program: Program, tbtc, @@ -239,31 +256,6 @@ async function unpause( .rpc(); } -async function setupMint( - program: Program, - tbtc, - authority, - recipient, -) { - const [tbtcMintPDA, _] = getTokenPDA(program, tbtc); - const associatedTokenAccount = spl.getAssociatedTokenAddressSync( - tbtcMintPDA, - recipient.publicKey, - ); - - await program.methods - .setupMint() - .accounts({ - tbtcMint: tbtcMintPDA, - tbtc: tbtc.publicKey, - payer: authority.publicKey, - recipientAccount: associatedTokenAccount, - recipient: recipient.publicKey, - }) - .signers([]) - .rpc() -} - async function mint( program: Program, tbtc, @@ -271,6 +263,7 @@ async function mint( minterInfoPDA, recipient, amount, + payer, ) { const [tbtcMintPDA, _] = getTokenPDA(program, tbtc); const associatedTokenAccount = spl.getAssociatedTokenAddressSync( @@ -287,8 +280,9 @@ async function mint( minter: minter.publicKey, recipientAccount: associatedTokenAccount, recipient: recipient.publicKey, + payer: payer.publicKey, }) - .signers([minter]) + .signers(maybeAuthorityAnd(payer, [minter])) .rpc(); } @@ -300,6 +294,7 @@ describe("tbtc", () => { const authority = (program.provider as anchor.AnchorProvider).wallet; + const newAuthority = anchor.web3.Keypair.generate(); const minterKeys = anchor.web3.Keypair.generate(); const minter2Keys = anchor.web3.Keypair.generate(); const impostorKeys = anchor.web3.Keypair.generate(); @@ -314,6 +309,14 @@ describe("tbtc", () => { await checkState(program, tbtcKeys, authority, 0, 0, 0); }); + it('change authority', async () => { + const tbtcKeys = anchor.web3.Keypair.generate(); + await setup(program, tbtcKeys, authority); + await checkState(program, tbtcKeys, authority, 0, 0, 0); + await changeAuthority(program, tbtcKeys, authority, newAuthority); + await checkState(program, tbtcKeys, newAuthority, 0, 0, 0); + }) + it('add minter', async () => { const tbtcKeys = anchor.web3.Keypair.generate(); await setup(program, tbtcKeys, authority); @@ -341,8 +344,8 @@ describe("tbtc", () => { await checkMinter(program, tbtcKeys, minterKeys); await checkState(program, tbtcKeys, authority, 1, 0, 0); - await setupMint(program, tbtcKeys, authority, recipientKeys); - await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000); + // await setupMint(program, tbtcKeys, authority, recipientKeys); + await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); await checkState(program, tbtcKeys, authority, 1, 0, 1000); }); @@ -355,10 +358,10 @@ describe("tbtc", () => { await checkMinter(program, tbtcKeys, minterKeys); await checkState(program, tbtcKeys, authority, 1, 0, 0); - await setupMint(program, tbtcKeys, authority, recipientKeys); + // await setupMint(program, tbtcKeys, authority, recipientKeys); try { - await mint(program, tbtcKeys, impostorKeys, minterInfoPDA, recipientKeys, 1000); + await mint(program, tbtcKeys, impostorKeys, minterInfoPDA, recipientKeys, 1000, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -377,11 +380,11 @@ describe("tbtc", () => { await checkMinter(program, tbtcKeys, minterKeys); await checkMinter(program, tbtcKeys, minter2Keys); await checkState(program, tbtcKeys, authority, 2, 0, 0); - await setupMint(program, tbtcKeys, authority, recipientKeys); + // await setupMint(program, tbtcKeys, authority, recipientKeys); // cannot mint with wrong keys try { - await mint(program, tbtcKeys, minter2Keys, minterInfoPDA, recipientKeys, 1000); + await mint(program, tbtcKeys, minter2Keys, minterInfoPDA, recipientKeys, 1000, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -401,7 +404,7 @@ describe("tbtc", () => { expect(err.program.equals(program.programId)).is.true; } - await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 500); + await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 500, authority); await checkState(program, tbtcKeys, authority, 2, 0, 500); }); @@ -534,10 +537,10 @@ describe("tbtc", () => { const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); await pause(program, tbtcKeys, guardianKeys); - await setupMint(program, tbtcKeys, authority, recipientKeys); + // await setupMint(program, tbtcKeys, authority, recipientKeys); try { - await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000); + await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { diff --git a/cross-chain/solana/yarn.lock b/cross-chain/solana/yarn.lock index 6a0e35f1f..fb1384a54 100644 --- a/cross-chain/solana/yarn.lock +++ b/cross-chain/solana/yarn.lock @@ -5,7 +5,7 @@ __metadata: version: 6 cacheKey: 8 -"@babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.22.3": +"@babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.22.6": version: 7.22.6 resolution: "@babel/runtime@npm:7.22.6" dependencies: @@ -130,10 +130,10 @@ __metadata: linkType: hard "@solana/web3.js@npm:^1.32.0, @solana/web3.js@npm:^1.68.0, @solana/web3.js@npm:^1.77.3": - version: 1.78.0 - resolution: "@solana/web3.js@npm:1.78.0" + version: 1.78.1 + resolution: "@solana/web3.js@npm:1.78.1" dependencies: - "@babel/runtime": ^7.22.3 + "@babel/runtime": ^7.22.6 "@noble/curves": ^1.0.0 "@noble/hashes": ^1.3.0 "@solana/buffer-layout": ^4.0.0 @@ -145,10 +145,10 @@ __metadata: buffer: 6.0.3 fast-stable-stringify: ^1.0.0 jayson: ^4.1.0 - node-fetch: ^2.6.11 + node-fetch: ^2.6.12 rpc-websockets: ^7.5.1 superstruct: ^0.14.2 - checksum: 9f0aae54fa8f2d9285ae525b4f962a17160fd98ac588fbf528742630fb2cf0208ec7b6c0c307d6bba82a92a0e8cbb5411b965d553cc4c62488e24b57c2211d84 + checksum: cf3b139fd9be47d1ed5d1df301729b722f6f53b8afe3ce33d17575e9753c153bfc2ad655582e3a4df1683977bbb26ac7808fc09cae3e61084e7506b6ef2ab51e languageName: node linkType: hard @@ -199,9 +199,9 @@ __metadata: linkType: hard "@types/node@npm:*": - version: 20.4.2 - resolution: "@types/node@npm:20.4.2" - checksum: 99e544ea7560d51f01f95627fc40394c24a13da8f041121a0da13e4ef0a2aa332932eaf9a5e8d0e30d1c07106e96a183be392cbba62e8cf0bf6a085d5c0f4149 + version: 20.4.5 + resolution: "@types/node@npm:20.4.5" + checksum: 36a0304a8dc346a1b2d2edac4c4633eecf70875793d61a5274d0df052d7a7af7a8e34f29884eac4fbd094c4f0201477dcb39c0ecd3307ca141688806538d1138 languageName: node linkType: hard @@ -1253,15 +1253,15 @@ __metadata: linkType: hard "jackspeak@npm:^2.0.3": - version: 2.2.1 - resolution: "jackspeak@npm:2.2.1" + version: 2.2.2 + resolution: "jackspeak@npm:2.2.2" dependencies: "@isaacs/cliui": ^8.0.2 "@pkgjs/parseargs": ^0.11.0 dependenciesMeta: "@pkgjs/parseargs": optional: true - checksum: e29291c0d0f280a063fa18fbd1e891ab8c2d7519fd34052c0ebde38538a15c603140d60c2c7f432375ff7ee4c5f1c10daa8b2ae19a97c3d4affe308c8360c1df + checksum: 7b1468dd910afc00642db87448f24b062346570b8b47531409aa9012bcb95fdf7ec2b1c48edbb8b57a938c08391f8cc01b5034fc335aa3a2e74dbcc0ee5c555a languageName: node linkType: hard @@ -1593,14 +1593,14 @@ __metadata: languageName: node linkType: hard -"ms@npm:2.1.2": +"ms@npm:2.1.2, ms@npm:^2.0.0": version: 2.1.2 resolution: "ms@npm:2.1.2" checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f languageName: node linkType: hard -"ms@npm:2.1.3, ms@npm:^2.0.0": +"ms@npm:2.1.3": version: 2.1.3 resolution: "ms@npm:2.1.3" checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d @@ -1633,7 +1633,7 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:^2.6.11, node-fetch@npm:^2.6.12": +"node-fetch@npm:^2.6.12": version: 2.6.12 resolution: "node-fetch@npm:2.6.12" dependencies: @@ -1979,9 +1979,9 @@ __metadata: linkType: hard "signal-exit@npm:^4.0.1": - version: 4.0.2 - resolution: "signal-exit@npm:4.0.2" - checksum: 41f5928431cc6e91087bf0343db786a6313dd7c6fd7e551dbc141c95bb5fb26663444fd9df8ea47c5d7fc202f60aa7468c3162a9365cbb0615fc5e1b1328fe31 + version: 4.1.0 + resolution: "signal-exit@npm:4.1.0" + checksum: 64c757b498cb8629ffa5f75485340594d2f8189e9b08700e69199069c8e3070fb3e255f7ab873c05dc0b3cec412aea7402e10a5990cb6a050bd33ba062a6c549 languageName: node linkType: hard @@ -2243,9 +2243,9 @@ __metadata: linkType: hard "tslib@npm:^2.0.3": - version: 2.6.0 - resolution: "tslib@npm:2.6.0" - checksum: c01066038f950016a18106ddeca4649b4d76caa76ec5a31e2a26e10586a59fceb4ee45e96719bf6c715648e7c14085a81fee5c62f7e9ebee68e77a5396e5538f + version: 2.6.1 + resolution: "tslib@npm:2.6.1" + checksum: b0d176d176487905b66ae4d5856647df50e37beea7571c53b8d10ba9222c074b81f1410fb91da13debaf2cbc970663609068bdebafa844ea9d69b146527c38fe languageName: node linkType: hard @@ -2437,20 +2437,13 @@ __metadata: languageName: node linkType: hard -"yargs-parser@npm:20.2.4": +"yargs-parser@npm:20.2.4, yargs-parser@npm:^20.2.2": version: 20.2.4 resolution: "yargs-parser@npm:20.2.4" checksum: d251998a374b2743a20271c2fd752b9fbef24eb881d53a3b99a7caa5e8227fcafd9abf1f345ac5de46435821be25ec12189a11030c12ee6481fef6863ed8b924 languageName: node linkType: hard -"yargs-parser@npm:^20.2.2": - version: 20.2.9 - resolution: "yargs-parser@npm:20.2.9" - checksum: 8bb69015f2b0ff9e17b2c8e6bfe224ab463dd00ca211eece72a4cd8a906224d2703fb8a326d36fdd0e68701e201b2a60ed7cf81ce0fd9b3799f9fe7745977ae3 - languageName: node - linkType: hard - "yargs-unparser@npm:2.0.0": version: 2.0.0 resolution: "yargs-unparser@npm:2.0.0" From c4e9bc8449286dacce8a3cb29a0a624c8dcb47ea Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Mon, 31 Jul 2023 10:33:58 -0500 Subject: [PATCH 026/205] solana: reformat; pin solana to 1.14 --- cross-chain/solana/Cargo.lock | 601 +-- cross-chain/solana/package-lock.json | 1947 --------- cross-chain/solana/programs/tbtc/Cargo.toml | 5 +- .../solana/programs/tbtc/src/constants.rs | 2 +- cross-chain/solana/programs/tbtc/src/lib.rs | 57 +- .../tbtc/src/processor/admin/add_guardian.rs | 4 +- .../tbtc/src/processor/admin/add_minter.rs | 4 +- .../src/processor/admin/change_authority.rs | 7 +- .../tbtc/src/processor/admin/initialize.rs | 18 +- .../programs/tbtc/src/processor/admin/mod.rs | 24 +- .../tbtc/src/processor/admin/pause.rs | 4 +- .../src/processor/admin/remove_guardian.rs | 2 +- .../tbtc/src/processor/admin/remove_minter.rs | 4 +- .../tbtc/src/processor/admin/unpause.rs | 7 +- .../programs/tbtc/src/processor/mint/mint.rs | 13 +- .../programs/tbtc/src/processor/mint/mod.rs | 3 +- .../solana/programs/tbtc/src/processor/mod.rs | 6 +- .../programs/tbtc/src/state/guardian_info.rs | 2 +- .../programs/tbtc/src/state/minter_info.rs | 2 +- .../solana/programs/tbtc/src/state/mod.rs | 2 +- .../solana/programs/tbtc/src/state/tbtc.rs | 3 +- .../solana/tests/{tbtc.ts => 01__tbtc.ts} | 0 cross-chain/solana/yarn.lock | 3669 ++++++----------- 23 files changed, 1390 insertions(+), 4996 deletions(-) delete mode 100644 cross-chain/solana/package-lock.json rename cross-chain/solana/tests/{tbtc.ts => 01__tbtc.ts} (100%) diff --git a/cross-chain/solana/Cargo.lock b/cross-chain/solana/Cargo.lock index 199b830d0..5ae732e2a 100644 --- a/cross-chain/solana/Cargo.lock +++ b/cross-chain/solana/Cargo.lock @@ -18,7 +18,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if", - "cipher", + "cipher 0.3.0", "cpufeatures", "opaque-debug", ] @@ -31,7 +31,7 @@ checksum = "589c637f0e68c877bbd59a4599bbe849cac8e5f3e4b5a3ebae8f528cd218dcdc" dependencies = [ "aead", "aes", - "cipher", + "cipher 0.3.0", "ctr", "polyval", "subtle", @@ -49,18 +49,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "ahash" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" -dependencies = [ - "cfg-if", - "getrandom 0.2.10", - "once_cell", - "version_check", -] - [[package]] name = "aho-corasick" version = "1.0.2" @@ -189,7 +177,7 @@ dependencies = [ "arrayref", "base64 0.13.1", "bincode", - "borsh 0.10.3", + "borsh", "bytemuck", "getrandom 0.2.10", "solana-program", @@ -235,132 +223,9 @@ checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" [[package]] name = "anyhow" -version = "1.0.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" - -[[package]] -name = "ark-bn254" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-std", -] - -[[package]] -name = "ark-ec" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" -dependencies = [ - "ark-ff", - "ark-poly", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown 0.13.2", - "itertools", - "num-traits", - "zeroize", -] - -[[package]] -name = "ark-ff" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" -dependencies = [ - "ark-ff-asm", - "ark-ff-macros", - "ark-serialize", - "ark-std", - "derivative", - "digest 0.10.7", - "itertools", - "num-bigint", - "num-traits", - "paste", - "rustc_version", - "zeroize", -] - -[[package]] -name = "ark-ff-asm" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" -dependencies = [ - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-ff-macros" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" -dependencies = [ - "num-bigint", - "num-traits", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-poly" -version = "0.4.2" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" -dependencies = [ - "ark-ff", - "ark-serialize", - "ark-std", - "derivative", - "hashbrown 0.13.2", -] - -[[package]] -name = "ark-serialize" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" -dependencies = [ - "ark-serialize-derive", - "ark-std", - "digest 0.10.7", - "num-bigint", -] - -[[package]] -name = "ark-serialize-derive" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ark-std" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" -dependencies = [ - "num-traits", - "rand 0.8.5", -] - -[[package]] -name = "array-bytes" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad284aeb45c13f2fb4f084de4a420ebf447423bdf9386c0540ce33cb3ef4b8c" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" [[package]] name = "arrayref" @@ -409,12 +274,6 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" -[[package]] -name = "base64" -version = "0.21.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" - [[package]] name = "bincode" version = "1.3.3" @@ -441,9 +300,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.4.1" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" +checksum = "a08e53fc5a564bb15bfe6fae56bd71522205f1f91893f9c0116edad6496c183f" dependencies = [ "arrayref", "arrayvec", @@ -484,41 +343,18 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" dependencies = [ - "borsh-derive 0.9.3", + "borsh-derive", "hashbrown 0.11.2", ] -[[package]] -name = "borsh" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" -dependencies = [ - "borsh-derive 0.10.3", - "hashbrown 0.13.2", -] - [[package]] name = "borsh-derive" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ - "borsh-derive-internal 0.9.3", - "borsh-schema-derive-internal 0.9.3", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" -dependencies = [ - "borsh-derive-internal 0.10.3", - "borsh-schema-derive-internal 0.10.3", + "borsh-derive-internal", + "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", "proc-macro2", "syn 1.0.109", @@ -535,17 +371,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "borsh-schema-derive-internal" version = "0.9.3" @@ -557,17 +382,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "bs58" version = "0.4.0" @@ -616,7 +430,7 @@ checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.28", ] [[package]] @@ -659,6 +473,16 @@ dependencies = [ "generic-array", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -681,9 +505,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "cpufeatures" @@ -724,7 +548,7 @@ dependencies = [ "autocfg", "cfg-if", "crossbeam-utils", - "memoffset", + "memoffset 0.9.0", "scopeguard", ] @@ -769,7 +593,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" dependencies = [ - "cipher", + "cipher 0.3.0", ] [[package]] @@ -786,58 +610,12 @@ dependencies = [ "zeroize", ] -[[package]] -name = "darling" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 2.0.25", -] - -[[package]] -name = "darling_macro" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" -dependencies = [ - "darling_core", - "quote", - "syn 2.0.25", -] - [[package]] name = "derivation-path" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e5c37193a1db1d8ed868c03ec7b152175f26160a5b740e5e484143877e0adf0" -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.9.0" @@ -875,7 +653,7 @@ checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek", "ed25519", - "rand 0.7.3", + "rand", "serde", "sha2 0.9.9", "zeroize", @@ -895,9 +673,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "env_logger" @@ -912,12 +690,6 @@ dependencies = [ "termcolor", ] -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - [[package]] name = "feature-probe" version = "0.1.1" @@ -973,24 +745,18 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.6", + "ahash", ] [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.8.3", + "ahash", ] -[[package]] -name = "hashbrown" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" - [[package]] name = "heck" version = "0.3.3" @@ -1051,12 +817,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "im" version = "15.1.0" @@ -1075,12 +835,21 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.0" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ - "equivalent", - "hashbrown 0.14.0", + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", ] [[package]] @@ -1094,9 +863,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" @@ -1150,7 +919,7 @@ dependencies = [ "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", - "rand 0.7.3", + "rand", "serde", "sha2 0.9.9", "typenum", @@ -1216,6 +985,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.9.0" @@ -1237,17 +1015,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "num-bigint" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-derive" version = "0.3.3" @@ -1259,21 +1026,11 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -1294,16 +1051,7 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" dependencies = [ - "num_enum_derive 0.5.11", -] - -[[package]] -name = "num_enum" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" -dependencies = [ - "num_enum_derive 0.6.1", + "num_enum_derive", ] [[package]] @@ -1318,18 +1066,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "num_enum_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" -dependencies = [ - "proc-macro-crate 1.3.1", - "proc-macro2", - "quote", - "syn 2.0.25", -] - [[package]] name = "once_cell" version = "1.18.0" @@ -1365,12 +1101,6 @@ dependencies = [ "windows-targets", ] -[[package]] -name = "paste" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" - [[package]] name = "pbkdf2" version = "0.4.0" @@ -1434,9 +1164,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -1452,9 +1182,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.29" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -1467,21 +1197,11 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom 0.1.16", "libc", - "rand_chacha 0.2.2", + "rand_chacha", "rand_core 0.5.1", "rand_hc", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - [[package]] name = "rand_chacha" version = "0.2.2" @@ -1492,16 +1212,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - [[package]] name = "rand_core" version = "0.5.1" @@ -1583,9 +1293,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf" +checksum = "b7b6d6190b7594385f61bd3911cd1be99dfddcfc365a4160cc2ab5bff4aed294" dependencies = [ "aho-corasick", "memchr", @@ -1615,90 +1325,68 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" [[package]] name = "serde" -version = "1.0.171" +version = "1.0.179" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9" +checksum = "0a5bf42b8d227d4abf38a1ddb08602e229108a517cd4e5bb28f9c7eaafdce5c0" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.11" +version = "0.11.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a16be4fe5320ade08736447e3198294a5ea9a6d44dde6f35f0a5e06859c427a" +checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.171" +version = "1.0.179" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" +checksum = "741e124f5485c7e60c03b043f79f320bff3527f4bbf12cf3831750dc46a0ec2c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.28", ] [[package]] name = "serde_json" -version = "1.0.100" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c" +checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" dependencies = [ "itoa", "ryu", "serde", ] -[[package]] -name = "serde_with" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" -dependencies = [ - "serde", - "serde_with_macros", -] - -[[package]] -name = "serde_with_macros" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.25", -] - [[package]] name = "sha2" version = "0.9.9" @@ -1769,13 +1457,13 @@ checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "solana-frozen-abi" -version = "1.16.3" +version = "1.14.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c272bd949536a92f0fc4d9572bf72b35b3545fc1f6ee031e44f9d075809055d" +checksum = "a7a100b7fa8198c20354eb7256c0d9789107d8a62280221f3efe15f7c9dc4cec" dependencies = [ - "ahash 0.8.3", + "ahash", "blake3", - "block-buffer 0.10.4", + "block-buffer 0.9.0", "bs58 0.4.0", "bv", "byteorder", @@ -1783,6 +1471,7 @@ dependencies = [ "either", "generic-array", "getrandom 0.1.16", + "hashbrown 0.12.3", "im", "lazy_static", "log", @@ -1802,21 +1491,21 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.16.3" +version = "1.14.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f84be4b6dd2cc4e8ad5baa54a23018c8936ec32322ebcffd88355631700292a" +checksum = "1f527f44601b35dd67d11bc72f2f7512976a466f9304ef574b87dac83ced8a42" dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.25", + "syn 1.0.109", ] [[package]] name = "solana-logger" -version = "1.16.3" +version = "1.14.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3cb934e8c9015e86cd9c7382ea3083578d1c0813a351644cfdabe3009591b03" +checksum = "8632c8bc480bb5615b70a18b807ede73024aebc7761503ff86a70b7f4906ae47" dependencies = [ "env_logger", "lazy_static", @@ -1825,20 +1514,16 @@ dependencies = [ [[package]] name = "solana-program" -version = "1.16.3" +version = "1.14.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "476510cb86b9602a793582788f5e23a9cca11929d3880b7427a67142b1e4a430" +checksum = "51ad5f48743ce505f6139a07e20aecdc689def12da7230fed661c2073ab97df8" dependencies = [ - "ark-bn254", - "ark-ec", - "ark-ff", - "ark-serialize", - "array-bytes", - "base64 0.21.2", + "base64 0.13.1", "bincode", "bitflags", "blake3", - "borsh 0.10.3", + "borsh", + "borsh-derive", "bs58 0.4.0", "bv", "bytemuck", @@ -1853,13 +1538,12 @@ dependencies = [ "libc", "libsecp256k1", "log", - "memoffset", - "num-bigint", + "memoffset 0.6.5", "num-derive", "num-traits", "parking_lot", - "rand 0.7.3", - "rand_chacha 0.2.2", + "rand", + "rand_chacha", "rustc_version", "rustversion", "serde", @@ -1879,15 +1563,15 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "1.16.3" +version = "1.14.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "352b70bb14d8968d5484aa73a1aede3acc816f10a0b264c6599108c5dd6b647b" +checksum = "1c515a5a5a5cdc115044c33959eb4d091680f5e7ca8be9eb5218fb0c21bf3568" dependencies = [ "assert_matches", - "base64 0.21.2", + "base64 0.13.1", "bincode", "bitflags", - "borsh 0.10.3", + "borsh", "bs58 0.4.0", "bytemuck", "byteorder", @@ -1906,18 +1590,16 @@ dependencies = [ "memmap2", "num-derive", "num-traits", - "num_enum 0.6.1", "pbkdf2 0.11.0", "qstring", - "rand 0.7.3", - "rand_chacha 0.2.2", + "rand", + "rand_chacha", "rustc_version", "rustversion", "serde", "serde_bytes", "serde_derive", "serde_json", - "serde_with", "sha2 0.10.7", "sha3 0.10.8", "solana-frozen-abi", @@ -1932,28 +1614,30 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.16.3" +version = "1.14.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e38a884c027b0759d0969efc1253f3b8798f9d5fbef2eb158cdb70763619d2f3" +checksum = "4bbc3ab3070c090e1a18fd5a0a07d729d0db2bc8524414dc3e16504286d38049" dependencies = [ "bs58 0.4.0", "proc-macro2", "quote", "rustversion", - "syn 2.0.25", + "syn 1.0.109", ] [[package]] name = "solana-zk-token-sdk" -version = "1.16.3" +version = "1.14.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a4c38e1cf77cc046a48d0e515ec3fe654d9c3ba49790523f2d8fd28a5e51d3" +checksum = "5d51d131cdefcb621a8034321ce487c4f788e813f81ce81e4f65eed8d4b4f2aa" dependencies = [ "aes-gcm-siv", - "base64 0.21.2", + "arrayref", + "base64 0.13.1", "bincode", "bytemuck", "byteorder", + "cipher 0.4.4", "curve25519-dalek", "getrandom 0.1.16", "itertools", @@ -1961,7 +1645,7 @@ dependencies = [ "merlin", "num-derive", "num-traits", - "rand 0.7.3", + "rand", "serde", "serde_json", "sha3 0.9.1", @@ -1979,7 +1663,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978dba3bcbe88d0c2c58366c254d9ea41c5f73357e72fc0bdee4d6b5fc99c8f4" dependencies = [ "assert_matches", - "borsh 0.9.3", + "borsh", "num-derive", "num-traits", "solana-program", @@ -2007,7 +1691,7 @@ dependencies = [ "bytemuck", "num-derive", "num-traits", - "num_enum 0.5.11", + "num_enum", "solana-program", "thiserror", ] @@ -2022,7 +1706,7 @@ dependencies = [ "bytemuck", "num-derive", "num-traits", - "num_enum 0.5.11", + "num_enum", "solana-program", "solana-zk-token-sdk", "spl-memo", @@ -2030,12 +1714,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "subtle" version = "2.4.1" @@ -2055,9 +1733,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.25" +version = "2.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" dependencies = [ "proc-macro2", "quote", @@ -2070,6 +1748,7 @@ version = "0.1.0" dependencies = [ "anchor-lang", "anchor-spl", + "solana-program", ] [[package]] @@ -2083,22 +1762,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.28", ] [[package]] @@ -2111,7 +1790,7 @@ dependencies = [ "hmac 0.8.1", "once_cell", "pbkdf2 0.4.0", - "rand 0.7.3", + "rand", "rustc-hash", "sha2 0.9.9", "thiserror", @@ -2146,15 +1825,15 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" [[package]] name = "toml_edit" -version = "0.19.12" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", "toml_datetime", @@ -2169,9 +1848,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -2247,7 +1926,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.28", "wasm-bindgen-shared", ] @@ -2269,7 +1948,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.28", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2380,9 +2059,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.9" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529" +checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" dependencies = [ "memchr", ] @@ -2404,5 +2083,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.28", ] diff --git a/cross-chain/solana/package-lock.json b/cross-chain/solana/package-lock.json deleted file mode 100644 index b524a8dc3..000000000 --- a/cross-chain/solana/package-lock.json +++ /dev/null @@ -1,1947 +0,0 @@ -{ - "name": "solana", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "dependencies": { - "@coral-xyz/anchor": "^0.28.0" - }, - "devDependencies": { - "@solana/spl-token": "^0.3.8", - "@solana/web3.js": "^1.77.3", - "@types/bn.js": "^5.1.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.0.0", - "chai": "^4.3.4", - "mocha": "^9.0.3", - "prettier": "^2.6.2", - "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" - } - }, - "node_modules/@babel/runtime": { - "version": "7.22.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.6.tgz", - "integrity": "sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==", - "dependencies": { - "regenerator-runtime": "^0.13.11" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@coral-xyz/anchor": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.28.0.tgz", - "integrity": "sha512-kQ02Hv2ZqxtWP30WN1d4xxT4QqlOXYDxmEd3k/bbneqhV3X5QMO4LAtoUFs7otxyivOgoqam5Il5qx81FuI4vw==", - "dependencies": { - "@coral-xyz/borsh": "^0.28.0", - "@solana/web3.js": "^1.68.0", - "base64-js": "^1.5.1", - "bn.js": "^5.1.2", - "bs58": "^4.0.1", - "buffer-layout": "^1.2.2", - "camelcase": "^6.3.0", - "cross-fetch": "^3.1.5", - "crypto-hash": "^1.3.0", - "eventemitter3": "^4.0.7", - "js-sha256": "^0.9.0", - "pako": "^2.0.3", - "snake-case": "^3.0.4", - "superstruct": "^0.15.4", - "toml": "^3.0.0" - }, - "engines": { - "node": ">=11" - } - }, - "node_modules/@coral-xyz/borsh": { - "version": "0.28.0", - "resolved": "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.28.0.tgz", - "integrity": "sha512-/u1VTzw7XooK7rqeD7JLUSwOyRSesPUk0U37BV9zK0axJc1q0nRbKFGFLYCQ16OtdOJTTwGfGp11Lx9B45bRCQ==", - "dependencies": { - "bn.js": "^5.1.2", - "buffer-layout": "^1.2.0" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "@solana/web3.js": "^1.68.0" - } - }, - "node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", - "dependencies": { - "@noble/hashes": "1.3.1" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@solana/buffer-layout": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz", - "integrity": "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==", - "dependencies": { - "buffer": "~6.0.3" - }, - "engines": { - "node": ">=5.10" - } - }, - "node_modules/@solana/buffer-layout-utils": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz", - "integrity": "sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g==", - "dev": true, - "dependencies": { - "@solana/buffer-layout": "^4.0.0", - "@solana/web3.js": "^1.32.0", - "bigint-buffer": "^1.1.5", - "bignumber.js": "^9.0.1" - }, - "engines": { - "node": ">= 10" - } - }, - "node_modules/@solana/spl-token": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.8.tgz", - "integrity": "sha512-ogwGDcunP9Lkj+9CODOWMiVJEdRtqHAtX2rWF62KxnnSWtMZtV9rDhTrZFshiyJmxDnRL/1nKE1yJHg4jjs3gg==", - "dev": true, - "dependencies": { - "@solana/buffer-layout": "^4.0.0", - "@solana/buffer-layout-utils": "^0.2.0", - "buffer": "^6.0.3" - }, - "engines": { - "node": ">=16" - }, - "peerDependencies": { - "@solana/web3.js": "^1.47.4" - } - }, - "node_modules/@solana/web3.js": { - "version": "1.78.1", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.78.1.tgz", - "integrity": "sha512-r0WZAYwCfVElfONP/dmWkEfw6wufL+u7lWojEsNecn9PyIIYq+r4eb0h2MRiJ3xkctvTN76G0T6FTGcTJhXh3Q==", - "dependencies": { - "@babel/runtime": "^7.22.6", - "@noble/curves": "^1.0.0", - "@noble/hashes": "^1.3.0", - "@solana/buffer-layout": "^4.0.0", - "agentkeepalive": "^4.2.1", - "bigint-buffer": "^1.1.5", - "bn.js": "^5.0.0", - "borsh": "^0.7.0", - "bs58": "^4.0.1", - "buffer": "6.0.3", - "fast-stable-stringify": "^1.0.0", - "jayson": "^4.1.0", - "node-fetch": "^2.6.12", - "rpc-websockets": "^7.5.1", - "superstruct": "^0.14.2" - } - }, - "node_modules/@solana/web3.js/node_modules/superstruct": { - "version": "0.14.2", - "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.14.2.tgz", - "integrity": "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==" - }, - "node_modules/@types/bn.js": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", - "integrity": "sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/chai": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.5.tgz", - "integrity": "sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==", - "dev": true - }, - "node_modules/@types/connect": { - "version": "3.4.35", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", - "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", - "dev": true, - "optional": true - }, - "node_modules/@types/mocha": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-9.1.1.tgz", - "integrity": "sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw==", - "dev": true - }, - "node_modules/@types/node": { - "version": "20.4.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.5.tgz", - "integrity": "sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg==" - }, - "node_modules/@types/ws": { - "version": "7.4.7", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", - "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true - }, - "node_modules/agentkeepalive": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.3.0.tgz", - "integrity": "sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg==", - "dependencies": { - "debug": "^4.1.0", - "depd": "^2.0.0", - "humanize-ms": "^1.2.1" - }, - "engines": { - "node": ">= 8.0.0" - } - }, - "node_modules/ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "node_modules/arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "node_modules/base-x": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", - "integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/bigint-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz", - "integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==", - "hasInstallScript": true, - "dependencies": { - "bindings": "^1.3.0" - }, - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/bignumber.js": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.1.tgz", - "integrity": "sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, - "node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" - }, - "node_modules/borsh": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", - "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", - "dependencies": { - "bn.js": "^5.2.0", - "bs58": "^4.0.0", - "text-encoding-utf-8": "^1.0.2" - } - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", - "dev": true, - "dependencies": { - "fill-range": "^7.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true - }, - "node_modules/bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "dependencies": { - "base-x": "^3.0.2" - } - }, - "node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true - }, - "node_modules/buffer-layout": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/buffer-layout/-/buffer-layout-1.2.2.tgz", - "integrity": "sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==", - "engines": { - "node": ">=4.5" - } - }, - "node_modules/bufferutil": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", - "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", - "hasInstallScript": true, - "optional": true, - "dependencies": { - "node-gyp-build": "^4.3.0" - }, - "engines": { - "node": ">=6.14.2" - } - }, - "node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/chai": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", - "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", - "dev": true, - "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^4.1.2", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chalk/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/chokidar": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", - "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true - }, - "node_modules/cross-fetch": { - "version": "3.1.8", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", - "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", - "dependencies": { - "node-fetch": "^2.6.12" - } - }, - "node_modules/crypto-hash": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/crypto-hash/-/crypto-hash-1.3.0.tgz", - "integrity": "sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg==", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/deep-eql": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", - "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==", - "dev": true, - "dependencies": { - "type-detect": "^4.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/delay": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz", - "integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/dot-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", - "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/es6-promise": { - "version": "4.2.8", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", - "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" - }, - "node_modules/es6-promisify": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", - "integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==", - "dependencies": { - "es6-promise": "^4.0.3" - } - }, - "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eventemitter3": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", - "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" - }, - "node_modules/eyes": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", - "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==", - "engines": { - "node": "> 0.1.90" - } - }, - "node_modules/fast-stable-stringify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", - "integrity": "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==" - }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, - "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true, - "bin": { - "flat": "cli.js" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true - }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/glob/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true, - "engines": { - "node": ">=4.x" - } - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true, - "bin": { - "he": "bin/he" - } - }, - "node_modules/humanize-ms": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", - "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", - "dependencies": { - "ms": "^2.0.0" - } - }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "dev": true, - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, - "node_modules/isomorphic-ws": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", - "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", - "peerDependencies": { - "ws": "*" - } - }, - "node_modules/jayson": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/jayson/-/jayson-4.1.0.tgz", - "integrity": "sha512-R6JlbyLN53Mjku329XoRT2zJAE6ZgOQ8f91ucYdMCD4nkGCF9kZSrcGXpHIU4jeKj58zUZke2p+cdQchU7Ly7A==", - "dependencies": { - "@types/connect": "^3.4.33", - "@types/node": "^12.12.54", - "@types/ws": "^7.4.4", - "commander": "^2.20.3", - "delay": "^5.0.0", - "es6-promisify": "^5.0.0", - "eyes": "^0.1.8", - "isomorphic-ws": "^4.0.1", - "json-stringify-safe": "^5.0.1", - "JSONStream": "^1.3.5", - "uuid": "^8.3.2", - "ws": "^7.4.5" - }, - "bin": { - "jayson": "bin/jayson.js" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/jayson/node_modules/@types/node": { - "version": "12.20.55", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz", - "integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==" - }, - "node_modules/js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" - }, - "node_modules/json5": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", - "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", - "dev": true, - "optional": true, - "dependencies": { - "minimist": "^1.2.0" - }, - "bin": { - "json5": "lib/cli.js" - } - }, - "node_modules/jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", - "engines": [ - "node >= 0.2.0" - ] - }, - "node_modules/JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dependencies": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - }, - "bin": { - "JSONStream": "bin.js" - }, - "engines": { - "node": "*" - } - }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/loupe": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.6.tgz", - "integrity": "sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==", - "dev": true, - "dependencies": { - "get-func-name": "^2.0.0" - } - }, - "node_modules/lower-case": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", - "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", - "dependencies": { - "tslib": "^2.0.3" - } - }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true - }, - "node_modules/minimatch": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-4.2.1.tgz", - "integrity": "sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dev": true, - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, - "node_modules/mocha": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.2.2.tgz", - "integrity": "sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g==", - "dev": true, - "dependencies": { - "@ungap/promise-all-settled": "1.1.2", - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", - "chokidar": "3.5.3", - "debug": "4.3.3", - "diff": "5.0.0", - "escape-string-regexp": "4.0.0", - "find-up": "5.0.0", - "glob": "7.2.0", - "growl": "1.10.5", - "he": "1.2.0", - "js-yaml": "4.1.0", - "log-symbols": "4.1.0", - "minimatch": "4.2.1", - "ms": "2.1.3", - "nanoid": "3.3.1", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "which": "2.0.2", - "workerpool": "6.2.0", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" - }, - "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mochajs" - } - }, - "node_modules/mocha/node_modules/debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/mocha/node_modules/debug/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "node_modules/mocha/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - }, - "node_modules/nanoid": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", - "integrity": "sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==", - "dev": true, - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, - "node_modules/no-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", - "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", - "dependencies": { - "lower-case": "^2.0.2", - "tslib": "^2.0.3" - } - }, - "node_modules/node-fetch": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", - "integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, - "node_modules/node-gyp-build": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz", - "integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==", - "optional": true, - "bin": { - "node-gyp-build": "bin.js", - "node-gyp-build-optional": "optional.js", - "node-gyp-build-test": "build-test.js" - } - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "dependencies": { - "p-limit": "^3.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pako": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", - "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==" - }, - "node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", - "dev": true, - "engines": { - "node": "*" - } - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/prettier": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", - "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", - "dev": true, - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/rpc-websockets": { - "version": "7.5.1", - "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-7.5.1.tgz", - "integrity": "sha512-kGFkeTsmd37pHPMaHIgN1LVKXMi0JD782v4Ds9ZKtLlwdTKjn+CxM9A9/gLT2LaOuEcEFGL98h1QWQtlOIdW0w==", - "dependencies": { - "@babel/runtime": "^7.17.2", - "eventemitter3": "^4.0.7", - "uuid": "^8.3.2", - "ws": "^8.5.0" - }, - "funding": { - "type": "paypal", - "url": "https://paypal.me/kozjak" - }, - "optionalDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - } - }, - "node_modules/rpc-websockets/node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", - "dev": true, - "dependencies": { - "randombytes": "^2.1.0" - } - }, - "node_modules/snake-case": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", - "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", - "dependencies": { - "dot-case": "^3.0.4", - "tslib": "^2.0.3" - } - }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/source-map-support": { - "version": "0.5.21", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", - "dev": true, - "dependencies": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - } - }, - "node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", - "dev": true, - "optional": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/superstruct": { - "version": "0.15.5", - "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz", - "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==" - }, - "node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, - "node_modules/text-encoding-utf-8": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", - "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" - }, - "node_modules/through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/toml": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", - "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" - }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, - "node_modules/ts-mocha": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-10.0.0.tgz", - "integrity": "sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw==", - "dev": true, - "dependencies": { - "ts-node": "7.0.1" - }, - "bin": { - "ts-mocha": "bin/ts-mocha" - }, - "engines": { - "node": ">= 6.X.X" - }, - "optionalDependencies": { - "tsconfig-paths": "^3.5.0" - }, - "peerDependencies": { - "mocha": "^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X" - } - }, - "node_modules/ts-node": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", - "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", - "dev": true, - "dependencies": { - "arrify": "^1.0.0", - "buffer-from": "^1.1.0", - "diff": "^3.1.0", - "make-error": "^1.1.1", - "minimist": "^1.2.0", - "mkdirp": "^0.5.1", - "source-map-support": "^0.5.6", - "yn": "^2.0.0" - }, - "bin": { - "ts-node": "dist/bin.js" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/ts-node/node_modules/diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true, - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/tsconfig-paths": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", - "integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==", - "dev": true, - "optional": true, - "dependencies": { - "@types/json5": "^0.0.29", - "json5": "^1.0.2", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - } - }, - "node_modules/tslib": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.1.tgz", - "integrity": "sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==" - }, - "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, - "node_modules/utf-8-validate": { - "version": "5.0.10", - "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", - "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", - "hasInstallScript": true, - "optional": true, - "dependencies": { - "node-gyp-build": "^4.3.0" - }, - "engines": { - "node": ">=6.14.2" - } - }, - "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/workerpool": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.0.tgz", - "integrity": "sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A==", - "dev": true - }, - "node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true - }, - "node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", - "engines": { - "node": ">=8.3.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "dev": true, - "dependencies": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/yn": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", - "integrity": "sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - } - } -} diff --git a/cross-chain/solana/programs/tbtc/Cargo.toml b/cross-chain/solana/programs/tbtc/Cargo.toml index 25ef87264..127bfb608 100644 --- a/cross-chain/solana/programs/tbtc/Cargo.toml +++ b/cross-chain/solana/programs/tbtc/Cargo.toml @@ -16,5 +16,6 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -anchor-lang = { version = "0.28.0", features = ["init-if-needed"] } -anchor-spl = "0.28.0" \ No newline at end of file +anchor-lang = { version = "=0.28.0", features = ["derive", "init-if-needed"] } +anchor-spl = "=0.28.0" +solana-program = "=1.14.20" diff --git a/cross-chain/solana/programs/tbtc/src/constants.rs b/cross-chain/solana/programs/tbtc/src/constants.rs index fb63dab07..35f37b14b 100644 --- a/cross-chain/solana/programs/tbtc/src/constants.rs +++ b/cross-chain/solana/programs/tbtc/src/constants.rs @@ -1,4 +1,4 @@ use anchor_lang::prelude::constant; #[constant] -pub const SEED_PREFIX_TBTC_MINT: &[u8] = b"tbtc-mint"; \ No newline at end of file +pub const SEED_PREFIX_TBTC_MINT: &[u8] = b"tbtc-mint"; diff --git a/cross-chain/solana/programs/tbtc/src/lib.rs b/cross-chain/solana/programs/tbtc/src/lib.rs index eb784c05c..94a987451 100644 --- a/cross-chain/solana/programs/tbtc/src/lib.rs +++ b/cross-chain/solana/programs/tbtc/src/lib.rs @@ -1,76 +1,55 @@ -use anchor_lang::prelude::*; - +mod constants; pub use constants::*; -pub use error::*; -pub(crate) use processor::*; -pub use state::*; -pub mod constants; pub mod error; + mod processor; -pub mod state; +pub(crate) use processor::*; + +mod state; +pub use state::*; + +use anchor_lang::prelude::*; declare_id!("HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG"); #[program] pub mod tbtc { use super::*; - - pub fn initialize( - ctx: Context, - ) -> Result<()> { + + pub fn initialize(ctx: Context) -> Result<()> { processor::initialize(ctx) } - pub fn change_authority( - ctx: Context, - ) -> Result<()> { + pub fn change_authority(ctx: Context) -> Result<()> { processor::change_authority(ctx) } - pub fn add_minter( - ctx: Context, - ) -> Result<()> { + pub fn add_minter(ctx: Context) -> Result<()> { processor::add_minter(ctx) } - pub fn remove_minter( - ctx: Context, - minter: Pubkey, - ) -> Result<()> { + pub fn remove_minter(ctx: Context, minter: Pubkey) -> Result<()> { processor::remove_minter(ctx, minter) } - pub fn add_guardian( - ctx: Context, - ) -> Result<()> { + pub fn add_guardian(ctx: Context) -> Result<()> { processor::add_guardian(ctx) } - pub fn remove_guardian( - ctx: Context, - guardian: Pubkey, - ) -> Result<()> { + pub fn remove_guardian(ctx: Context, guardian: Pubkey) -> Result<()> { processor::remove_guardian(ctx, guardian) } - pub fn pause( - ctx: Context, - ) -> Result<()> { + pub fn pause(ctx: Context) -> Result<()> { processor::pause(ctx) } - pub fn unpause( - ctx: Context, - ) -> Result<()> { + pub fn unpause(ctx: Context) -> Result<()> { processor::unpause(ctx) } - pub fn mint( - ctx: Context, - amount: u64, - ) -> Result<()> { + pub fn mint(ctx: Context, amount: u64) -> Result<()> { processor::mint(ctx, amount) } } - diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs index f0dab2236..ccce8f25b 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Tbtc, GuardianInfo}, + state::{GuardianInfo, Tbtc}, }; use anchor_lang::prelude::*; @@ -33,4 +33,4 @@ pub fn add_guardian(ctx: Context) -> Result<()> { ctx.accounts.tbtc.guardians += 1; Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs index cb3e4fe92..82db6f436 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Tbtc, MinterInfo}, + state::{MinterInfo, Tbtc}, }; use anchor_lang::prelude::*; @@ -33,4 +33,4 @@ pub fn add_minter(ctx: Context) -> Result<()> { ctx.accounts.tbtc.minters += 1; Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs index 6ce176d6d..2526c88f7 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs @@ -1,7 +1,4 @@ -use crate::{ - error::TbtcError, - state::{Tbtc}, -}; +use crate::{error::TbtcError, state::Tbtc}; use anchor_lang::prelude::*; #[derive(Accounts)] @@ -20,4 +17,4 @@ pub struct ChangeAuthority<'info> { pub fn change_authority(ctx: Context) -> Result<()> { ctx.accounts.tbtc.authority = ctx.accounts.new_authority.key(); Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs index 0fcb7b980..d4feff73b 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs @@ -1,14 +1,6 @@ -use crate::{ - constants::SEED_PREFIX_TBTC_MINT, - state::{Tbtc}, -}; +use crate::{constants::SEED_PREFIX_TBTC_MINT, state::Tbtc}; use anchor_lang::prelude::*; -use anchor_spl::{ - token, -}; - - - +use anchor_spl::token; #[derive(Accounts)] pub struct Initialize<'info> { @@ -29,9 +21,9 @@ pub struct Initialize<'info> { #[account(mut)] pub authority: Signer<'info>, - + pub token_program: Program<'info, token::Token>, - pub system_program: Program<'info, System> + pub system_program: Program<'info, System>, } pub fn initialize(ctx: Context) -> Result<()> { @@ -44,4 +36,4 @@ pub fn initialize(ctx: Context) -> Result<()> { paused: false, }); Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs index 8e6c69a39..bc1f98170 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs @@ -1,17 +1,23 @@ mod add_guardian; -mod add_minter; -mod change_authority; -mod initialize; -mod pause; -mod remove_guardian; -mod remove_minter; -mod unpause; - pub use add_guardian::*; + +mod add_minter; pub use add_minter::*; + +mod change_authority; pub use change_authority::*; + +mod initialize; pub use initialize::*; + +mod pause; pub use pause::*; + +mod remove_guardian; pub use remove_guardian::*; + +mod remove_minter; pub use remove_minter::*; -pub use unpause::*; \ No newline at end of file + +mod unpause; +pub use unpause::*; diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs index 11b078d85..798b2b79f 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Tbtc, GuardianInfo}, + state::{GuardianInfo, Tbtc}, }; use anchor_lang::prelude::*; @@ -23,4 +23,4 @@ pub struct Pause<'info> { pub fn pause(ctx: Context) -> Result<()> { ctx.accounts.tbtc.paused = true; Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs index 17dda7d85..9fb2f1aea 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Tbtc, GuardianInfo}, + state::{GuardianInfo, Tbtc}, }; use anchor_lang::prelude::*; diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs index 7b0183d79..9ed557727 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Tbtc, MinterInfo}, + state::{MinterInfo, Tbtc}, }; use anchor_lang::prelude::*; @@ -26,4 +26,4 @@ pub struct RemoveMinter<'info> { pub fn remove_minter(ctx: Context, _minter: Pubkey) -> Result<()> { ctx.accounts.tbtc.minters -= 1; Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs index c1c594243..a8c46c759 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs @@ -1,7 +1,4 @@ -use crate::{ - error::TbtcError, - state::Tbtc, -}; +use crate::{error::TbtcError, state::Tbtc}; use anchor_lang::prelude::*; #[derive(Accounts)] @@ -18,4 +15,4 @@ pub struct Unpause<'info> { pub fn unpause(ctx: Context) -> Result<()> { ctx.accounts.tbtc.paused = false; Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs b/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs index 089e0a914..aaf3517a9 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs @@ -1,13 +1,10 @@ use crate::{ constants::SEED_PREFIX_TBTC_MINT, error::TbtcError, - state::{Tbtc, MinterInfo}, + state::{MinterInfo, Tbtc}, }; use anchor_lang::prelude::*; -use anchor_spl::{ - associated_token::AssociatedToken, - token, -}; +use anchor_spl::{associated_token::AssociatedToken, token}; #[derive(Accounts)] pub struct Mint<'info> { @@ -49,9 +46,7 @@ pub struct Mint<'info> { /// Validating the recipient is the minter's responsibility. pub recipient: UncheckedAccount<'info>, - #[account( - mut, - )] + #[account(mut)] pub payer: Signer<'info>, pub token_program: Program<'info, token::Token>, @@ -75,4 +70,4 @@ pub fn mint(ctx: Context, amount: u64) -> Result<()> { signer, ); token::mint_to(cpi_ctx, amount) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs b/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs index 6eac15698..21177667f 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs @@ -1,3 +1,2 @@ mod mint; - -pub use mint::*; \ No newline at end of file +pub use mint::*; diff --git a/cross-chain/solana/programs/tbtc/src/processor/mod.rs b/cross-chain/solana/programs/tbtc/src/processor/mod.rs index 3e7105fef..e54b71164 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/mod.rs @@ -1,5 +1,5 @@ mod admin; -mod mint; - pub use admin::*; -pub use mint::*; \ No newline at end of file + +mod mint; +pub use mint::*; diff --git a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs index 385d4c1d7..656b767bb 100644 --- a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs @@ -14,4 +14,4 @@ impl GuardianInfo { pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; // discriminator + pubkey + bump pub const SEED_PREFIX: &'static [u8; 13] = b"guardian-info"; -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/state/minter_info.rs b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs index b287c2514..978f6ff9d 100644 --- a/cross-chain/solana/programs/tbtc/src/state/minter_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs @@ -14,4 +14,4 @@ impl MinterInfo { pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; // discriminator + pubkey + bump pub const SEED_PREFIX: &'static [u8; 11] = b"minter-info"; -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/state/mod.rs b/cross-chain/solana/programs/tbtc/src/state/mod.rs index 234adb0d0..abfdadb81 100644 --- a/cross-chain/solana/programs/tbtc/src/state/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/state/mod.rs @@ -4,4 +4,4 @@ pub use tbtc::*; pub mod guardian_info; pub mod minter_info; -pub mod tbtc; \ No newline at end of file +pub mod tbtc; diff --git a/cross-chain/solana/programs/tbtc/src/state/tbtc.rs b/cross-chain/solana/programs/tbtc/src/state/tbtc.rs index 3254e0b81..c5a3027b7 100644 --- a/cross-chain/solana/programs/tbtc/src/state/tbtc.rs +++ b/cross-chain/solana/programs/tbtc/src/state/tbtc.rs @@ -1,6 +1,5 @@ use anchor_lang::prelude::*; - #[account] #[derive(Default)] pub struct Tbtc { @@ -21,4 +20,4 @@ impl Tbtc { // 1 u8 // 1 bool pub const MAXIMUM_SIZE: usize = 8 + 32 + 32 + 1 + 1 + 1 + 1; -} \ No newline at end of file +} diff --git a/cross-chain/solana/tests/tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts similarity index 100% rename from cross-chain/solana/tests/tbtc.ts rename to cross-chain/solana/tests/01__tbtc.ts diff --git a/cross-chain/solana/yarn.lock b/cross-chain/solana/yarn.lock index fb1384a54..a8ab27ba6 100644 --- a/cross-chain/solana/yarn.lock +++ b/cross-chain/solana/yarn.lock @@ -1,2486 +1,1183 @@ -# This file is generated by running "yarn install" inside your project. -# Manual changes might be lost - proceed with caution! - -__metadata: - version: 6 - cacheKey: 8 - -"@babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.22.6": - version: 7.22.6 - resolution: "@babel/runtime@npm:7.22.6" - dependencies: - regenerator-runtime: ^0.13.11 - checksum: e585338287c4514a713babf4fdb8fc2a67adcebab3e7723a739fc62c79cfda875b314c90fd25f827afb150d781af97bc16c85bfdbfa2889f06053879a1ddb597 - languageName: node - linkType: hard - -"@coral-xyz/anchor@npm:^0.28.0": - version: 0.28.0 - resolution: "@coral-xyz/anchor@npm:0.28.0" - dependencies: - "@coral-xyz/borsh": ^0.28.0 - "@solana/web3.js": ^1.68.0 - base64-js: ^1.5.1 - bn.js: ^5.1.2 - bs58: ^4.0.1 - buffer-layout: ^1.2.2 - camelcase: ^6.3.0 - cross-fetch: ^3.1.5 - crypto-hash: ^1.3.0 - eventemitter3: ^4.0.7 - js-sha256: ^0.9.0 - pako: ^2.0.3 - snake-case: ^3.0.4 - superstruct: ^0.15.4 - toml: ^3.0.0 - checksum: 58b3677b5b2ce2c779045184ce4a0ef696966a6a58f41c1c56f6f178db0491acecb6ec677ce0502f0b382a2c724f9c2860d82cc88601784d556d95fbeda415e5 - languageName: node - linkType: hard - -"@coral-xyz/borsh@npm:^0.28.0": - version: 0.28.0 - resolution: "@coral-xyz/borsh@npm:0.28.0" - dependencies: - bn.js: ^5.1.2 - buffer-layout: ^1.2.0 - peerDependencies: - "@solana/web3.js": ^1.68.0 - checksum: bc2b06b777f9ed43d3b886d2350826bd44d5b932c4fd4471af5956e8755236f5854938c890ee4986d88f61d1439e1d84e715c43dcb6dca4e76198c1ce8dc7a58 - languageName: node - linkType: hard - -"@isaacs/cliui@npm:^8.0.2": - version: 8.0.2 - resolution: "@isaacs/cliui@npm:8.0.2" - dependencies: - string-width: ^5.1.2 - string-width-cjs: "npm:string-width@^4.2.0" - strip-ansi: ^7.0.1 - strip-ansi-cjs: "npm:strip-ansi@^6.0.1" - wrap-ansi: ^8.1.0 - wrap-ansi-cjs: "npm:wrap-ansi@^7.0.0" - checksum: 4a473b9b32a7d4d3cfb7a614226e555091ff0c5a29a1734c28c72a182c2f6699b26fc6b5c2131dfd841e86b185aea714c72201d7c98c2fba5f17709333a67aeb - languageName: node - linkType: hard - -"@noble/curves@npm:^1.0.0": - version: 1.1.0 - resolution: "@noble/curves@npm:1.1.0" - dependencies: - "@noble/hashes": 1.3.1 - checksum: 2658cdd3f84f71079b4e3516c47559d22cf4b55c23ac8ee9d2b1f8e5b72916d9689e59820e0f9d9cb4a46a8423af5b56dc6bb7782405c88be06a015180508db5 - languageName: node - linkType: hard - -"@noble/hashes@npm:1.3.1, @noble/hashes@npm:^1.3.0": - version: 1.3.1 - resolution: "@noble/hashes@npm:1.3.1" - checksum: 7fdefc0f7a0c1ec27acc6ff88841793e3f93ec4ce6b8a6a12bfc0dd70ae6b7c4c82fe305fdfeda1735d5ad4a9eebe761e6693b3d355689c559e91242f4bc95b1 - languageName: node - linkType: hard - -"@npmcli/fs@npm:^3.1.0": - version: 3.1.0 - resolution: "@npmcli/fs@npm:3.1.0" - dependencies: - semver: ^7.3.5 - checksum: a50a6818de5fc557d0b0e6f50ec780a7a02ab8ad07e5ac8b16bf519e0ad60a144ac64f97d05c443c3367235d337182e1d012bbac0eb8dbae8dc7b40b193efd0e - languageName: node - linkType: hard - -"@pkgjs/parseargs@npm:^0.11.0": - version: 0.11.0 - resolution: "@pkgjs/parseargs@npm:0.11.0" - checksum: 6ad6a00fc4f2f2cfc6bff76fb1d88b8ee20bc0601e18ebb01b6d4be583733a860239a521a7fbca73b612e66705078809483549d2b18f370eb346c5155c8e4a0f - languageName: node - linkType: hard - -"@solana/buffer-layout-utils@npm:^0.2.0": - version: 0.2.0 - resolution: "@solana/buffer-layout-utils@npm:0.2.0" - dependencies: - "@solana/buffer-layout": ^4.0.0 - "@solana/web3.js": ^1.32.0 - bigint-buffer: ^1.1.5 - bignumber.js: ^9.0.1 - checksum: 9284242245b18b49577195ba7548263850be865a4a2d183944fa01bb76382039db589aab8473698e9bb734b515ada9b4d70db0a72e341c5d567c59b83d6d0840 - languageName: node - linkType: hard - -"@solana/buffer-layout@npm:^4.0.0": - version: 4.0.1 - resolution: "@solana/buffer-layout@npm:4.0.1" - dependencies: - buffer: ~6.0.3 - checksum: bf846888e813187243d4008a7a9f58b49d16cbd995b9d7f1b72898aa510ed77b1ce5e8468e7b2fd26dd81e557a4e74a666e21fccb95f123c1f740d41138bbacd - languageName: node - linkType: hard - -"@solana/spl-token@npm:^0.3.8": - version: 0.3.8 - resolution: "@solana/spl-token@npm:0.3.8" - dependencies: - "@solana/buffer-layout": ^4.0.0 - "@solana/buffer-layout-utils": ^0.2.0 - buffer: ^6.0.3 - peerDependencies: - "@solana/web3.js": ^1.47.4 - checksum: 01f4f87112b0ad277701a3bcb8e03069b69449b92724b17959107686731082bfd3475b5f105e1e8f04badd2e810a43d5ef811744ced5178eea1232de8fd75147 - languageName: node - linkType: hard - -"@solana/web3.js@npm:^1.32.0, @solana/web3.js@npm:^1.68.0, @solana/web3.js@npm:^1.77.3": - version: 1.78.1 - resolution: "@solana/web3.js@npm:1.78.1" - dependencies: - "@babel/runtime": ^7.22.6 - "@noble/curves": ^1.0.0 - "@noble/hashes": ^1.3.0 - "@solana/buffer-layout": ^4.0.0 - agentkeepalive: ^4.2.1 - bigint-buffer: ^1.1.5 - bn.js: ^5.0.0 - borsh: ^0.7.0 - bs58: ^4.0.1 - buffer: 6.0.3 - fast-stable-stringify: ^1.0.0 - jayson: ^4.1.0 - node-fetch: ^2.6.12 - rpc-websockets: ^7.5.1 - superstruct: ^0.14.2 - checksum: cf3b139fd9be47d1ed5d1df301729b722f6f53b8afe3ce33d17575e9753c153bfc2ad655582e3a4df1683977bbb26ac7808fc09cae3e61084e7506b6ef2ab51e - languageName: node - linkType: hard - -"@tootallnate/once@npm:2": - version: 2.0.0 - resolution: "@tootallnate/once@npm:2.0.0" - checksum: ad87447820dd3f24825d2d947ebc03072b20a42bfc96cbafec16bff8bbda6c1a81fcb0be56d5b21968560c5359a0af4038a68ba150c3e1694fe4c109a063bed8 - languageName: node - linkType: hard - -"@types/bn.js@npm:^5.1.0": - version: 5.1.1 - resolution: "@types/bn.js@npm:5.1.1" - dependencies: - "@types/node": "*" - checksum: e50ed2dd3abe997e047caf90e0352c71e54fc388679735217978b4ceb7e336e51477791b715f49fd77195ac26dd296c7bad08a3be9750e235f9b2e1edb1b51c2 - languageName: node - linkType: hard - -"@types/chai@npm:^4.3.0": - version: 4.3.5 - resolution: "@types/chai@npm:4.3.5" - checksum: c8f26a88c6b5b53a3275c7f5ff8f107028e3cbb9ff26795fff5f3d9dea07106a54ce9e2dce5e40347f7c4cc35657900aaf0c83934a25a1ae12e61e0f5516e431 - languageName: node - linkType: hard - -"@types/connect@npm:^3.4.33": - version: 3.4.35 - resolution: "@types/connect@npm:3.4.35" - dependencies: - "@types/node": "*" - checksum: fe81351470f2d3165e8b12ce33542eef89ea893e36dd62e8f7d72566dfb7e448376ae962f9f3ea888547ce8b55a40020ca0e01d637fab5d99567673084542641 - languageName: node - linkType: hard - -"@types/json5@npm:^0.0.29": - version: 0.0.29 - resolution: "@types/json5@npm:0.0.29" - checksum: e60b153664572116dfea673c5bda7778dbff150498f44f998e34b5886d8afc47f16799280e4b6e241c0472aef1bc36add771c569c68fc5125fc2ae519a3eb9ac - languageName: node - linkType: hard - -"@types/mocha@npm:^9.0.0": - version: 9.1.1 - resolution: "@types/mocha@npm:9.1.1" - checksum: 516077c0acd9806dc78317f88aaac0df5aaf0bdc2f63dfdadeabdf0b0137953b6ca65472e6ff7c30bc93ce4e0ae76eae70e8d46764b9a8eae4877a928b6ef49a - languageName: node - linkType: hard - -"@types/node@npm:*": - version: 20.4.5 - resolution: "@types/node@npm:20.4.5" - checksum: 36a0304a8dc346a1b2d2edac4c4633eecf70875793d61a5274d0df052d7a7af7a8e34f29884eac4fbd094c4f0201477dcb39c0ecd3307ca141688806538d1138 - languageName: node - linkType: hard - -"@types/node@npm:^12.12.54": - version: 12.20.55 - resolution: "@types/node@npm:12.20.55" - checksum: e4f86785f4092706e0d3b0edff8dca5a13b45627e4b36700acd8dfe6ad53db71928c8dee914d4276c7fd3b6ccd829aa919811c9eb708a2c8e4c6eb3701178c37 - languageName: node - linkType: hard - -"@types/ws@npm:^7.4.4": - version: 7.4.7 - resolution: "@types/ws@npm:7.4.7" - dependencies: - "@types/node": "*" - checksum: b4c9b8ad209620c9b21e78314ce4ff07515c0cadab9af101c1651e7bfb992d7fd933bd8b9c99d110738fd6db523ed15f82f29f50b45510288da72e964dedb1a3 - languageName: node - linkType: hard - -"@ungap/promise-all-settled@npm:1.1.2": - version: 1.1.2 - resolution: "@ungap/promise-all-settled@npm:1.1.2" - checksum: 08d37fdfa23a6fe8139f1305313562ebad973f3fac01bcce2773b2bda5bcb0146dfdcf3cb6a722cf0a5f2ca0bc56a827eac8f1e7b3beddc548f654addf1fc34c - languageName: node - linkType: hard - -"JSONStream@npm:^1.3.5": - version: 1.3.5 - resolution: "JSONStream@npm:1.3.5" - dependencies: - jsonparse: ^1.2.0 - through: ">=2.2.7 <3" - bin: - JSONStream: ./bin.js - checksum: 2605fa124260c61bad38bb65eba30d2f72216a78e94d0ab19b11b4e0327d572b8d530c0c9cc3b0764f727ad26d39e00bf7ebad57781ca6368394d73169c59e46 - languageName: node - linkType: hard - -"abbrev@npm:^1.0.0": - version: 1.1.1 - resolution: "abbrev@npm:1.1.1" - checksum: a4a97ec07d7ea112c517036882b2ac22f3109b7b19077dc656316d07d308438aac28e4d9746dc4d84bf6b1e75b4a7b0a5f3cb30592419f128ca9a8cee3bcfa17 - languageName: node - linkType: hard - -"agent-base@npm:6, agent-base@npm:^6.0.2": - version: 6.0.2 - resolution: "agent-base@npm:6.0.2" - dependencies: - debug: 4 - checksum: f52b6872cc96fd5f622071b71ef200e01c7c4c454ee68bc9accca90c98cfb39f2810e3e9aa330435835eedc8c23f4f8a15267f67c6e245d2b33757575bdac49d - languageName: node - linkType: hard - -"agentkeepalive@npm:^4.2.1": - version: 4.3.0 - resolution: "agentkeepalive@npm:4.3.0" - dependencies: - debug: ^4.1.0 - depd: ^2.0.0 - humanize-ms: ^1.2.1 - checksum: 982453aa44c11a06826c836025e5162c846e1200adb56f2d075400da7d32d87021b3b0a58768d949d824811f5654223d5a8a3dad120921a2439625eb847c6260 - languageName: node - linkType: hard - -"aggregate-error@npm:^3.0.0": - version: 3.1.0 - resolution: "aggregate-error@npm:3.1.0" - dependencies: - clean-stack: ^2.0.0 - indent-string: ^4.0.0 - checksum: 1101a33f21baa27a2fa8e04b698271e64616b886795fd43c31068c07533c7b3facfcaf4e9e0cab3624bd88f729a592f1c901a1a229c9e490eafce411a8644b79 - languageName: node - linkType: hard - -"ansi-colors@npm:4.1.1": - version: 4.1.1 - resolution: "ansi-colors@npm:4.1.1" - checksum: 138d04a51076cb085da0a7e2d000c5c0bb09f6e772ed5c65c53cb118d37f6c5f1637506d7155fb5f330f0abcf6f12fa2e489ac3f8cdab9da393bf1bb4f9a32b0 - languageName: node - linkType: hard - -"ansi-regex@npm:^5.0.1": - version: 5.0.1 - resolution: "ansi-regex@npm:5.0.1" - checksum: 2aa4bb54caf2d622f1afdad09441695af2a83aa3fe8b8afa581d205e57ed4261c183c4d3877cee25794443fde5876417d859c108078ab788d6af7e4fe52eb66b - languageName: node - linkType: hard - -"ansi-regex@npm:^6.0.1": - version: 6.0.1 - resolution: "ansi-regex@npm:6.0.1" - checksum: 1ff8b7667cded1de4fa2c9ae283e979fc87036864317da86a2e546725f96406746411d0d85e87a2d12fa5abd715d90006de7fa4fa0477c92321ad3b4c7d4e169 - languageName: node - linkType: hard - -"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0": - version: 4.3.0 - resolution: "ansi-styles@npm:4.3.0" - dependencies: - color-convert: ^2.0.1 - checksum: 513b44c3b2105dd14cc42a19271e80f386466c4be574bccf60b627432f9198571ebf4ab1e4c3ba17347658f4ee1711c163d574248c0c1cdc2d5917a0ad582ec4 - languageName: node - linkType: hard - -"ansi-styles@npm:^6.1.0": - version: 6.2.1 - resolution: "ansi-styles@npm:6.2.1" - checksum: ef940f2f0ced1a6347398da88a91da7930c33ecac3c77b72c5905f8b8fe402c52e6fde304ff5347f616e27a742da3f1dc76de98f6866c69251ad0b07a66776d9 - languageName: node - linkType: hard - -"anymatch@npm:~3.1.2": - version: 3.1.3 - resolution: "anymatch@npm:3.1.3" - dependencies: - normalize-path: ^3.0.0 - picomatch: ^2.0.4 - checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 - languageName: node - linkType: hard - -"aproba@npm:^1.0.3 || ^2.0.0": - version: 2.0.0 - resolution: "aproba@npm:2.0.0" - checksum: 5615cadcfb45289eea63f8afd064ab656006361020e1735112e346593856f87435e02d8dcc7ff0d11928bc7d425f27bc7c2a84f6c0b35ab0ff659c814c138a24 - languageName: node - linkType: hard - -"are-we-there-yet@npm:^3.0.0": - version: 3.0.1 - resolution: "are-we-there-yet@npm:3.0.1" - dependencies: - delegates: ^1.0.0 - readable-stream: ^3.6.0 - checksum: 52590c24860fa7173bedeb69a4c05fb573473e860197f618b9a28432ee4379049336727ae3a1f9c4cb083114601c1140cee578376164d0e651217a9843f9fe83 - languageName: node - linkType: hard - -"argparse@npm:^2.0.1": - version: 2.0.1 - resolution: "argparse@npm:2.0.1" - checksum: 83644b56493e89a254bae05702abf3a1101b4fa4d0ca31df1c9985275a5a5bd47b3c27b7fa0b71098d41114d8ca000e6ed90cad764b306f8a503665e4d517ced - languageName: node - linkType: hard - -"arrify@npm:^1.0.0": - version: 1.0.1 - resolution: "arrify@npm:1.0.1" - checksum: 745075dd4a4624ff0225c331dacb99be501a515d39bcb7c84d24660314a6ec28e68131b137e6f7e16318170842ce97538cd298fc4cd6b2cc798e0b957f2747e7 - languageName: node - linkType: hard - -"assertion-error@npm:^1.1.0": - version: 1.1.0 - resolution: "assertion-error@npm:1.1.0" - checksum: fd9429d3a3d4fd61782eb3962ae76b6d08aa7383123fca0596020013b3ebd6647891a85b05ce821c47d1471ed1271f00b0545cf6a4326cf2fc91efcc3b0fbecf - languageName: node - linkType: hard - -"balanced-match@npm:^1.0.0": - version: 1.0.2 - resolution: "balanced-match@npm:1.0.2" - checksum: 9706c088a283058a8a99e0bf91b0a2f75497f185980d9ffa8b304de1d9e58ebda7c72c07ebf01dadedaac5b2907b2c6f566f660d62bd336c3468e960403b9d65 - languageName: node - linkType: hard - -"base-x@npm:^3.0.2": - version: 3.0.9 - resolution: "base-x@npm:3.0.9" - dependencies: - safe-buffer: ^5.0.1 - checksum: 957101d6fd09e1903e846fd8f69fd7e5e3e50254383e61ab667c725866bec54e5ece5ba49ce385128ae48f9ec93a26567d1d5ebb91f4d56ef4a9cc0d5a5481e8 - languageName: node - linkType: hard - -"base64-js@npm:^1.3.1, base64-js@npm:^1.5.1": - version: 1.5.1 - resolution: "base64-js@npm:1.5.1" - checksum: 669632eb3745404c2f822a18fc3a0122d2f9a7a13f7fb8b5823ee19d1d2ff9ee5b52c53367176ea4ad093c332fd5ab4bd0ebae5a8e27917a4105a4cfc86b1005 - languageName: node - linkType: hard - -"bigint-buffer@npm:^1.1.5": - version: 1.1.5 - resolution: "bigint-buffer@npm:1.1.5" - dependencies: - bindings: ^1.3.0 - node-gyp: latest - checksum: d010c9f57758bcdaccb435d88b483ffcc95fe8bbc6e7fb3a44fb5221f29c894ffaf4a3c5a4a530e0e7d6608203c2cde9b79ee4f2386cd6d4462d1070bc8c9f4e - languageName: node - linkType: hard - -"bignumber.js@npm:^9.0.1": - version: 9.1.1 - resolution: "bignumber.js@npm:9.1.1" - checksum: ad243b7e2f9120b112d670bb3d674128f0bd2ca1745b0a6c9df0433bd2c0252c43e6315d944c2ac07b4c639e7496b425e46842773cf89c6a2dcd4f31e5c4b11e - languageName: node - linkType: hard - -"binary-extensions@npm:^2.0.0": - version: 2.2.0 - resolution: "binary-extensions@npm:2.2.0" - checksum: ccd267956c58d2315f5d3ea6757cf09863c5fc703e50fbeb13a7dc849b812ef76e3cf9ca8f35a0c48498776a7478d7b4a0418e1e2b8cb9cb9731f2922aaad7f8 - languageName: node - linkType: hard - -"bindings@npm:^1.3.0": - version: 1.5.0 - resolution: "bindings@npm:1.5.0" - dependencies: - file-uri-to-path: 1.0.0 - checksum: 65b6b48095717c2e6105a021a7da4ea435aa8d3d3cd085cb9e85bcb6e5773cf318c4745c3f7c504412855940b585bdf9b918236612a1c7a7942491de176f1ae7 - languageName: node - linkType: hard - -"bn.js@npm:^5.0.0, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0": - version: 5.2.1 - resolution: "bn.js@npm:5.2.1" - checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3 - languageName: node - linkType: hard - -"borsh@npm:^0.7.0": - version: 0.7.0 - resolution: "borsh@npm:0.7.0" - dependencies: - bn.js: ^5.2.0 - bs58: ^4.0.0 - text-encoding-utf-8: ^1.0.2 - checksum: e98bfb5f7cfb820819c2870b884dac58dd4b4ce6a86c286c8fbf5c9ca582e73a8c6094df67e81a28c418ff07a309c6b118b2e27fdfea83fd92b8100c741da0b5 - languageName: node - linkType: hard - -"brace-expansion@npm:^1.1.7": - version: 1.1.11 - resolution: "brace-expansion@npm:1.1.11" - dependencies: - balanced-match: ^1.0.0 - concat-map: 0.0.1 - checksum: faf34a7bb0c3fcf4b59c7808bc5d2a96a40988addf2e7e09dfbb67a2251800e0d14cd2bfc1aa79174f2f5095c54ff27f46fb1289fe2d77dac755b5eb3434cc07 - languageName: node - linkType: hard - -"brace-expansion@npm:^2.0.1": - version: 2.0.1 - resolution: "brace-expansion@npm:2.0.1" - dependencies: - balanced-match: ^1.0.0 - checksum: a61e7cd2e8a8505e9f0036b3b6108ba5e926b4b55089eeb5550cd04a471fe216c96d4fe7e4c7f995c728c554ae20ddfc4244cad10aef255e72b62930afd233d1 - languageName: node - linkType: hard - -"braces@npm:~3.0.2": - version: 3.0.2 - resolution: "braces@npm:3.0.2" - dependencies: - fill-range: ^7.0.1 - checksum: e2a8e769a863f3d4ee887b5fe21f63193a891c68b612ddb4b68d82d1b5f3ff9073af066c343e9867a393fe4c2555dcb33e89b937195feb9c1613d259edfcd459 - languageName: node - linkType: hard - -"browser-stdout@npm:1.3.1": - version: 1.3.1 - resolution: "browser-stdout@npm:1.3.1" - checksum: b717b19b25952dd6af483e368f9bcd6b14b87740c3d226c2977a65e84666ffd67000bddea7d911f111a9b6ddc822b234de42d52ab6507bce4119a4cc003ef7b3 - languageName: node - linkType: hard - -"bs58@npm:^4.0.0, bs58@npm:^4.0.1": - version: 4.0.1 - resolution: "bs58@npm:4.0.1" - dependencies: - base-x: ^3.0.2 - checksum: b3c5365bb9e0c561e1a82f1a2d809a1a692059fae016be233a6127ad2f50a6b986467c3a50669ce4c18929dcccb297c5909314dd347a25a68c21b68eb3e95ac2 - languageName: node - linkType: hard - -"buffer-from@npm:^1.0.0, buffer-from@npm:^1.1.0": - version: 1.1.2 - resolution: "buffer-from@npm:1.1.2" - checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb - languageName: node - linkType: hard - -"buffer-layout@npm:^1.2.0, buffer-layout@npm:^1.2.2": - version: 1.2.2 - resolution: "buffer-layout@npm:1.2.2" - checksum: e5809ba275530bf4e52fd09558b7c2111fbda5b405124f581acf364261d9c154e271800271898cd40473f9bcbb42c31584efb04219bde549d3460ca4bafeaa07 - languageName: node - linkType: hard - -"buffer@npm:6.0.3, buffer@npm:^6.0.3, buffer@npm:~6.0.3": - version: 6.0.3 - resolution: "buffer@npm:6.0.3" - dependencies: - base64-js: ^1.3.1 - ieee754: ^1.2.1 - checksum: 5ad23293d9a731e4318e420025800b42bf0d264004c0286c8cc010af7a270c7a0f6522e84f54b9ad65cbd6db20b8badbfd8d2ebf4f80fa03dab093b89e68c3f9 - languageName: node - linkType: hard - -"bufferutil@npm:^4.0.1": - version: 4.0.7 - resolution: "bufferutil@npm:4.0.7" - dependencies: - node-gyp: latest - node-gyp-build: ^4.3.0 - checksum: f75aa87e3d1b99b87a95f60a855e63f70af07b57fb8443e75a2ddfef2e47788d130fdd46e3a78fd7e0c10176082b26dfbed970c5b8632e1cc299cafa0e93ce45 - languageName: node - linkType: hard - -"cacache@npm:^17.0.0": - version: 17.1.3 - resolution: "cacache@npm:17.1.3" - dependencies: - "@npmcli/fs": ^3.1.0 - fs-minipass: ^3.0.0 - glob: ^10.2.2 - lru-cache: ^7.7.1 - minipass: ^5.0.0 - minipass-collect: ^1.0.2 - minipass-flush: ^1.0.5 - minipass-pipeline: ^1.2.4 - p-map: ^4.0.0 - ssri: ^10.0.0 - tar: ^6.1.11 - unique-filename: ^3.0.0 - checksum: 385756781e1e21af089160d89d7462b7ed9883c978e848c7075b90b73cb823680e66092d61513050164588387d2ca87dd6d910e28d64bc13a9ac82cd8580c796 - languageName: node - linkType: hard - -"camelcase@npm:^6.0.0, camelcase@npm:^6.3.0": - version: 6.3.0 - resolution: "camelcase@npm:6.3.0" - checksum: 8c96818a9076434998511251dcb2761a94817ea17dbdc37f47ac080bd088fc62c7369429a19e2178b993497132c8cbcf5cc1f44ba963e76782ba469c0474938d - languageName: node - linkType: hard - -"chai@npm:^4.3.4": - version: 4.3.7 - resolution: "chai@npm:4.3.7" - dependencies: - assertion-error: ^1.1.0 - check-error: ^1.0.2 - deep-eql: ^4.1.2 - get-func-name: ^2.0.0 - loupe: ^2.3.1 - pathval: ^1.1.1 - type-detect: ^4.0.5 - checksum: 0bba7d267848015246a66995f044ce3f0ebc35e530da3cbdf171db744e14cbe301ab913a8d07caf7952b430257ccbb1a4a983c570a7c5748dc537897e5131f7c - languageName: node - linkType: hard - -"chalk@npm:^4.1.0": - version: 4.1.2 - resolution: "chalk@npm:4.1.2" - dependencies: - ansi-styles: ^4.1.0 - supports-color: ^7.1.0 - checksum: fe75c9d5c76a7a98d45495b91b2172fa3b7a09e0cc9370e5c8feb1c567b85c4288e2b3fded7cfdd7359ac28d6b3844feb8b82b8686842e93d23c827c417e83fc - languageName: node - linkType: hard - -"check-error@npm:^1.0.2": - version: 1.0.2 - resolution: "check-error@npm:1.0.2" - checksum: d9d106504404b8addd1ee3f63f8c0eaa7cd962a1a28eb9c519b1c4a1dc7098be38007fc0060f045ee00f075fbb7a2a4f42abcf61d68323677e11ab98dc16042e - languageName: node - linkType: hard - -"chokidar@npm:3.5.3": - version: 3.5.3 - resolution: "chokidar@npm:3.5.3" - dependencies: - anymatch: ~3.1.2 - braces: ~3.0.2 - fsevents: ~2.3.2 - glob-parent: ~5.1.2 - is-binary-path: ~2.1.0 - is-glob: ~4.0.1 - normalize-path: ~3.0.0 - readdirp: ~3.6.0 - dependenciesMeta: - fsevents: - optional: true - checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c - languageName: node - linkType: hard - -"chownr@npm:^2.0.0": - version: 2.0.0 - resolution: "chownr@npm:2.0.0" - checksum: c57cf9dd0791e2f18a5ee9c1a299ae6e801ff58fee96dc8bfd0dcb4738a6ce58dd252a3605b1c93c6418fe4f9d5093b28ffbf4d66648cb2a9c67eaef9679be2f - languageName: node - linkType: hard - -"clean-stack@npm:^2.0.0": - version: 2.2.0 - resolution: "clean-stack@npm:2.2.0" - checksum: 2ac8cd2b2f5ec986a3c743935ec85b07bc174d5421a5efc8017e1f146a1cf5f781ae962618f416352103b32c9cd7e203276e8c28241bbe946160cab16149fb68 - languageName: node - linkType: hard - -"cliui@npm:^7.0.2": - version: 7.0.4 - resolution: "cliui@npm:7.0.4" - dependencies: - string-width: ^4.2.0 - strip-ansi: ^6.0.0 - wrap-ansi: ^7.0.0 - checksum: ce2e8f578a4813806788ac399b9e866297740eecd4ad1823c27fd344d78b22c5f8597d548adbcc46f0573e43e21e751f39446c5a5e804a12aace402b7a315d7f - languageName: node - linkType: hard - -"color-convert@npm:^2.0.1": - version: 2.0.1 - resolution: "color-convert@npm:2.0.1" - dependencies: - color-name: ~1.1.4 - checksum: 79e6bdb9fd479a205c71d89574fccfb22bd9053bd98c6c4d870d65c132e5e904e6034978e55b43d69fcaa7433af2016ee203ce76eeba9cfa554b373e7f7db336 - languageName: node - linkType: hard - -"color-name@npm:~1.1.4": - version: 1.1.4 - resolution: "color-name@npm:1.1.4" - checksum: b0445859521eb4021cd0fb0cc1a75cecf67fceecae89b63f62b201cca8d345baf8b952c966862a9d9a2632987d4f6581f0ec8d957dfacece86f0a7919316f610 - languageName: node - linkType: hard - -"color-support@npm:^1.1.3": - version: 1.1.3 - resolution: "color-support@npm:1.1.3" - bin: - color-support: bin.js - checksum: 9b7356817670b9a13a26ca5af1c21615463b500783b739b7634a0c2047c16cef4b2865d7576875c31c3cddf9dd621fa19285e628f20198b233a5cfdda6d0793b - languageName: node - linkType: hard - -"commander@npm:^2.20.3": - version: 2.20.3 - resolution: "commander@npm:2.20.3" - checksum: ab8c07884e42c3a8dbc5dd9592c606176c7eb5c1ca5ff274bcf907039b2c41de3626f684ea75ccf4d361ba004bbaff1f577d5384c155f3871e456bdf27becf9e - languageName: node - linkType: hard - -"concat-map@npm:0.0.1": - version: 0.0.1 - resolution: "concat-map@npm:0.0.1" - checksum: 902a9f5d8967a3e2faf138d5cb784b9979bad2e6db5357c5b21c568df4ebe62bcb15108af1b2253744844eb964fc023fbd9afbbbb6ddd0bcc204c6fb5b7bf3af - languageName: node - linkType: hard - -"console-control-strings@npm:^1.1.0": - version: 1.1.0 - resolution: "console-control-strings@npm:1.1.0" - checksum: 8755d76787f94e6cf79ce4666f0c5519906d7f5b02d4b884cf41e11dcd759ed69c57da0670afd9236d229a46e0f9cf519db0cd829c6dca820bb5a5c3def584ed - languageName: node - linkType: hard - -"cross-fetch@npm:^3.1.5": - version: 3.1.8 - resolution: "cross-fetch@npm:3.1.8" - dependencies: - node-fetch: ^2.6.12 - checksum: 78f993fa099eaaa041122ab037fe9503ecbbcb9daef234d1d2e0b9230a983f64d645d088c464e21a247b825a08dc444a6e7064adfa93536d3a9454b4745b3632 - languageName: node - linkType: hard - -"cross-spawn@npm:^7.0.0": - version: 7.0.3 - resolution: "cross-spawn@npm:7.0.3" - dependencies: - path-key: ^3.1.0 - shebang-command: ^2.0.0 - which: ^2.0.1 - checksum: 671cc7c7288c3a8406f3c69a3ae2fc85555c04169e9d611def9a675635472614f1c0ed0ef80955d5b6d4e724f6ced67f0ad1bb006c2ea643488fcfef994d7f52 - languageName: node - linkType: hard - -"crypto-hash@npm:^1.3.0": - version: 1.3.0 - resolution: "crypto-hash@npm:1.3.0" - checksum: a3a507e0d2b18fbd2da8088a1c62d0c53c009a99bbfa6d851cac069734ffa546922fa51bdd776d006459701cdda873463e5059ece3431aca048fd99e7573d138 - languageName: node - linkType: hard - -"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.3.3": - version: 4.3.4 - resolution: "debug@npm:4.3.4" - dependencies: - ms: 2.1.2 - peerDependenciesMeta: - supports-color: - optional: true - checksum: 3dbad3f94ea64f34431a9cbf0bafb61853eda57bff2880036153438f50fb5a84f27683ba0d8e5426bf41a8c6ff03879488120cf5b3a761e77953169c0600a708 - languageName: node - linkType: hard - -"debug@npm:4.3.3": - version: 4.3.3 - resolution: "debug@npm:4.3.3" - dependencies: - ms: 2.1.2 - peerDependenciesMeta: - supports-color: - optional: true - checksum: 14472d56fe4a94dbcfaa6dbed2dd3849f1d72ba78104a1a328047bb564643ca49df0224c3a17fa63533fd11dd3d4c8636cd861191232a2c6735af00cc2d4de16 - languageName: node - linkType: hard - -"decamelize@npm:^4.0.0": - version: 4.0.0 - resolution: "decamelize@npm:4.0.0" - checksum: b7d09b82652c39eead4d6678bb578e3bebd848add894b76d0f6b395bc45b2d692fb88d977e7cfb93c4ed6c119b05a1347cef261174916c2e75c0a8ca57da1809 - languageName: node - linkType: hard - -"deep-eql@npm:^4.1.2": - version: 4.1.3 - resolution: "deep-eql@npm:4.1.3" - dependencies: - type-detect: ^4.0.0 - checksum: 7f6d30cb41c713973dc07eaadded848b2ab0b835e518a88b91bea72f34e08c4c71d167a722a6f302d3a6108f05afd8e6d7650689a84d5d29ec7fe6220420397f - languageName: node - linkType: hard - -"delay@npm:^5.0.0": - version: 5.0.0 - resolution: "delay@npm:5.0.0" - checksum: 62f151151ecfde0d9afbb8a6be37a6d103c4cb24f35a20ef3fe56f920b0d0d0bb02bc9c0a3084d0179ef669ca332b91155f2ee4d9854622cd2cdba5fc95285f9 - languageName: node - linkType: hard - -"delegates@npm:^1.0.0": - version: 1.0.0 - resolution: "delegates@npm:1.0.0" - checksum: a51744d9b53c164ba9c0492471a1a2ffa0b6727451bdc89e31627fdf4adda9d51277cfcbfb20f0a6f08ccb3c436f341df3e92631a3440226d93a8971724771fd - languageName: node - linkType: hard - -"depd@npm:^2.0.0": - version: 2.0.0 - resolution: "depd@npm:2.0.0" - checksum: abbe19c768c97ee2eed6282d8ce3031126662252c58d711f646921c9623f9052e3e1906443066beec1095832f534e57c523b7333f8e7e0d93051ab6baef5ab3a - languageName: node - linkType: hard - -"diff@npm:5.0.0": - version: 5.0.0 - resolution: "diff@npm:5.0.0" - checksum: f19fe29284b633afdb2725c2a8bb7d25761ea54d321d8e67987ac851c5294be4afeab532bd84531e02583a3fe7f4014aa314a3eda84f5590e7a9e6b371ef3b46 - languageName: node - linkType: hard - -"diff@npm:^3.1.0": - version: 3.5.0 - resolution: "diff@npm:3.5.0" - checksum: 00842950a6551e26ce495bdbce11047e31667deea546527902661f25cc2e73358967ebc78cf86b1a9736ec3e14286433225f9970678155753a6291c3bca5227b - languageName: node - linkType: hard - -"dot-case@npm:^3.0.4": - version: 3.0.4 - resolution: "dot-case@npm:3.0.4" - dependencies: - no-case: ^3.0.4 - tslib: ^2.0.3 - checksum: a65e3519414856df0228b9f645332f974f2bf5433370f544a681122eab59e66038fc3349b4be1cdc47152779dac71a5864f1ccda2f745e767c46e9c6543b1169 - languageName: node - linkType: hard - -"eastasianwidth@npm:^0.2.0": - version: 0.2.0 - resolution: "eastasianwidth@npm:0.2.0" - checksum: 7d00d7cd8e49b9afa762a813faac332dee781932d6f2c848dc348939c4253f1d4564341b7af1d041853bc3f32c2ef141b58e0a4d9862c17a7f08f68df1e0f1ed - languageName: node - linkType: hard - -"emoji-regex@npm:^8.0.0": - version: 8.0.0 - resolution: "emoji-regex@npm:8.0.0" - checksum: d4c5c39d5a9868b5fa152f00cada8a936868fd3367f33f71be515ecee4c803132d11b31a6222b2571b1e5f7e13890156a94880345594d0ce7e3c9895f560f192 - languageName: node - linkType: hard - -"emoji-regex@npm:^9.2.2": - version: 9.2.2 - resolution: "emoji-regex@npm:9.2.2" - checksum: 8487182da74aabd810ac6d6f1994111dfc0e331b01271ae01ec1eb0ad7b5ecc2bbbbd2f053c05cb55a1ac30449527d819bbfbf0e3de1023db308cbcb47f86601 - languageName: node - linkType: hard - -"encoding@npm:^0.1.13": - version: 0.1.13 - resolution: "encoding@npm:0.1.13" - dependencies: - iconv-lite: ^0.6.2 - checksum: bb98632f8ffa823996e508ce6a58ffcf5856330fde839ae42c9e1f436cc3b5cc651d4aeae72222916545428e54fd0f6aa8862fd8d25bdbcc4589f1e3f3715e7f - languageName: node - linkType: hard - -"env-paths@npm:^2.2.0": - version: 2.2.1 - resolution: "env-paths@npm:2.2.1" - checksum: 65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e - languageName: node - linkType: hard - -"err-code@npm:^2.0.2": - version: 2.0.3 - resolution: "err-code@npm:2.0.3" - checksum: 8b7b1be20d2de12d2255c0bc2ca638b7af5171142693299416e6a9339bd7d88fc8d7707d913d78e0993176005405a236b066b45666b27b797252c771156ace54 - languageName: node - linkType: hard - -"es6-promise@npm:^4.0.3": - version: 4.2.8 - resolution: "es6-promise@npm:4.2.8" - checksum: 95614a88873611cb9165a85d36afa7268af5c03a378b35ca7bda9508e1d4f1f6f19a788d4bc755b3fd37c8ebba40782018e02034564ff24c9d6fa37e959ad57d - languageName: node - linkType: hard - -"es6-promisify@npm:^5.0.0": - version: 5.0.0 - resolution: "es6-promisify@npm:5.0.0" - dependencies: - es6-promise: ^4.0.3 - checksum: fbed9d791598831413be84a5374eca8c24800ec71a16c1c528c43a98e2dadfb99331483d83ae6094ddb9b87e6f799a15d1553cebf756047e0865c753bc346b92 - languageName: node - linkType: hard - -"escalade@npm:^3.1.1": - version: 3.1.1 - resolution: "escalade@npm:3.1.1" - checksum: a3e2a99f07acb74b3ad4989c48ca0c3140f69f923e56d0cba0526240ee470b91010f9d39001f2a4a313841d237ede70a729e92125191ba5d21e74b106800b133 - languageName: node - linkType: hard - -"escape-string-regexp@npm:4.0.0": - version: 4.0.0 - resolution: "escape-string-regexp@npm:4.0.0" - checksum: 98b48897d93060f2322108bf29db0feba7dd774be96cd069458d1453347b25ce8682ecc39859d4bca2203cc0ab19c237bcc71755eff49a0f8d90beadeeba5cc5 - languageName: node - linkType: hard - -"eventemitter3@npm:^4.0.7": - version: 4.0.7 - resolution: "eventemitter3@npm:4.0.7" - checksum: 1875311c42fcfe9c707b2712c32664a245629b42bb0a5a84439762dd0fd637fc54d078155ea83c2af9e0323c9ac13687e03cfba79b03af9f40c89b4960099374 - languageName: node - linkType: hard - -"exponential-backoff@npm:^3.1.1": - version: 3.1.1 - resolution: "exponential-backoff@npm:3.1.1" - checksum: 3d21519a4f8207c99f7457287291316306255a328770d320b401114ec8481986e4e467e854cb9914dd965e0a1ca810a23ccb559c642c88f4c7f55c55778a9b48 - languageName: node - linkType: hard - -"eyes@npm:^0.1.8": - version: 0.1.8 - resolution: "eyes@npm:0.1.8" - checksum: c31703a92bf36ba75ee8d379ee7985c24ee6149f3a6175f44cec7a05b178c38bce9836d3ca48c9acb0329a960ac2c4b2ead4e60cdd4fe6e8c92cad7cd6913687 - languageName: node - linkType: hard - -"fast-stable-stringify@npm:^1.0.0": - version: 1.0.0 - resolution: "fast-stable-stringify@npm:1.0.0" - checksum: ef1203d246a7e8ac15e2bfbda0a89fa375947bccf9f7910be0ea759856dbe8ea5024a0d8cc2cceabe18a9cb67e95927b78bb6173a3ae37ec55a518cf36e5244b - languageName: node - linkType: hard - -"file-uri-to-path@npm:1.0.0": - version: 1.0.0 - resolution: "file-uri-to-path@npm:1.0.0" - checksum: b648580bdd893a008c92c7ecc96c3ee57a5e7b6c4c18a9a09b44fb5d36d79146f8e442578bc0e173dc027adf3987e254ba1dfd6e3ec998b7c282873010502144 - languageName: node - linkType: hard - -"fill-range@npm:^7.0.1": - version: 7.0.1 - resolution: "fill-range@npm:7.0.1" - dependencies: - to-regex-range: ^5.0.1 - checksum: cc283f4e65b504259e64fd969bcf4def4eb08d85565e906b7d36516e87819db52029a76b6363d0f02d0d532f0033c9603b9e2d943d56ee3b0d4f7ad3328ff917 - languageName: node - linkType: hard - -"find-up@npm:5.0.0": - version: 5.0.0 - resolution: "find-up@npm:5.0.0" - dependencies: - locate-path: ^6.0.0 - path-exists: ^4.0.0 - checksum: 07955e357348f34660bde7920783204ff5a26ac2cafcaa28bace494027158a97b9f56faaf2d89a6106211a8174db650dd9f503f9c0d526b1202d5554a00b9095 - languageName: node - linkType: hard - -"flat@npm:^5.0.2": - version: 5.0.2 - resolution: "flat@npm:5.0.2" - bin: - flat: cli.js - checksum: 12a1536ac746db74881316a181499a78ef953632ddd28050b7a3a43c62ef5462e3357c8c29d76072bb635f147f7a9a1f0c02efef6b4be28f8db62ceb3d5c7f5d - languageName: node - linkType: hard - -"foreground-child@npm:^3.1.0": - version: 3.1.1 - resolution: "foreground-child@npm:3.1.1" - dependencies: - cross-spawn: ^7.0.0 - signal-exit: ^4.0.1 - checksum: 139d270bc82dc9e6f8bc045fe2aae4001dc2472157044fdfad376d0a3457f77857fa883c1c8b21b491c6caade9a926a4bed3d3d2e8d3c9202b151a4cbbd0bcd5 - languageName: node - linkType: hard - -"fs-minipass@npm:^2.0.0": - version: 2.1.0 - resolution: "fs-minipass@npm:2.1.0" - dependencies: - minipass: ^3.0.0 - checksum: 1b8d128dae2ac6cc94230cc5ead341ba3e0efaef82dab46a33d171c044caaa6ca001364178d42069b2809c35a1c3c35079a32107c770e9ffab3901b59af8c8b1 - languageName: node - linkType: hard - -"fs-minipass@npm:^3.0.0": - version: 3.0.2 - resolution: "fs-minipass@npm:3.0.2" - dependencies: - minipass: ^5.0.0 - checksum: e9cc0e1f2d01c6f6f62f567aee59530aba65c6c7b2ae88c5027bc34c711ebcfcfaefd0caf254afa6adfe7d1fba16bc2537508a6235196bac7276747d078aef0a - languageName: node - linkType: hard - -"fs.realpath@npm:^1.0.0": - version: 1.0.0 - resolution: "fs.realpath@npm:1.0.0" - checksum: 99ddea01a7e75aa276c250a04eedeffe5662bce66c65c07164ad6264f9de18fb21be9433ead460e54cff20e31721c811f4fb5d70591799df5f85dce6d6746fd0 - languageName: node - linkType: hard - -"fsevents@npm:~2.3.2": - version: 2.3.2 - resolution: "fsevents@npm:2.3.2" - dependencies: - node-gyp: latest - checksum: 97ade64e75091afee5265e6956cb72ba34db7819b4c3e94c431d4be2b19b8bb7a2d4116da417950c3425f17c8fe693d25e20212cac583ac1521ad066b77ae31f - conditions: os=darwin - languageName: node - linkType: hard - -"fsevents@patch:fsevents@~2.3.2#~builtin": - version: 2.3.2 - resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" - dependencies: - node-gyp: latest - conditions: os=darwin - languageName: node - linkType: hard - -"gauge@npm:^4.0.3": - version: 4.0.4 - resolution: "gauge@npm:4.0.4" - dependencies: - aproba: ^1.0.3 || ^2.0.0 - color-support: ^1.1.3 - console-control-strings: ^1.1.0 - has-unicode: ^2.0.1 - signal-exit: ^3.0.7 - string-width: ^4.2.3 - strip-ansi: ^6.0.1 - wide-align: ^1.1.5 - checksum: 788b6bfe52f1dd8e263cda800c26ac0ca2ff6de0b6eee2fe0d9e3abf15e149b651bd27bf5226be10e6e3edb5c4e5d5985a5a1a98137e7a892f75eff76467ad2d - languageName: node - linkType: hard - -"get-caller-file@npm:^2.0.5": - version: 2.0.5 - resolution: "get-caller-file@npm:2.0.5" - checksum: b9769a836d2a98c3ee734a88ba712e62703f1df31b94b784762c433c27a386dd6029ff55c2a920c392e33657d80191edbf18c61487e198844844516f843496b9 - languageName: node - linkType: hard - -"get-func-name@npm:^2.0.0": - version: 2.0.0 - resolution: "get-func-name@npm:2.0.0" - checksum: 8d82e69f3e7fab9e27c547945dfe5cc0c57fc0adf08ce135dddb01081d75684a03e7a0487466f478872b341d52ac763ae49e660d01ab83741f74932085f693c3 - languageName: node - linkType: hard - -"glob-parent@npm:~5.1.2": - version: 5.1.2 - resolution: "glob-parent@npm:5.1.2" - dependencies: - is-glob: ^4.0.1 - checksum: f4f2bfe2425296e8a47e36864e4f42be38a996db40420fe434565e4480e3322f18eb37589617a98640c5dc8fdec1a387007ee18dbb1f3f5553409c34d17f425e - languageName: node - linkType: hard - -"glob@npm:7.2.0": - version: 7.2.0 - resolution: "glob@npm:7.2.0" - dependencies: - fs.realpath: ^1.0.0 - inflight: ^1.0.4 - inherits: 2 - minimatch: ^3.0.4 - once: ^1.3.0 - path-is-absolute: ^1.0.0 - checksum: 78a8ea942331f08ed2e055cb5b9e40fe6f46f579d7fd3d694f3412fe5db23223d29b7fee1575440202e9a7ff9a72ab106a39fee39934c7bedafe5e5f8ae20134 - languageName: node - linkType: hard - -"glob@npm:^10.2.2": - version: 10.3.3 - resolution: "glob@npm:10.3.3" - dependencies: - foreground-child: ^3.1.0 - jackspeak: ^2.0.3 - minimatch: ^9.0.1 - minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 - path-scurry: ^1.10.1 - bin: - glob: dist/cjs/src/bin.js - checksum: 29190d3291f422da0cb40b77a72fc8d2c51a36524e99b8bf412548b7676a6627489528b57250429612b6eec2e6fe7826d328451d3e694a9d15e575389308ec53 - languageName: node - linkType: hard - -"glob@npm:^7.1.3, glob@npm:^7.1.4": - version: 7.2.3 - resolution: "glob@npm:7.2.3" - dependencies: - fs.realpath: ^1.0.0 - inflight: ^1.0.4 - inherits: 2 - minimatch: ^3.1.1 - once: ^1.3.0 - path-is-absolute: ^1.0.0 - checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133 - languageName: node - linkType: hard - -"graceful-fs@npm:^4.2.6": - version: 4.2.11 - resolution: "graceful-fs@npm:4.2.11" - checksum: ac85f94da92d8eb6b7f5a8b20ce65e43d66761c55ce85ac96df6865308390da45a8d3f0296dd3a663de65d30ba497bd46c696cc1e248c72b13d6d567138a4fc7 - languageName: node - linkType: hard - -"growl@npm:1.10.5": - version: 1.10.5 - resolution: "growl@npm:1.10.5" - checksum: 4b86685de6831cebcbb19f93870bea624afee61124b0a20c49017013987cd129e73a8c4baeca295728f41d21265e1f859d25ef36731b142ca59c655fea94bb1a - languageName: node - linkType: hard - -"has-flag@npm:^4.0.0": - version: 4.0.0 - resolution: "has-flag@npm:4.0.0" - checksum: 261a1357037ead75e338156b1f9452c016a37dcd3283a972a30d9e4a87441ba372c8b81f818cd0fbcd9c0354b4ae7e18b9e1afa1971164aef6d18c2b6095a8ad - languageName: node - linkType: hard - -"has-unicode@npm:^2.0.1": - version: 2.0.1 - resolution: "has-unicode@npm:2.0.1" - checksum: 1eab07a7436512db0be40a710b29b5dc21fa04880b7f63c9980b706683127e3c1b57cb80ea96d47991bdae2dfe479604f6a1ba410106ee1046a41d1bd0814400 - languageName: node - linkType: hard - -"he@npm:1.2.0": - version: 1.2.0 - resolution: "he@npm:1.2.0" - bin: - he: bin/he - checksum: 3d4d6babccccd79c5c5a3f929a68af33360d6445587d628087f39a965079d84f18ce9c3d3f917ee1e3978916fc833bb8b29377c3b403f919426f91bc6965e7a7 - languageName: node - linkType: hard - -"http-cache-semantics@npm:^4.1.1": - version: 4.1.1 - resolution: "http-cache-semantics@npm:4.1.1" - checksum: 83ac0bc60b17a3a36f9953e7be55e5c8f41acc61b22583060e8dedc9dd5e3607c823a88d0926f9150e571f90946835c7fe150732801010845c72cd8bbff1a236 - languageName: node - linkType: hard - -"http-proxy-agent@npm:^5.0.0": - version: 5.0.0 - resolution: "http-proxy-agent@npm:5.0.0" - dependencies: - "@tootallnate/once": 2 - agent-base: 6 - debug: 4 - checksum: e2ee1ff1656a131953839b2a19cd1f3a52d97c25ba87bd2559af6ae87114abf60971e498021f9b73f9fd78aea8876d1fb0d4656aac8a03c6caa9fc175f22b786 - languageName: node - linkType: hard - -"https-proxy-agent@npm:^5.0.0": - version: 5.0.1 - resolution: "https-proxy-agent@npm:5.0.1" - dependencies: - agent-base: 6 - debug: 4 - checksum: 571fccdf38184f05943e12d37d6ce38197becdd69e58d03f43637f7fa1269cf303a7d228aa27e5b27bbd3af8f09fd938e1c91dcfefff2df7ba77c20ed8dfc765 - languageName: node - linkType: hard - -"humanize-ms@npm:^1.2.1": - version: 1.2.1 - resolution: "humanize-ms@npm:1.2.1" - dependencies: - ms: ^2.0.0 - checksum: 9c7a74a2827f9294c009266c82031030eae811ca87b0da3dceb8d6071b9bde22c9f3daef0469c3c533cc67a97d8a167cd9fc0389350e5f415f61a79b171ded16 - languageName: node - linkType: hard - -"iconv-lite@npm:^0.6.2": - version: 0.6.3 - resolution: "iconv-lite@npm:0.6.3" - dependencies: - safer-buffer: ">= 2.1.2 < 3.0.0" - checksum: 3f60d47a5c8fc3313317edfd29a00a692cc87a19cac0159e2ce711d0ebc9019064108323b5e493625e25594f11c6236647d8e256fbe7a58f4a3b33b89e6d30bf - languageName: node - linkType: hard - -"ieee754@npm:^1.2.1": - version: 1.2.1 - resolution: "ieee754@npm:1.2.1" - checksum: 5144c0c9815e54ada181d80a0b810221a253562422e7c6c3a60b1901154184f49326ec239d618c416c1c5945a2e197107aee8d986a3dd836b53dffefd99b5e7e - languageName: node - linkType: hard - -"imurmurhash@npm:^0.1.4": - version: 0.1.4 - resolution: "imurmurhash@npm:0.1.4" - checksum: 7cae75c8cd9a50f57dadd77482359f659eaebac0319dd9368bcd1714f55e65badd6929ca58569da2b6494ef13fdd5598cd700b1eba23f8b79c5f19d195a3ecf7 - languageName: node - linkType: hard - -"indent-string@npm:^4.0.0": - version: 4.0.0 - resolution: "indent-string@npm:4.0.0" - checksum: 824cfb9929d031dabf059bebfe08cf3137365e112019086ed3dcff6a0a7b698cb80cf67ccccde0e25b9e2d7527aa6cc1fed1ac490c752162496caba3e6699612 - languageName: node - linkType: hard - -"inflight@npm:^1.0.4": - version: 1.0.6 - resolution: "inflight@npm:1.0.6" - dependencies: - once: ^1.3.0 - wrappy: 1 - checksum: f4f76aa072ce19fae87ce1ef7d221e709afb59d445e05d47fba710e85470923a75de35bfae47da6de1b18afc3ce83d70facf44cfb0aff89f0a3f45c0a0244dfd - languageName: node - linkType: hard - -"inherits@npm:2, inherits@npm:^2.0.3": - version: 2.0.4 - resolution: "inherits@npm:2.0.4" - checksum: 4a48a733847879d6cf6691860a6b1e3f0f4754176e4d71494c41f3475553768b10f84b5ce1d40fbd0e34e6bfbb864ee35858ad4dd2cf31e02fc4a154b724d7f1 - languageName: node - linkType: hard - -"ip@npm:^2.0.0": - version: 2.0.0 - resolution: "ip@npm:2.0.0" - checksum: cfcfac6b873b701996d71ec82a7dd27ba92450afdb421e356f44044ed688df04567344c36cbacea7d01b1c39a4c732dc012570ebe9bebfb06f27314bca625349 - languageName: node - linkType: hard - -"is-binary-path@npm:~2.1.0": - version: 2.1.0 - resolution: "is-binary-path@npm:2.1.0" - dependencies: - binary-extensions: ^2.0.0 - checksum: 84192eb88cff70d320426f35ecd63c3d6d495da9d805b19bc65b518984b7c0760280e57dbf119b7e9be6b161784a5a673ab2c6abe83abb5198a432232ad5b35c - languageName: node - linkType: hard - -"is-extglob@npm:^2.1.1": - version: 2.1.1 - resolution: "is-extglob@npm:2.1.1" - checksum: df033653d06d0eb567461e58a7a8c9f940bd8c22274b94bf7671ab36df5719791aae15eef6d83bbb5e23283967f2f984b8914559d4449efda578c775c4be6f85 - languageName: node - linkType: hard - -"is-fullwidth-code-point@npm:^3.0.0": - version: 3.0.0 - resolution: "is-fullwidth-code-point@npm:3.0.0" - checksum: 44a30c29457c7fb8f00297bce733f0a64cd22eca270f83e58c105e0d015e45c019491a4ab2faef91ab51d4738c670daff901c799f6a700e27f7314029e99e348 - languageName: node - linkType: hard - -"is-glob@npm:^4.0.1, is-glob@npm:~4.0.1": - version: 4.0.3 - resolution: "is-glob@npm:4.0.3" - dependencies: - is-extglob: ^2.1.1 - checksum: d381c1319fcb69d341cc6e6c7cd588e17cd94722d9a32dbd60660b993c4fb7d0f19438674e68dfec686d09b7c73139c9166b47597f846af387450224a8101ab4 - languageName: node - linkType: hard - -"is-lambda@npm:^1.0.1": - version: 1.0.1 - resolution: "is-lambda@npm:1.0.1" - checksum: 93a32f01940220532e5948538699ad610d5924ac86093fcee83022252b363eb0cc99ba53ab084a04e4fb62bf7b5731f55496257a4c38adf87af9c4d352c71c35 - languageName: node - linkType: hard - -"is-number@npm:^7.0.0": - version: 7.0.0 - resolution: "is-number@npm:7.0.0" - checksum: 456ac6f8e0f3111ed34668a624e45315201dff921e5ac181f8ec24923b99e9f32ca1a194912dc79d539c97d33dba17dc635202ff0b2cf98326f608323276d27a - languageName: node - linkType: hard - -"is-plain-obj@npm:^2.1.0": - version: 2.1.0 - resolution: "is-plain-obj@npm:2.1.0" - checksum: cec9100678b0a9fe0248a81743041ed990c2d4c99f893d935545cfbc42876cbe86d207f3b895700c690ad2fa520e568c44afc1605044b535a7820c1d40e38daa - languageName: node - linkType: hard - -"is-unicode-supported@npm:^0.1.0": - version: 0.1.0 - resolution: "is-unicode-supported@npm:0.1.0" - checksum: a2aab86ee7712f5c2f999180daaba5f361bdad1efadc9610ff5b8ab5495b86e4f627839d085c6530363c6d6d4ecbde340fb8e54bdb83da4ba8e0865ed5513c52 - languageName: node - linkType: hard - -"isexe@npm:^2.0.0": - version: 2.0.0 - resolution: "isexe@npm:2.0.0" - checksum: 26bf6c5480dda5161c820c5b5c751ae1e766c587b1f951ea3fcfc973bafb7831ae5b54a31a69bd670220e42e99ec154475025a468eae58ea262f813fdc8d1c62 - languageName: node - linkType: hard - -"isomorphic-ws@npm:^4.0.1": - version: 4.0.1 - resolution: "isomorphic-ws@npm:4.0.1" - peerDependencies: - ws: "*" - checksum: d7190eadefdc28bdb93d67b5f0c603385aaf87724fa2974abb382ac1ec9756ed2cfb27065cbe76122879c2d452e2982bc4314317f3d6c737ddda6c047328771a - languageName: node - linkType: hard - -"jackspeak@npm:^2.0.3": - version: 2.2.2 - resolution: "jackspeak@npm:2.2.2" - dependencies: - "@isaacs/cliui": ^8.0.2 - "@pkgjs/parseargs": ^0.11.0 - dependenciesMeta: - "@pkgjs/parseargs": - optional: true - checksum: 7b1468dd910afc00642db87448f24b062346570b8b47531409aa9012bcb95fdf7ec2b1c48edbb8b57a938c08391f8cc01b5034fc335aa3a2e74dbcc0ee5c555a - languageName: node - linkType: hard - -"jayson@npm:^4.1.0": - version: 4.1.0 - resolution: "jayson@npm:4.1.0" - dependencies: - "@types/connect": ^3.4.33 - "@types/node": ^12.12.54 - "@types/ws": ^7.4.4 - JSONStream: ^1.3.5 - commander: ^2.20.3 - delay: ^5.0.0 - es6-promisify: ^5.0.0 - eyes: ^0.1.8 - isomorphic-ws: ^4.0.1 - json-stringify-safe: ^5.0.1 - uuid: ^8.3.2 - ws: ^7.4.5 - bin: - jayson: bin/jayson.js - checksum: 86464322fbdc6db65d2bb4fc278cb6c86fad5c2a506065490d39459f09ba0d30f2b4fb740b33828a1424791419b6c8bd295dc54d361a4ad959bf70cc62b1ca7e - languageName: node - linkType: hard - -"js-sha256@npm:^0.9.0": - version: 0.9.0 - resolution: "js-sha256@npm:0.9.0" - checksum: ffad54b3373f81581e245866abfda50a62c483803a28176dd5c28fd2d313e0bdf830e77dac7ff8afd193c53031618920f3d98daf21cbbe80082753ab639c0365 - languageName: node - linkType: hard - -"js-yaml@npm:4.1.0": - version: 4.1.0 - resolution: "js-yaml@npm:4.1.0" - dependencies: - argparse: ^2.0.1 - bin: - js-yaml: bin/js-yaml.js - checksum: c7830dfd456c3ef2c6e355cc5a92e6700ceafa1d14bba54497b34a99f0376cecbb3e9ac14d3e5849b426d5a5140709a66237a8c991c675431271c4ce5504151a - languageName: node - linkType: hard - -"json-stringify-safe@npm:^5.0.1": - version: 5.0.1 - resolution: "json-stringify-safe@npm:5.0.1" - checksum: 48ec0adad5280b8a96bb93f4563aa1667fd7a36334f79149abd42446d0989f2ddc58274b479f4819f1f00617957e6344c886c55d05a4e15ebb4ab931e4a6a8ee - languageName: node - linkType: hard - -"json5@npm:^1.0.2": - version: 1.0.2 - resolution: "json5@npm:1.0.2" - dependencies: - minimist: ^1.2.0 - bin: - json5: lib/cli.js - checksum: 866458a8c58a95a49bef3adba929c625e82532bcff1fe93f01d29cb02cac7c3fe1f4b79951b7792c2da9de0b32871a8401a6e3c5b36778ad852bf5b8a61165d7 - languageName: node - linkType: hard - -"jsonparse@npm:^1.2.0": - version: 1.3.1 - resolution: "jsonparse@npm:1.3.1" - checksum: 6514a7be4674ebf407afca0eda3ba284b69b07f9958a8d3113ef1005f7ec610860c312be067e450c569aab8b89635e332cee3696789c750692bb60daba627f4d - languageName: node - linkType: hard - -"locate-path@npm:^6.0.0": - version: 6.0.0 - resolution: "locate-path@npm:6.0.0" - dependencies: - p-locate: ^5.0.0 - checksum: 72eb661788a0368c099a184c59d2fee760b3831c9c1c33955e8a19ae4a21b4116e53fa736dc086cdeb9fce9f7cc508f2f92d2d3aae516f133e16a2bb59a39f5a - languageName: node - linkType: hard - -"log-symbols@npm:4.1.0": - version: 4.1.0 - resolution: "log-symbols@npm:4.1.0" - dependencies: - chalk: ^4.1.0 - is-unicode-supported: ^0.1.0 - checksum: fce1497b3135a0198803f9f07464165e9eb83ed02ceb2273930a6f8a508951178d8cf4f0378e9d28300a2ed2bc49050995d2bd5f53ab716bb15ac84d58c6ef74 - languageName: node - linkType: hard - -"loupe@npm:^2.3.1": - version: 2.3.6 - resolution: "loupe@npm:2.3.6" - dependencies: - get-func-name: ^2.0.0 - checksum: cc83f1b124a1df7384601d72d8d1f5fe95fd7a8185469fec48bb2e4027e45243949e7a013e8d91051a138451ff0552310c32aa9786e60b6a30d1e801bdc2163f - languageName: node - linkType: hard - -"lower-case@npm:^2.0.2": - version: 2.0.2 - resolution: "lower-case@npm:2.0.2" - dependencies: - tslib: ^2.0.3 - checksum: 83a0a5f159ad7614bee8bf976b96275f3954335a84fad2696927f609ddae902802c4f3312d86668722e668bef41400254807e1d3a7f2e8c3eede79691aa1f010 - languageName: node - linkType: hard - -"lru-cache@npm:^6.0.0": - version: 6.0.0 - resolution: "lru-cache@npm:6.0.0" - dependencies: - yallist: ^4.0.0 - checksum: f97f499f898f23e4585742138a22f22526254fdba6d75d41a1c2526b3b6cc5747ef59c5612ba7375f42aca4f8461950e925ba08c991ead0651b4918b7c978297 - languageName: node - linkType: hard - -"lru-cache@npm:^7.7.1": - version: 7.18.3 - resolution: "lru-cache@npm:7.18.3" - checksum: e550d772384709deea3f141af34b6d4fa392e2e418c1498c078de0ee63670f1f46f5eee746e8ef7e69e1c895af0d4224e62ee33e66a543a14763b0f2e74c1356 - languageName: node - linkType: hard - -"lru-cache@npm:^9.1.1 || ^10.0.0": - version: 10.0.0 - resolution: "lru-cache@npm:10.0.0" - checksum: 18f101675fe283bc09cda0ef1e3cc83781aeb8373b439f086f758d1d91b28730950db785999cd060d3c825a8571c03073e8c14512b6655af2188d623031baf50 - languageName: node - linkType: hard - -"make-error@npm:^1.1.1": - version: 1.3.6 - resolution: "make-error@npm:1.3.6" - checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 - languageName: node - linkType: hard - -"make-fetch-happen@npm:^11.0.3": - version: 11.1.1 - resolution: "make-fetch-happen@npm:11.1.1" - dependencies: - agentkeepalive: ^4.2.1 - cacache: ^17.0.0 - http-cache-semantics: ^4.1.1 - http-proxy-agent: ^5.0.0 - https-proxy-agent: ^5.0.0 - is-lambda: ^1.0.1 - lru-cache: ^7.7.1 - minipass: ^5.0.0 - minipass-fetch: ^3.0.0 - minipass-flush: ^1.0.5 - minipass-pipeline: ^1.2.4 - negotiator: ^0.6.3 - promise-retry: ^2.0.1 - socks-proxy-agent: ^7.0.0 - ssri: ^10.0.0 - checksum: 7268bf274a0f6dcf0343829489a4506603ff34bd0649c12058753900b0eb29191dce5dba12680719a5d0a983d3e57810f594a12f3c18494e93a1fbc6348a4540 - languageName: node - linkType: hard - -"minimatch@npm:4.2.1": - version: 4.2.1 - resolution: "minimatch@npm:4.2.1" - dependencies: - brace-expansion: ^1.1.7 - checksum: 2b1514e3d0f29a549912f0db7ae7b82c5cab4a8f2dd0369f1c6451a325b3f12b2cf473c95873b6157bb8df183d6cf6db82ff03614b6adaaf1d7e055beccdfd01 - languageName: node - linkType: hard - -"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1": - version: 3.1.2 - resolution: "minimatch@npm:3.1.2" - dependencies: - brace-expansion: ^1.1.7 - checksum: c154e566406683e7bcb746e000b84d74465b3a832c45d59912b9b55cd50dee66e5c4b1e5566dba26154040e51672f9aa450a9aef0c97cfc7336b78b7afb9540a - languageName: node - linkType: hard - -"minimatch@npm:^9.0.1": - version: 9.0.3 - resolution: "minimatch@npm:9.0.3" - dependencies: - brace-expansion: ^2.0.1 - checksum: 253487976bf485b612f16bf57463520a14f512662e592e95c571afdab1442a6a6864b6c88f248ce6fc4ff0b6de04ac7aa6c8bb51e868e99d1d65eb0658a708b5 - languageName: node - linkType: hard - -"minimist@npm:^1.2.0, minimist@npm:^1.2.6": - version: 1.2.8 - resolution: "minimist@npm:1.2.8" - checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0 - languageName: node - linkType: hard - -"minipass-collect@npm:^1.0.2": - version: 1.0.2 - resolution: "minipass-collect@npm:1.0.2" - dependencies: - minipass: ^3.0.0 - checksum: 14df761028f3e47293aee72888f2657695ec66bd7d09cae7ad558da30415fdc4752bbfee66287dcc6fd5e6a2fa3466d6c484dc1cbd986525d9393b9523d97f10 - languageName: node - linkType: hard - -"minipass-fetch@npm:^3.0.0": - version: 3.0.3 - resolution: "minipass-fetch@npm:3.0.3" - dependencies: - encoding: ^0.1.13 - minipass: ^5.0.0 - minipass-sized: ^1.0.3 - minizlib: ^2.1.2 - dependenciesMeta: - encoding: - optional: true - checksum: af5ab2552a16fcf505d35fd7ffb84b57f4a0eeb269e6e1d9a2a75824dda48b36e527083250b7cca4a4def21d9544e2ade441e4730e233c0bc2133f6abda31e18 - languageName: node - linkType: hard - -"minipass-flush@npm:^1.0.5": - version: 1.0.5 - resolution: "minipass-flush@npm:1.0.5" - dependencies: - minipass: ^3.0.0 - checksum: 56269a0b22bad756a08a94b1ffc36b7c9c5de0735a4dd1ab2b06c066d795cfd1f0ac44a0fcae13eece5589b908ecddc867f04c745c7009be0b566421ea0944cf - languageName: node - linkType: hard - -"minipass-pipeline@npm:^1.2.4": - version: 1.2.4 - resolution: "minipass-pipeline@npm:1.2.4" - dependencies: - minipass: ^3.0.0 - checksum: b14240dac0d29823c3d5911c286069e36d0b81173d7bdf07a7e4a91ecdef92cdff4baaf31ea3746f1c61e0957f652e641223970870e2353593f382112257971b - languageName: node - linkType: hard - -"minipass-sized@npm:^1.0.3": - version: 1.0.3 - resolution: "minipass-sized@npm:1.0.3" - dependencies: - minipass: ^3.0.0 - checksum: 79076749fcacf21b5d16dd596d32c3b6bf4d6e62abb43868fac21674078505c8b15eaca4e47ed844985a4514854f917d78f588fcd029693709417d8f98b2bd60 - languageName: node - linkType: hard - -"minipass@npm:^3.0.0": - version: 3.3.6 - resolution: "minipass@npm:3.3.6" - dependencies: - yallist: ^4.0.0 - checksum: a30d083c8054cee83cdcdc97f97e4641a3f58ae743970457b1489ce38ee1167b3aaf7d815cd39ec7a99b9c40397fd4f686e83750e73e652b21cb516f6d845e48 - languageName: node - linkType: hard - -"minipass@npm:^5.0.0": - version: 5.0.0 - resolution: "minipass@npm:5.0.0" - checksum: 425dab288738853fded43da3314a0b5c035844d6f3097a8e3b5b29b328da8f3c1af6fc70618b32c29ff906284cf6406b6841376f21caaadd0793c1d5a6a620ea - languageName: node - linkType: hard - -"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0": - version: 7.0.2 - resolution: "minipass@npm:7.0.2" - checksum: 46776de732eb7cef2c7404a15fb28c41f5c54a22be50d47b03c605bf21f5c18d61a173c0a20b49a97e7a65f78d887245066410642551e45fffe04e9ac9e325bc - languageName: node - linkType: hard - -"minizlib@npm:^2.1.1, minizlib@npm:^2.1.2": - version: 2.1.2 - resolution: "minizlib@npm:2.1.2" - dependencies: - minipass: ^3.0.0 - yallist: ^4.0.0 - checksum: f1fdeac0b07cf8f30fcf12f4b586795b97be856edea22b5e9072707be51fc95d41487faec3f265b42973a304fe3a64acd91a44a3826a963e37b37bafde0212c3 - languageName: node - linkType: hard - -"mkdirp@npm:^0.5.1": - version: 0.5.6 - resolution: "mkdirp@npm:0.5.6" - dependencies: - minimist: ^1.2.6 - bin: - mkdirp: bin/cmd.js - checksum: 0c91b721bb12c3f9af4b77ebf73604baf350e64d80df91754dc509491ae93bf238581e59c7188360cec7cb62fc4100959245a42cfe01834efedc5e9d068376c2 - languageName: node - linkType: hard - -"mkdirp@npm:^1.0.3": - version: 1.0.4 - resolution: "mkdirp@npm:1.0.4" - bin: - mkdirp: bin/cmd.js - checksum: a96865108c6c3b1b8e1d5e9f11843de1e077e57737602de1b82030815f311be11f96f09cce59bd5b903d0b29834733e5313f9301e3ed6d6f6fba2eae0df4298f - languageName: node - linkType: hard - -"mocha@npm:^9.0.3": - version: 9.2.2 - resolution: "mocha@npm:9.2.2" - dependencies: - "@ungap/promise-all-settled": 1.1.2 - ansi-colors: 4.1.1 - browser-stdout: 1.3.1 - chokidar: 3.5.3 - debug: 4.3.3 - diff: 5.0.0 - escape-string-regexp: 4.0.0 - find-up: 5.0.0 - glob: 7.2.0 - growl: 1.10.5 - he: 1.2.0 - js-yaml: 4.1.0 - log-symbols: 4.1.0 - minimatch: 4.2.1 - ms: 2.1.3 - nanoid: 3.3.1 - serialize-javascript: 6.0.0 - strip-json-comments: 3.1.1 - supports-color: 8.1.1 - which: 2.0.2 - workerpool: 6.2.0 - yargs: 16.2.0 - yargs-parser: 20.2.4 - yargs-unparser: 2.0.0 - bin: - _mocha: bin/_mocha - mocha: bin/mocha - checksum: 4d5ca4ce33fc66627e63acdf09a634e2358c9a00f61de7788b1091b6aad430da04f97f9ecb82d56dc034b623cb833b65576136fd010d77679c03fcea5bc1e12d - languageName: node - linkType: hard - -"ms@npm:2.1.2, ms@npm:^2.0.0": - version: 2.1.2 - resolution: "ms@npm:2.1.2" - checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f - languageName: node - linkType: hard - -"ms@npm:2.1.3": - version: 2.1.3 - resolution: "ms@npm:2.1.3" - checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d - languageName: node - linkType: hard - -"nanoid@npm:3.3.1": - version: 3.3.1 - resolution: "nanoid@npm:3.3.1" - bin: - nanoid: bin/nanoid.cjs - checksum: 4ef0969e1bbe866fc223eb32276cbccb0961900bfe79104fa5abe34361979dead8d0e061410a5c03bc3d47455685adf32c09d6f27790f4a6898fb51f7df7ec86 - languageName: node - linkType: hard - -"negotiator@npm:^0.6.3": - version: 0.6.3 - resolution: "negotiator@npm:0.6.3" - checksum: b8ffeb1e262eff7968fc90a2b6767b04cfd9842582a9d0ece0af7049537266e7b2506dfb1d107a32f06dd849ab2aea834d5830f7f4d0e5cb7d36e1ae55d021d9 - languageName: node - linkType: hard - -"no-case@npm:^3.0.4": - version: 3.0.4 - resolution: "no-case@npm:3.0.4" - dependencies: - lower-case: ^2.0.2 - tslib: ^2.0.3 - checksum: 0b2ebc113dfcf737d48dde49cfebf3ad2d82a8c3188e7100c6f375e30eafbef9e9124aadc3becef237b042fd5eb0aad2fd78669c20972d045bbe7fea8ba0be5c - languageName: node - linkType: hard - -"node-fetch@npm:^2.6.12": - version: 2.6.12 - resolution: "node-fetch@npm:2.6.12" - dependencies: - whatwg-url: ^5.0.0 - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - checksum: 3bc1655203d47ee8e313c0d96664b9673a3d4dd8002740318e9d27d14ef306693a4b2ef8d6525775056fd912a19e23f3ac0d7111ad8925877b7567b29a625592 - languageName: node - linkType: hard - -"node-gyp-build@npm:^4.3.0": - version: 4.6.0 - resolution: "node-gyp-build@npm:4.6.0" - bin: - node-gyp-build: bin.js - node-gyp-build-optional: optional.js - node-gyp-build-test: build-test.js - checksum: 25d78c5ef1f8c24291f4a370c47ba52fcea14f39272041a90a7894cd50d766f7c8cb8fb06c0f42bf6f69b204b49d9be3c8fc344aac09714d5bdb95965499eb15 - languageName: node - linkType: hard - -"node-gyp@npm:latest": - version: 9.4.0 - resolution: "node-gyp@npm:9.4.0" - dependencies: - env-paths: ^2.2.0 - exponential-backoff: ^3.1.1 - glob: ^7.1.4 - graceful-fs: ^4.2.6 - make-fetch-happen: ^11.0.3 - nopt: ^6.0.0 - npmlog: ^6.0.0 - rimraf: ^3.0.2 - semver: ^7.3.5 - tar: ^6.1.2 - which: ^2.0.2 - bin: - node-gyp: bin/node-gyp.js - checksum: 78b404e2e0639d64e145845f7f5a3cb20c0520cdaf6dda2f6e025e9b644077202ea7de1232396ba5bde3fee84cdc79604feebe6ba3ec84d464c85d407bb5da99 - languageName: node - linkType: hard - -"nopt@npm:^6.0.0": - version: 6.0.0 - resolution: "nopt@npm:6.0.0" - dependencies: - abbrev: ^1.0.0 - bin: - nopt: bin/nopt.js - checksum: 82149371f8be0c4b9ec2f863cc6509a7fd0fa729929c009f3a58e4eb0c9e4cae9920e8f1f8eb46e7d032fec8fb01bede7f0f41a67eb3553b7b8e14fa53de1dac - languageName: node - linkType: hard - -"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": - version: 3.0.0 - resolution: "normalize-path@npm:3.0.0" - checksum: 88eeb4da891e10b1318c4b2476b6e2ecbeb5ff97d946815ffea7794c31a89017c70d7f34b3c2ebf23ef4e9fc9fb99f7dffe36da22011b5b5c6ffa34f4873ec20 - languageName: node - linkType: hard - -"npmlog@npm:^6.0.0": - version: 6.0.2 - resolution: "npmlog@npm:6.0.2" - dependencies: - are-we-there-yet: ^3.0.0 - console-control-strings: ^1.1.0 - gauge: ^4.0.3 - set-blocking: ^2.0.0 - checksum: ae238cd264a1c3f22091cdd9e2b106f684297d3c184f1146984ecbe18aaa86343953f26b9520dedd1b1372bc0316905b736c1932d778dbeb1fcf5a1001390e2a - languageName: node - linkType: hard - -"once@npm:^1.3.0": - version: 1.4.0 - resolution: "once@npm:1.4.0" - dependencies: - wrappy: 1 - checksum: cd0a88501333edd640d95f0d2700fbde6bff20b3d4d9bdc521bdd31af0656b5706570d6c6afe532045a20bb8dc0849f8332d6f2a416e0ba6d3d3b98806c7db68 - languageName: node - linkType: hard - -"p-limit@npm:^3.0.2": - version: 3.1.0 - resolution: "p-limit@npm:3.1.0" - dependencies: - yocto-queue: ^0.1.0 - checksum: 7c3690c4dbf62ef625671e20b7bdf1cbc9534e83352a2780f165b0d3ceba21907e77ad63401708145ca4e25bfc51636588d89a8c0aeb715e6c37d1c066430360 - languageName: node - linkType: hard - -"p-locate@npm:^5.0.0": - version: 5.0.0 - resolution: "p-locate@npm:5.0.0" - dependencies: - p-limit: ^3.0.2 - checksum: 1623088f36cf1cbca58e9b61c4e62bf0c60a07af5ae1ca99a720837356b5b6c5ba3eb1b2127e47a06865fee59dd0453cad7cc844cda9d5a62ac1a5a51b7c86d3 - languageName: node - linkType: hard - -"p-map@npm:^4.0.0": - version: 4.0.0 - resolution: "p-map@npm:4.0.0" - dependencies: - aggregate-error: ^3.0.0 - checksum: cb0ab21ec0f32ddffd31dfc250e3afa61e103ef43d957cc45497afe37513634589316de4eb88abdfd969fe6410c22c0b93ab24328833b8eb1ccc087fc0442a1c - languageName: node - linkType: hard - -"pako@npm:^2.0.3": - version: 2.1.0 - resolution: "pako@npm:2.1.0" - checksum: 71666548644c9a4d056bcaba849ca6fd7242c6cf1af0646d3346f3079a1c7f4a66ffec6f7369ee0dc88f61926c10d6ab05da3e1fca44b83551839e89edd75a3e - languageName: node - linkType: hard - -"path-exists@npm:^4.0.0": - version: 4.0.0 - resolution: "path-exists@npm:4.0.0" - checksum: 505807199dfb7c50737b057dd8d351b82c033029ab94cb10a657609e00c1bc53b951cfdbccab8de04c5584d5eff31128ce6afd3db79281874a5ef2adbba55ed1 - languageName: node - linkType: hard - -"path-is-absolute@npm:^1.0.0": - version: 1.0.1 - resolution: "path-is-absolute@npm:1.0.1" - checksum: 060840f92cf8effa293bcc1bea81281bd7d363731d214cbe5c227df207c34cd727430f70c6037b5159c8a870b9157cba65e775446b0ab06fd5ecc7e54615a3b8 - languageName: node - linkType: hard - -"path-key@npm:^3.1.0": - version: 3.1.1 - resolution: "path-key@npm:3.1.1" - checksum: 55cd7a9dd4b343412a8386a743f9c746ef196e57c823d90ca3ab917f90ab9f13dd0ded27252ba49dbdfcab2b091d998bc446f6220cd3cea65db407502a740020 - languageName: node - linkType: hard - -"path-scurry@npm:^1.10.1": - version: 1.10.1 - resolution: "path-scurry@npm:1.10.1" - dependencies: - lru-cache: ^9.1.1 || ^10.0.0 - minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 - checksum: e2557cff3a8fb8bc07afdd6ab163a92587884f9969b05bbbaf6fe7379348bfb09af9ed292af12ed32398b15fb443e81692047b786d1eeb6d898a51eb17ed7d90 - languageName: node - linkType: hard - -"pathval@npm:^1.1.1": - version: 1.1.1 - resolution: "pathval@npm:1.1.1" - checksum: 090e3147716647fb7fb5b4b8c8e5b55e5d0a6086d085b6cd23f3d3c01fcf0ff56fd3cc22f2f4a033bd2e46ed55d61ed8379e123b42afe7d531a2a5fc8bb556d6 - languageName: node - linkType: hard - -"picomatch@npm:^2.0.4, picomatch@npm:^2.2.1": - version: 2.3.1 - resolution: "picomatch@npm:2.3.1" - checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf - languageName: node - linkType: hard - -"prettier@npm:^2.6.2": - version: 2.8.8 - resolution: "prettier@npm:2.8.8" - bin: - prettier: bin-prettier.js - checksum: b49e409431bf129dd89238d64299ba80717b57ff5a6d1c1a8b1a28b590d998a34e083fa13573bc732bb8d2305becb4c9a4407f8486c81fa7d55100eb08263cf8 - languageName: node - linkType: hard - -"promise-retry@npm:^2.0.1": - version: 2.0.1 - resolution: "promise-retry@npm:2.0.1" - dependencies: - err-code: ^2.0.2 - retry: ^0.12.0 - checksum: f96a3f6d90b92b568a26f71e966cbbc0f63ab85ea6ff6c81284dc869b41510e6cdef99b6b65f9030f0db422bf7c96652a3fff9f2e8fb4a0f069d8f4430359429 - languageName: node - linkType: hard - -"randombytes@npm:^2.1.0": - version: 2.1.0 - resolution: "randombytes@npm:2.1.0" - dependencies: - safe-buffer: ^5.1.0 - checksum: d779499376bd4cbb435ef3ab9a957006c8682f343f14089ed5f27764e4645114196e75b7f6abf1cbd84fd247c0cb0651698444df8c9bf30e62120fbbc52269d6 - languageName: node - linkType: hard - -"readable-stream@npm:^3.6.0": - version: 3.6.2 - resolution: "readable-stream@npm:3.6.2" - dependencies: - inherits: ^2.0.3 - string_decoder: ^1.1.1 - util-deprecate: ^1.0.1 - checksum: bdcbe6c22e846b6af075e32cf8f4751c2576238c5043169a1c221c92ee2878458a816a4ea33f4c67623c0b6827c8a400409bfb3cf0bf3381392d0b1dfb52ac8d - languageName: node - linkType: hard - -"readdirp@npm:~3.6.0": - version: 3.6.0 - resolution: "readdirp@npm:3.6.0" - dependencies: - picomatch: ^2.2.1 - checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 - languageName: node - linkType: hard - -"regenerator-runtime@npm:^0.13.11": - version: 0.13.11 - resolution: "regenerator-runtime@npm:0.13.11" - checksum: 27481628d22a1c4e3ff551096a683b424242a216fee44685467307f14d58020af1e19660bf2e26064de946bad7eff28950eae9f8209d55723e2d9351e632bbb4 - languageName: node - linkType: hard - -"require-directory@npm:^2.1.1": - version: 2.1.1 - resolution: "require-directory@npm:2.1.1" - checksum: fb47e70bf0001fdeabdc0429d431863e9475e7e43ea5f94ad86503d918423c1543361cc5166d713eaa7029dd7a3d34775af04764bebff99ef413111a5af18c80 - languageName: node - linkType: hard - -"retry@npm:^0.12.0": - version: 0.12.0 - resolution: "retry@npm:0.12.0" - checksum: 623bd7d2e5119467ba66202d733ec3c2e2e26568074923bc0585b6b99db14f357e79bdedb63cab56cec47491c4a0da7e6021a7465ca6dc4f481d3898fdd3158c - languageName: node - linkType: hard - -"rimraf@npm:^3.0.2": - version: 3.0.2 - resolution: "rimraf@npm:3.0.2" - dependencies: - glob: ^7.1.3 - bin: - rimraf: bin.js - checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0 - languageName: node - linkType: hard - -"root-workspace-0b6124@workspace:.": - version: 0.0.0-use.local - resolution: "root-workspace-0b6124@workspace:." - dependencies: - "@coral-xyz/anchor": ^0.28.0 - "@solana/spl-token": ^0.3.8 - "@solana/web3.js": ^1.77.3 - "@types/bn.js": ^5.1.0 - "@types/chai": ^4.3.0 - "@types/mocha": ^9.0.0 - chai: ^4.3.4 - mocha: ^9.0.3 - prettier: ^2.6.2 - ts-mocha: ^10.0.0 - typescript: ^4.3.5 - languageName: unknown - linkType: soft - -"rpc-websockets@npm:^7.5.1": - version: 7.5.1 - resolution: "rpc-websockets@npm:7.5.1" - dependencies: - "@babel/runtime": ^7.17.2 - bufferutil: ^4.0.1 - eventemitter3: ^4.0.7 - utf-8-validate: ^5.0.2 - uuid: ^8.3.2 - ws: ^8.5.0 - dependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 9dda8c63a1d3e85e11597e1c364835ec6aa9a8de1b5cfb1629d0eafc3ae04509011d485025ed4f717c0b1dd048e2aafdd75080e866540b93e55fd8a2cd91bcfe - languageName: node - linkType: hard - -"safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:~5.2.0": - version: 5.2.1 - resolution: "safe-buffer@npm:5.2.1" - checksum: b99c4b41fdd67a6aaf280fcd05e9ffb0813654894223afb78a31f14a19ad220bba8aba1cb14eddce1fcfb037155fe6de4e861784eb434f7d11ed58d1e70dd491 - languageName: node - linkType: hard - -"safer-buffer@npm:>= 2.1.2 < 3.0.0": - version: 2.1.2 - resolution: "safer-buffer@npm:2.1.2" - checksum: cab8f25ae6f1434abee8d80023d7e72b598cf1327164ddab31003c51215526801e40b66c5e65d658a0af1e9d6478cadcb4c745f4bd6751f97d8644786c0978b0 - languageName: node - linkType: hard - -"semver@npm:^7.3.5": - version: 7.5.4 - resolution: "semver@npm:7.5.4" - dependencies: - lru-cache: ^6.0.0 - bin: - semver: bin/semver.js - checksum: 12d8ad952fa353b0995bf180cdac205a4068b759a140e5d3c608317098b3575ac2f1e09182206bf2eb26120e1c0ed8fb92c48c592f6099680de56bb071423ca3 - languageName: node - linkType: hard - -"serialize-javascript@npm:6.0.0": - version: 6.0.0 - resolution: "serialize-javascript@npm:6.0.0" - dependencies: - randombytes: ^2.1.0 - checksum: 56f90b562a1bdc92e55afb3e657c6397c01a902c588c0fe3d4c490efdcc97dcd2a3074ba12df9e94630f33a5ce5b76a74784a7041294628a6f4306e0ec84bf93 - languageName: node - linkType: hard - -"set-blocking@npm:^2.0.0": - version: 2.0.0 - resolution: "set-blocking@npm:2.0.0" - checksum: 6e65a05f7cf7ebdf8b7c75b101e18c0b7e3dff4940d480efed8aad3a36a4005140b660fa1d804cb8bce911cac290441dc728084a30504d3516ac2ff7ad607b02 - languageName: node - linkType: hard - -"shebang-command@npm:^2.0.0": - version: 2.0.0 - resolution: "shebang-command@npm:2.0.0" - dependencies: - shebang-regex: ^3.0.0 - checksum: 6b52fe87271c12968f6a054e60f6bde5f0f3d2db483a1e5c3e12d657c488a15474121a1d55cd958f6df026a54374ec38a4a963988c213b7570e1d51575cea7fa - languageName: node - linkType: hard - -"shebang-regex@npm:^3.0.0": - version: 3.0.0 - resolution: "shebang-regex@npm:3.0.0" - checksum: 1a2bcae50de99034fcd92ad4212d8e01eedf52c7ec7830eedcf886622804fe36884278f2be8be0ea5fde3fd1c23911643a4e0f726c8685b61871c8908af01222 - languageName: node - linkType: hard - -"signal-exit@npm:^3.0.7": - version: 3.0.7 - resolution: "signal-exit@npm:3.0.7" - checksum: a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 - languageName: node - linkType: hard - -"signal-exit@npm:^4.0.1": - version: 4.1.0 - resolution: "signal-exit@npm:4.1.0" - checksum: 64c757b498cb8629ffa5f75485340594d2f8189e9b08700e69199069c8e3070fb3e255f7ab873c05dc0b3cec412aea7402e10a5990cb6a050bd33ba062a6c549 - languageName: node - linkType: hard - -"smart-buffer@npm:^4.2.0": - version: 4.2.0 - resolution: "smart-buffer@npm:4.2.0" - checksum: b5167a7142c1da704c0e3af85c402002b597081dd9575031a90b4f229ca5678e9a36e8a374f1814c8156a725d17008ae3bde63b92f9cfd132526379e580bec8b - languageName: node - linkType: hard - -"snake-case@npm:^3.0.4": - version: 3.0.4 - resolution: "snake-case@npm:3.0.4" - dependencies: - dot-case: ^3.0.4 - tslib: ^2.0.3 - checksum: 0a7a79900bbb36f8aaa922cf111702a3647ac6165736d5dc96d3ef367efc50465cac70c53cd172c382b022dac72ec91710608e5393de71f76d7142e6fd80e8a3 - languageName: node - linkType: hard - -"socks-proxy-agent@npm:^7.0.0": - version: 7.0.0 - resolution: "socks-proxy-agent@npm:7.0.0" - dependencies: - agent-base: ^6.0.2 - debug: ^4.3.3 - socks: ^2.6.2 - checksum: 720554370154cbc979e2e9ce6a6ec6ced205d02757d8f5d93fe95adae454fc187a5cbfc6b022afab850a5ce9b4c7d73e0f98e381879cf45f66317a4895953846 - languageName: node - linkType: hard - -"socks@npm:^2.6.2": - version: 2.7.1 - resolution: "socks@npm:2.7.1" - dependencies: - ip: ^2.0.0 - smart-buffer: ^4.2.0 - checksum: 259d9e3e8e1c9809a7f5c32238c3d4d2a36b39b83851d0f573bfde5f21c4b1288417ce1af06af1452569cd1eb0841169afd4998f0e04ba04656f6b7f0e46d748 - languageName: node - linkType: hard - -"source-map-support@npm:^0.5.6": - version: 0.5.21 - resolution: "source-map-support@npm:0.5.21" - dependencies: - buffer-from: ^1.0.0 - source-map: ^0.6.0 - checksum: 43e98d700d79af1d36f859bdb7318e601dfc918c7ba2e98456118ebc4c4872b327773e5a1df09b0524e9e5063bb18f0934538eace60cca2710d1fa687645d137 - languageName: node - linkType: hard - -"source-map@npm:^0.6.0": - version: 0.6.1 - resolution: "source-map@npm:0.6.1" - checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2 - languageName: node - linkType: hard - -"ssri@npm:^10.0.0": - version: 10.0.4 - resolution: "ssri@npm:10.0.4" - dependencies: - minipass: ^5.0.0 - checksum: fb14da9f8a72b04eab163eb13a9dda11d5962cd2317f85457c4e0b575e9a6e0e3a6a87b5bf122c75cb36565830cd5f263fb457571bf6f1587eb5f95d095d6165 - languageName: node - linkType: hard - -"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": - version: 4.2.3 - resolution: "string-width@npm:4.2.3" - dependencies: - emoji-regex: ^8.0.0 - is-fullwidth-code-point: ^3.0.0 - strip-ansi: ^6.0.1 - checksum: e52c10dc3fbfcd6c3a15f159f54a90024241d0f149cf8aed2982a2d801d2e64df0bf1dc351cf8e95c3319323f9f220c16e740b06faecd53e2462df1d2b5443fb - languageName: node - linkType: hard - -"string-width@npm:^5.0.1, string-width@npm:^5.1.2": - version: 5.1.2 - resolution: "string-width@npm:5.1.2" - dependencies: - eastasianwidth: ^0.2.0 - emoji-regex: ^9.2.2 - strip-ansi: ^7.0.1 - checksum: 7369deaa29f21dda9a438686154b62c2c5f661f8dda60449088f9f980196f7908fc39fdd1803e3e01541970287cf5deae336798337e9319a7055af89dafa7193 - languageName: node - linkType: hard - -"string_decoder@npm:^1.1.1": - version: 1.3.0 - resolution: "string_decoder@npm:1.3.0" - dependencies: - safe-buffer: ~5.2.0 - checksum: 8417646695a66e73aefc4420eb3b84cc9ffd89572861fe004e6aeb13c7bc00e2f616247505d2dbbef24247c372f70268f594af7126f43548565c68c117bdeb56 - languageName: node - linkType: hard - -"strip-ansi-cjs@npm:strip-ansi@^6.0.1, strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1": - version: 6.0.1 - resolution: "strip-ansi@npm:6.0.1" - dependencies: - ansi-regex: ^5.0.1 - checksum: f3cd25890aef3ba6e1a74e20896c21a46f482e93df4a06567cebf2b57edabb15133f1f94e57434e0a958d61186087b1008e89c94875d019910a213181a14fc8c - languageName: node - linkType: hard - -"strip-ansi@npm:^7.0.1": - version: 7.1.0 - resolution: "strip-ansi@npm:7.1.0" - dependencies: - ansi-regex: ^6.0.1 - checksum: 859c73fcf27869c22a4e4d8c6acfe690064659e84bef9458aa6d13719d09ca88dcfd40cbf31fd0be63518ea1a643fe070b4827d353e09533a5b0b9fd4553d64d - languageName: node - linkType: hard - -"strip-bom@npm:^3.0.0": - version: 3.0.0 - resolution: "strip-bom@npm:3.0.0" - checksum: 8d50ff27b7ebe5ecc78f1fe1e00fcdff7af014e73cf724b46fb81ef889eeb1015fc5184b64e81a2efe002180f3ba431bdd77e300da5c6685d702780fbf0c8d5b - languageName: node - linkType: hard - -"strip-json-comments@npm:3.1.1": - version: 3.1.1 - resolution: "strip-json-comments@npm:3.1.1" - checksum: 492f73e27268f9b1c122733f28ecb0e7e8d8a531a6662efbd08e22cccb3f9475e90a1b82cab06a392f6afae6d2de636f977e231296400d0ec5304ba70f166443 - languageName: node - linkType: hard - -"superstruct@npm:^0.14.2": - version: 0.14.2 - resolution: "superstruct@npm:0.14.2" - checksum: c5c4840f432da82125b923ec45faca5113217e83ae416e314d80eae012b8bb603d2e745025d173450758d116348820bc7028157f8c9a72b6beae879f94b837c0 - languageName: node - linkType: hard - -"superstruct@npm:^0.15.4": - version: 0.15.5 - resolution: "superstruct@npm:0.15.5" - checksum: 6d1f5249fee789424b7178fa0a1ffb2ace629c5480c39505885bd8c0046a4ff8b267569a3442fa53b8c560a7ba6599cf3f8af94225aebeb2cf6023f7dd911050 - languageName: node - linkType: hard - -"supports-color@npm:8.1.1": - version: 8.1.1 - resolution: "supports-color@npm:8.1.1" - dependencies: - has-flag: ^4.0.0 - checksum: c052193a7e43c6cdc741eb7f378df605636e01ad434badf7324f17fb60c69a880d8d8fcdcb562cf94c2350e57b937d7425ab5b8326c67c2adc48f7c87c1db406 - languageName: node - linkType: hard - -"supports-color@npm:^7.1.0": - version: 7.2.0 - resolution: "supports-color@npm:7.2.0" - dependencies: - has-flag: ^4.0.0 - checksum: 3dda818de06ebbe5b9653e07842d9479f3555ebc77e9a0280caf5a14fb877ffee9ed57007c3b78f5a6324b8dbeec648d9e97a24e2ed9fdb81ddc69ea07100f4a - languageName: node - linkType: hard - -"tar@npm:^6.1.11, tar@npm:^6.1.2": - version: 6.1.15 - resolution: "tar@npm:6.1.15" - dependencies: - chownr: ^2.0.0 - fs-minipass: ^2.0.0 - minipass: ^5.0.0 - minizlib: ^2.1.1 - mkdirp: ^1.0.3 - yallist: ^4.0.0 - checksum: f23832fceeba7578bf31907aac744ae21e74a66f4a17a9e94507acf460e48f6db598c7023882db33bab75b80e027c21f276d405e4a0322d58f51c7088d428268 - languageName: node - linkType: hard - -"text-encoding-utf-8@npm:^1.0.2": - version: 1.0.2 - resolution: "text-encoding-utf-8@npm:1.0.2" - checksum: ec4c15d50e738c5dba7327ad432ebf0725ec75d4d69c0bd55609254c5a3bc5341272d7003691084a0a73d60d981c8eb0e87603676fdb6f3fed60f4c9192309f9 - languageName: node - linkType: hard - -"through@npm:>=2.2.7 <3": - version: 2.3.8 - resolution: "through@npm:2.3.8" - checksum: a38c3e059853c494af95d50c072b83f8b676a9ba2818dcc5b108ef252230735c54e0185437618596c790bbba8fcdaef5b290405981ffa09dce67b1f1bf190cbd - languageName: node - linkType: hard - -"to-regex-range@npm:^5.0.1": - version: 5.0.1 - resolution: "to-regex-range@npm:5.0.1" - dependencies: - is-number: ^7.0.0 - checksum: f76fa01b3d5be85db6a2a143e24df9f60dd047d151062d0ba3df62953f2f697b16fe5dad9b0ac6191c7efc7b1d9dcaa4b768174b7b29da89d4428e64bc0a20ed - languageName: node - linkType: hard - -"toml@npm:^3.0.0": - version: 3.0.0 - resolution: "toml@npm:3.0.0" - checksum: 5d7f1d8413ad7780e9bdecce8ea4c3f5130dd53b0a4f2e90b93340979a137739879d7b9ce2ce05c938b8cc828897fe9e95085197342a1377dd8850bf5125f15f - languageName: node - linkType: hard - -"tr46@npm:~0.0.3": - version: 0.0.3 - resolution: "tr46@npm:0.0.3" - checksum: 726321c5eaf41b5002e17ffbd1fb7245999a073e8979085dacd47c4b4e8068ff5777142fc6726d6ca1fd2ff16921b48788b87225cbc57c72636f6efa8efbffe3 - languageName: node - linkType: hard - -"ts-mocha@npm:^10.0.0": - version: 10.0.0 - resolution: "ts-mocha@npm:10.0.0" - dependencies: - ts-node: 7.0.1 - tsconfig-paths: ^3.5.0 - peerDependencies: - mocha: ^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X - dependenciesMeta: - tsconfig-paths: - optional: true - bin: - ts-mocha: bin/ts-mocha - checksum: b11f2a8ceecf195b0db724da429159982fef12e4357088fe900289223587217e8c126ead7929679edd58bf19ad96c5da5911535d26f535386632e18fbff10c40 - languageName: node - linkType: hard - -"ts-node@npm:7.0.1": - version: 7.0.1 - resolution: "ts-node@npm:7.0.1" - dependencies: - arrify: ^1.0.0 - buffer-from: ^1.1.0 - diff: ^3.1.0 - make-error: ^1.1.1 - minimist: ^1.2.0 - mkdirp: ^0.5.1 - source-map-support: ^0.5.6 - yn: ^2.0.0 - bin: - ts-node: dist/bin.js - checksum: 07ed6ea1805361828737a767cfd6c57ea6e267ee8679282afb933610af02405e1a87c1f2aea1d38ed8e66b34fcbf6272b6021ab95d78849105d2e57fc283870b - languageName: node - linkType: hard - -"tsconfig-paths@npm:^3.5.0": - version: 3.14.2 - resolution: "tsconfig-paths@npm:3.14.2" - dependencies: - "@types/json5": ^0.0.29 - json5: ^1.0.2 - minimist: ^1.2.6 - strip-bom: ^3.0.0 - checksum: a6162eaa1aed680537f93621b82399c7856afd10ec299867b13a0675e981acac4e0ec00896860480efc59fc10fd0b16fdc928c0b885865b52be62cadac692447 - languageName: node - linkType: hard - -"tslib@npm:^2.0.3": - version: 2.6.1 - resolution: "tslib@npm:2.6.1" - checksum: b0d176d176487905b66ae4d5856647df50e37beea7571c53b8d10ba9222c074b81f1410fb91da13debaf2cbc970663609068bdebafa844ea9d69b146527c38fe - languageName: node - linkType: hard - -"type-detect@npm:^4.0.0, type-detect@npm:^4.0.5": - version: 4.0.8 - resolution: "type-detect@npm:4.0.8" - checksum: 62b5628bff67c0eb0b66afa371bd73e230399a8d2ad30d852716efcc4656a7516904570cd8631a49a3ce57c10225adf5d0cbdcb47f6b0255fe6557c453925a15 - languageName: node - linkType: hard - -"typescript@npm:^4.3.5": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db - languageName: node - linkType: hard - -"typescript@patch:typescript@^4.3.5#~builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=289587" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 1f8f3b6aaea19f0f67cba79057674ba580438a7db55057eb89cc06950483c5d632115c14077f6663ea76fd09fce3c190e6414bb98582ec80aa5a4eaf345d5b68 - languageName: node - linkType: hard - -"unique-filename@npm:^3.0.0": - version: 3.0.0 - resolution: "unique-filename@npm:3.0.0" - dependencies: - unique-slug: ^4.0.0 - checksum: 8e2f59b356cb2e54aab14ff98a51ac6c45781d15ceaab6d4f1c2228b780193dc70fae4463ce9e1df4479cb9d3304d7c2043a3fb905bdeca71cc7e8ce27e063df - languageName: node - linkType: hard - -"unique-slug@npm:^4.0.0": - version: 4.0.0 - resolution: "unique-slug@npm:4.0.0" - dependencies: - imurmurhash: ^0.1.4 - checksum: 0884b58365af59f89739e6f71e3feacb5b1b41f2df2d842d0757933620e6de08eff347d27e9d499b43c40476cbaf7988638d3acb2ffbcb9d35fd035591adfd15 - languageName: node - linkType: hard - -"utf-8-validate@npm:^5.0.2": - version: 5.0.10 - resolution: "utf-8-validate@npm:5.0.10" - dependencies: - node-gyp: latest - node-gyp-build: ^4.3.0 - checksum: 5579350a023c66a2326752b6c8804cc7b39dcd251bb088241da38db994b8d78352e388dcc24ad398ab98385ba3c5ffcadb6b5b14b2637e43f767869055e46ba6 - languageName: node - linkType: hard - -"util-deprecate@npm:^1.0.1": - version: 1.0.2 - resolution: "util-deprecate@npm:1.0.2" - checksum: 474acf1146cb2701fe3b074892217553dfcf9a031280919ba1b8d651a068c9b15d863b7303cb15bd00a862b498e6cf4ad7b4a08fb134edd5a6f7641681cb54a2 - languageName: node - linkType: hard - -"uuid@npm:^8.3.2": - version: 8.3.2 - resolution: "uuid@npm:8.3.2" - bin: - uuid: dist/bin/uuid - checksum: 5575a8a75c13120e2f10e6ddc801b2c7ed7d8f3c8ac22c7ed0c7b2ba6383ec0abda88c905085d630e251719e0777045ae3236f04c812184b7c765f63a70e58df - languageName: node - linkType: hard - -"webidl-conversions@npm:^3.0.0": - version: 3.0.1 - resolution: "webidl-conversions@npm:3.0.1" - checksum: c92a0a6ab95314bde9c32e1d0a6dfac83b578f8fa5f21e675bc2706ed6981bc26b7eb7e6a1fab158e5ce4adf9caa4a0aee49a52505d4d13c7be545f15021b17c - languageName: node - linkType: hard - -"whatwg-url@npm:^5.0.0": - version: 5.0.0 - resolution: "whatwg-url@npm:5.0.0" - dependencies: - tr46: ~0.0.3 - webidl-conversions: ^3.0.0 - checksum: b8daed4ad3356cc4899048a15b2c143a9aed0dfae1f611ebd55073310c7b910f522ad75d727346ad64203d7e6c79ef25eafd465f4d12775ca44b90fa82ed9e2c - languageName: node - linkType: hard - -"which@npm:2.0.2, which@npm:^2.0.1, which@npm:^2.0.2": - version: 2.0.2 - resolution: "which@npm:2.0.2" - dependencies: - isexe: ^2.0.0 - bin: - node-which: ./bin/node-which - checksum: 1a5c563d3c1b52d5f893c8b61afe11abc3bab4afac492e8da5bde69d550de701cf9806235f20a47b5c8fa8a1d6a9135841de2596535e998027a54589000e66d1 - languageName: node - linkType: hard - -"wide-align@npm:^1.1.5": - version: 1.1.5 - resolution: "wide-align@npm:1.1.5" - dependencies: - string-width: ^1.0.2 || 2 || 3 || 4 - checksum: d5fc37cd561f9daee3c80e03b92ed3e84d80dde3365a8767263d03dacfc8fa06b065ffe1df00d8c2a09f731482fcacae745abfbb478d4af36d0a891fad4834d3 - languageName: node - linkType: hard - -"workerpool@npm:6.2.0": - version: 6.2.0 - resolution: "workerpool@npm:6.2.0" - checksum: 3493b4f0ef979a23d2c1583d7ef85f62fc9463cc02f82829d3e7e663b517f8ae9707da0249b382e46ac58986deb0ca2232ee1081713741211bda9254b429c9bb - languageName: node - linkType: hard - -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0, wrap-ansi@npm:^7.0.0": - version: 7.0.0 - resolution: "wrap-ansi@npm:7.0.0" - dependencies: - ansi-styles: ^4.0.0 - string-width: ^4.1.0 - strip-ansi: ^6.0.0 - checksum: a790b846fd4505de962ba728a21aaeda189b8ee1c7568ca5e817d85930e06ef8d1689d49dbf0e881e8ef84436af3a88bc49115c2e2788d841ff1b8b5b51a608b - languageName: node - linkType: hard - -"wrap-ansi@npm:^8.1.0": - version: 8.1.0 - resolution: "wrap-ansi@npm:8.1.0" - dependencies: - ansi-styles: ^6.1.0 - string-width: ^5.0.1 - strip-ansi: ^7.0.1 - checksum: 371733296dc2d616900ce15a0049dca0ef67597d6394c57347ba334393599e800bab03c41d4d45221b6bc967b8c453ec3ae4749eff3894202d16800fdfe0e238 - languageName: node - linkType: hard - -"wrappy@npm:1": - version: 1.0.2 - resolution: "wrappy@npm:1.0.2" - checksum: 159da4805f7e84a3d003d8841557196034155008f817172d4e986bd591f74aa82aa7db55929a54222309e01079a65a92a9e6414da5a6aa4b01ee44a511ac3ee5 - languageName: node - linkType: hard - -"ws@npm:^7.4.5": - version: 7.5.9 - resolution: "ws@npm:7.5.9" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: c3c100a181b731f40b7f2fddf004aa023f79d64f489706a28bc23ff88e87f6a64b3c6651fbec3a84a53960b75159574d7a7385709847a62ddb7ad6af76f49138 - languageName: node - linkType: hard - -"ws@npm:^8.5.0": - version: 8.13.0 - resolution: "ws@npm:8.13.0" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 53e991bbf928faf5dc6efac9b8eb9ab6497c69feeb94f963d648b7a3530a720b19ec2e0ec037344257e05a4f35bd9ad04d9de6f289615ffb133282031b18c61c - languageName: node - linkType: hard - -"y18n@npm:^5.0.5": - version: 5.0.8 - resolution: "y18n@npm:5.0.8" - checksum: 54f0fb95621ee60898a38c572c515659e51cc9d9f787fb109cef6fde4befbe1c4602dc999d30110feee37456ad0f1660fa2edcfde6a9a740f86a290999550d30 - languageName: node - linkType: hard - -"yallist@npm:^4.0.0": - version: 4.0.0 - resolution: "yallist@npm:4.0.0" - checksum: 343617202af32df2a15a3be36a5a8c0c8545208f3d3dfbc6bb7c3e3b7e8c6f8e7485432e4f3b88da3031a6e20afa7c711eded32ddfb122896ac5d914e75848d5 - languageName: node - linkType: hard - -"yargs-parser@npm:20.2.4, yargs-parser@npm:^20.2.2": - version: 20.2.4 - resolution: "yargs-parser@npm:20.2.4" - checksum: d251998a374b2743a20271c2fd752b9fbef24eb881d53a3b99a7caa5e8227fcafd9abf1f345ac5de46435821be25ec12189a11030c12ee6481fef6863ed8b924 - languageName: node - linkType: hard - -"yargs-unparser@npm:2.0.0": - version: 2.0.0 - resolution: "yargs-unparser@npm:2.0.0" - dependencies: - camelcase: ^6.0.0 - decamelize: ^4.0.0 - flat: ^5.0.2 - is-plain-obj: ^2.1.0 - checksum: 68f9a542c6927c3768c2f16c28f71b19008710abd6b8f8efbac6dcce26bbb68ab6503bed1d5994bdbc2df9a5c87c161110c1dfe04c6a3fe5c6ad1b0e15d9a8a3 - languageName: node - linkType: hard - -"yargs@npm:16.2.0": - version: 16.2.0 - resolution: "yargs@npm:16.2.0" - dependencies: - cliui: ^7.0.2 - escalade: ^3.1.1 - get-caller-file: ^2.0.5 - require-directory: ^2.1.1 - string-width: ^4.2.0 - y18n: ^5.0.5 - yargs-parser: ^20.2.2 - checksum: b14afbb51e3251a204d81937c86a7e9d4bdbf9a2bcee38226c900d00f522969ab675703bee2a6f99f8e20103f608382936034e64d921b74df82b63c07c5e8f59 - languageName: node - linkType: hard - -"yn@npm:^2.0.0": - version: 2.0.0 - resolution: "yn@npm:2.0.0" - checksum: 9d49527cb3e9a0948cc057223810bf30607bf04b9ff7666cc1681a6501d660b60d90000c16f9e29311b0f28d8a06222ada565ccdca5f1049cdfefb1908217572 - languageName: node - linkType: hard - -"yocto-queue@npm:^0.1.0": - version: 0.1.0 - resolution: "yocto-queue@npm:0.1.0" - checksum: f77b3d8d00310def622123df93d4ee654fc6a0096182af8bd60679ddcdfb3474c56c6c7190817c84a2785648cdee9d721c0154eb45698c62176c322fb46fc700 - languageName: node - linkType: hard +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/runtime@^7.17.2", "@babel/runtime@^7.22.6": + version "7.22.6" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438" + integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ== + dependencies: + regenerator-runtime "^0.13.11" + +"@coral-xyz/anchor@^0.28.0": + version "0.28.0" + resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.28.0.tgz#8345c3c9186a91f095f704d7b90cd256f7e8b2dc" + integrity sha512-kQ02Hv2ZqxtWP30WN1d4xxT4QqlOXYDxmEd3k/bbneqhV3X5QMO4LAtoUFs7otxyivOgoqam5Il5qx81FuI4vw== + dependencies: + "@coral-xyz/borsh" "^0.28.0" + "@solana/web3.js" "^1.68.0" + base64-js "^1.5.1" + bn.js "^5.1.2" + bs58 "^4.0.1" + buffer-layout "^1.2.2" + camelcase "^6.3.0" + cross-fetch "^3.1.5" + crypto-hash "^1.3.0" + eventemitter3 "^4.0.7" + js-sha256 "^0.9.0" + pako "^2.0.3" + snake-case "^3.0.4" + superstruct "^0.15.4" + toml "^3.0.0" + +"@coral-xyz/borsh@^0.28.0": + version "0.28.0" + resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.28.0.tgz#fa368a2f2475bbf6f828f4657f40a52102e02b6d" + integrity sha512-/u1VTzw7XooK7rqeD7JLUSwOyRSesPUk0U37BV9zK0axJc1q0nRbKFGFLYCQ16OtdOJTTwGfGp11Lx9B45bRCQ== + dependencies: + bn.js "^5.1.2" + buffer-layout "^1.2.0" + +"@noble/curves@^1.0.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.1.0.tgz#f13fc667c89184bc04cccb9b11e8e7bae27d8c3d" + integrity sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA== + dependencies: + "@noble/hashes" "1.3.1" + +"@noble/hashes@1.3.1", "@noble/hashes@^1.3.0": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9" + integrity sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA== + +"@solana/buffer-layout-utils@^0.2.0": + version "0.2.0" + resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca" + integrity sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g== + dependencies: + "@solana/buffer-layout" "^4.0.0" + "@solana/web3.js" "^1.32.0" + bigint-buffer "^1.1.5" + bignumber.js "^9.0.1" + +"@solana/buffer-layout@^4.0.0": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15" + integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA== + dependencies: + buffer "~6.0.3" + +"@solana/spl-token@^0.3.8": + version "0.3.8" + resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.3.8.tgz#8e9515ea876e40a4cc1040af865f61fc51d27edf" + integrity sha512-ogwGDcunP9Lkj+9CODOWMiVJEdRtqHAtX2rWF62KxnnSWtMZtV9rDhTrZFshiyJmxDnRL/1nKE1yJHg4jjs3gg== + dependencies: + "@solana/buffer-layout" "^4.0.0" + "@solana/buffer-layout-utils" "^0.2.0" + buffer "^6.0.3" + +"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.77.3": + version "1.78.1" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.78.1.tgz#1b1023f81aa98f53ef45eaec642be11c0a0877f3" + integrity sha512-r0WZAYwCfVElfONP/dmWkEfw6wufL+u7lWojEsNecn9PyIIYq+r4eb0h2MRiJ3xkctvTN76G0T6FTGcTJhXh3Q== + dependencies: + "@babel/runtime" "^7.22.6" + "@noble/curves" "^1.0.0" + "@noble/hashes" "^1.3.0" + "@solana/buffer-layout" "^4.0.0" + agentkeepalive "^4.2.1" + bigint-buffer "^1.1.5" + bn.js "^5.0.0" + borsh "^0.7.0" + bs58 "^4.0.1" + buffer "6.0.3" + fast-stable-stringify "^1.0.0" + jayson "^4.1.0" + node-fetch "^2.6.12" + rpc-websockets "^7.5.1" + superstruct "^0.14.2" + +"@types/bn.js@^5.1.0": + version "5.1.1" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.1.tgz#b51e1b55920a4ca26e9285ff79936bbdec910682" + integrity sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g== + dependencies: + "@types/node" "*" + +"@types/chai@^4.3.0": + version "4.3.5" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.5.tgz#ae69bcbb1bebb68c4ac0b11e9d8ed04526b3562b" + integrity sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng== + +"@types/connect@^3.4.33": + version "3.4.35" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" + integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== + dependencies: + "@types/node" "*" + +"@types/json5@^0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" + integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== + +"@types/mocha@^9.0.0": + version "9.1.1" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" + integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== + +"@types/node@*": + version "20.4.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.5.tgz#9dc0a5cb1ccce4f7a731660935ab70b9c00a5d69" + integrity sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg== + +"@types/node@^12.12.54": + version "12.20.55" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" + integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== + +"@types/ws@^7.4.4": + version "7.4.7" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" + integrity sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww== + dependencies: + "@types/node" "*" + +"@ungap/promise-all-settled@1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" + integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== + +JSONStream@^1.3.5: + version "1.3.5" + resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" + integrity sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ== + dependencies: + jsonparse "^1.2.0" + through ">=2.2.7 <3" + +agentkeepalive@^4.2.1: + version "4.3.0" + resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.3.0.tgz#bb999ff07412653c1803b3ced35e50729830a255" + integrity sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg== + dependencies: + debug "^4.1.0" + depd "^2.0.0" + humanize-ms "^1.2.1" + +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== + +assertion-error@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" + integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +base-x@^3.0.2: + version "3.0.9" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" + integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== + dependencies: + safe-buffer "^5.0.1" + +base64-js@^1.3.1, base64-js@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + +bigint-buffer@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.5.tgz#d038f31c8e4534c1f8d0015209bf34b4fa6dd442" + integrity sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA== + dependencies: + bindings "^1.3.0" + +bignumber.js@^9.0.1: + version "9.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6" + integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig== + +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + +bindings@^1.3.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + +bn.js@^5.0.0, bn.js@^5.1.2, bn.js@^5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" + integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== + +borsh@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a" + integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA== + dependencies: + bn.js "^5.2.0" + bs58 "^4.0.0" + text-encoding-utf-8 "^1.0.2" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +bs58@^4.0.0, bs58@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" + integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== + dependencies: + base-x "^3.0.2" + +buffer-from@^1.0.0, buffer-from@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +buffer-layout@^1.2.0, buffer-layout@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" + integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA== + +buffer@6.0.3, buffer@^6.0.3, buffer@~6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + +bufferutil@^4.0.1: + version "4.0.7" + resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.7.tgz#60c0d19ba2c992dd8273d3f73772ffc894c153ad" + integrity sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw== + dependencies: + node-gyp-build "^4.3.0" + +camelcase@^6.0.0, camelcase@^6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +chai@^4.3.4: + version "4.3.7" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.7.tgz#ec63f6df01829088e8bf55fca839bcd464a8ec51" + integrity sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A== + dependencies: + assertion-error "^1.1.0" + check-error "^1.0.2" + deep-eql "^4.1.2" + get-func-name "^2.0.0" + loupe "^2.3.1" + pathval "^1.1.1" + type-detect "^4.0.5" + +chalk@^4.1.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +check-error@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" + integrity sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA== + +chokidar@3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +commander@^2.20.3: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +cross-fetch@^3.1.5: + version "3.1.8" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" + integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== + dependencies: + node-fetch "^2.6.12" + +crypto-hash@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/crypto-hash/-/crypto-hash-1.3.0.tgz#b402cb08f4529e9f4f09346c3e275942f845e247" + integrity sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg== + +debug@4.3.3: + version "4.3.3" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" + integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q== + dependencies: + ms "2.1.2" + +debug@^4.1.0: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + +deep-eql@^4.1.2: + version "4.1.3" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.3.tgz#7c7775513092f7df98d8df9996dd085eb668cc6d" + integrity sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw== + dependencies: + type-detect "^4.0.0" + +delay@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" + integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== + +depd@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== + +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + +diff@^3.1.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== + +dot-case@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751" + integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w== + dependencies: + no-case "^3.0.4" + tslib "^2.0.3" + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +es6-promise@^4.0.3: + version "4.2.8" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" + integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== + +es6-promisify@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" + integrity sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ== + dependencies: + es6-promise "^4.0.3" + +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +escape-string-regexp@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eventemitter3@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +eyes@^0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" + integrity sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ== + +fast-stable-stringify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz#5c5543462b22aeeefd36d05b34e51c78cb86d313" + integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag== + +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-func-name@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" + integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig== + +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob@7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +growl@1.10.5: + version "1.10.5" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" + integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + +humanize-ms@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" + integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== + dependencies: + ms "^2.0.0" + +ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +isomorphic-ws@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" + integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== + +jayson@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/jayson/-/jayson-4.1.0.tgz#60dc946a85197317f2b1439d672a8b0a99cea2f9" + integrity sha512-R6JlbyLN53Mjku329XoRT2zJAE6ZgOQ8f91ucYdMCD4nkGCF9kZSrcGXpHIU4jeKj58zUZke2p+cdQchU7Ly7A== + dependencies: + "@types/connect" "^3.4.33" + "@types/node" "^12.12.54" + "@types/ws" "^7.4.4" + JSONStream "^1.3.5" + commander "^2.20.3" + delay "^5.0.0" + es6-promisify "^5.0.0" + eyes "^0.1.8" + isomorphic-ws "^4.0.1" + json-stringify-safe "^5.0.1" + uuid "^8.3.2" + ws "^7.4.5" + +js-sha256@^0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" + integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== + +js-yaml@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +json-stringify-safe@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== + +json5@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" + integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== + dependencies: + minimist "^1.2.0" + +jsonparse@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" + integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +log-symbols@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + +loupe@^2.3.1: + version "2.3.6" + resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.6.tgz#76e4af498103c532d1ecc9be102036a21f787b53" + integrity sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA== + dependencies: + get-func-name "^2.0.0" + +lower-case@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" + integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg== + dependencies: + tslib "^2.0.3" + +make-error@^1.1.1: + version "1.3.6" + resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" + integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== + +minimatch@4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-4.2.1.tgz#40d9d511a46bdc4e563c22c3080cde9c0d8299b4" + integrity sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g== + dependencies: + brace-expansion "^1.1.7" + +minimatch@^3.0.4: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.2.0, minimist@^1.2.6: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== + +mkdirp@^0.5.1: + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + +mocha@^9.0.3: + version "9.2.2" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.2.2.tgz#d70db46bdb93ca57402c809333e5a84977a88fb9" + integrity sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g== + dependencies: + "@ungap/promise-all-settled" "1.1.2" + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.3" + debug "4.3.3" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "7.2.0" + growl "1.10.5" + he "1.2.0" + js-yaml "4.1.0" + log-symbols "4.1.0" + minimatch "4.2.1" + ms "2.1.3" + nanoid "3.3.1" + serialize-javascript "6.0.0" + strip-json-comments "3.1.1" + supports-color "8.1.1" + which "2.0.2" + workerpool "6.2.0" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@2.1.3, ms@^2.0.0: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +nanoid@3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" + integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== + +no-case@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" + integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg== + dependencies: + lower-case "^2.0.2" + tslib "^2.0.3" + +node-fetch@^2.6.12: + version "2.6.12" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" + integrity sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g== + dependencies: + whatwg-url "^5.0.0" + +node-gyp-build@^4.3.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.0.tgz#0c52e4cbf54bbd28b709820ef7b6a3c2d6209055" + integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ== + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +pako@^2.0.3: + version "2.1.0" + resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" + integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +pathval@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" + integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== + +picomatch@^2.0.4, picomatch@^2.2.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +prettier@^2.6.2: + version "2.8.8" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" + integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== + +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +regenerator-runtime@^0.13.11: + version "0.13.11" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" + integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +rpc-websockets@^7.5.1: + version "7.5.1" + resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-7.5.1.tgz#e0a05d525a97e7efc31a0617f093a13a2e10c401" + integrity sha512-kGFkeTsmd37pHPMaHIgN1LVKXMi0JD782v4Ds9ZKtLlwdTKjn+CxM9A9/gLT2LaOuEcEFGL98h1QWQtlOIdW0w== + dependencies: + "@babel/runtime" "^7.17.2" + eventemitter3 "^4.0.7" + uuid "^8.3.2" + ws "^8.5.0" + optionalDependencies: + bufferutil "^4.0.1" + utf-8-validate "^5.0.2" + +safe-buffer@^5.0.1, safe-buffer@^5.1.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" + +snake-case@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c" + integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg== + dependencies: + dot-case "^3.0.4" + tslib "^2.0.3" + +source-map-support@^0.5.6: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== + +strip-json-comments@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +superstruct@^0.14.2: + version "0.14.2" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b" + integrity sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ== + +superstruct@^0.15.4: + version "0.15.5" + resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.15.5.tgz#0f0a8d3ce31313f0d84c6096cd4fa1bfdedc9dab" + integrity sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ== + +supports-color@8.1.1: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +text-encoding-utf-8@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13" + integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== + +"through@>=2.2.7 <3": + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +toml@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee" + integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w== + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + +ts-mocha@^10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/ts-mocha/-/ts-mocha-10.0.0.tgz#41a8d099ac90dbbc64b06976c5025ffaebc53cb9" + integrity sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw== + dependencies: + ts-node "7.0.1" + optionalDependencies: + tsconfig-paths "^3.5.0" + +ts-node@7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.1.tgz#9562dc2d1e6d248d24bc55f773e3f614337d9baf" + integrity sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw== + dependencies: + arrify "^1.0.0" + buffer-from "^1.1.0" + diff "^3.1.0" + make-error "^1.1.1" + minimist "^1.2.0" + mkdirp "^0.5.1" + source-map-support "^0.5.6" + yn "^2.0.0" + +tsconfig-paths@^3.5.0: + version "3.14.2" + resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" + integrity sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g== + dependencies: + "@types/json5" "^0.0.29" + json5 "^1.0.2" + minimist "^1.2.6" + strip-bom "^3.0.0" + +tslib@^2.0.3: + version "2.6.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" + integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== + +type-detect@^4.0.0, type-detect@^4.0.5: + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" + integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== + +typescript@^4.3.5: + version "4.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" + integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== + +utf-8-validate@^5.0.2: + version "5.0.10" + resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2" + integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ== + dependencies: + node-gyp-build "^4.3.0" + +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + +which@2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +workerpool@6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.0.tgz#827d93c9ba23ee2019c3ffaff5c27fccea289e8b" + integrity sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A== + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +ws@^7.4.5: + version "7.5.9" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" + integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q== + +ws@^8.5.0: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" + integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^20.2.2: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@16.2.0: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yn@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" + integrity sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ== + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== From 1892686475f12acad39735f57367989344764ab9 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Mon, 31 Jul 2023 19:01:10 +0100 Subject: [PATCH 027/205] Add current state of wormhole gateway --- cross-chain/solana/Anchor.toml | 3 +- cross-chain/solana/Cargo.lock | 9 + .../programs/wormhole-gateway/Cargo.toml | 21 + .../programs/wormhole-gateway/Xargo.toml | 2 + .../programs/wormhole-gateway/src/error.rs | 7 + .../programs/wormhole-gateway/src/lib.rs | 57 + .../src/processor/deposit_wormhole_tbtc.rs | 62 + .../src/processor/initialize.rs | 46 + .../wormhole-gateway/src/processor/mod.rs | 17 + .../src/processor/receive_tbtc.rs | 70 + .../src/processor/send_tbtc.rs | 79 + .../src/processor/update_gateway_address.rs | 36 + .../src/processor/update_minting_limit.rs | 22 + .../src/state/gateway_info.rs | 13 + .../wormhole-gateway/src/state/mod.rs | 5 + .../src/state/wormhole_gateway.rs | 22 + cross-chain/solana/yarn.lock | 3676 +++++++++++------ 17 files changed, 2963 insertions(+), 1184 deletions(-) create mode 100644 cross-chain/solana/programs/wormhole-gateway/Cargo.toml create mode 100644 cross-chain/solana/programs/wormhole-gateway/Xargo.toml create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/error.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/lib.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/state/mod.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/state/wormhole_gateway.rs diff --git a/cross-chain/solana/Anchor.toml b/cross-chain/solana/Anchor.toml index 415474b08..789ca54fd 100644 --- a/cross-chain/solana/Anchor.toml +++ b/cross-chain/solana/Anchor.toml @@ -3,13 +3,14 @@ seeds = false skip-lint = false [programs.localnet] tbtc = "HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG" +wormhole-gateway = "8H9F5JGbEMyERycwaGuzLS5MQnV7dn2wm2h6egJ3Leiu" [registry] url = "https://api.apr.dev" [provider] cluster = "Localnet" -wallet = "~/.config/solana/id.json" +wallet = "/home/eth/.config/solana/id.json" [scripts] test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" diff --git a/cross-chain/solana/Cargo.lock b/cross-chain/solana/Cargo.lock index 5ae732e2a..8aa7d04c6 100644 --- a/cross-chain/solana/Cargo.lock +++ b/cross-chain/solana/Cargo.lock @@ -2066,6 +2066,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "wormhole-gateway" +version = "0.1.0" +dependencies = [ + "anchor-lang", + "anchor-spl", + "tbtc", +] + [[package]] name = "zeroize" version = "1.3.0" diff --git a/cross-chain/solana/programs/wormhole-gateway/Cargo.toml b/cross-chain/solana/programs/wormhole-gateway/Cargo.toml new file mode 100644 index 000000000..0df55d930 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "wormhole-gateway" +version = "0.1.0" +description = "Created with Anchor" +edition = "2021" + +[lib] +crate-type = ["cdylib", "lib"] +name = "wormhole_gateway" + +[features] +no-entrypoint = [] +no-idl = [] +no-log-ix-name = [] +cpi = ["no-entrypoint"] +default = [] + +[dependencies] +anchor-lang = { version="0.28.0", features = ["init-if-needed"]} +anchor-spl = "0.28.0" +tbtc = { path = "../tbtc" } \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/Xargo.toml b/cross-chain/solana/programs/wormhole-gateway/Xargo.toml new file mode 100644 index 000000000..475fb71ed --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/Xargo.toml @@ -0,0 +1,2 @@ +[target.bpfel-unknown-unknown.dependencies.std] +features = [] diff --git a/cross-chain/solana/programs/wormhole-gateway/src/error.rs b/cross-chain/solana/programs/wormhole-gateway/src/error.rs new file mode 100644 index 000000000..9ebe15782 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/error.rs @@ -0,0 +1,7 @@ +use anchor_lang::prelude::error_code; + +#[error_code] +pub enum WormholeGatewayError { + MintingLimitExceeded, + IsNotAuthority, +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/lib.rs b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs new file mode 100644 index 000000000..245124cbb --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs @@ -0,0 +1,57 @@ +pub mod error; + +mod processor; +pub(crate) use processor::*; + +mod state; +pub use state::*; + +use anchor_lang::prelude::*; + +declare_id!("8H9F5JGbEMyERycwaGuzLS5MQnV7dn2wm2h6egJ3Leiu"); + +#[program] +pub mod wormhole_gateway { + use std::os::unix::process; + + use super::*; + + pub fn initialize(ctx: Context, minting_limit: u64) -> Result<()> { + processor::initialize(ctx, minting_limit) + } + + pub fn update_gateway_address( + ctx: Context, + chain_id: u16, + gateway_address: [u8; 32] + ) -> Result<()> { + processor::update_gateway_address(ctx, chain_id, gateway_address) + } + + pub fn update_minting_limit( + ctx: Context, + new_limit: u64, + ) -> Result<()> { + processor::update_minting_limit(ctx, new_limit) + } + + pub fn receive_tbtc( + ctx: Context, + ) -> Result<()> { + processor::receive_tbtc(ctx) + } + + pub fn send_tbtc( + ctx: Context, + amount: u64, + recipient_chain: u16, + arbiter_fee: u64, + nonce: u32, + ) -> Result<()> { + processor::send_tbtc(ctx, amount, recipient_chain, arbiter_fee, nonce) + } + + pub fn deposit_wormhole_tbtc(ctx: Context, amount: u64) -> Result<()> { + processor::deposit_wormhole_tbtc(ctx, amount) + } +} \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs new file mode 100644 index 000000000..0858c006f --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs @@ -0,0 +1,62 @@ +use crate::{ + error::WormholeGatewayError, + state::WormholeGateway, +}; +use tbtc::{tbtc}; + +use anchor_lang::prelude::*; +use anchor_spl::token; + +#[derive(Accounts)] +#[instruction(amount: u64)] +pub struct DepositWormholeTbtc<'info> { + #[account(mut)] + pub tbtc_mint: Account<'info, token::Mint>, + pub tbtc: Account<'info, tbtc::Tbtc>, + pub minter_info: Account<'info, tbtc::MinterInfo>, + + // Use the associated token account for the recipient. + #[account( + associated_token::mint = tbtc_mint, + associated_token::authority = recipient, + )] + pub recipient_account: Account<'info, token::TokenAccount>, + pub recipient: Signer<'info>, + #[account( + constraint = wormhole_gateway.minting_limit > wormhole_gateway.minted_amount + amount @ WormholeGatewayError::MintingLimitExceeded + )] + pub wormhole_gateway: Account<'info, WormholeGateway>, +} + +pub fn deposit_wormhole_tbtc( + ctx: Context, + amount: u64, +) -> Result<()> { + ctx.accounts.wormhole_gateway.minted_amount += amount; + + let transfer_cpi_ctx = CpiContext::new_with_signer( + // + ); + // wormhole::transfer + + let seed_prefix = WormholeGateway::SEED_PREFIX; + let key_seed = ctx.accounts.wormhole_gateway.key(); + let gateway_bump = ctx.accounts.wormhole_gateway.self_bump; + + let signer: &[&[&[u8]]] = &[&[seed_prefix, key_seed.as_ref(), &[gateway_bump]]]; + + let mint_cpi_ctx = CpiContext::new_with_signer( + ctx.accounts.tbtc.to_account_info(), + tbtc::Mint { + tbtc_mint: ctx.accounts.tbtc_mint.to_account_info(), + tbtc: ctx.accounts.tbtc.to_account_info(), + minter_info: ctx.accounts.minter_info.to_account_info(), + minter: ctx.accounts.wormhole_gateway.to_account_info(), + recipient_account: ctx.accounts.recipient_account.to_account_info(), + recipient: ctx.accounts.recipient.to_account_info(), + payer: ctx.accounts.payer.to_account_info(), + }, + signer, + ); + tbtc::mint(mint_cpi_ctx, amount); +} \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs new file mode 100644 index 000000000..c971f30fb --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs @@ -0,0 +1,46 @@ +use crate::{ + state::WormholeGateway, +}; + +use anchor_lang::prelude::*; +use anchor_spl::token; + +#[derive(Accounts)] +pub struct Initialize<'info> { + #[account( + seeds = [SEED_PREFIX_TBTC_MINT, tbtc.key().as_ref()], + bump, + mint::decimals = 9, + mint::authority = tbtc_mint, + )] + pub tbtc_mint: Account<'info, token::Mint>, + pub tbtc: Account<'info, tbtc::Tbtc>, + + #[account( + init, payer = authority, space = WormholeGateway::MAXIMUM_SIZE + )] + pub wormhole_gateway: Account<'info, WormholeGateway>, + + pub wormhole_token_bridge: Account<'info, _>, + pub wormhole_bridge_token_mint: Account<'info, token::Mint>, + + #[account(mut)] + pub authority: Signer<'info>, + + pub token_program: Program<'info, token::Token>, + pub system_program: Program<'info, System>, +} + +pub fn initialize(ctx: Context, minting_limit: u64) -> Result<()> { + ctx.accounts.wormhole_gateway.set_inner(WormholeGateway { + authority: ctx.accounts.authority.key(), + wormhole_token_bridge: ctx.accounts.wormhole_token_bridge.key(), + wormhole_bridge_token_mint: ctx.accounts.wormhole_bridge_token_mint.key(), + tbtc: ctx.accounts.tbtc.key(), + tbtc_mint: ctx.accounts.tbtc_mint.key(), + minting_limit: minting_limit, + minted_amount: 0, + self_bump: ctx.bumps.get("wormhole_gateway").unwrap(), + }); + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs new file mode 100644 index 000000000..1481aefa2 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs @@ -0,0 +1,17 @@ +mod deposit_wormhole_tbtc; +pub use deposit_wormhole_tbtc::*; + +mod initialize; +pub use initialize::*; + +mod receive_tbtc; +pub use receive_tbtc::*; + +mod send_tbtc; +pub use send_tbtc::*; + +mod update_gateway_address; +pub use update_gateway_address::*; + +mod update_minting_limit; +pub use update_minting_limit::*; \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs new file mode 100644 index 000000000..cc9905c45 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs @@ -0,0 +1,70 @@ +use crate::{ + state::WormholeGateway, +}; + +use tbtc::{tbtc}; + +use anchor_lang::prelude::*; +use anchor_spl::token; + +#[derive(Accounts)] +pub struct ReceiveTbtc<'info> { + #[account(mut)] + pub tbtc_mint: Account<'info, token::Mint>, + pub tbtc: Account<'info, tbtc::Tbtc>, + pub minter_info: Account<'info, tbtc::MinterInfo>, + + // Use the associated token account for the recipient. + #[account( + associated_token::mint = tbtc_mint, + associated_token::authority = recipient, + )] + pub recipient_account: Account<'info, token::TokenAccount>, + /// CHECK: the recipient doesn't need to sign the mint, + /// and it doesn't conform to any specific rules. + /// Validating the recipient is the minter's responsibility. + pub recipient: UncheckedAccount<'info>, + + #[account(mut)] + pub payer: Signer<'info>, + + pub wormhole_gateway: Account<'info, WormholeGateway>, +} + +pub fn receive_tbtc( + ctx: Context, +) -> Result <()> { + // get balance delta + + let amount = _; + + let minted_amount = ctx.accounts.wormhole_gateway.minted_amount; + let minting_limit = ctx.accounts.wormhole_gateway.minting_limit; + + if (minted_amount + amount > minting_limit) { + // transfer bridge token + } else { + ctx.accounts.wormhole_gateway.minted_amount += amount; + + let seed_prefix = WormholeGateway::SEED_PREFIX; + let key_seed = ctx.accounts.wormhole_gateway.key(); + let gateway_bump = ctx.accounts.wormhole_gateway.self_bump; + + let signer: &[&[&[u8]]] = &[&[seed_prefix, key_seed.as_ref(), &[gateway_bump]]]; + + let mint_cpi_ctx = CpiContext::new_with_signer( + ctx.accounts.tbtc.to_account_info(), + tbtc::Mint { + tbtc_mint: ctx.accounts.tbtc_mint.to_account_info(), + tbtc: ctx.accounts.tbtc.to_account_info(), + minter_info: ctx.accounts.minter_info.to_account_info(), + minter: ctx.accounts.wormhole_gateway.to_account_info(), + recipient_account: ctx.accounts.recipient_account.to_account_info(), + recipient: ctx.accounts.recipient.to_account_info(), + payer: ctx.accounts.payer.to_account_info(), + }, + signer, + ); + tbtc::mint(mint_cpi_ctx, amount) + } +} \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc.rs new file mode 100644 index 000000000..dd4b971c8 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc.rs @@ -0,0 +1,79 @@ +use crate::{ + state::{GatewayInfo, WormholeGateway}, +}; + +use tbtc::{tbtc}; + +use anchor_lang::prelude::*; +use anchor_spl::token; + +#[derive(Accounts)] +#[instruction(recipient_chain: u16)] +pub struct SendTbtc<'info> { + #[account( + mut, + seeds = [tbtc::SEED_PREFIX_TBTC_MINT, tbtc.key().as_ref()], + bump, + mint::decimals = 9, + mint::authority = tbtc_mint, + )] + pub tbtc_mint: Account<'info, token::Mint>, + pub tbtc: Account<'info, tbtc::Tbtc>, + + pub wormhole_gateway: Account<'info, WormholeGateway>, + + pub wormhole_token_bridge: Account<'info, _>, + pub wormhole_bridge_token_mint: Account<'info, token::Mint>, + + #[account( + seeds = [GatewayInfo::SEED_PREFIX, wormhole_gateway.key().as_ref(), recipient_chain], + bump = gateway_info.bump, + )] + pub gateway_info: Account<'info, GatewayInfo>, + + pub sender_account: Account<'info, token::TokenAccount>, + pub sender: Signer<'info>, + + pub token_program: Program<'info, token::Token>, +} + +pub fn send_tbtc( + ctx: Context, + amount: u64, + recipient_chain: u16, + arbiter_fee: u64, + nonce: u32, +) -> Result<()> { + let normalized_amount = normalize(amount); + + let gateway = ctx.accounts.gateway_info.gateway; + + ctx.accounts.wormhole_gateway.minted_amount -= normalized_amount; + + let seed_prefix = WormholeGateway::SEED_PREFIX; + let key_seed = ctx.accounts.wormhole_gateway.key(); + let gateway_bump = ctx.accounts.wormhole_gateway.self_bump; + + let signer: &[&[&[u8]]] = &[&[seed_prefix, key_seed.as_ref(), &[gateway_bump]]]; + + let burn_cpi_ctx = CpiContext::new_with_signer( + ctx.accounts.token_program.to_account_info(), + token::Burn { + mint: ctx.accounts.tbtc_mint.to_account_info(), + from: ctx.accounts.sender_account.to_account_info(), + authority: ctx.accounts.wormhole_gateway.to_account_info(), + }, + signer, + ); + token::burn(burn_cpi_ctx, amount) + + + // approve bridge token + // transfer tokens +} + +fn normalize(amount: u64) -> u64 { + let divAmount = amount / 10; + let normAmount = divAmount * 10; + normAmount +} \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs new file mode 100644 index 000000000..e0f3ef36d --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs @@ -0,0 +1,36 @@ +use crate::{ + error::WormholeGatewayError, + state::{GatewayInfo, WormholeGateway}, +}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +#[instruction(chain_id: u16)] +pub struct UpdateGatewayAddress<'info> { + #[account( + has_one = authority @ WormholeGatewayError::IsNotAuthority, + )] + pub wormhole_gateway: Account<'info, WormholeGateway>, + #[account( + init_if_needed, + payer = payer, + space = GatewayInfo::MAXIMUM_SIZE, + seeds = [GatewayInfo::SEED_PREFIX, wormhole_gateway.key().as_ref(), chain_id], + bump, + )] + pub gateway_info: Account<'info, GatewayInfo>, + pub authority: Signer<'info>, + #[account(mut)] + pub payer: Signer<'info>, + + pub system_program: Program<'info, System>, +} + +pub fn update_gateway_address( + ctx: Context, + chain_id: u16, + gateway_address: [u8; 32], +) -> Result<()> { + ctx.accounts.gateway_info.gateway = gateway_address; + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs new file mode 100644 index 000000000..3553c818d --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs @@ -0,0 +1,22 @@ +use crate::{ + error::WormholeGatewayError, + state::WormholeGateway, +}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct UpdateMintingLimit<'info> { + #[account( + mut, + has_one = authority @ WormholeGatewayError::IsNotAuthority, + )] + pub wormhole_gateway: Account<'info, WormholeGateway>, + pub authority: Signer<'info>, + #[account(mut)] + pub payer: Signer<'info>, +} + +pub fn update_minting_limit(ctx: Context, new_limit: u64) -> Result<()> { + ctx.accounts.wormhole_gateway.minting_limit = new_limit; + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs new file mode 100644 index 000000000..8e0867d3a --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs @@ -0,0 +1,13 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Default)] +pub struct GatewayInfo { + pub gateway: [u8; 32], + pub bump: u8, +} + +impl GatewayInfo { + pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; + pub const SEED_PREFIX: &'static [u8; 12] = b"gateway-info"; +} \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/mod.rs new file mode 100644 index 000000000..b7f0583ab --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/state/mod.rs @@ -0,0 +1,5 @@ +pub use gateway_info::*; +pub use wormhole_gateway::*; + +pub mod gateway_info; +pub mod wormhole_gateway; \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/wormhole_gateway.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/wormhole_gateway.rs new file mode 100644 index 000000000..887f7f01e --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/state/wormhole_gateway.rs @@ -0,0 +1,22 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Default)] +pub struct WormholeGateway { + pub authority: Pubkey, + pub wormhole_token_bridge: Pubkey, + pub wormhole_bridge_token_mint: Pubkey, + pub tbtc: Pubkey, + pub tbtc_mint: Pubkey, + pub minting_limit: u64, + pub minted_amount: u64, + pub self_bump: u8, +} + +impl WormholeGateway { + // 8 discriminator + // 32 * 5 = 160 (5 pubkeys) + // 8 * 2 = 16 (2 u64s) + // 1 (bump) + pub const MAXIMUM_SIZE: usize = 8 + 160 + 16 + 1; +} \ No newline at end of file diff --git a/cross-chain/solana/yarn.lock b/cross-chain/solana/yarn.lock index a8ab27ba6..581984048 100644 --- a/cross-chain/solana/yarn.lock +++ b/cross-chain/solana/yarn.lock @@ -1,1183 +1,2493 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@babel/runtime@^7.17.2", "@babel/runtime@^7.22.6": - version "7.22.6" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438" - integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ== - dependencies: - regenerator-runtime "^0.13.11" - -"@coral-xyz/anchor@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.28.0.tgz#8345c3c9186a91f095f704d7b90cd256f7e8b2dc" - integrity sha512-kQ02Hv2ZqxtWP30WN1d4xxT4QqlOXYDxmEd3k/bbneqhV3X5QMO4LAtoUFs7otxyivOgoqam5Il5qx81FuI4vw== - dependencies: - "@coral-xyz/borsh" "^0.28.0" - "@solana/web3.js" "^1.68.0" - base64-js "^1.5.1" - bn.js "^5.1.2" - bs58 "^4.0.1" - buffer-layout "^1.2.2" - camelcase "^6.3.0" - cross-fetch "^3.1.5" - crypto-hash "^1.3.0" - eventemitter3 "^4.0.7" - js-sha256 "^0.9.0" - pako "^2.0.3" - snake-case "^3.0.4" - superstruct "^0.15.4" - toml "^3.0.0" - -"@coral-xyz/borsh@^0.28.0": - version "0.28.0" - resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.28.0.tgz#fa368a2f2475bbf6f828f4657f40a52102e02b6d" - integrity sha512-/u1VTzw7XooK7rqeD7JLUSwOyRSesPUk0U37BV9zK0axJc1q0nRbKFGFLYCQ16OtdOJTTwGfGp11Lx9B45bRCQ== - dependencies: - bn.js "^5.1.2" - buffer-layout "^1.2.0" - -"@noble/curves@^1.0.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.1.0.tgz#f13fc667c89184bc04cccb9b11e8e7bae27d8c3d" - integrity sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA== - dependencies: - "@noble/hashes" "1.3.1" - -"@noble/hashes@1.3.1", "@noble/hashes@^1.3.0": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9" - integrity sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA== - -"@solana/buffer-layout-utils@^0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca" - integrity sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g== - dependencies: - "@solana/buffer-layout" "^4.0.0" - "@solana/web3.js" "^1.32.0" - bigint-buffer "^1.1.5" - bignumber.js "^9.0.1" - -"@solana/buffer-layout@^4.0.0": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15" - integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA== - dependencies: - buffer "~6.0.3" - -"@solana/spl-token@^0.3.8": - version "0.3.8" - resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.3.8.tgz#8e9515ea876e40a4cc1040af865f61fc51d27edf" - integrity sha512-ogwGDcunP9Lkj+9CODOWMiVJEdRtqHAtX2rWF62KxnnSWtMZtV9rDhTrZFshiyJmxDnRL/1nKE1yJHg4jjs3gg== - dependencies: - "@solana/buffer-layout" "^4.0.0" - "@solana/buffer-layout-utils" "^0.2.0" - buffer "^6.0.3" - -"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.68.0", "@solana/web3.js@^1.77.3": - version "1.78.1" - resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.78.1.tgz#1b1023f81aa98f53ef45eaec642be11c0a0877f3" - integrity sha512-r0WZAYwCfVElfONP/dmWkEfw6wufL+u7lWojEsNecn9PyIIYq+r4eb0h2MRiJ3xkctvTN76G0T6FTGcTJhXh3Q== - dependencies: - "@babel/runtime" "^7.22.6" - "@noble/curves" "^1.0.0" - "@noble/hashes" "^1.3.0" - "@solana/buffer-layout" "^4.0.0" - agentkeepalive "^4.2.1" - bigint-buffer "^1.1.5" - bn.js "^5.0.0" - borsh "^0.7.0" - bs58 "^4.0.1" - buffer "6.0.3" - fast-stable-stringify "^1.0.0" - jayson "^4.1.0" - node-fetch "^2.6.12" - rpc-websockets "^7.5.1" - superstruct "^0.14.2" - -"@types/bn.js@^5.1.0": - version "5.1.1" - resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.1.1.tgz#b51e1b55920a4ca26e9285ff79936bbdec910682" - integrity sha512-qNrYbZqMx0uJAfKnKclPh+dTwK33KfLHYqtyODwd5HnXOjnkhc4qgn3BrK6RWyGZm5+sIFE7Q7Vz6QQtJB7w7g== - dependencies: - "@types/node" "*" - -"@types/chai@^4.3.0": - version "4.3.5" - resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.5.tgz#ae69bcbb1bebb68c4ac0b11e9d8ed04526b3562b" - integrity sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng== - -"@types/connect@^3.4.33": - version "3.4.35" - resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" - integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== - dependencies: - "@types/node" "*" - -"@types/json5@^0.0.29": - version "0.0.29" - resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" - integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== - -"@types/mocha@^9.0.0": - version "9.1.1" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" - integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== - -"@types/node@*": - version "20.4.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.5.tgz#9dc0a5cb1ccce4f7a731660935ab70b9c00a5d69" - integrity sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg== - -"@types/node@^12.12.54": - version "12.20.55" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" - integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ== - -"@types/ws@^7.4.4": - version "7.4.7" - resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702" - integrity sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww== - dependencies: - "@types/node" "*" - -"@ungap/promise-all-settled@1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" - integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== - -JSONStream@^1.3.5: - version "1.3.5" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" - integrity sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ== - dependencies: - jsonparse "^1.2.0" - through ">=2.2.7 <3" - -agentkeepalive@^4.2.1: - version "4.3.0" - resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.3.0.tgz#bb999ff07412653c1803b3ced35e50729830a255" - integrity sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg== - dependencies: - debug "^4.1.0" - depd "^2.0.0" - humanize-ms "^1.2.1" - -ansi-colors@4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== - -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - -ansi-styles@^4.0.0, ansi-styles@^4.1.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" - integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== - dependencies: - color-convert "^2.0.1" - -anymatch@~3.1.2: - version "3.1.3" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" - integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -argparse@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" - integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== - -arrify@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" - integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== - -assertion-error@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" - integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -base-x@^3.0.2: - version "3.0.9" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320" - integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ== - dependencies: - safe-buffer "^5.0.1" - -base64-js@^1.3.1, base64-js@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - -bigint-buffer@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.5.tgz#d038f31c8e4534c1f8d0015209bf34b4fa6dd442" - integrity sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA== - dependencies: - bindings "^1.3.0" - -bignumber.js@^9.0.1: - version "9.1.1" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6" - integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig== - -binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - -bindings@^1.3.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" - integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== - dependencies: - file-uri-to-path "1.0.0" - -bn.js@^5.0.0, bn.js@^5.1.2, bn.js@^5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" - integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== - -borsh@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a" - integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA== - dependencies: - bn.js "^5.2.0" - bs58 "^4.0.0" - text-encoding-utf-8 "^1.0.2" - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -browser-stdout@1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" - integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== - -bs58@^4.0.0, bs58@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" - integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw== - dependencies: - base-x "^3.0.2" - -buffer-from@^1.0.0, buffer-from@^1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" - integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== - -buffer-layout@^1.2.0, buffer-layout@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5" - integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA== - -buffer@6.0.3, buffer@^6.0.3, buffer@~6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" - integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - -bufferutil@^4.0.1: - version "4.0.7" - resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.7.tgz#60c0d19ba2c992dd8273d3f73772ffc894c153ad" - integrity sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw== - dependencies: - node-gyp-build "^4.3.0" - -camelcase@^6.0.0, camelcase@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" - integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== - -chai@^4.3.4: - version "4.3.7" - resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.7.tgz#ec63f6df01829088e8bf55fca839bcd464a8ec51" - integrity sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A== - dependencies: - assertion-error "^1.1.0" - check-error "^1.0.2" - deep-eql "^4.1.2" - get-func-name "^2.0.0" - loupe "^2.3.1" - pathval "^1.1.1" - type-detect "^4.0.5" - -chalk@^4.1.0: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - -check-error@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" - integrity sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA== - -chokidar@3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - -color-convert@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" - integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== - dependencies: - color-name "~1.1.4" - -color-name@~1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" - integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== - -commander@^2.20.3: - version "2.20.3" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" - integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -cross-fetch@^3.1.5: - version "3.1.8" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" - integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== - dependencies: - node-fetch "^2.6.12" - -crypto-hash@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/crypto-hash/-/crypto-hash-1.3.0.tgz#b402cb08f4529e9f4f09346c3e275942f845e247" - integrity sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg== - -debug@4.3.3: - version "4.3.3" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" - integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q== - dependencies: - ms "2.1.2" - -debug@^4.1.0: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -decamelize@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" - integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== - -deep-eql@^4.1.2: - version "4.1.3" - resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.3.tgz#7c7775513092f7df98d8df9996dd085eb668cc6d" - integrity sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw== - dependencies: - type-detect "^4.0.0" - -delay@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" - integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== - -depd@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" - integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== - -diff@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" - integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== - -diff@^3.1.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" - integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== - -dot-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751" - integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - -emoji-regex@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" - integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== - -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ== - dependencies: - es6-promise "^4.0.3" - -escalade@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" - integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== - -escape-string-regexp@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" - integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== - -eventemitter3@^4.0.7: - version "4.0.7" - resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" - integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== - -eyes@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" - integrity sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ== - -fast-stable-stringify@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz#5c5543462b22aeeefd36d05b34e51c78cb86d313" - integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag== - -file-uri-to-path@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" - integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -find-up@5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" - integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== - dependencies: - locate-path "^6.0.0" - path-exists "^4.0.0" - -flat@^5.0.2: - version "5.0.2" - resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" - integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== - -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -get-caller-file@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" - integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== - -get-func-name@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" - integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig== - -glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -glob@7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -growl@1.10.5: - version "1.10.5" - resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" - integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== - -has-flag@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" - integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== - -he@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" - integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== - -humanize-ms@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" - integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== - dependencies: - ms "^2.0.0" - -ieee754@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - -is-fullwidth-code-point@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" - integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -is-plain-obj@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" - integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== - -is-unicode-supported@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" - integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== - -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== - -isomorphic-ws@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc" - integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w== - -jayson@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/jayson/-/jayson-4.1.0.tgz#60dc946a85197317f2b1439d672a8b0a99cea2f9" - integrity sha512-R6JlbyLN53Mjku329XoRT2zJAE6ZgOQ8f91ucYdMCD4nkGCF9kZSrcGXpHIU4jeKj58zUZke2p+cdQchU7Ly7A== - dependencies: - "@types/connect" "^3.4.33" - "@types/node" "^12.12.54" - "@types/ws" "^7.4.4" - JSONStream "^1.3.5" - commander "^2.20.3" - delay "^5.0.0" - es6-promisify "^5.0.0" - eyes "^0.1.8" - isomorphic-ws "^4.0.1" - json-stringify-safe "^5.0.1" - uuid "^8.3.2" - ws "^7.4.5" - -js-sha256@^0.9.0: - version "0.9.0" - resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" - integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== - -js-yaml@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" - integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== - dependencies: - argparse "^2.0.1" - -json-stringify-safe@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== - -json5@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" - integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== - dependencies: - minimist "^1.2.0" - -jsonparse@^1.2.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" - integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== - -locate-path@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" - integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== - dependencies: - p-locate "^5.0.0" - -log-symbols@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" - integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== - dependencies: - chalk "^4.1.0" - is-unicode-supported "^0.1.0" - -loupe@^2.3.1: - version "2.3.6" - resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.6.tgz#76e4af498103c532d1ecc9be102036a21f787b53" - integrity sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA== - dependencies: - get-func-name "^2.0.0" - -lower-case@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" - integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg== - dependencies: - tslib "^2.0.3" - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -minimatch@4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-4.2.1.tgz#40d9d511a46bdc4e563c22c3080cde9c0d8299b4" - integrity sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g== - dependencies: - brace-expansion "^1.1.7" - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -minimist@^1.2.0, minimist@^1.2.6: - version "1.2.8" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" - integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== - -mkdirp@^0.5.1: - version "0.5.6" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" - integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== - dependencies: - minimist "^1.2.6" - -mocha@^9.0.3: - version "9.2.2" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.2.2.tgz#d70db46bdb93ca57402c809333e5a84977a88fb9" - integrity sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g== - dependencies: - "@ungap/promise-all-settled" "1.1.2" - ansi-colors "4.1.1" - browser-stdout "1.3.1" - chokidar "3.5.3" - debug "4.3.3" - diff "5.0.0" - escape-string-regexp "4.0.0" - find-up "5.0.0" - glob "7.2.0" - growl "1.10.5" - he "1.2.0" - js-yaml "4.1.0" - log-symbols "4.1.0" - minimatch "4.2.1" - ms "2.1.3" - nanoid "3.3.1" - serialize-javascript "6.0.0" - strip-json-comments "3.1.1" - supports-color "8.1.1" - which "2.0.2" - workerpool "6.2.0" - yargs "16.2.0" - yargs-parser "20.2.4" - yargs-unparser "2.0.0" - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@2.1.3, ms@^2.0.0: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -nanoid@3.3.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" - integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== - -no-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" - integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg== - dependencies: - lower-case "^2.0.2" - tslib "^2.0.3" - -node-fetch@^2.6.12: - version "2.6.12" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" - integrity sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g== - dependencies: - whatwg-url "^5.0.0" - -node-gyp-build@^4.3.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.0.tgz#0c52e4cbf54bbd28b709820ef7b6a3c2d6209055" - integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ== - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - -p-limit@^3.0.2: - version "3.1.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" - integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== - dependencies: - yocto-queue "^0.1.0" - -p-locate@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" - integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== - dependencies: - p-limit "^3.0.2" - -pako@^2.0.3: - version "2.1.0" - resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" - integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== - -path-exists@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" - integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== - -pathval@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" - integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== - -picomatch@^2.0.4, picomatch@^2.2.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -prettier@^2.6.2: - version "2.8.8" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" - integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== - -randombytes@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" - integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== - dependencies: - safe-buffer "^5.1.0" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -regenerator-runtime@^0.13.11: - version "0.13.11" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" - integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== - -require-directory@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== - -rpc-websockets@^7.5.1: - version "7.5.1" - resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-7.5.1.tgz#e0a05d525a97e7efc31a0617f093a13a2e10c401" - integrity sha512-kGFkeTsmd37pHPMaHIgN1LVKXMi0JD782v4Ds9ZKtLlwdTKjn+CxM9A9/gLT2LaOuEcEFGL98h1QWQtlOIdW0w== - dependencies: - "@babel/runtime" "^7.17.2" - eventemitter3 "^4.0.7" - uuid "^8.3.2" - ws "^8.5.0" - optionalDependencies: - bufferutil "^4.0.1" - utf-8-validate "^5.0.2" - -safe-buffer@^5.0.1, safe-buffer@^5.1.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" - integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== - -serialize-javascript@6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" - integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== - dependencies: - randombytes "^2.1.0" - -snake-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c" - integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg== - dependencies: - dot-case "^3.0.4" - tslib "^2.0.3" - -source-map-support@^0.5.6: - version "0.5.21" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" - integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== - -string-width@^4.1.0, string-width@^4.2.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - -strip-bom@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" - integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== - -strip-json-comments@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" - integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== - -superstruct@^0.14.2: - version "0.14.2" - resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b" - integrity sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ== - -superstruct@^0.15.4: - version "0.15.5" - resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.15.5.tgz#0f0a8d3ce31313f0d84c6096cd4fa1bfdedc9dab" - integrity sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ== - -supports-color@8.1.1: - version "8.1.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" - integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== - dependencies: - has-flag "^4.0.0" - -supports-color@^7.1.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" - integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== - dependencies: - has-flag "^4.0.0" - -text-encoding-utf-8@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13" - integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg== - -"through@>=2.2.7 <3": - version "2.3.8" - resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -toml@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee" - integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w== - -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - -ts-mocha@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/ts-mocha/-/ts-mocha-10.0.0.tgz#41a8d099ac90dbbc64b06976c5025ffaebc53cb9" - integrity sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw== - dependencies: - ts-node "7.0.1" - optionalDependencies: - tsconfig-paths "^3.5.0" - -ts-node@7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.1.tgz#9562dc2d1e6d248d24bc55f773e3f614337d9baf" - integrity sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw== - dependencies: - arrify "^1.0.0" - buffer-from "^1.1.0" - diff "^3.1.0" - make-error "^1.1.1" - minimist "^1.2.0" - mkdirp "^0.5.1" - source-map-support "^0.5.6" - yn "^2.0.0" - -tsconfig-paths@^3.5.0: - version "3.14.2" - resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" - integrity sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g== - dependencies: - "@types/json5" "^0.0.29" - json5 "^1.0.2" - minimist "^1.2.6" - strip-bom "^3.0.0" - -tslib@^2.0.3: - version "2.6.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" - integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== - -type-detect@^4.0.0, type-detect@^4.0.5: - version "4.0.8" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" - integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== - -typescript@^4.3.5: - version "4.9.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" - integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== - -utf-8-validate@^5.0.2: - version "5.0.10" - resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2" - integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ== - dependencies: - node-gyp-build "^4.3.0" - -uuid@^8.3.2: - version "8.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" - integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== - -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - -which@2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - -workerpool@6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.0.tgz#827d93c9ba23ee2019c3ffaff5c27fccea289e8b" - integrity sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A== - -wrap-ansi@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" - integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== - dependencies: - ansi-styles "^4.0.0" - string-width "^4.1.0" - strip-ansi "^6.0.0" - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== - -ws@^7.4.5: - version "7.5.9" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591" - integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q== - -ws@^8.5.0: - version "8.13.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" - integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== - -y18n@^5.0.5: - version "5.0.8" - resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" - integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== - -yargs-parser@20.2.4: - version "20.2.4" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" - integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== - -yargs-parser@^20.2.2: - version "20.2.9" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" - integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== - -yargs-unparser@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" - integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== - dependencies: - camelcase "^6.0.0" - decamelize "^4.0.0" - flat "^5.0.2" - is-plain-obj "^2.1.0" - -yargs@16.2.0: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" - -yn@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a" - integrity sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ== - -yocto-queue@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== +# This file is generated by running "yarn install" inside your project. +# Manual changes might be lost - proceed with caution! + +__metadata: + version: 6 + cacheKey: 8 + +"@babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.22.6": + version: 7.22.6 + resolution: "@babel/runtime@npm:7.22.6" + dependencies: + regenerator-runtime: ^0.13.11 + checksum: e585338287c4514a713babf4fdb8fc2a67adcebab3e7723a739fc62c79cfda875b314c90fd25f827afb150d781af97bc16c85bfdbfa2889f06053879a1ddb597 + languageName: node + linkType: hard + +"@coral-xyz/anchor@npm:^0.28.0": + version: 0.28.0 + resolution: "@coral-xyz/anchor@npm:0.28.0" + dependencies: + "@coral-xyz/borsh": ^0.28.0 + "@solana/web3.js": ^1.68.0 + base64-js: ^1.5.1 + bn.js: ^5.1.2 + bs58: ^4.0.1 + buffer-layout: ^1.2.2 + camelcase: ^6.3.0 + cross-fetch: ^3.1.5 + crypto-hash: ^1.3.0 + eventemitter3: ^4.0.7 + js-sha256: ^0.9.0 + pako: ^2.0.3 + snake-case: ^3.0.4 + superstruct: ^0.15.4 + toml: ^3.0.0 + checksum: 58b3677b5b2ce2c779045184ce4a0ef696966a6a58f41c1c56f6f178db0491acecb6ec677ce0502f0b382a2c724f9c2860d82cc88601784d556d95fbeda415e5 + languageName: node + linkType: hard + +"@coral-xyz/borsh@npm:^0.28.0": + version: 0.28.0 + resolution: "@coral-xyz/borsh@npm:0.28.0" + dependencies: + bn.js: ^5.1.2 + buffer-layout: ^1.2.0 + peerDependencies: + "@solana/web3.js": ^1.68.0 + checksum: bc2b06b777f9ed43d3b886d2350826bd44d5b932c4fd4471af5956e8755236f5854938c890ee4986d88f61d1439e1d84e715c43dcb6dca4e76198c1ce8dc7a58 + languageName: node + linkType: hard + +"@isaacs/cliui@npm:^8.0.2": + version: 8.0.2 + resolution: "@isaacs/cliui@npm:8.0.2" + dependencies: + string-width: ^5.1.2 + string-width-cjs: "npm:string-width@^4.2.0" + strip-ansi: ^7.0.1 + strip-ansi-cjs: "npm:strip-ansi@^6.0.1" + wrap-ansi: ^8.1.0 + wrap-ansi-cjs: "npm:wrap-ansi@^7.0.0" + checksum: 4a473b9b32a7d4d3cfb7a614226e555091ff0c5a29a1734c28c72a182c2f6699b26fc6b5c2131dfd841e86b185aea714c72201d7c98c2fba5f17709333a67aeb + languageName: node + linkType: hard + +"@noble/curves@npm:^1.0.0": + version: 1.1.0 + resolution: "@noble/curves@npm:1.1.0" + dependencies: + "@noble/hashes": 1.3.1 + checksum: 2658cdd3f84f71079b4e3516c47559d22cf4b55c23ac8ee9d2b1f8e5b72916d9689e59820e0f9d9cb4a46a8423af5b56dc6bb7782405c88be06a015180508db5 + languageName: node + linkType: hard + +"@noble/hashes@npm:1.3.1, @noble/hashes@npm:^1.3.0": + version: 1.3.1 + resolution: "@noble/hashes@npm:1.3.1" + checksum: 7fdefc0f7a0c1ec27acc6ff88841793e3f93ec4ce6b8a6a12bfc0dd70ae6b7c4c82fe305fdfeda1735d5ad4a9eebe761e6693b3d355689c559e91242f4bc95b1 + languageName: node + linkType: hard + +"@npmcli/fs@npm:^3.1.0": + version: 3.1.0 + resolution: "@npmcli/fs@npm:3.1.0" + dependencies: + semver: ^7.3.5 + checksum: a50a6818de5fc557d0b0e6f50ec780a7a02ab8ad07e5ac8b16bf519e0ad60a144ac64f97d05c443c3367235d337182e1d012bbac0eb8dbae8dc7b40b193efd0e + languageName: node + linkType: hard + +"@pkgjs/parseargs@npm:^0.11.0": + version: 0.11.0 + resolution: "@pkgjs/parseargs@npm:0.11.0" + checksum: 6ad6a00fc4f2f2cfc6bff76fb1d88b8ee20bc0601e18ebb01b6d4be583733a860239a521a7fbca73b612e66705078809483549d2b18f370eb346c5155c8e4a0f + languageName: node + linkType: hard + +"@solana/buffer-layout-utils@npm:^0.2.0": + version: 0.2.0 + resolution: "@solana/buffer-layout-utils@npm:0.2.0" + dependencies: + "@solana/buffer-layout": ^4.0.0 + "@solana/web3.js": ^1.32.0 + bigint-buffer: ^1.1.5 + bignumber.js: ^9.0.1 + checksum: 9284242245b18b49577195ba7548263850be865a4a2d183944fa01bb76382039db589aab8473698e9bb734b515ada9b4d70db0a72e341c5d567c59b83d6d0840 + languageName: node + linkType: hard + +"@solana/buffer-layout@npm:^4.0.0": + version: 4.0.1 + resolution: "@solana/buffer-layout@npm:4.0.1" + dependencies: + buffer: ~6.0.3 + checksum: bf846888e813187243d4008a7a9f58b49d16cbd995b9d7f1b72898aa510ed77b1ce5e8468e7b2fd26dd81e557a4e74a666e21fccb95f123c1f740d41138bbacd + languageName: node + linkType: hard + +"@solana/spl-token@npm:^0.3.8": + version: 0.3.8 + resolution: "@solana/spl-token@npm:0.3.8" + dependencies: + "@solana/buffer-layout": ^4.0.0 + "@solana/buffer-layout-utils": ^0.2.0 + buffer: ^6.0.3 + peerDependencies: + "@solana/web3.js": ^1.47.4 + checksum: 01f4f87112b0ad277701a3bcb8e03069b69449b92724b17959107686731082bfd3475b5f105e1e8f04badd2e810a43d5ef811744ced5178eea1232de8fd75147 + languageName: node + linkType: hard + +"@solana/web3.js@npm:^1.32.0, @solana/web3.js@npm:^1.68.0, @solana/web3.js@npm:^1.77.3": + version: 1.78.1 + resolution: "@solana/web3.js@npm:1.78.1" + dependencies: + "@babel/runtime": ^7.22.6 + "@noble/curves": ^1.0.0 + "@noble/hashes": ^1.3.0 + "@solana/buffer-layout": ^4.0.0 + agentkeepalive: ^4.2.1 + bigint-buffer: ^1.1.5 + bn.js: ^5.0.0 + borsh: ^0.7.0 + bs58: ^4.0.1 + buffer: 6.0.3 + fast-stable-stringify: ^1.0.0 + jayson: ^4.1.0 + node-fetch: ^2.6.12 + rpc-websockets: ^7.5.1 + superstruct: ^0.14.2 + checksum: cf3b139fd9be47d1ed5d1df301729b722f6f53b8afe3ce33d17575e9753c153bfc2ad655582e3a4df1683977bbb26ac7808fc09cae3e61084e7506b6ef2ab51e + languageName: node + linkType: hard + +"@tootallnate/once@npm:2": + version: 2.0.0 + resolution: "@tootallnate/once@npm:2.0.0" + checksum: ad87447820dd3f24825d2d947ebc03072b20a42bfc96cbafec16bff8bbda6c1a81fcb0be56d5b21968560c5359a0af4038a68ba150c3e1694fe4c109a063bed8 + languageName: node + linkType: hard + +"@types/bn.js@npm:^5.1.0": + version: 5.1.1 + resolution: "@types/bn.js@npm:5.1.1" + dependencies: + "@types/node": "*" + checksum: e50ed2dd3abe997e047caf90e0352c71e54fc388679735217978b4ceb7e336e51477791b715f49fd77195ac26dd296c7bad08a3be9750e235f9b2e1edb1b51c2 + languageName: node + linkType: hard + +"@types/chai@npm:^4.3.0": + version: 4.3.5 + resolution: "@types/chai@npm:4.3.5" + checksum: c8f26a88c6b5b53a3275c7f5ff8f107028e3cbb9ff26795fff5f3d9dea07106a54ce9e2dce5e40347f7c4cc35657900aaf0c83934a25a1ae12e61e0f5516e431 + languageName: node + linkType: hard + +"@types/connect@npm:^3.4.33": + version: 3.4.35 + resolution: "@types/connect@npm:3.4.35" + dependencies: + "@types/node": "*" + checksum: fe81351470f2d3165e8b12ce33542eef89ea893e36dd62e8f7d72566dfb7e448376ae962f9f3ea888547ce8b55a40020ca0e01d637fab5d99567673084542641 + languageName: node + linkType: hard + +"@types/json5@npm:^0.0.29": + version: 0.0.29 + resolution: "@types/json5@npm:0.0.29" + checksum: e60b153664572116dfea673c5bda7778dbff150498f44f998e34b5886d8afc47f16799280e4b6e241c0472aef1bc36add771c569c68fc5125fc2ae519a3eb9ac + languageName: node + linkType: hard + +"@types/mocha@npm:^9.0.0": + version: 9.1.1 + resolution: "@types/mocha@npm:9.1.1" + checksum: 516077c0acd9806dc78317f88aaac0df5aaf0bdc2f63dfdadeabdf0b0137953b6ca65472e6ff7c30bc93ce4e0ae76eae70e8d46764b9a8eae4877a928b6ef49a + languageName: node + linkType: hard + +"@types/node@npm:*": + version: 20.4.5 + resolution: "@types/node@npm:20.4.5" + checksum: 36a0304a8dc346a1b2d2edac4c4633eecf70875793d61a5274d0df052d7a7af7a8e34f29884eac4fbd094c4f0201477dcb39c0ecd3307ca141688806538d1138 + languageName: node + linkType: hard + +"@types/node@npm:^12.12.54": + version: 12.20.55 + resolution: "@types/node@npm:12.20.55" + checksum: e4f86785f4092706e0d3b0edff8dca5a13b45627e4b36700acd8dfe6ad53db71928c8dee914d4276c7fd3b6ccd829aa919811c9eb708a2c8e4c6eb3701178c37 + languageName: node + linkType: hard + +"@types/ws@npm:^7.4.4": + version: 7.4.7 + resolution: "@types/ws@npm:7.4.7" + dependencies: + "@types/node": "*" + checksum: b4c9b8ad209620c9b21e78314ce4ff07515c0cadab9af101c1651e7bfb992d7fd933bd8b9c99d110738fd6db523ed15f82f29f50b45510288da72e964dedb1a3 + languageName: node + linkType: hard + +"@ungap/promise-all-settled@npm:1.1.2": + version: 1.1.2 + resolution: "@ungap/promise-all-settled@npm:1.1.2" + checksum: 08d37fdfa23a6fe8139f1305313562ebad973f3fac01bcce2773b2bda5bcb0146dfdcf3cb6a722cf0a5f2ca0bc56a827eac8f1e7b3beddc548f654addf1fc34c + languageName: node + linkType: hard + +"JSONStream@npm:^1.3.5": + version: 1.3.5 + resolution: "JSONStream@npm:1.3.5" + dependencies: + jsonparse: ^1.2.0 + through: ">=2.2.7 <3" + bin: + JSONStream: ./bin.js + checksum: 2605fa124260c61bad38bb65eba30d2f72216a78e94d0ab19b11b4e0327d572b8d530c0c9cc3b0764f727ad26d39e00bf7ebad57781ca6368394d73169c59e46 + languageName: node + linkType: hard + +"abbrev@npm:^1.0.0": + version: 1.1.1 + resolution: "abbrev@npm:1.1.1" + checksum: a4a97ec07d7ea112c517036882b2ac22f3109b7b19077dc656316d07d308438aac28e4d9746dc4d84bf6b1e75b4a7b0a5f3cb30592419f128ca9a8cee3bcfa17 + languageName: node + linkType: hard + +"agent-base@npm:6, agent-base@npm:^6.0.2": + version: 6.0.2 + resolution: "agent-base@npm:6.0.2" + dependencies: + debug: 4 + checksum: f52b6872cc96fd5f622071b71ef200e01c7c4c454ee68bc9accca90c98cfb39f2810e3e9aa330435835eedc8c23f4f8a15267f67c6e245d2b33757575bdac49d + languageName: node + linkType: hard + +"agentkeepalive@npm:^4.2.1": + version: 4.3.0 + resolution: "agentkeepalive@npm:4.3.0" + dependencies: + debug: ^4.1.0 + depd: ^2.0.0 + humanize-ms: ^1.2.1 + checksum: 982453aa44c11a06826c836025e5162c846e1200adb56f2d075400da7d32d87021b3b0a58768d949d824811f5654223d5a8a3dad120921a2439625eb847c6260 + languageName: node + linkType: hard + +"aggregate-error@npm:^3.0.0": + version: 3.1.0 + resolution: "aggregate-error@npm:3.1.0" + dependencies: + clean-stack: ^2.0.0 + indent-string: ^4.0.0 + checksum: 1101a33f21baa27a2fa8e04b698271e64616b886795fd43c31068c07533c7b3facfcaf4e9e0cab3624bd88f729a592f1c901a1a229c9e490eafce411a8644b79 + languageName: node + linkType: hard + +"ansi-colors@npm:4.1.1": + version: 4.1.1 + resolution: "ansi-colors@npm:4.1.1" + checksum: 138d04a51076cb085da0a7e2d000c5c0bb09f6e772ed5c65c53cb118d37f6c5f1637506d7155fb5f330f0abcf6f12fa2e489ac3f8cdab9da393bf1bb4f9a32b0 + languageName: node + linkType: hard + +"ansi-regex@npm:^5.0.1": + version: 5.0.1 + resolution: "ansi-regex@npm:5.0.1" + checksum: 2aa4bb54caf2d622f1afdad09441695af2a83aa3fe8b8afa581d205e57ed4261c183c4d3877cee25794443fde5876417d859c108078ab788d6af7e4fe52eb66b + languageName: node + linkType: hard + +"ansi-regex@npm:^6.0.1": + version: 6.0.1 + resolution: "ansi-regex@npm:6.0.1" + checksum: 1ff8b7667cded1de4fa2c9ae283e979fc87036864317da86a2e546725f96406746411d0d85e87a2d12fa5abd715d90006de7fa4fa0477c92321ad3b4c7d4e169 + languageName: node + linkType: hard + +"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0": + version: 4.3.0 + resolution: "ansi-styles@npm:4.3.0" + dependencies: + color-convert: ^2.0.1 + checksum: 513b44c3b2105dd14cc42a19271e80f386466c4be574bccf60b627432f9198571ebf4ab1e4c3ba17347658f4ee1711c163d574248c0c1cdc2d5917a0ad582ec4 + languageName: node + linkType: hard + +"ansi-styles@npm:^6.1.0": + version: 6.2.1 + resolution: "ansi-styles@npm:6.2.1" + checksum: ef940f2f0ced1a6347398da88a91da7930c33ecac3c77b72c5905f8b8fe402c52e6fde304ff5347f616e27a742da3f1dc76de98f6866c69251ad0b07a66776d9 + languageName: node + linkType: hard + +"anymatch@npm:~3.1.2": + version: 3.1.3 + resolution: "anymatch@npm:3.1.3" + dependencies: + normalize-path: ^3.0.0 + picomatch: ^2.0.4 + checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 + languageName: node + linkType: hard + +"aproba@npm:^1.0.3 || ^2.0.0": + version: 2.0.0 + resolution: "aproba@npm:2.0.0" + checksum: 5615cadcfb45289eea63f8afd064ab656006361020e1735112e346593856f87435e02d8dcc7ff0d11928bc7d425f27bc7c2a84f6c0b35ab0ff659c814c138a24 + languageName: node + linkType: hard + +"are-we-there-yet@npm:^3.0.0": + version: 3.0.1 + resolution: "are-we-there-yet@npm:3.0.1" + dependencies: + delegates: ^1.0.0 + readable-stream: ^3.6.0 + checksum: 52590c24860fa7173bedeb69a4c05fb573473e860197f618b9a28432ee4379049336727ae3a1f9c4cb083114601c1140cee578376164d0e651217a9843f9fe83 + languageName: node + linkType: hard + +"argparse@npm:^2.0.1": + version: 2.0.1 + resolution: "argparse@npm:2.0.1" + checksum: 83644b56493e89a254bae05702abf3a1101b4fa4d0ca31df1c9985275a5a5bd47b3c27b7fa0b71098d41114d8ca000e6ed90cad764b306f8a503665e4d517ced + languageName: node + linkType: hard + +"arrify@npm:^1.0.0": + version: 1.0.1 + resolution: "arrify@npm:1.0.1" + checksum: 745075dd4a4624ff0225c331dacb99be501a515d39bcb7c84d24660314a6ec28e68131b137e6f7e16318170842ce97538cd298fc4cd6b2cc798e0b957f2747e7 + languageName: node + linkType: hard + +"assertion-error@npm:^1.1.0": + version: 1.1.0 + resolution: "assertion-error@npm:1.1.0" + checksum: fd9429d3a3d4fd61782eb3962ae76b6d08aa7383123fca0596020013b3ebd6647891a85b05ce821c47d1471ed1271f00b0545cf6a4326cf2fc91efcc3b0fbecf + languageName: node + linkType: hard + +"balanced-match@npm:^1.0.0": + version: 1.0.2 + resolution: "balanced-match@npm:1.0.2" + checksum: 9706c088a283058a8a99e0bf91b0a2f75497f185980d9ffa8b304de1d9e58ebda7c72c07ebf01dadedaac5b2907b2c6f566f660d62bd336c3468e960403b9d65 + languageName: node + linkType: hard + +"base-x@npm:^3.0.2": + version: 3.0.9 + resolution: "base-x@npm:3.0.9" + dependencies: + safe-buffer: ^5.0.1 + checksum: 957101d6fd09e1903e846fd8f69fd7e5e3e50254383e61ab667c725866bec54e5ece5ba49ce385128ae48f9ec93a26567d1d5ebb91f4d56ef4a9cc0d5a5481e8 + languageName: node + linkType: hard + +"base64-js@npm:^1.3.1, base64-js@npm:^1.5.1": + version: 1.5.1 + resolution: "base64-js@npm:1.5.1" + checksum: 669632eb3745404c2f822a18fc3a0122d2f9a7a13f7fb8b5823ee19d1d2ff9ee5b52c53367176ea4ad093c332fd5ab4bd0ebae5a8e27917a4105a4cfc86b1005 + languageName: node + linkType: hard + +"bigint-buffer@npm:^1.1.5": + version: 1.1.5 + resolution: "bigint-buffer@npm:1.1.5" + dependencies: + bindings: ^1.3.0 + node-gyp: latest + checksum: d010c9f57758bcdaccb435d88b483ffcc95fe8bbc6e7fb3a44fb5221f29c894ffaf4a3c5a4a530e0e7d6608203c2cde9b79ee4f2386cd6d4462d1070bc8c9f4e + languageName: node + linkType: hard + +"bignumber.js@npm:^9.0.1": + version: 9.1.1 + resolution: "bignumber.js@npm:9.1.1" + checksum: ad243b7e2f9120b112d670bb3d674128f0bd2ca1745b0a6c9df0433bd2c0252c43e6315d944c2ac07b4c639e7496b425e46842773cf89c6a2dcd4f31e5c4b11e + languageName: node + linkType: hard + +"binary-extensions@npm:^2.0.0": + version: 2.2.0 + resolution: "binary-extensions@npm:2.2.0" + checksum: ccd267956c58d2315f5d3ea6757cf09863c5fc703e50fbeb13a7dc849b812ef76e3cf9ca8f35a0c48498776a7478d7b4a0418e1e2b8cb9cb9731f2922aaad7f8 + languageName: node + linkType: hard + +"bindings@npm:^1.3.0": + version: 1.5.0 + resolution: "bindings@npm:1.5.0" + dependencies: + file-uri-to-path: 1.0.0 + checksum: 65b6b48095717c2e6105a021a7da4ea435aa8d3d3cd085cb9e85bcb6e5773cf318c4745c3f7c504412855940b585bdf9b918236612a1c7a7942491de176f1ae7 + languageName: node + linkType: hard + +"bn.js@npm:^5.0.0, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0": + version: 5.2.1 + resolution: "bn.js@npm:5.2.1" + checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3 + languageName: node + linkType: hard + +"borsh@npm:^0.7.0": + version: 0.7.0 + resolution: "borsh@npm:0.7.0" + dependencies: + bn.js: ^5.2.0 + bs58: ^4.0.0 + text-encoding-utf-8: ^1.0.2 + checksum: e98bfb5f7cfb820819c2870b884dac58dd4b4ce6a86c286c8fbf5c9ca582e73a8c6094df67e81a28c418ff07a309c6b118b2e27fdfea83fd92b8100c741da0b5 + languageName: node + linkType: hard + +"brace-expansion@npm:^1.1.7": + version: 1.1.11 + resolution: "brace-expansion@npm:1.1.11" + dependencies: + balanced-match: ^1.0.0 + concat-map: 0.0.1 + checksum: faf34a7bb0c3fcf4b59c7808bc5d2a96a40988addf2e7e09dfbb67a2251800e0d14cd2bfc1aa79174f2f5095c54ff27f46fb1289fe2d77dac755b5eb3434cc07 + languageName: node + linkType: hard + +"brace-expansion@npm:^2.0.1": + version: 2.0.1 + resolution: "brace-expansion@npm:2.0.1" + dependencies: + balanced-match: ^1.0.0 + checksum: a61e7cd2e8a8505e9f0036b3b6108ba5e926b4b55089eeb5550cd04a471fe216c96d4fe7e4c7f995c728c554ae20ddfc4244cad10aef255e72b62930afd233d1 + languageName: node + linkType: hard + +"braces@npm:~3.0.2": + version: 3.0.2 + resolution: "braces@npm:3.0.2" + dependencies: + fill-range: ^7.0.1 + checksum: e2a8e769a863f3d4ee887b5fe21f63193a891c68b612ddb4b68d82d1b5f3ff9073af066c343e9867a393fe4c2555dcb33e89b937195feb9c1613d259edfcd459 + languageName: node + linkType: hard + +"browser-stdout@npm:1.3.1": + version: 1.3.1 + resolution: "browser-stdout@npm:1.3.1" + checksum: b717b19b25952dd6af483e368f9bcd6b14b87740c3d226c2977a65e84666ffd67000bddea7d911f111a9b6ddc822b234de42d52ab6507bce4119a4cc003ef7b3 + languageName: node + linkType: hard + +"bs58@npm:^4.0.0, bs58@npm:^4.0.1": + version: 4.0.1 + resolution: "bs58@npm:4.0.1" + dependencies: + base-x: ^3.0.2 + checksum: b3c5365bb9e0c561e1a82f1a2d809a1a692059fae016be233a6127ad2f50a6b986467c3a50669ce4c18929dcccb297c5909314dd347a25a68c21b68eb3e95ac2 + languageName: node + linkType: hard + +"buffer-from@npm:^1.0.0, buffer-from@npm:^1.1.0": + version: 1.1.2 + resolution: "buffer-from@npm:1.1.2" + checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb + languageName: node + linkType: hard + +"buffer-layout@npm:^1.2.0, buffer-layout@npm:^1.2.2": + version: 1.2.2 + resolution: "buffer-layout@npm:1.2.2" + checksum: e5809ba275530bf4e52fd09558b7c2111fbda5b405124f581acf364261d9c154e271800271898cd40473f9bcbb42c31584efb04219bde549d3460ca4bafeaa07 + languageName: node + linkType: hard + +"buffer@npm:6.0.3, buffer@npm:^6.0.3, buffer@npm:~6.0.3": + version: 6.0.3 + resolution: "buffer@npm:6.0.3" + dependencies: + base64-js: ^1.3.1 + ieee754: ^1.2.1 + checksum: 5ad23293d9a731e4318e420025800b42bf0d264004c0286c8cc010af7a270c7a0f6522e84f54b9ad65cbd6db20b8badbfd8d2ebf4f80fa03dab093b89e68c3f9 + languageName: node + linkType: hard + +"bufferutil@npm:^4.0.1": + version: 4.0.7 + resolution: "bufferutil@npm:4.0.7" + dependencies: + node-gyp: latest + node-gyp-build: ^4.3.0 + checksum: f75aa87e3d1b99b87a95f60a855e63f70af07b57fb8443e75a2ddfef2e47788d130fdd46e3a78fd7e0c10176082b26dfbed970c5b8632e1cc299cafa0e93ce45 + languageName: node + linkType: hard + +"cacache@npm:^17.0.0": + version: 17.1.3 + resolution: "cacache@npm:17.1.3" + dependencies: + "@npmcli/fs": ^3.1.0 + fs-minipass: ^3.0.0 + glob: ^10.2.2 + lru-cache: ^7.7.1 + minipass: ^5.0.0 + minipass-collect: ^1.0.2 + minipass-flush: ^1.0.5 + minipass-pipeline: ^1.2.4 + p-map: ^4.0.0 + ssri: ^10.0.0 + tar: ^6.1.11 + unique-filename: ^3.0.0 + checksum: 385756781e1e21af089160d89d7462b7ed9883c978e848c7075b90b73cb823680e66092d61513050164588387d2ca87dd6d910e28d64bc13a9ac82cd8580c796 + languageName: node + linkType: hard + +"camelcase@npm:^6.0.0, camelcase@npm:^6.3.0": + version: 6.3.0 + resolution: "camelcase@npm:6.3.0" + checksum: 8c96818a9076434998511251dcb2761a94817ea17dbdc37f47ac080bd088fc62c7369429a19e2178b993497132c8cbcf5cc1f44ba963e76782ba469c0474938d + languageName: node + linkType: hard + +"chai@npm:^4.3.4": + version: 4.3.7 + resolution: "chai@npm:4.3.7" + dependencies: + assertion-error: ^1.1.0 + check-error: ^1.0.2 + deep-eql: ^4.1.2 + get-func-name: ^2.0.0 + loupe: ^2.3.1 + pathval: ^1.1.1 + type-detect: ^4.0.5 + checksum: 0bba7d267848015246a66995f044ce3f0ebc35e530da3cbdf171db744e14cbe301ab913a8d07caf7952b430257ccbb1a4a983c570a7c5748dc537897e5131f7c + languageName: node + linkType: hard + +"chalk@npm:^4.1.0": + version: 4.1.2 + resolution: "chalk@npm:4.1.2" + dependencies: + ansi-styles: ^4.1.0 + supports-color: ^7.1.0 + checksum: fe75c9d5c76a7a98d45495b91b2172fa3b7a09e0cc9370e5c8feb1c567b85c4288e2b3fded7cfdd7359ac28d6b3844feb8b82b8686842e93d23c827c417e83fc + languageName: node + linkType: hard + +"check-error@npm:^1.0.2": + version: 1.0.2 + resolution: "check-error@npm:1.0.2" + checksum: d9d106504404b8addd1ee3f63f8c0eaa7cd962a1a28eb9c519b1c4a1dc7098be38007fc0060f045ee00f075fbb7a2a4f42abcf61d68323677e11ab98dc16042e + languageName: node + linkType: hard + +"chokidar@npm:3.5.3": + version: 3.5.3 + resolution: "chokidar@npm:3.5.3" + dependencies: + anymatch: ~3.1.2 + braces: ~3.0.2 + fsevents: ~2.3.2 + glob-parent: ~5.1.2 + is-binary-path: ~2.1.0 + is-glob: ~4.0.1 + normalize-path: ~3.0.0 + readdirp: ~3.6.0 + dependenciesMeta: + fsevents: + optional: true + checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c + languageName: node + linkType: hard + +"chownr@npm:^2.0.0": + version: 2.0.0 + resolution: "chownr@npm:2.0.0" + checksum: c57cf9dd0791e2f18a5ee9c1a299ae6e801ff58fee96dc8bfd0dcb4738a6ce58dd252a3605b1c93c6418fe4f9d5093b28ffbf4d66648cb2a9c67eaef9679be2f + languageName: node + linkType: hard + +"clean-stack@npm:^2.0.0": + version: 2.2.0 + resolution: "clean-stack@npm:2.2.0" + checksum: 2ac8cd2b2f5ec986a3c743935ec85b07bc174d5421a5efc8017e1f146a1cf5f781ae962618f416352103b32c9cd7e203276e8c28241bbe946160cab16149fb68 + languageName: node + linkType: hard + +"cliui@npm:^7.0.2": + version: 7.0.4 + resolution: "cliui@npm:7.0.4" + dependencies: + string-width: ^4.2.0 + strip-ansi: ^6.0.0 + wrap-ansi: ^7.0.0 + checksum: ce2e8f578a4813806788ac399b9e866297740eecd4ad1823c27fd344d78b22c5f8597d548adbcc46f0573e43e21e751f39446c5a5e804a12aace402b7a315d7f + languageName: node + linkType: hard + +"color-convert@npm:^2.0.1": + version: 2.0.1 + resolution: "color-convert@npm:2.0.1" + dependencies: + color-name: ~1.1.4 + checksum: 79e6bdb9fd479a205c71d89574fccfb22bd9053bd98c6c4d870d65c132e5e904e6034978e55b43d69fcaa7433af2016ee203ce76eeba9cfa554b373e7f7db336 + languageName: node + linkType: hard + +"color-name@npm:~1.1.4": + version: 1.1.4 + resolution: "color-name@npm:1.1.4" + checksum: b0445859521eb4021cd0fb0cc1a75cecf67fceecae89b63f62b201cca8d345baf8b952c966862a9d9a2632987d4f6581f0ec8d957dfacece86f0a7919316f610 + languageName: node + linkType: hard + +"color-support@npm:^1.1.3": + version: 1.1.3 + resolution: "color-support@npm:1.1.3" + bin: + color-support: bin.js + checksum: 9b7356817670b9a13a26ca5af1c21615463b500783b739b7634a0c2047c16cef4b2865d7576875c31c3cddf9dd621fa19285e628f20198b233a5cfdda6d0793b + languageName: node + linkType: hard + +"commander@npm:^2.20.3": + version: 2.20.3 + resolution: "commander@npm:2.20.3" + checksum: ab8c07884e42c3a8dbc5dd9592c606176c7eb5c1ca5ff274bcf907039b2c41de3626f684ea75ccf4d361ba004bbaff1f577d5384c155f3871e456bdf27becf9e + languageName: node + linkType: hard + +"concat-map@npm:0.0.1": + version: 0.0.1 + resolution: "concat-map@npm:0.0.1" + checksum: 902a9f5d8967a3e2faf138d5cb784b9979bad2e6db5357c5b21c568df4ebe62bcb15108af1b2253744844eb964fc023fbd9afbbbb6ddd0bcc204c6fb5b7bf3af + languageName: node + linkType: hard + +"console-control-strings@npm:^1.1.0": + version: 1.1.0 + resolution: "console-control-strings@npm:1.1.0" + checksum: 8755d76787f94e6cf79ce4666f0c5519906d7f5b02d4b884cf41e11dcd759ed69c57da0670afd9236d229a46e0f9cf519db0cd829c6dca820bb5a5c3def584ed + languageName: node + linkType: hard + +"cross-fetch@npm:^3.1.5": + version: 3.1.8 + resolution: "cross-fetch@npm:3.1.8" + dependencies: + node-fetch: ^2.6.12 + checksum: 78f993fa099eaaa041122ab037fe9503ecbbcb9daef234d1d2e0b9230a983f64d645d088c464e21a247b825a08dc444a6e7064adfa93536d3a9454b4745b3632 + languageName: node + linkType: hard + +"cross-spawn@npm:^7.0.0": + version: 7.0.3 + resolution: "cross-spawn@npm:7.0.3" + dependencies: + path-key: ^3.1.0 + shebang-command: ^2.0.0 + which: ^2.0.1 + checksum: 671cc7c7288c3a8406f3c69a3ae2fc85555c04169e9d611def9a675635472614f1c0ed0ef80955d5b6d4e724f6ced67f0ad1bb006c2ea643488fcfef994d7f52 + languageName: node + linkType: hard + +"crypto-hash@npm:^1.3.0": + version: 1.3.0 + resolution: "crypto-hash@npm:1.3.0" + checksum: a3a507e0d2b18fbd2da8088a1c62d0c53c009a99bbfa6d851cac069734ffa546922fa51bdd776d006459701cdda873463e5059ece3431aca048fd99e7573d138 + languageName: node + linkType: hard + +"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.3.3": + version: 4.3.4 + resolution: "debug@npm:4.3.4" + dependencies: + ms: 2.1.2 + peerDependenciesMeta: + supports-color: + optional: true + checksum: 3dbad3f94ea64f34431a9cbf0bafb61853eda57bff2880036153438f50fb5a84f27683ba0d8e5426bf41a8c6ff03879488120cf5b3a761e77953169c0600a708 + languageName: node + linkType: hard + +"debug@npm:4.3.3": + version: 4.3.3 + resolution: "debug@npm:4.3.3" + dependencies: + ms: 2.1.2 + peerDependenciesMeta: + supports-color: + optional: true + checksum: 14472d56fe4a94dbcfaa6dbed2dd3849f1d72ba78104a1a328047bb564643ca49df0224c3a17fa63533fd11dd3d4c8636cd861191232a2c6735af00cc2d4de16 + languageName: node + linkType: hard + +"decamelize@npm:^4.0.0": + version: 4.0.0 + resolution: "decamelize@npm:4.0.0" + checksum: b7d09b82652c39eead4d6678bb578e3bebd848add894b76d0f6b395bc45b2d692fb88d977e7cfb93c4ed6c119b05a1347cef261174916c2e75c0a8ca57da1809 + languageName: node + linkType: hard + +"deep-eql@npm:^4.1.2": + version: 4.1.3 + resolution: "deep-eql@npm:4.1.3" + dependencies: + type-detect: ^4.0.0 + checksum: 7f6d30cb41c713973dc07eaadded848b2ab0b835e518a88b91bea72f34e08c4c71d167a722a6f302d3a6108f05afd8e6d7650689a84d5d29ec7fe6220420397f + languageName: node + linkType: hard + +"delay@npm:^5.0.0": + version: 5.0.0 + resolution: "delay@npm:5.0.0" + checksum: 62f151151ecfde0d9afbb8a6be37a6d103c4cb24f35a20ef3fe56f920b0d0d0bb02bc9c0a3084d0179ef669ca332b91155f2ee4d9854622cd2cdba5fc95285f9 + languageName: node + linkType: hard + +"delegates@npm:^1.0.0": + version: 1.0.0 + resolution: "delegates@npm:1.0.0" + checksum: a51744d9b53c164ba9c0492471a1a2ffa0b6727451bdc89e31627fdf4adda9d51277cfcbfb20f0a6f08ccb3c436f341df3e92631a3440226d93a8971724771fd + languageName: node + linkType: hard + +"depd@npm:^2.0.0": + version: 2.0.0 + resolution: "depd@npm:2.0.0" + checksum: abbe19c768c97ee2eed6282d8ce3031126662252c58d711f646921c9623f9052e3e1906443066beec1095832f534e57c523b7333f8e7e0d93051ab6baef5ab3a + languageName: node + linkType: hard + +"diff@npm:5.0.0": + version: 5.0.0 + resolution: "diff@npm:5.0.0" + checksum: f19fe29284b633afdb2725c2a8bb7d25761ea54d321d8e67987ac851c5294be4afeab532bd84531e02583a3fe7f4014aa314a3eda84f5590e7a9e6b371ef3b46 + languageName: node + linkType: hard + +"diff@npm:^3.1.0": + version: 3.5.0 + resolution: "diff@npm:3.5.0" + checksum: 00842950a6551e26ce495bdbce11047e31667deea546527902661f25cc2e73358967ebc78cf86b1a9736ec3e14286433225f9970678155753a6291c3bca5227b + languageName: node + linkType: hard + +"dot-case@npm:^3.0.4": + version: 3.0.4 + resolution: "dot-case@npm:3.0.4" + dependencies: + no-case: ^3.0.4 + tslib: ^2.0.3 + checksum: a65e3519414856df0228b9f645332f974f2bf5433370f544a681122eab59e66038fc3349b4be1cdc47152779dac71a5864f1ccda2f745e767c46e9c6543b1169 + languageName: node + linkType: hard + +"eastasianwidth@npm:^0.2.0": + version: 0.2.0 + resolution: "eastasianwidth@npm:0.2.0" + checksum: 7d00d7cd8e49b9afa762a813faac332dee781932d6f2c848dc348939c4253f1d4564341b7af1d041853bc3f32c2ef141b58e0a4d9862c17a7f08f68df1e0f1ed + languageName: node + linkType: hard + +"emoji-regex@npm:^8.0.0": + version: 8.0.0 + resolution: "emoji-regex@npm:8.0.0" + checksum: d4c5c39d5a9868b5fa152f00cada8a936868fd3367f33f71be515ecee4c803132d11b31a6222b2571b1e5f7e13890156a94880345594d0ce7e3c9895f560f192 + languageName: node + linkType: hard + +"emoji-regex@npm:^9.2.2": + version: 9.2.2 + resolution: "emoji-regex@npm:9.2.2" + checksum: 8487182da74aabd810ac6d6f1994111dfc0e331b01271ae01ec1eb0ad7b5ecc2bbbbd2f053c05cb55a1ac30449527d819bbfbf0e3de1023db308cbcb47f86601 + languageName: node + linkType: hard + +"encoding@npm:^0.1.13": + version: 0.1.13 + resolution: "encoding@npm:0.1.13" + dependencies: + iconv-lite: ^0.6.2 + checksum: bb98632f8ffa823996e508ce6a58ffcf5856330fde839ae42c9e1f436cc3b5cc651d4aeae72222916545428e54fd0f6aa8862fd8d25bdbcc4589f1e3f3715e7f + languageName: node + linkType: hard + +"env-paths@npm:^2.2.0": + version: 2.2.1 + resolution: "env-paths@npm:2.2.1" + checksum: 65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e + languageName: node + linkType: hard + +"err-code@npm:^2.0.2": + version: 2.0.3 + resolution: "err-code@npm:2.0.3" + checksum: 8b7b1be20d2de12d2255c0bc2ca638b7af5171142693299416e6a9339bd7d88fc8d7707d913d78e0993176005405a236b066b45666b27b797252c771156ace54 + languageName: node + linkType: hard + +"es6-promise@npm:^4.0.3": + version: 4.2.8 + resolution: "es6-promise@npm:4.2.8" + checksum: 95614a88873611cb9165a85d36afa7268af5c03a378b35ca7bda9508e1d4f1f6f19a788d4bc755b3fd37c8ebba40782018e02034564ff24c9d6fa37e959ad57d + languageName: node + linkType: hard + +"es6-promisify@npm:^5.0.0": + version: 5.0.0 + resolution: "es6-promisify@npm:5.0.0" + dependencies: + es6-promise: ^4.0.3 + checksum: fbed9d791598831413be84a5374eca8c24800ec71a16c1c528c43a98e2dadfb99331483d83ae6094ddb9b87e6f799a15d1553cebf756047e0865c753bc346b92 + languageName: node + linkType: hard + +"escalade@npm:^3.1.1": + version: 3.1.1 + resolution: "escalade@npm:3.1.1" + checksum: a3e2a99f07acb74b3ad4989c48ca0c3140f69f923e56d0cba0526240ee470b91010f9d39001f2a4a313841d237ede70a729e92125191ba5d21e74b106800b133 + languageName: node + linkType: hard + +"escape-string-regexp@npm:4.0.0": + version: 4.0.0 + resolution: "escape-string-regexp@npm:4.0.0" + checksum: 98b48897d93060f2322108bf29db0feba7dd774be96cd069458d1453347b25ce8682ecc39859d4bca2203cc0ab19c237bcc71755eff49a0f8d90beadeeba5cc5 + languageName: node + linkType: hard + +"eventemitter3@npm:^4.0.7": + version: 4.0.7 + resolution: "eventemitter3@npm:4.0.7" + checksum: 1875311c42fcfe9c707b2712c32664a245629b42bb0a5a84439762dd0fd637fc54d078155ea83c2af9e0323c9ac13687e03cfba79b03af9f40c89b4960099374 + languageName: node + linkType: hard + +"exponential-backoff@npm:^3.1.1": + version: 3.1.1 + resolution: "exponential-backoff@npm:3.1.1" + checksum: 3d21519a4f8207c99f7457287291316306255a328770d320b401114ec8481986e4e467e854cb9914dd965e0a1ca810a23ccb559c642c88f4c7f55c55778a9b48 + languageName: node + linkType: hard + +"eyes@npm:^0.1.8": + version: 0.1.8 + resolution: "eyes@npm:0.1.8" + checksum: c31703a92bf36ba75ee8d379ee7985c24ee6149f3a6175f44cec7a05b178c38bce9836d3ca48c9acb0329a960ac2c4b2ead4e60cdd4fe6e8c92cad7cd6913687 + languageName: node + linkType: hard + +"fast-stable-stringify@npm:^1.0.0": + version: 1.0.0 + resolution: "fast-stable-stringify@npm:1.0.0" + checksum: ef1203d246a7e8ac15e2bfbda0a89fa375947bccf9f7910be0ea759856dbe8ea5024a0d8cc2cceabe18a9cb67e95927b78bb6173a3ae37ec55a518cf36e5244b + languageName: node + linkType: hard + +"file-uri-to-path@npm:1.0.0": + version: 1.0.0 + resolution: "file-uri-to-path@npm:1.0.0" + checksum: b648580bdd893a008c92c7ecc96c3ee57a5e7b6c4c18a9a09b44fb5d36d79146f8e442578bc0e173dc027adf3987e254ba1dfd6e3ec998b7c282873010502144 + languageName: node + linkType: hard + +"fill-range@npm:^7.0.1": + version: 7.0.1 + resolution: "fill-range@npm:7.0.1" + dependencies: + to-regex-range: ^5.0.1 + checksum: cc283f4e65b504259e64fd969bcf4def4eb08d85565e906b7d36516e87819db52029a76b6363d0f02d0d532f0033c9603b9e2d943d56ee3b0d4f7ad3328ff917 + languageName: node + linkType: hard + +"find-up@npm:5.0.0": + version: 5.0.0 + resolution: "find-up@npm:5.0.0" + dependencies: + locate-path: ^6.0.0 + path-exists: ^4.0.0 + checksum: 07955e357348f34660bde7920783204ff5a26ac2cafcaa28bace494027158a97b9f56faaf2d89a6106211a8174db650dd9f503f9c0d526b1202d5554a00b9095 + languageName: node + linkType: hard + +"flat@npm:^5.0.2": + version: 5.0.2 + resolution: "flat@npm:5.0.2" + bin: + flat: cli.js + checksum: 12a1536ac746db74881316a181499a78ef953632ddd28050b7a3a43c62ef5462e3357c8c29d76072bb635f147f7a9a1f0c02efef6b4be28f8db62ceb3d5c7f5d + languageName: node + linkType: hard + +"foreground-child@npm:^3.1.0": + version: 3.1.1 + resolution: "foreground-child@npm:3.1.1" + dependencies: + cross-spawn: ^7.0.0 + signal-exit: ^4.0.1 + checksum: 139d270bc82dc9e6f8bc045fe2aae4001dc2472157044fdfad376d0a3457f77857fa883c1c8b21b491c6caade9a926a4bed3d3d2e8d3c9202b151a4cbbd0bcd5 + languageName: node + linkType: hard + +"fs-minipass@npm:^2.0.0": + version: 2.1.0 + resolution: "fs-minipass@npm:2.1.0" + dependencies: + minipass: ^3.0.0 + checksum: 1b8d128dae2ac6cc94230cc5ead341ba3e0efaef82dab46a33d171c044caaa6ca001364178d42069b2809c35a1c3c35079a32107c770e9ffab3901b59af8c8b1 + languageName: node + linkType: hard + +"fs-minipass@npm:^3.0.0": + version: 3.0.2 + resolution: "fs-minipass@npm:3.0.2" + dependencies: + minipass: ^5.0.0 + checksum: e9cc0e1f2d01c6f6f62f567aee59530aba65c6c7b2ae88c5027bc34c711ebcfcfaefd0caf254afa6adfe7d1fba16bc2537508a6235196bac7276747d078aef0a + languageName: node + linkType: hard + +"fs.realpath@npm:^1.0.0": + version: 1.0.0 + resolution: "fs.realpath@npm:1.0.0" + checksum: 99ddea01a7e75aa276c250a04eedeffe5662bce66c65c07164ad6264f9de18fb21be9433ead460e54cff20e31721c811f4fb5d70591799df5f85dce6d6746fd0 + languageName: node + linkType: hard + +"fsevents@npm:~2.3.2": + version: 2.3.2 + resolution: "fsevents@npm:2.3.2" + dependencies: + node-gyp: latest + checksum: 97ade64e75091afee5265e6956cb72ba34db7819b4c3e94c431d4be2b19b8bb7a2d4116da417950c3425f17c8fe693d25e20212cac583ac1521ad066b77ae31f + conditions: os=darwin + languageName: node + linkType: hard + +"fsevents@patch:fsevents@~2.3.2#~builtin": + version: 2.3.2 + resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" + dependencies: + node-gyp: latest + conditions: os=darwin + languageName: node + linkType: hard + +"gauge@npm:^4.0.3": + version: 4.0.4 + resolution: "gauge@npm:4.0.4" + dependencies: + aproba: ^1.0.3 || ^2.0.0 + color-support: ^1.1.3 + console-control-strings: ^1.1.0 + has-unicode: ^2.0.1 + signal-exit: ^3.0.7 + string-width: ^4.2.3 + strip-ansi: ^6.0.1 + wide-align: ^1.1.5 + checksum: 788b6bfe52f1dd8e263cda800c26ac0ca2ff6de0b6eee2fe0d9e3abf15e149b651bd27bf5226be10e6e3edb5c4e5d5985a5a1a98137e7a892f75eff76467ad2d + languageName: node + linkType: hard + +"get-caller-file@npm:^2.0.5": + version: 2.0.5 + resolution: "get-caller-file@npm:2.0.5" + checksum: b9769a836d2a98c3ee734a88ba712e62703f1df31b94b784762c433c27a386dd6029ff55c2a920c392e33657d80191edbf18c61487e198844844516f843496b9 + languageName: node + linkType: hard + +"get-func-name@npm:^2.0.0": + version: 2.0.0 + resolution: "get-func-name@npm:2.0.0" + checksum: 8d82e69f3e7fab9e27c547945dfe5cc0c57fc0adf08ce135dddb01081d75684a03e7a0487466f478872b341d52ac763ae49e660d01ab83741f74932085f693c3 + languageName: node + linkType: hard + +"glob-parent@npm:~5.1.2": + version: 5.1.2 + resolution: "glob-parent@npm:5.1.2" + dependencies: + is-glob: ^4.0.1 + checksum: f4f2bfe2425296e8a47e36864e4f42be38a996db40420fe434565e4480e3322f18eb37589617a98640c5dc8fdec1a387007ee18dbb1f3f5553409c34d17f425e + languageName: node + linkType: hard + +"glob@npm:7.2.0": + version: 7.2.0 + resolution: "glob@npm:7.2.0" + dependencies: + fs.realpath: ^1.0.0 + inflight: ^1.0.4 + inherits: 2 + minimatch: ^3.0.4 + once: ^1.3.0 + path-is-absolute: ^1.0.0 + checksum: 78a8ea942331f08ed2e055cb5b9e40fe6f46f579d7fd3d694f3412fe5db23223d29b7fee1575440202e9a7ff9a72ab106a39fee39934c7bedafe5e5f8ae20134 + languageName: node + linkType: hard + +"glob@npm:^10.2.2": + version: 10.3.3 + resolution: "glob@npm:10.3.3" + dependencies: + foreground-child: ^3.1.0 + jackspeak: ^2.0.3 + minimatch: ^9.0.1 + minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 + path-scurry: ^1.10.1 + bin: + glob: dist/cjs/src/bin.js + checksum: 29190d3291f422da0cb40b77a72fc8d2c51a36524e99b8bf412548b7676a6627489528b57250429612b6eec2e6fe7826d328451d3e694a9d15e575389308ec53 + languageName: node + linkType: hard + +"glob@npm:^7.1.3, glob@npm:^7.1.4": + version: 7.2.3 + resolution: "glob@npm:7.2.3" + dependencies: + fs.realpath: ^1.0.0 + inflight: ^1.0.4 + inherits: 2 + minimatch: ^3.1.1 + once: ^1.3.0 + path-is-absolute: ^1.0.0 + checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133 + languageName: node + linkType: hard + +"graceful-fs@npm:^4.2.6": + version: 4.2.11 + resolution: "graceful-fs@npm:4.2.11" + checksum: ac85f94da92d8eb6b7f5a8b20ce65e43d66761c55ce85ac96df6865308390da45a8d3f0296dd3a663de65d30ba497bd46c696cc1e248c72b13d6d567138a4fc7 + languageName: node + linkType: hard + +"growl@npm:1.10.5": + version: 1.10.5 + resolution: "growl@npm:1.10.5" + checksum: 4b86685de6831cebcbb19f93870bea624afee61124b0a20c49017013987cd129e73a8c4baeca295728f41d21265e1f859d25ef36731b142ca59c655fea94bb1a + languageName: node + linkType: hard + +"has-flag@npm:^4.0.0": + version: 4.0.0 + resolution: "has-flag@npm:4.0.0" + checksum: 261a1357037ead75e338156b1f9452c016a37dcd3283a972a30d9e4a87441ba372c8b81f818cd0fbcd9c0354b4ae7e18b9e1afa1971164aef6d18c2b6095a8ad + languageName: node + linkType: hard + +"has-unicode@npm:^2.0.1": + version: 2.0.1 + resolution: "has-unicode@npm:2.0.1" + checksum: 1eab07a7436512db0be40a710b29b5dc21fa04880b7f63c9980b706683127e3c1b57cb80ea96d47991bdae2dfe479604f6a1ba410106ee1046a41d1bd0814400 + languageName: node + linkType: hard + +"he@npm:1.2.0": + version: 1.2.0 + resolution: "he@npm:1.2.0" + bin: + he: bin/he + checksum: 3d4d6babccccd79c5c5a3f929a68af33360d6445587d628087f39a965079d84f18ce9c3d3f917ee1e3978916fc833bb8b29377c3b403f919426f91bc6965e7a7 + languageName: node + linkType: hard + +"http-cache-semantics@npm:^4.1.1": + version: 4.1.1 + resolution: "http-cache-semantics@npm:4.1.1" + checksum: 83ac0bc60b17a3a36f9953e7be55e5c8f41acc61b22583060e8dedc9dd5e3607c823a88d0926f9150e571f90946835c7fe150732801010845c72cd8bbff1a236 + languageName: node + linkType: hard + +"http-proxy-agent@npm:^5.0.0": + version: 5.0.0 + resolution: "http-proxy-agent@npm:5.0.0" + dependencies: + "@tootallnate/once": 2 + agent-base: 6 + debug: 4 + checksum: e2ee1ff1656a131953839b2a19cd1f3a52d97c25ba87bd2559af6ae87114abf60971e498021f9b73f9fd78aea8876d1fb0d4656aac8a03c6caa9fc175f22b786 + languageName: node + linkType: hard + +"https-proxy-agent@npm:^5.0.0": + version: 5.0.1 + resolution: "https-proxy-agent@npm:5.0.1" + dependencies: + agent-base: 6 + debug: 4 + checksum: 571fccdf38184f05943e12d37d6ce38197becdd69e58d03f43637f7fa1269cf303a7d228aa27e5b27bbd3af8f09fd938e1c91dcfefff2df7ba77c20ed8dfc765 + languageName: node + linkType: hard + +"humanize-ms@npm:^1.2.1": + version: 1.2.1 + resolution: "humanize-ms@npm:1.2.1" + dependencies: + ms: ^2.0.0 + checksum: 9c7a74a2827f9294c009266c82031030eae811ca87b0da3dceb8d6071b9bde22c9f3daef0469c3c533cc67a97d8a167cd9fc0389350e5f415f61a79b171ded16 + languageName: node + linkType: hard + +"iconv-lite@npm:^0.6.2": + version: 0.6.3 + resolution: "iconv-lite@npm:0.6.3" + dependencies: + safer-buffer: ">= 2.1.2 < 3.0.0" + checksum: 3f60d47a5c8fc3313317edfd29a00a692cc87a19cac0159e2ce711d0ebc9019064108323b5e493625e25594f11c6236647d8e256fbe7a58f4a3b33b89e6d30bf + languageName: node + linkType: hard + +"ieee754@npm:^1.2.1": + version: 1.2.1 + resolution: "ieee754@npm:1.2.1" + checksum: 5144c0c9815e54ada181d80a0b810221a253562422e7c6c3a60b1901154184f49326ec239d618c416c1c5945a2e197107aee8d986a3dd836b53dffefd99b5e7e + languageName: node + linkType: hard + +"imurmurhash@npm:^0.1.4": + version: 0.1.4 + resolution: "imurmurhash@npm:0.1.4" + checksum: 7cae75c8cd9a50f57dadd77482359f659eaebac0319dd9368bcd1714f55e65badd6929ca58569da2b6494ef13fdd5598cd700b1eba23f8b79c5f19d195a3ecf7 + languageName: node + linkType: hard + +"indent-string@npm:^4.0.0": + version: 4.0.0 + resolution: "indent-string@npm:4.0.0" + checksum: 824cfb9929d031dabf059bebfe08cf3137365e112019086ed3dcff6a0a7b698cb80cf67ccccde0e25b9e2d7527aa6cc1fed1ac490c752162496caba3e6699612 + languageName: node + linkType: hard + +"inflight@npm:^1.0.4": + version: 1.0.6 + resolution: "inflight@npm:1.0.6" + dependencies: + once: ^1.3.0 + wrappy: 1 + checksum: f4f76aa072ce19fae87ce1ef7d221e709afb59d445e05d47fba710e85470923a75de35bfae47da6de1b18afc3ce83d70facf44cfb0aff89f0a3f45c0a0244dfd + languageName: node + linkType: hard + +"inherits@npm:2, inherits@npm:^2.0.3": + version: 2.0.4 + resolution: "inherits@npm:2.0.4" + checksum: 4a48a733847879d6cf6691860a6b1e3f0f4754176e4d71494c41f3475553768b10f84b5ce1d40fbd0e34e6bfbb864ee35858ad4dd2cf31e02fc4a154b724d7f1 + languageName: node + linkType: hard + +"ip@npm:^2.0.0": + version: 2.0.0 + resolution: "ip@npm:2.0.0" + checksum: cfcfac6b873b701996d71ec82a7dd27ba92450afdb421e356f44044ed688df04567344c36cbacea7d01b1c39a4c732dc012570ebe9bebfb06f27314bca625349 + languageName: node + linkType: hard + +"is-binary-path@npm:~2.1.0": + version: 2.1.0 + resolution: "is-binary-path@npm:2.1.0" + dependencies: + binary-extensions: ^2.0.0 + checksum: 84192eb88cff70d320426f35ecd63c3d6d495da9d805b19bc65b518984b7c0760280e57dbf119b7e9be6b161784a5a673ab2c6abe83abb5198a432232ad5b35c + languageName: node + linkType: hard + +"is-extglob@npm:^2.1.1": + version: 2.1.1 + resolution: "is-extglob@npm:2.1.1" + checksum: df033653d06d0eb567461e58a7a8c9f940bd8c22274b94bf7671ab36df5719791aae15eef6d83bbb5e23283967f2f984b8914559d4449efda578c775c4be6f85 + languageName: node + linkType: hard + +"is-fullwidth-code-point@npm:^3.0.0": + version: 3.0.0 + resolution: "is-fullwidth-code-point@npm:3.0.0" + checksum: 44a30c29457c7fb8f00297bce733f0a64cd22eca270f83e58c105e0d015e45c019491a4ab2faef91ab51d4738c670daff901c799f6a700e27f7314029e99e348 + languageName: node + linkType: hard + +"is-glob@npm:^4.0.1, is-glob@npm:~4.0.1": + version: 4.0.3 + resolution: "is-glob@npm:4.0.3" + dependencies: + is-extglob: ^2.1.1 + checksum: d381c1319fcb69d341cc6e6c7cd588e17cd94722d9a32dbd60660b993c4fb7d0f19438674e68dfec686d09b7c73139c9166b47597f846af387450224a8101ab4 + languageName: node + linkType: hard + +"is-lambda@npm:^1.0.1": + version: 1.0.1 + resolution: "is-lambda@npm:1.0.1" + checksum: 93a32f01940220532e5948538699ad610d5924ac86093fcee83022252b363eb0cc99ba53ab084a04e4fb62bf7b5731f55496257a4c38adf87af9c4d352c71c35 + languageName: node + linkType: hard + +"is-number@npm:^7.0.0": + version: 7.0.0 + resolution: "is-number@npm:7.0.0" + checksum: 456ac6f8e0f3111ed34668a624e45315201dff921e5ac181f8ec24923b99e9f32ca1a194912dc79d539c97d33dba17dc635202ff0b2cf98326f608323276d27a + languageName: node + linkType: hard + +"is-plain-obj@npm:^2.1.0": + version: 2.1.0 + resolution: "is-plain-obj@npm:2.1.0" + checksum: cec9100678b0a9fe0248a81743041ed990c2d4c99f893d935545cfbc42876cbe86d207f3b895700c690ad2fa520e568c44afc1605044b535a7820c1d40e38daa + languageName: node + linkType: hard + +"is-unicode-supported@npm:^0.1.0": + version: 0.1.0 + resolution: "is-unicode-supported@npm:0.1.0" + checksum: a2aab86ee7712f5c2f999180daaba5f361bdad1efadc9610ff5b8ab5495b86e4f627839d085c6530363c6d6d4ecbde340fb8e54bdb83da4ba8e0865ed5513c52 + languageName: node + linkType: hard + +"isexe@npm:^2.0.0": + version: 2.0.0 + resolution: "isexe@npm:2.0.0" + checksum: 26bf6c5480dda5161c820c5b5c751ae1e766c587b1f951ea3fcfc973bafb7831ae5b54a31a69bd670220e42e99ec154475025a468eae58ea262f813fdc8d1c62 + languageName: node + linkType: hard + +"isomorphic-ws@npm:^4.0.1": + version: 4.0.1 + resolution: "isomorphic-ws@npm:4.0.1" + peerDependencies: + ws: "*" + checksum: d7190eadefdc28bdb93d67b5f0c603385aaf87724fa2974abb382ac1ec9756ed2cfb27065cbe76122879c2d452e2982bc4314317f3d6c737ddda6c047328771a + languageName: node + linkType: hard + +"jackspeak@npm:^2.0.3": + version: 2.2.2 + resolution: "jackspeak@npm:2.2.2" + dependencies: + "@isaacs/cliui": ^8.0.2 + "@pkgjs/parseargs": ^0.11.0 + dependenciesMeta: + "@pkgjs/parseargs": + optional: true + checksum: 7b1468dd910afc00642db87448f24b062346570b8b47531409aa9012bcb95fdf7ec2b1c48edbb8b57a938c08391f8cc01b5034fc335aa3a2e74dbcc0ee5c555a + languageName: node + linkType: hard + +"jayson@npm:^4.1.0": + version: 4.1.0 + resolution: "jayson@npm:4.1.0" + dependencies: + "@types/connect": ^3.4.33 + "@types/node": ^12.12.54 + "@types/ws": ^7.4.4 + JSONStream: ^1.3.5 + commander: ^2.20.3 + delay: ^5.0.0 + es6-promisify: ^5.0.0 + eyes: ^0.1.8 + isomorphic-ws: ^4.0.1 + json-stringify-safe: ^5.0.1 + uuid: ^8.3.2 + ws: ^7.4.5 + bin: + jayson: bin/jayson.js + checksum: 86464322fbdc6db65d2bb4fc278cb6c86fad5c2a506065490d39459f09ba0d30f2b4fb740b33828a1424791419b6c8bd295dc54d361a4ad959bf70cc62b1ca7e + languageName: node + linkType: hard + +"js-sha256@npm:^0.9.0": + version: 0.9.0 + resolution: "js-sha256@npm:0.9.0" + checksum: ffad54b3373f81581e245866abfda50a62c483803a28176dd5c28fd2d313e0bdf830e77dac7ff8afd193c53031618920f3d98daf21cbbe80082753ab639c0365 + languageName: node + linkType: hard + +"js-yaml@npm:4.1.0": + version: 4.1.0 + resolution: "js-yaml@npm:4.1.0" + dependencies: + argparse: ^2.0.1 + bin: + js-yaml: bin/js-yaml.js + checksum: c7830dfd456c3ef2c6e355cc5a92e6700ceafa1d14bba54497b34a99f0376cecbb3e9ac14d3e5849b426d5a5140709a66237a8c991c675431271c4ce5504151a + languageName: node + linkType: hard + +"json-stringify-safe@npm:^5.0.1": + version: 5.0.1 + resolution: "json-stringify-safe@npm:5.0.1" + checksum: 48ec0adad5280b8a96bb93f4563aa1667fd7a36334f79149abd42446d0989f2ddc58274b479f4819f1f00617957e6344c886c55d05a4e15ebb4ab931e4a6a8ee + languageName: node + linkType: hard + +"json5@npm:^1.0.2": + version: 1.0.2 + resolution: "json5@npm:1.0.2" + dependencies: + minimist: ^1.2.0 + bin: + json5: lib/cli.js + checksum: 866458a8c58a95a49bef3adba929c625e82532bcff1fe93f01d29cb02cac7c3fe1f4b79951b7792c2da9de0b32871a8401a6e3c5b36778ad852bf5b8a61165d7 + languageName: node + linkType: hard + +"jsonparse@npm:^1.2.0": + version: 1.3.1 + resolution: "jsonparse@npm:1.3.1" + checksum: 6514a7be4674ebf407afca0eda3ba284b69b07f9958a8d3113ef1005f7ec610860c312be067e450c569aab8b89635e332cee3696789c750692bb60daba627f4d + languageName: node + linkType: hard + +"locate-path@npm:^6.0.0": + version: 6.0.0 + resolution: "locate-path@npm:6.0.0" + dependencies: + p-locate: ^5.0.0 + checksum: 72eb661788a0368c099a184c59d2fee760b3831c9c1c33955e8a19ae4a21b4116e53fa736dc086cdeb9fce9f7cc508f2f92d2d3aae516f133e16a2bb59a39f5a + languageName: node + linkType: hard + +"log-symbols@npm:4.1.0": + version: 4.1.0 + resolution: "log-symbols@npm:4.1.0" + dependencies: + chalk: ^4.1.0 + is-unicode-supported: ^0.1.0 + checksum: fce1497b3135a0198803f9f07464165e9eb83ed02ceb2273930a6f8a508951178d8cf4f0378e9d28300a2ed2bc49050995d2bd5f53ab716bb15ac84d58c6ef74 + languageName: node + linkType: hard + +"loupe@npm:^2.3.1": + version: 2.3.6 + resolution: "loupe@npm:2.3.6" + dependencies: + get-func-name: ^2.0.0 + checksum: cc83f1b124a1df7384601d72d8d1f5fe95fd7a8185469fec48bb2e4027e45243949e7a013e8d91051a138451ff0552310c32aa9786e60b6a30d1e801bdc2163f + languageName: node + linkType: hard + +"lower-case@npm:^2.0.2": + version: 2.0.2 + resolution: "lower-case@npm:2.0.2" + dependencies: + tslib: ^2.0.3 + checksum: 83a0a5f159ad7614bee8bf976b96275f3954335a84fad2696927f609ddae902802c4f3312d86668722e668bef41400254807e1d3a7f2e8c3eede79691aa1f010 + languageName: node + linkType: hard + +"lru-cache@npm:^6.0.0": + version: 6.0.0 + resolution: "lru-cache@npm:6.0.0" + dependencies: + yallist: ^4.0.0 + checksum: f97f499f898f23e4585742138a22f22526254fdba6d75d41a1c2526b3b6cc5747ef59c5612ba7375f42aca4f8461950e925ba08c991ead0651b4918b7c978297 + languageName: node + linkType: hard + +"lru-cache@npm:^7.7.1": + version: 7.18.3 + resolution: "lru-cache@npm:7.18.3" + checksum: e550d772384709deea3f141af34b6d4fa392e2e418c1498c078de0ee63670f1f46f5eee746e8ef7e69e1c895af0d4224e62ee33e66a543a14763b0f2e74c1356 + languageName: node + linkType: hard + +"lru-cache@npm:^9.1.1 || ^10.0.0": + version: 10.0.0 + resolution: "lru-cache@npm:10.0.0" + checksum: 18f101675fe283bc09cda0ef1e3cc83781aeb8373b439f086f758d1d91b28730950db785999cd060d3c825a8571c03073e8c14512b6655af2188d623031baf50 + languageName: node + linkType: hard + +"make-error@npm:^1.1.1": + version: 1.3.6 + resolution: "make-error@npm:1.3.6" + checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 + languageName: node + linkType: hard + +"make-fetch-happen@npm:^11.0.3": + version: 11.1.1 + resolution: "make-fetch-happen@npm:11.1.1" + dependencies: + agentkeepalive: ^4.2.1 + cacache: ^17.0.0 + http-cache-semantics: ^4.1.1 + http-proxy-agent: ^5.0.0 + https-proxy-agent: ^5.0.0 + is-lambda: ^1.0.1 + lru-cache: ^7.7.1 + minipass: ^5.0.0 + minipass-fetch: ^3.0.0 + minipass-flush: ^1.0.5 + minipass-pipeline: ^1.2.4 + negotiator: ^0.6.3 + promise-retry: ^2.0.1 + socks-proxy-agent: ^7.0.0 + ssri: ^10.0.0 + checksum: 7268bf274a0f6dcf0343829489a4506603ff34bd0649c12058753900b0eb29191dce5dba12680719a5d0a983d3e57810f594a12f3c18494e93a1fbc6348a4540 + languageName: node + linkType: hard + +"minimatch@npm:4.2.1": + version: 4.2.1 + resolution: "minimatch@npm:4.2.1" + dependencies: + brace-expansion: ^1.1.7 + checksum: 2b1514e3d0f29a549912f0db7ae7b82c5cab4a8f2dd0369f1c6451a325b3f12b2cf473c95873b6157bb8df183d6cf6db82ff03614b6adaaf1d7e055beccdfd01 + languageName: node + linkType: hard + +"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1": + version: 3.1.2 + resolution: "minimatch@npm:3.1.2" + dependencies: + brace-expansion: ^1.1.7 + checksum: c154e566406683e7bcb746e000b84d74465b3a832c45d59912b9b55cd50dee66e5c4b1e5566dba26154040e51672f9aa450a9aef0c97cfc7336b78b7afb9540a + languageName: node + linkType: hard + +"minimatch@npm:^9.0.1": + version: 9.0.3 + resolution: "minimatch@npm:9.0.3" + dependencies: + brace-expansion: ^2.0.1 + checksum: 253487976bf485b612f16bf57463520a14f512662e592e95c571afdab1442a6a6864b6c88f248ce6fc4ff0b6de04ac7aa6c8bb51e868e99d1d65eb0658a708b5 + languageName: node + linkType: hard + +"minimist@npm:^1.2.0, minimist@npm:^1.2.6": + version: 1.2.8 + resolution: "minimist@npm:1.2.8" + checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0 + languageName: node + linkType: hard + +"minipass-collect@npm:^1.0.2": + version: 1.0.2 + resolution: "minipass-collect@npm:1.0.2" + dependencies: + minipass: ^3.0.0 + checksum: 14df761028f3e47293aee72888f2657695ec66bd7d09cae7ad558da30415fdc4752bbfee66287dcc6fd5e6a2fa3466d6c484dc1cbd986525d9393b9523d97f10 + languageName: node + linkType: hard + +"minipass-fetch@npm:^3.0.0": + version: 3.0.3 + resolution: "minipass-fetch@npm:3.0.3" + dependencies: + encoding: ^0.1.13 + minipass: ^5.0.0 + minipass-sized: ^1.0.3 + minizlib: ^2.1.2 + dependenciesMeta: + encoding: + optional: true + checksum: af5ab2552a16fcf505d35fd7ffb84b57f4a0eeb269e6e1d9a2a75824dda48b36e527083250b7cca4a4def21d9544e2ade441e4730e233c0bc2133f6abda31e18 + languageName: node + linkType: hard + +"minipass-flush@npm:^1.0.5": + version: 1.0.5 + resolution: "minipass-flush@npm:1.0.5" + dependencies: + minipass: ^3.0.0 + checksum: 56269a0b22bad756a08a94b1ffc36b7c9c5de0735a4dd1ab2b06c066d795cfd1f0ac44a0fcae13eece5589b908ecddc867f04c745c7009be0b566421ea0944cf + languageName: node + linkType: hard + +"minipass-pipeline@npm:^1.2.4": + version: 1.2.4 + resolution: "minipass-pipeline@npm:1.2.4" + dependencies: + minipass: ^3.0.0 + checksum: b14240dac0d29823c3d5911c286069e36d0b81173d7bdf07a7e4a91ecdef92cdff4baaf31ea3746f1c61e0957f652e641223970870e2353593f382112257971b + languageName: node + linkType: hard + +"minipass-sized@npm:^1.0.3": + version: 1.0.3 + resolution: "minipass-sized@npm:1.0.3" + dependencies: + minipass: ^3.0.0 + checksum: 79076749fcacf21b5d16dd596d32c3b6bf4d6e62abb43868fac21674078505c8b15eaca4e47ed844985a4514854f917d78f588fcd029693709417d8f98b2bd60 + languageName: node + linkType: hard + +"minipass@npm:^3.0.0": + version: 3.3.6 + resolution: "minipass@npm:3.3.6" + dependencies: + yallist: ^4.0.0 + checksum: a30d083c8054cee83cdcdc97f97e4641a3f58ae743970457b1489ce38ee1167b3aaf7d815cd39ec7a99b9c40397fd4f686e83750e73e652b21cb516f6d845e48 + languageName: node + linkType: hard + +"minipass@npm:^5.0.0": + version: 5.0.0 + resolution: "minipass@npm:5.0.0" + checksum: 425dab288738853fded43da3314a0b5c035844d6f3097a8e3b5b29b328da8f3c1af6fc70618b32c29ff906284cf6406b6841376f21caaadd0793c1d5a6a620ea + languageName: node + linkType: hard + +"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0": + version: 7.0.2 + resolution: "minipass@npm:7.0.2" + checksum: 46776de732eb7cef2c7404a15fb28c41f5c54a22be50d47b03c605bf21f5c18d61a173c0a20b49a97e7a65f78d887245066410642551e45fffe04e9ac9e325bc + languageName: node + linkType: hard + +"minizlib@npm:^2.1.1, minizlib@npm:^2.1.2": + version: 2.1.2 + resolution: "minizlib@npm:2.1.2" + dependencies: + minipass: ^3.0.0 + yallist: ^4.0.0 + checksum: f1fdeac0b07cf8f30fcf12f4b586795b97be856edea22b5e9072707be51fc95d41487faec3f265b42973a304fe3a64acd91a44a3826a963e37b37bafde0212c3 + languageName: node + linkType: hard + +"mkdirp@npm:^0.5.1": + version: 0.5.6 + resolution: "mkdirp@npm:0.5.6" + dependencies: + minimist: ^1.2.6 + bin: + mkdirp: bin/cmd.js + checksum: 0c91b721bb12c3f9af4b77ebf73604baf350e64d80df91754dc509491ae93bf238581e59c7188360cec7cb62fc4100959245a42cfe01834efedc5e9d068376c2 + languageName: node + linkType: hard + +"mkdirp@npm:^1.0.3": + version: 1.0.4 + resolution: "mkdirp@npm:1.0.4" + bin: + mkdirp: bin/cmd.js + checksum: a96865108c6c3b1b8e1d5e9f11843de1e077e57737602de1b82030815f311be11f96f09cce59bd5b903d0b29834733e5313f9301e3ed6d6f6fba2eae0df4298f + languageName: node + linkType: hard + +"mocha@npm:^9.0.3": + version: 9.2.2 + resolution: "mocha@npm:9.2.2" + dependencies: + "@ungap/promise-all-settled": 1.1.2 + ansi-colors: 4.1.1 + browser-stdout: 1.3.1 + chokidar: 3.5.3 + debug: 4.3.3 + diff: 5.0.0 + escape-string-regexp: 4.0.0 + find-up: 5.0.0 + glob: 7.2.0 + growl: 1.10.5 + he: 1.2.0 + js-yaml: 4.1.0 + log-symbols: 4.1.0 + minimatch: 4.2.1 + ms: 2.1.3 + nanoid: 3.3.1 + serialize-javascript: 6.0.0 + strip-json-comments: 3.1.1 + supports-color: 8.1.1 + which: 2.0.2 + workerpool: 6.2.0 + yargs: 16.2.0 + yargs-parser: 20.2.4 + yargs-unparser: 2.0.0 + bin: + _mocha: bin/_mocha + mocha: bin/mocha + checksum: 4d5ca4ce33fc66627e63acdf09a634e2358c9a00f61de7788b1091b6aad430da04f97f9ecb82d56dc034b623cb833b65576136fd010d77679c03fcea5bc1e12d + languageName: node + linkType: hard + +"ms@npm:2.1.2": + version: 2.1.2 + resolution: "ms@npm:2.1.2" + checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f + languageName: node + linkType: hard + +"ms@npm:2.1.3, ms@npm:^2.0.0": + version: 2.1.3 + resolution: "ms@npm:2.1.3" + checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d + languageName: node + linkType: hard + +"nanoid@npm:3.3.1": + version: 3.3.1 + resolution: "nanoid@npm:3.3.1" + bin: + nanoid: bin/nanoid.cjs + checksum: 4ef0969e1bbe866fc223eb32276cbccb0961900bfe79104fa5abe34361979dead8d0e061410a5c03bc3d47455685adf32c09d6f27790f4a6898fb51f7df7ec86 + languageName: node + linkType: hard + +"negotiator@npm:^0.6.3": + version: 0.6.3 + resolution: "negotiator@npm:0.6.3" + checksum: b8ffeb1e262eff7968fc90a2b6767b04cfd9842582a9d0ece0af7049537266e7b2506dfb1d107a32f06dd849ab2aea834d5830f7f4d0e5cb7d36e1ae55d021d9 + languageName: node + linkType: hard + +"no-case@npm:^3.0.4": + version: 3.0.4 + resolution: "no-case@npm:3.0.4" + dependencies: + lower-case: ^2.0.2 + tslib: ^2.0.3 + checksum: 0b2ebc113dfcf737d48dde49cfebf3ad2d82a8c3188e7100c6f375e30eafbef9e9124aadc3becef237b042fd5eb0aad2fd78669c20972d045bbe7fea8ba0be5c + languageName: node + linkType: hard + +"node-fetch@npm:^2.6.12": + version: 2.6.12 + resolution: "node-fetch@npm:2.6.12" + dependencies: + whatwg-url: ^5.0.0 + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true + checksum: 3bc1655203d47ee8e313c0d96664b9673a3d4dd8002740318e9d27d14ef306693a4b2ef8d6525775056fd912a19e23f3ac0d7111ad8925877b7567b29a625592 + languageName: node + linkType: hard + +"node-gyp-build@npm:^4.3.0": + version: 4.6.0 + resolution: "node-gyp-build@npm:4.6.0" + bin: + node-gyp-build: bin.js + node-gyp-build-optional: optional.js + node-gyp-build-test: build-test.js + checksum: 25d78c5ef1f8c24291f4a370c47ba52fcea14f39272041a90a7894cd50d766f7c8cb8fb06c0f42bf6f69b204b49d9be3c8fc344aac09714d5bdb95965499eb15 + languageName: node + linkType: hard + +"node-gyp@npm:latest": + version: 9.4.0 + resolution: "node-gyp@npm:9.4.0" + dependencies: + env-paths: ^2.2.0 + exponential-backoff: ^3.1.1 + glob: ^7.1.4 + graceful-fs: ^4.2.6 + make-fetch-happen: ^11.0.3 + nopt: ^6.0.0 + npmlog: ^6.0.0 + rimraf: ^3.0.2 + semver: ^7.3.5 + tar: ^6.1.2 + which: ^2.0.2 + bin: + node-gyp: bin/node-gyp.js + checksum: 78b404e2e0639d64e145845f7f5a3cb20c0520cdaf6dda2f6e025e9b644077202ea7de1232396ba5bde3fee84cdc79604feebe6ba3ec84d464c85d407bb5da99 + languageName: node + linkType: hard + +"nopt@npm:^6.0.0": + version: 6.0.0 + resolution: "nopt@npm:6.0.0" + dependencies: + abbrev: ^1.0.0 + bin: + nopt: bin/nopt.js + checksum: 82149371f8be0c4b9ec2f863cc6509a7fd0fa729929c009f3a58e4eb0c9e4cae9920e8f1f8eb46e7d032fec8fb01bede7f0f41a67eb3553b7b8e14fa53de1dac + languageName: node + linkType: hard + +"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": + version: 3.0.0 + resolution: "normalize-path@npm:3.0.0" + checksum: 88eeb4da891e10b1318c4b2476b6e2ecbeb5ff97d946815ffea7794c31a89017c70d7f34b3c2ebf23ef4e9fc9fb99f7dffe36da22011b5b5c6ffa34f4873ec20 + languageName: node + linkType: hard + +"npmlog@npm:^6.0.0": + version: 6.0.2 + resolution: "npmlog@npm:6.0.2" + dependencies: + are-we-there-yet: ^3.0.0 + console-control-strings: ^1.1.0 + gauge: ^4.0.3 + set-blocking: ^2.0.0 + checksum: ae238cd264a1c3f22091cdd9e2b106f684297d3c184f1146984ecbe18aaa86343953f26b9520dedd1b1372bc0316905b736c1932d778dbeb1fcf5a1001390e2a + languageName: node + linkType: hard + +"once@npm:^1.3.0": + version: 1.4.0 + resolution: "once@npm:1.4.0" + dependencies: + wrappy: 1 + checksum: cd0a88501333edd640d95f0d2700fbde6bff20b3d4d9bdc521bdd31af0656b5706570d6c6afe532045a20bb8dc0849f8332d6f2a416e0ba6d3d3b98806c7db68 + languageName: node + linkType: hard + +"p-limit@npm:^3.0.2": + version: 3.1.0 + resolution: "p-limit@npm:3.1.0" + dependencies: + yocto-queue: ^0.1.0 + checksum: 7c3690c4dbf62ef625671e20b7bdf1cbc9534e83352a2780f165b0d3ceba21907e77ad63401708145ca4e25bfc51636588d89a8c0aeb715e6c37d1c066430360 + languageName: node + linkType: hard + +"p-locate@npm:^5.0.0": + version: 5.0.0 + resolution: "p-locate@npm:5.0.0" + dependencies: + p-limit: ^3.0.2 + checksum: 1623088f36cf1cbca58e9b61c4e62bf0c60a07af5ae1ca99a720837356b5b6c5ba3eb1b2127e47a06865fee59dd0453cad7cc844cda9d5a62ac1a5a51b7c86d3 + languageName: node + linkType: hard + +"p-map@npm:^4.0.0": + version: 4.0.0 + resolution: "p-map@npm:4.0.0" + dependencies: + aggregate-error: ^3.0.0 + checksum: cb0ab21ec0f32ddffd31dfc250e3afa61e103ef43d957cc45497afe37513634589316de4eb88abdfd969fe6410c22c0b93ab24328833b8eb1ccc087fc0442a1c + languageName: node + linkType: hard + +"pako@npm:^2.0.3": + version: 2.1.0 + resolution: "pako@npm:2.1.0" + checksum: 71666548644c9a4d056bcaba849ca6fd7242c6cf1af0646d3346f3079a1c7f4a66ffec6f7369ee0dc88f61926c10d6ab05da3e1fca44b83551839e89edd75a3e + languageName: node + linkType: hard + +"path-exists@npm:^4.0.0": + version: 4.0.0 + resolution: "path-exists@npm:4.0.0" + checksum: 505807199dfb7c50737b057dd8d351b82c033029ab94cb10a657609e00c1bc53b951cfdbccab8de04c5584d5eff31128ce6afd3db79281874a5ef2adbba55ed1 + languageName: node + linkType: hard + +"path-is-absolute@npm:^1.0.0": + version: 1.0.1 + resolution: "path-is-absolute@npm:1.0.1" + checksum: 060840f92cf8effa293bcc1bea81281bd7d363731d214cbe5c227df207c34cd727430f70c6037b5159c8a870b9157cba65e775446b0ab06fd5ecc7e54615a3b8 + languageName: node + linkType: hard + +"path-key@npm:^3.1.0": + version: 3.1.1 + resolution: "path-key@npm:3.1.1" + checksum: 55cd7a9dd4b343412a8386a743f9c746ef196e57c823d90ca3ab917f90ab9f13dd0ded27252ba49dbdfcab2b091d998bc446f6220cd3cea65db407502a740020 + languageName: node + linkType: hard + +"path-scurry@npm:^1.10.1": + version: 1.10.1 + resolution: "path-scurry@npm:1.10.1" + dependencies: + lru-cache: ^9.1.1 || ^10.0.0 + minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 + checksum: e2557cff3a8fb8bc07afdd6ab163a92587884f9969b05bbbaf6fe7379348bfb09af9ed292af12ed32398b15fb443e81692047b786d1eeb6d898a51eb17ed7d90 + languageName: node + linkType: hard + +"pathval@npm:^1.1.1": + version: 1.1.1 + resolution: "pathval@npm:1.1.1" + checksum: 090e3147716647fb7fb5b4b8c8e5b55e5d0a6086d085b6cd23f3d3c01fcf0ff56fd3cc22f2f4a033bd2e46ed55d61ed8379e123b42afe7d531a2a5fc8bb556d6 + languageName: node + linkType: hard + +"picomatch@npm:^2.0.4, picomatch@npm:^2.2.1": + version: 2.3.1 + resolution: "picomatch@npm:2.3.1" + checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf + languageName: node + linkType: hard + +"prettier@npm:^2.6.2": + version: 2.8.8 + resolution: "prettier@npm:2.8.8" + bin: + prettier: bin-prettier.js + checksum: b49e409431bf129dd89238d64299ba80717b57ff5a6d1c1a8b1a28b590d998a34e083fa13573bc732bb8d2305becb4c9a4407f8486c81fa7d55100eb08263cf8 + languageName: node + linkType: hard + +"promise-retry@npm:^2.0.1": + version: 2.0.1 + resolution: "promise-retry@npm:2.0.1" + dependencies: + err-code: ^2.0.2 + retry: ^0.12.0 + checksum: f96a3f6d90b92b568a26f71e966cbbc0f63ab85ea6ff6c81284dc869b41510e6cdef99b6b65f9030f0db422bf7c96652a3fff9f2e8fb4a0f069d8f4430359429 + languageName: node + linkType: hard + +"randombytes@npm:^2.1.0": + version: 2.1.0 + resolution: "randombytes@npm:2.1.0" + dependencies: + safe-buffer: ^5.1.0 + checksum: d779499376bd4cbb435ef3ab9a957006c8682f343f14089ed5f27764e4645114196e75b7f6abf1cbd84fd247c0cb0651698444df8c9bf30e62120fbbc52269d6 + languageName: node + linkType: hard + +"readable-stream@npm:^3.6.0": + version: 3.6.2 + resolution: "readable-stream@npm:3.6.2" + dependencies: + inherits: ^2.0.3 + string_decoder: ^1.1.1 + util-deprecate: ^1.0.1 + checksum: bdcbe6c22e846b6af075e32cf8f4751c2576238c5043169a1c221c92ee2878458a816a4ea33f4c67623c0b6827c8a400409bfb3cf0bf3381392d0b1dfb52ac8d + languageName: node + linkType: hard + +"readdirp@npm:~3.6.0": + version: 3.6.0 + resolution: "readdirp@npm:3.6.0" + dependencies: + picomatch: ^2.2.1 + checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 + languageName: node + linkType: hard + +"regenerator-runtime@npm:^0.13.11": + version: 0.13.11 + resolution: "regenerator-runtime@npm:0.13.11" + checksum: 27481628d22a1c4e3ff551096a683b424242a216fee44685467307f14d58020af1e19660bf2e26064de946bad7eff28950eae9f8209d55723e2d9351e632bbb4 + languageName: node + linkType: hard + +"require-directory@npm:^2.1.1": + version: 2.1.1 + resolution: "require-directory@npm:2.1.1" + checksum: fb47e70bf0001fdeabdc0429d431863e9475e7e43ea5f94ad86503d918423c1543361cc5166d713eaa7029dd7a3d34775af04764bebff99ef413111a5af18c80 + languageName: node + linkType: hard + +"retry@npm:^0.12.0": + version: 0.12.0 + resolution: "retry@npm:0.12.0" + checksum: 623bd7d2e5119467ba66202d733ec3c2e2e26568074923bc0585b6b99db14f357e79bdedb63cab56cec47491c4a0da7e6021a7465ca6dc4f481d3898fdd3158c + languageName: node + linkType: hard + +"rimraf@npm:^3.0.2": + version: 3.0.2 + resolution: "rimraf@npm:3.0.2" + dependencies: + glob: ^7.1.3 + bin: + rimraf: bin.js + checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0 + languageName: node + linkType: hard + +"root-workspace-0b6124@workspace:.": + version: 0.0.0-use.local + resolution: "root-workspace-0b6124@workspace:." + dependencies: + "@coral-xyz/anchor": ^0.28.0 + "@solana/spl-token": ^0.3.8 + "@solana/web3.js": ^1.77.3 + "@types/bn.js": ^5.1.0 + "@types/chai": ^4.3.0 + "@types/mocha": ^9.0.0 + chai: ^4.3.4 + mocha: ^9.0.3 + prettier: ^2.6.2 + ts-mocha: ^10.0.0 + typescript: ^4.3.5 + languageName: unknown + linkType: soft + +"rpc-websockets@npm:^7.5.1": + version: 7.5.1 + resolution: "rpc-websockets@npm:7.5.1" + dependencies: + "@babel/runtime": ^7.17.2 + bufferutil: ^4.0.1 + eventemitter3: ^4.0.7 + utf-8-validate: ^5.0.2 + uuid: ^8.3.2 + ws: ^8.5.0 + dependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 9dda8c63a1d3e85e11597e1c364835ec6aa9a8de1b5cfb1629d0eafc3ae04509011d485025ed4f717c0b1dd048e2aafdd75080e866540b93e55fd8a2cd91bcfe + languageName: node + linkType: hard + +"safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:~5.2.0": + version: 5.2.1 + resolution: "safe-buffer@npm:5.2.1" + checksum: b99c4b41fdd67a6aaf280fcd05e9ffb0813654894223afb78a31f14a19ad220bba8aba1cb14eddce1fcfb037155fe6de4e861784eb434f7d11ed58d1e70dd491 + languageName: node + linkType: hard + +"safer-buffer@npm:>= 2.1.2 < 3.0.0": + version: 2.1.2 + resolution: "safer-buffer@npm:2.1.2" + checksum: cab8f25ae6f1434abee8d80023d7e72b598cf1327164ddab31003c51215526801e40b66c5e65d658a0af1e9d6478cadcb4c745f4bd6751f97d8644786c0978b0 + languageName: node + linkType: hard + +"semver@npm:^7.3.5": + version: 7.5.4 + resolution: "semver@npm:7.5.4" + dependencies: + lru-cache: ^6.0.0 + bin: + semver: bin/semver.js + checksum: 12d8ad952fa353b0995bf180cdac205a4068b759a140e5d3c608317098b3575ac2f1e09182206bf2eb26120e1c0ed8fb92c48c592f6099680de56bb071423ca3 + languageName: node + linkType: hard + +"serialize-javascript@npm:6.0.0": + version: 6.0.0 + resolution: "serialize-javascript@npm:6.0.0" + dependencies: + randombytes: ^2.1.0 + checksum: 56f90b562a1bdc92e55afb3e657c6397c01a902c588c0fe3d4c490efdcc97dcd2a3074ba12df9e94630f33a5ce5b76a74784a7041294628a6f4306e0ec84bf93 + languageName: node + linkType: hard + +"set-blocking@npm:^2.0.0": + version: 2.0.0 + resolution: "set-blocking@npm:2.0.0" + checksum: 6e65a05f7cf7ebdf8b7c75b101e18c0b7e3dff4940d480efed8aad3a36a4005140b660fa1d804cb8bce911cac290441dc728084a30504d3516ac2ff7ad607b02 + languageName: node + linkType: hard + +"shebang-command@npm:^2.0.0": + version: 2.0.0 + resolution: "shebang-command@npm:2.0.0" + dependencies: + shebang-regex: ^3.0.0 + checksum: 6b52fe87271c12968f6a054e60f6bde5f0f3d2db483a1e5c3e12d657c488a15474121a1d55cd958f6df026a54374ec38a4a963988c213b7570e1d51575cea7fa + languageName: node + linkType: hard + +"shebang-regex@npm:^3.0.0": + version: 3.0.0 + resolution: "shebang-regex@npm:3.0.0" + checksum: 1a2bcae50de99034fcd92ad4212d8e01eedf52c7ec7830eedcf886622804fe36884278f2be8be0ea5fde3fd1c23911643a4e0f726c8685b61871c8908af01222 + languageName: node + linkType: hard + +"signal-exit@npm:^3.0.7": + version: 3.0.7 + resolution: "signal-exit@npm:3.0.7" + checksum: a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 + languageName: node + linkType: hard + +"signal-exit@npm:^4.0.1": + version: 4.1.0 + resolution: "signal-exit@npm:4.1.0" + checksum: 64c757b498cb8629ffa5f75485340594d2f8189e9b08700e69199069c8e3070fb3e255f7ab873c05dc0b3cec412aea7402e10a5990cb6a050bd33ba062a6c549 + languageName: node + linkType: hard + +"smart-buffer@npm:^4.2.0": + version: 4.2.0 + resolution: "smart-buffer@npm:4.2.0" + checksum: b5167a7142c1da704c0e3af85c402002b597081dd9575031a90b4f229ca5678e9a36e8a374f1814c8156a725d17008ae3bde63b92f9cfd132526379e580bec8b + languageName: node + linkType: hard + +"snake-case@npm:^3.0.4": + version: 3.0.4 + resolution: "snake-case@npm:3.0.4" + dependencies: + dot-case: ^3.0.4 + tslib: ^2.0.3 + checksum: 0a7a79900bbb36f8aaa922cf111702a3647ac6165736d5dc96d3ef367efc50465cac70c53cd172c382b022dac72ec91710608e5393de71f76d7142e6fd80e8a3 + languageName: node + linkType: hard + +"socks-proxy-agent@npm:^7.0.0": + version: 7.0.0 + resolution: "socks-proxy-agent@npm:7.0.0" + dependencies: + agent-base: ^6.0.2 + debug: ^4.3.3 + socks: ^2.6.2 + checksum: 720554370154cbc979e2e9ce6a6ec6ced205d02757d8f5d93fe95adae454fc187a5cbfc6b022afab850a5ce9b4c7d73e0f98e381879cf45f66317a4895953846 + languageName: node + linkType: hard + +"socks@npm:^2.6.2": + version: 2.7.1 + resolution: "socks@npm:2.7.1" + dependencies: + ip: ^2.0.0 + smart-buffer: ^4.2.0 + checksum: 259d9e3e8e1c9809a7f5c32238c3d4d2a36b39b83851d0f573bfde5f21c4b1288417ce1af06af1452569cd1eb0841169afd4998f0e04ba04656f6b7f0e46d748 + languageName: node + linkType: hard + +"source-map-support@npm:^0.5.6": + version: 0.5.21 + resolution: "source-map-support@npm:0.5.21" + dependencies: + buffer-from: ^1.0.0 + source-map: ^0.6.0 + checksum: 43e98d700d79af1d36f859bdb7318e601dfc918c7ba2e98456118ebc4c4872b327773e5a1df09b0524e9e5063bb18f0934538eace60cca2710d1fa687645d137 + languageName: node + linkType: hard + +"source-map@npm:^0.6.0": + version: 0.6.1 + resolution: "source-map@npm:0.6.1" + checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2 + languageName: node + linkType: hard + +"ssri@npm:^10.0.0": + version: 10.0.4 + resolution: "ssri@npm:10.0.4" + dependencies: + minipass: ^5.0.0 + checksum: fb14da9f8a72b04eab163eb13a9dda11d5962cd2317f85457c4e0b575e9a6e0e3a6a87b5bf122c75cb36565830cd5f263fb457571bf6f1587eb5f95d095d6165 + languageName: node + linkType: hard + +"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": + version: 4.2.3 + resolution: "string-width@npm:4.2.3" + dependencies: + emoji-regex: ^8.0.0 + is-fullwidth-code-point: ^3.0.0 + strip-ansi: ^6.0.1 + checksum: e52c10dc3fbfcd6c3a15f159f54a90024241d0f149cf8aed2982a2d801d2e64df0bf1dc351cf8e95c3319323f9f220c16e740b06faecd53e2462df1d2b5443fb + languageName: node + linkType: hard + +"string-width@npm:^5.0.1, string-width@npm:^5.1.2": + version: 5.1.2 + resolution: "string-width@npm:5.1.2" + dependencies: + eastasianwidth: ^0.2.0 + emoji-regex: ^9.2.2 + strip-ansi: ^7.0.1 + checksum: 7369deaa29f21dda9a438686154b62c2c5f661f8dda60449088f9f980196f7908fc39fdd1803e3e01541970287cf5deae336798337e9319a7055af89dafa7193 + languageName: node + linkType: hard + +"string_decoder@npm:^1.1.1": + version: 1.3.0 + resolution: "string_decoder@npm:1.3.0" + dependencies: + safe-buffer: ~5.2.0 + checksum: 8417646695a66e73aefc4420eb3b84cc9ffd89572861fe004e6aeb13c7bc00e2f616247505d2dbbef24247c372f70268f594af7126f43548565c68c117bdeb56 + languageName: node + linkType: hard + +"strip-ansi-cjs@npm:strip-ansi@^6.0.1, strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1": + version: 6.0.1 + resolution: "strip-ansi@npm:6.0.1" + dependencies: + ansi-regex: ^5.0.1 + checksum: f3cd25890aef3ba6e1a74e20896c21a46f482e93df4a06567cebf2b57edabb15133f1f94e57434e0a958d61186087b1008e89c94875d019910a213181a14fc8c + languageName: node + linkType: hard + +"strip-ansi@npm:^7.0.1": + version: 7.1.0 + resolution: "strip-ansi@npm:7.1.0" + dependencies: + ansi-regex: ^6.0.1 + checksum: 859c73fcf27869c22a4e4d8c6acfe690064659e84bef9458aa6d13719d09ca88dcfd40cbf31fd0be63518ea1a643fe070b4827d353e09533a5b0b9fd4553d64d + languageName: node + linkType: hard + +"strip-bom@npm:^3.0.0": + version: 3.0.0 + resolution: "strip-bom@npm:3.0.0" + checksum: 8d50ff27b7ebe5ecc78f1fe1e00fcdff7af014e73cf724b46fb81ef889eeb1015fc5184b64e81a2efe002180f3ba431bdd77e300da5c6685d702780fbf0c8d5b + languageName: node + linkType: hard + +"strip-json-comments@npm:3.1.1": + version: 3.1.1 + resolution: "strip-json-comments@npm:3.1.1" + checksum: 492f73e27268f9b1c122733f28ecb0e7e8d8a531a6662efbd08e22cccb3f9475e90a1b82cab06a392f6afae6d2de636f977e231296400d0ec5304ba70f166443 + languageName: node + linkType: hard + +"superstruct@npm:^0.14.2": + version: 0.14.2 + resolution: "superstruct@npm:0.14.2" + checksum: c5c4840f432da82125b923ec45faca5113217e83ae416e314d80eae012b8bb603d2e745025d173450758d116348820bc7028157f8c9a72b6beae879f94b837c0 + languageName: node + linkType: hard + +"superstruct@npm:^0.15.4": + version: 0.15.5 + resolution: "superstruct@npm:0.15.5" + checksum: 6d1f5249fee789424b7178fa0a1ffb2ace629c5480c39505885bd8c0046a4ff8b267569a3442fa53b8c560a7ba6599cf3f8af94225aebeb2cf6023f7dd911050 + languageName: node + linkType: hard + +"supports-color@npm:8.1.1": + version: 8.1.1 + resolution: "supports-color@npm:8.1.1" + dependencies: + has-flag: ^4.0.0 + checksum: c052193a7e43c6cdc741eb7f378df605636e01ad434badf7324f17fb60c69a880d8d8fcdcb562cf94c2350e57b937d7425ab5b8326c67c2adc48f7c87c1db406 + languageName: node + linkType: hard + +"supports-color@npm:^7.1.0": + version: 7.2.0 + resolution: "supports-color@npm:7.2.0" + dependencies: + has-flag: ^4.0.0 + checksum: 3dda818de06ebbe5b9653e07842d9479f3555ebc77e9a0280caf5a14fb877ffee9ed57007c3b78f5a6324b8dbeec648d9e97a24e2ed9fdb81ddc69ea07100f4a + languageName: node + linkType: hard + +"tar@npm:^6.1.11, tar@npm:^6.1.2": + version: 6.1.15 + resolution: "tar@npm:6.1.15" + dependencies: + chownr: ^2.0.0 + fs-minipass: ^2.0.0 + minipass: ^5.0.0 + minizlib: ^2.1.1 + mkdirp: ^1.0.3 + yallist: ^4.0.0 + checksum: f23832fceeba7578bf31907aac744ae21e74a66f4a17a9e94507acf460e48f6db598c7023882db33bab75b80e027c21f276d405e4a0322d58f51c7088d428268 + languageName: node + linkType: hard + +"text-encoding-utf-8@npm:^1.0.2": + version: 1.0.2 + resolution: "text-encoding-utf-8@npm:1.0.2" + checksum: ec4c15d50e738c5dba7327ad432ebf0725ec75d4d69c0bd55609254c5a3bc5341272d7003691084a0a73d60d981c8eb0e87603676fdb6f3fed60f4c9192309f9 + languageName: node + linkType: hard + +"through@npm:>=2.2.7 <3": + version: 2.3.8 + resolution: "through@npm:2.3.8" + checksum: a38c3e059853c494af95d50c072b83f8b676a9ba2818dcc5b108ef252230735c54e0185437618596c790bbba8fcdaef5b290405981ffa09dce67b1f1bf190cbd + languageName: node + linkType: hard + +"to-regex-range@npm:^5.0.1": + version: 5.0.1 + resolution: "to-regex-range@npm:5.0.1" + dependencies: + is-number: ^7.0.0 + checksum: f76fa01b3d5be85db6a2a143e24df9f60dd047d151062d0ba3df62953f2f697b16fe5dad9b0ac6191c7efc7b1d9dcaa4b768174b7b29da89d4428e64bc0a20ed + languageName: node + linkType: hard + +"toml@npm:^3.0.0": + version: 3.0.0 + resolution: "toml@npm:3.0.0" + checksum: 5d7f1d8413ad7780e9bdecce8ea4c3f5130dd53b0a4f2e90b93340979a137739879d7b9ce2ce05c938b8cc828897fe9e95085197342a1377dd8850bf5125f15f + languageName: node + linkType: hard + +"tr46@npm:~0.0.3": + version: 0.0.3 + resolution: "tr46@npm:0.0.3" + checksum: 726321c5eaf41b5002e17ffbd1fb7245999a073e8979085dacd47c4b4e8068ff5777142fc6726d6ca1fd2ff16921b48788b87225cbc57c72636f6efa8efbffe3 + languageName: node + linkType: hard + +"ts-mocha@npm:^10.0.0": + version: 10.0.0 + resolution: "ts-mocha@npm:10.0.0" + dependencies: + ts-node: 7.0.1 + tsconfig-paths: ^3.5.0 + peerDependencies: + mocha: ^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X + dependenciesMeta: + tsconfig-paths: + optional: true + bin: + ts-mocha: bin/ts-mocha + checksum: b11f2a8ceecf195b0db724da429159982fef12e4357088fe900289223587217e8c126ead7929679edd58bf19ad96c5da5911535d26f535386632e18fbff10c40 + languageName: node + linkType: hard + +"ts-node@npm:7.0.1": + version: 7.0.1 + resolution: "ts-node@npm:7.0.1" + dependencies: + arrify: ^1.0.0 + buffer-from: ^1.1.0 + diff: ^3.1.0 + make-error: ^1.1.1 + minimist: ^1.2.0 + mkdirp: ^0.5.1 + source-map-support: ^0.5.6 + yn: ^2.0.0 + bin: + ts-node: dist/bin.js + checksum: 07ed6ea1805361828737a767cfd6c57ea6e267ee8679282afb933610af02405e1a87c1f2aea1d38ed8e66b34fcbf6272b6021ab95d78849105d2e57fc283870b + languageName: node + linkType: hard + +"tsconfig-paths@npm:^3.5.0": + version: 3.14.2 + resolution: "tsconfig-paths@npm:3.14.2" + dependencies: + "@types/json5": ^0.0.29 + json5: ^1.0.2 + minimist: ^1.2.6 + strip-bom: ^3.0.0 + checksum: a6162eaa1aed680537f93621b82399c7856afd10ec299867b13a0675e981acac4e0ec00896860480efc59fc10fd0b16fdc928c0b885865b52be62cadac692447 + languageName: node + linkType: hard + +"tslib@npm:^2.0.3": + version: 2.6.1 + resolution: "tslib@npm:2.6.1" + checksum: b0d176d176487905b66ae4d5856647df50e37beea7571c53b8d10ba9222c074b81f1410fb91da13debaf2cbc970663609068bdebafa844ea9d69b146527c38fe + languageName: node + linkType: hard + +"type-detect@npm:^4.0.0, type-detect@npm:^4.0.5": + version: 4.0.8 + resolution: "type-detect@npm:4.0.8" + checksum: 62b5628bff67c0eb0b66afa371bd73e230399a8d2ad30d852716efcc4656a7516904570cd8631a49a3ce57c10225adf5d0cbdcb47f6b0255fe6557c453925a15 + languageName: node + linkType: hard + +"typescript@npm:^4.3.5": + version: 4.9.5 + resolution: "typescript@npm:4.9.5" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db + languageName: node + linkType: hard + +"typescript@patch:typescript@^4.3.5#~builtin": + version: 4.9.5 + resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=289587" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 1f8f3b6aaea19f0f67cba79057674ba580438a7db55057eb89cc06950483c5d632115c14077f6663ea76fd09fce3c190e6414bb98582ec80aa5a4eaf345d5b68 + languageName: node + linkType: hard + +"unique-filename@npm:^3.0.0": + version: 3.0.0 + resolution: "unique-filename@npm:3.0.0" + dependencies: + unique-slug: ^4.0.0 + checksum: 8e2f59b356cb2e54aab14ff98a51ac6c45781d15ceaab6d4f1c2228b780193dc70fae4463ce9e1df4479cb9d3304d7c2043a3fb905bdeca71cc7e8ce27e063df + languageName: node + linkType: hard + +"unique-slug@npm:^4.0.0": + version: 4.0.0 + resolution: "unique-slug@npm:4.0.0" + dependencies: + imurmurhash: ^0.1.4 + checksum: 0884b58365af59f89739e6f71e3feacb5b1b41f2df2d842d0757933620e6de08eff347d27e9d499b43c40476cbaf7988638d3acb2ffbcb9d35fd035591adfd15 + languageName: node + linkType: hard + +"utf-8-validate@npm:^5.0.2": + version: 5.0.10 + resolution: "utf-8-validate@npm:5.0.10" + dependencies: + node-gyp: latest + node-gyp-build: ^4.3.0 + checksum: 5579350a023c66a2326752b6c8804cc7b39dcd251bb088241da38db994b8d78352e388dcc24ad398ab98385ba3c5ffcadb6b5b14b2637e43f767869055e46ba6 + languageName: node + linkType: hard + +"util-deprecate@npm:^1.0.1": + version: 1.0.2 + resolution: "util-deprecate@npm:1.0.2" + checksum: 474acf1146cb2701fe3b074892217553dfcf9a031280919ba1b8d651a068c9b15d863b7303cb15bd00a862b498e6cf4ad7b4a08fb134edd5a6f7641681cb54a2 + languageName: node + linkType: hard + +"uuid@npm:^8.3.2": + version: 8.3.2 + resolution: "uuid@npm:8.3.2" + bin: + uuid: dist/bin/uuid + checksum: 5575a8a75c13120e2f10e6ddc801b2c7ed7d8f3c8ac22c7ed0c7b2ba6383ec0abda88c905085d630e251719e0777045ae3236f04c812184b7c765f63a70e58df + languageName: node + linkType: hard + +"webidl-conversions@npm:^3.0.0": + version: 3.0.1 + resolution: "webidl-conversions@npm:3.0.1" + checksum: c92a0a6ab95314bde9c32e1d0a6dfac83b578f8fa5f21e675bc2706ed6981bc26b7eb7e6a1fab158e5ce4adf9caa4a0aee49a52505d4d13c7be545f15021b17c + languageName: node + linkType: hard + +"whatwg-url@npm:^5.0.0": + version: 5.0.0 + resolution: "whatwg-url@npm:5.0.0" + dependencies: + tr46: ~0.0.3 + webidl-conversions: ^3.0.0 + checksum: b8daed4ad3356cc4899048a15b2c143a9aed0dfae1f611ebd55073310c7b910f522ad75d727346ad64203d7e6c79ef25eafd465f4d12775ca44b90fa82ed9e2c + languageName: node + linkType: hard + +"which@npm:2.0.2, which@npm:^2.0.1, which@npm:^2.0.2": + version: 2.0.2 + resolution: "which@npm:2.0.2" + dependencies: + isexe: ^2.0.0 + bin: + node-which: ./bin/node-which + checksum: 1a5c563d3c1b52d5f893c8b61afe11abc3bab4afac492e8da5bde69d550de701cf9806235f20a47b5c8fa8a1d6a9135841de2596535e998027a54589000e66d1 + languageName: node + linkType: hard + +"wide-align@npm:^1.1.5": + version: 1.1.5 + resolution: "wide-align@npm:1.1.5" + dependencies: + string-width: ^1.0.2 || 2 || 3 || 4 + checksum: d5fc37cd561f9daee3c80e03b92ed3e84d80dde3365a8767263d03dacfc8fa06b065ffe1df00d8c2a09f731482fcacae745abfbb478d4af36d0a891fad4834d3 + languageName: node + linkType: hard + +"workerpool@npm:6.2.0": + version: 6.2.0 + resolution: "workerpool@npm:6.2.0" + checksum: 3493b4f0ef979a23d2c1583d7ef85f62fc9463cc02f82829d3e7e663b517f8ae9707da0249b382e46ac58986deb0ca2232ee1081713741211bda9254b429c9bb + languageName: node + linkType: hard + +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0, wrap-ansi@npm:^7.0.0": + version: 7.0.0 + resolution: "wrap-ansi@npm:7.0.0" + dependencies: + ansi-styles: ^4.0.0 + string-width: ^4.1.0 + strip-ansi: ^6.0.0 + checksum: a790b846fd4505de962ba728a21aaeda189b8ee1c7568ca5e817d85930e06ef8d1689d49dbf0e881e8ef84436af3a88bc49115c2e2788d841ff1b8b5b51a608b + languageName: node + linkType: hard + +"wrap-ansi@npm:^8.1.0": + version: 8.1.0 + resolution: "wrap-ansi@npm:8.1.0" + dependencies: + ansi-styles: ^6.1.0 + string-width: ^5.0.1 + strip-ansi: ^7.0.1 + checksum: 371733296dc2d616900ce15a0049dca0ef67597d6394c57347ba334393599e800bab03c41d4d45221b6bc967b8c453ec3ae4749eff3894202d16800fdfe0e238 + languageName: node + linkType: hard + +"wrappy@npm:1": + version: 1.0.2 + resolution: "wrappy@npm:1.0.2" + checksum: 159da4805f7e84a3d003d8841557196034155008f817172d4e986bd591f74aa82aa7db55929a54222309e01079a65a92a9e6414da5a6aa4b01ee44a511ac3ee5 + languageName: node + linkType: hard + +"ws@npm:^7.4.5": + version: 7.5.9 + resolution: "ws@npm:7.5.9" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: c3c100a181b731f40b7f2fddf004aa023f79d64f489706a28bc23ff88e87f6a64b3c6651fbec3a84a53960b75159574d7a7385709847a62ddb7ad6af76f49138 + languageName: node + linkType: hard + +"ws@npm:^8.5.0": + version: 8.13.0 + resolution: "ws@npm:8.13.0" + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ">=5.0.2" + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + checksum: 53e991bbf928faf5dc6efac9b8eb9ab6497c69feeb94f963d648b7a3530a720b19ec2e0ec037344257e05a4f35bd9ad04d9de6f289615ffb133282031b18c61c + languageName: node + linkType: hard + +"y18n@npm:^5.0.5": + version: 5.0.8 + resolution: "y18n@npm:5.0.8" + checksum: 54f0fb95621ee60898a38c572c515659e51cc9d9f787fb109cef6fde4befbe1c4602dc999d30110feee37456ad0f1660fa2edcfde6a9a740f86a290999550d30 + languageName: node + linkType: hard + +"yallist@npm:^4.0.0": + version: 4.0.0 + resolution: "yallist@npm:4.0.0" + checksum: 343617202af32df2a15a3be36a5a8c0c8545208f3d3dfbc6bb7c3e3b7e8c6f8e7485432e4f3b88da3031a6e20afa7c711eded32ddfb122896ac5d914e75848d5 + languageName: node + linkType: hard + +"yargs-parser@npm:20.2.4": + version: 20.2.4 + resolution: "yargs-parser@npm:20.2.4" + checksum: d251998a374b2743a20271c2fd752b9fbef24eb881d53a3b99a7caa5e8227fcafd9abf1f345ac5de46435821be25ec12189a11030c12ee6481fef6863ed8b924 + languageName: node + linkType: hard + +"yargs-parser@npm:^20.2.2": + version: 20.2.9 + resolution: "yargs-parser@npm:20.2.9" + checksum: 8bb69015f2b0ff9e17b2c8e6bfe224ab463dd00ca211eece72a4cd8a906224d2703fb8a326d36fdd0e68701e201b2a60ed7cf81ce0fd9b3799f9fe7745977ae3 + languageName: node + linkType: hard + +"yargs-unparser@npm:2.0.0": + version: 2.0.0 + resolution: "yargs-unparser@npm:2.0.0" + dependencies: + camelcase: ^6.0.0 + decamelize: ^4.0.0 + flat: ^5.0.2 + is-plain-obj: ^2.1.0 + checksum: 68f9a542c6927c3768c2f16c28f71b19008710abd6b8f8efbac6dcce26bbb68ab6503bed1d5994bdbc2df9a5c87c161110c1dfe04c6a3fe5c6ad1b0e15d9a8a3 + languageName: node + linkType: hard + +"yargs@npm:16.2.0": + version: 16.2.0 + resolution: "yargs@npm:16.2.0" + dependencies: + cliui: ^7.0.2 + escalade: ^3.1.1 + get-caller-file: ^2.0.5 + require-directory: ^2.1.1 + string-width: ^4.2.0 + y18n: ^5.0.5 + yargs-parser: ^20.2.2 + checksum: b14afbb51e3251a204d81937c86a7e9d4bdbf9a2bcee38226c900d00f522969ab675703bee2a6f99f8e20103f608382936034e64d921b74df82b63c07c5e8f59 + languageName: node + linkType: hard + +"yn@npm:^2.0.0": + version: 2.0.0 + resolution: "yn@npm:2.0.0" + checksum: 9d49527cb3e9a0948cc057223810bf30607bf04b9ff7666cc1681a6501d660b60d90000c16f9e29311b0f28d8a06222ada565ccdca5f1049cdfefb1908217572 + languageName: node + linkType: hard + +"yocto-queue@npm:^0.1.0": + version: 0.1.0 + resolution: "yocto-queue@npm:0.1.0" + checksum: f77b3d8d00310def622123df93d4ee654fc6a0096182af8bd60679ddcdfb3474c56c6c7190817c84a2785648cdee9d721c0154eb45698c62176c322fb46fc700 + languageName: node + linkType: hard From 136d04e78c6b62a38881656704fa9a4a861c2494 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Mon, 31 Jul 2023 19:06:41 +0100 Subject: [PATCH 028/205] Remove second signers from adding minter and guardian --- .../solana/programs/tbtc/src/processor/admin/add_guardian.rs | 3 ++- .../solana/programs/tbtc/src/processor/admin/add_minter.rs | 3 ++- cross-chain/solana/tests/01__tbtc.ts | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs index ccce8f25b..cd79f2d5e 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs @@ -12,7 +12,8 @@ pub struct AddGuardian<'info> { )] pub tbtc: Account<'info, Tbtc>, pub authority: Signer<'info>, - pub guardian: Signer<'info>, + /// CHECK: the guardian does not need to sign + pub guardian: UncheckedAccount<'info>, #[account(mut)] pub payer: Signer<'info>, #[account( diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs index 82db6f436..f263dafe6 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs @@ -12,7 +12,8 @@ pub struct AddMinter<'info> { )] pub tbtc: Account<'info, Tbtc>, pub authority: Signer<'info>, - pub minter: Signer<'info>, + /// CHECK: the minter does not need to sign + pub minter: UncheckedAccount<'info>, #[account(mut)] pub payer: Signer<'info>, #[account( diff --git a/cross-chain/solana/tests/01__tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts index 53e71e1da..f5976b7e1 100644 --- a/cross-chain/solana/tests/01__tbtc.ts +++ b/cross-chain/solana/tests/01__tbtc.ts @@ -122,7 +122,7 @@ async function addMinter( payer: payer.publicKey, minterInfo: minterInfoPDA, }) - .signers(maybeAuthorityAnd(authority, [minter])) + .signers(maybeAuthorityAnd(authority, [])) .rpc(); return minterInfoPDA; } @@ -189,7 +189,7 @@ async function addGuardian( payer: payer.publicKey, guardianInfo: guardianInfoPDA, }) - .signers(maybeAuthorityAnd(authority, [guardian])) + .signers(maybeAuthorityAnd(authority, [])) .rpc(); return guardianInfoPDA; } From 5c180246fc3bf7a00ce45130e516b7a5f13a3a0d Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Mon, 31 Jul 2023 19:09:35 +0100 Subject: [PATCH 029/205] Remove autocompleted typo from wormhole_gateway --- cross-chain/solana/programs/wormhole-gateway/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/cross-chain/solana/programs/wormhole-gateway/src/lib.rs b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs index 245124cbb..4b3223473 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/lib.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs @@ -12,7 +12,6 @@ declare_id!("8H9F5JGbEMyERycwaGuzLS5MQnV7dn2wm2h6egJ3Leiu"); #[program] pub mod wormhole_gateway { - use std::os::unix::process; use super::*; From 89f4a0b6a37ace9d2b30f167d2ca5a10179c6879 Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Mon, 31 Jul 2023 13:47:13 -0500 Subject: [PATCH 030/205] solana: refactor tbtc program state: tbtc -> config make config pda (remove generated keypair) fix tests --- cross-chain/solana/programs/tbtc/src/lib.rs | 8 +- .../tbtc/src/processor/admin/add_guardian.rs | 32 +- .../tbtc/src/processor/admin/add_minter.rs | 32 +- .../src/processor/admin/change_authority.rs | 16 +- .../tbtc/src/processor/admin/initialize.rs | 35 +- .../tbtc/src/processor/admin/pause.rs | 18 +- .../src/processor/admin/remove_guardian.rs | 20 +- .../tbtc/src/processor/admin/remove_minter.rs | 24 +- .../tbtc/src/processor/admin/unpause.rs | 15 +- .../programs/tbtc/src/processor/mint/mint.rs | 70 ++-- .../solana/programs/tbtc/src/state/config.rs | 23 ++ .../programs/tbtc/src/state/guardian_info.rs | 7 +- .../programs/tbtc/src/state/minter_info.rs | 9 +- .../solana/programs/tbtc/src/state/mod.rs | 11 +- .../solana/programs/tbtc/src/state/tbtc.rs | 23 -- cross-chain/solana/tests/01__tbtc.ts | 383 +++++++++--------- 16 files changed, 380 insertions(+), 346 deletions(-) create mode 100644 cross-chain/solana/programs/tbtc/src/state/config.rs delete mode 100644 cross-chain/solana/programs/tbtc/src/state/tbtc.rs diff --git a/cross-chain/solana/programs/tbtc/src/lib.rs b/cross-chain/solana/programs/tbtc/src/lib.rs index 94a987451..5accd9bc8 100644 --- a/cross-chain/solana/programs/tbtc/src/lib.rs +++ b/cross-chain/solana/programs/tbtc/src/lib.rs @@ -29,16 +29,16 @@ pub mod tbtc { processor::add_minter(ctx) } - pub fn remove_minter(ctx: Context, minter: Pubkey) -> Result<()> { - processor::remove_minter(ctx, minter) + pub fn remove_minter(ctx: Context) -> Result<()> { + processor::remove_minter(ctx) } pub fn add_guardian(ctx: Context) -> Result<()> { processor::add_guardian(ctx) } - pub fn remove_guardian(ctx: Context, guardian: Pubkey) -> Result<()> { - processor::remove_guardian(ctx, guardian) + pub fn remove_guardian(ctx: Context) -> Result<()> { + processor::remove_guardian(ctx) } pub fn pause(ctx: Context) -> Result<()> { diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs index cd79f2d5e..422bac905 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{GuardianInfo, Tbtc}, + state::{Config, GuardianInfo}, }; use anchor_lang::prelude::*; @@ -8,30 +8,36 @@ use anchor_lang::prelude::*; pub struct AddGuardian<'info> { #[account( mut, + seeds = [Config::SEED_PREFIX], + bump, has_one = authority @ TbtcError::IsNotAuthority )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, - /// CHECK: the guardian does not need to sign - pub guardian: UncheckedAccount<'info>, + config: Account<'info, Config>, + #[account(mut)] - pub payer: Signer<'info>, + authority: Signer<'info>, + #[account( init, - payer = payer, - space = GuardianInfo::MAXIMUM_SIZE, - seeds = [GuardianInfo::SEED_PREFIX, tbtc.key().as_ref(), guardian.key().as_ref()], bump + payer = authority, + space = 8 + GuardianInfo::INIT_SPACE, + seeds = [GuardianInfo::SEED_PREFIX, guardian.key().as_ref()], + bump )] - pub guardian_info: Account<'info, GuardianInfo>, - pub system_program: Program<'info, System>, + guardian_info: Account<'info, GuardianInfo>, + + /// CHECK: Required authority to pause contract. This pubkey lives in `GuardianInfo`. + guardian: AccountInfo<'info>, + + system_program: Program<'info, System>, } pub fn add_guardian(ctx: Context) -> Result<()> { ctx.accounts.guardian_info.set_inner(GuardianInfo { guardian: ctx.accounts.guardian.key(), - bump: *ctx.bumps.get("guardian_info").unwrap(), + bump: ctx.bumps["guardian_info"], }); - ctx.accounts.tbtc.guardians += 1; + ctx.accounts.config.num_guardians += 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs index f263dafe6..ccb8620cb 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{MinterInfo, Tbtc}, + state::{Config, MinterInfo}, }; use anchor_lang::prelude::*; @@ -8,30 +8,36 @@ use anchor_lang::prelude::*; pub struct AddMinter<'info> { #[account( mut, + seeds = [Config::SEED_PREFIX], + bump, has_one = authority @ TbtcError::IsNotAuthority )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, - /// CHECK: the minter does not need to sign - pub minter: UncheckedAccount<'info>, + config: Account<'info, Config>, + #[account(mut)] - pub payer: Signer<'info>, + authority: Signer<'info>, + #[account( init, - payer = payer, - space = MinterInfo::MAXIMUM_SIZE, - seeds = [MinterInfo::SEED_PREFIX, tbtc.key().as_ref(), minter.key().as_ref()], bump + payer = authority, + space = 8 + MinterInfo::INIT_SPACE, + seeds = [MinterInfo::SEED_PREFIX, minter.key().as_ref()], + bump )] - pub minter_info: Account<'info, MinterInfo>, - pub system_program: Program<'info, System>, + minter_info: Account<'info, MinterInfo>, + + /// CHECK: Required authority to mint tokens. This pubkey lives in `MinterInfo`. + minter: AccountInfo<'info>, + + system_program: Program<'info, System>, } pub fn add_minter(ctx: Context) -> Result<()> { ctx.accounts.minter_info.set_inner(MinterInfo { minter: ctx.accounts.minter.key(), - bump: *ctx.bumps.get("minter_info").unwrap(), + bump: ctx.bumps["minter_info"], }); - ctx.accounts.tbtc.minters += 1; + ctx.accounts.config.num_minters += 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs index 2526c88f7..d2d0d1669 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs @@ -1,20 +1,22 @@ -use crate::{error::TbtcError, state::Tbtc}; +use crate::{error::TbtcError, state::Config}; use anchor_lang::prelude::*; #[derive(Accounts)] pub struct ChangeAuthority<'info> { #[account( mut, + seeds = [Config::SEED_PREFIX], + bump, has_one = authority @ TbtcError::IsNotAuthority )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, - #[account(mut)] - pub payer: Signer<'info>, - pub new_authority: Signer<'info>, + config: Account<'info, Config>, + + authority: Signer<'info>, + + new_authority: Signer<'info>, } pub fn change_authority(ctx: Context) -> Result<()> { - ctx.accounts.tbtc.authority = ctx.accounts.new_authority.key(); + ctx.accounts.config.authority = ctx.accounts.new_authority.key(); Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs index d4feff73b..9b418ddfd 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs @@ -1,4 +1,4 @@ -use crate::{constants::SEED_PREFIX_TBTC_MINT, state::Tbtc}; +use crate::{constants::SEED_PREFIX_TBTC_MINT, state::Config}; use anchor_lang::prelude::*; use anchor_spl::token; @@ -8,31 +8,38 @@ pub struct Initialize<'info> { // so we can sign for it from the program #[account( init, - seeds = [SEED_PREFIX_TBTC_MINT, tbtc.key().as_ref()], + seeds = [SEED_PREFIX_TBTC_MINT], bump, payer = authority, mint::decimals = 9, - mint::authority = tbtc_mint, + mint::authority = config, )] - pub tbtc_mint: Account<'info, token::Mint>, + mint: Account<'info, token::Mint>, - #[account(init, payer = authority, space = Tbtc::MAXIMUM_SIZE)] - pub tbtc: Account<'info, Tbtc>, + #[account( + init, + payer = authority, + space = 8 + Config::INIT_SPACE, + seeds = [Config::SEED_PREFIX], + bump, + )] + config: Account<'info, Config>, #[account(mut)] - pub authority: Signer<'info>, + authority: Signer<'info>, - pub token_program: Program<'info, token::Token>, - pub system_program: Program<'info, System>, + token_program: Program<'info, token::Token>, + system_program: Program<'info, System>, } pub fn initialize(ctx: Context) -> Result<()> { - ctx.accounts.tbtc.set_inner(Tbtc { + ctx.accounts.config.set_inner(Config { + bump: ctx.bumps["config"], authority: ctx.accounts.authority.key(), - token_mint: ctx.accounts.tbtc_mint.key(), - token_bump: *ctx.bumps.get("tbtc_mint").unwrap(), - minters: 0, - guardians: 0, + mint: ctx.accounts.mint.key(), + mint_bump: ctx.bumps["mint"], + num_minters: 0, + num_guardians: 0, paused: false, }); Ok(()) diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs index 798b2b79f..afa376f8a 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{GuardianInfo, Tbtc}, + state::{Config, GuardianInfo}, }; use anchor_lang::prelude::*; @@ -8,19 +8,23 @@ use anchor_lang::prelude::*; pub struct Pause<'info> { #[account( mut, - constraint = !tbtc.paused @ TbtcError::IsPaused + seeds = [Config::SEED_PREFIX], + bump, + constraint = !config.paused @ TbtcError::IsPaused )] - pub tbtc: Account<'info, Tbtc>, + config: Account<'info, Config>, + #[account( has_one = guardian, - seeds = [GuardianInfo::SEED_PREFIX, tbtc.key().as_ref(), guardian.key().as_ref()], + seeds = [GuardianInfo::SEED_PREFIX, guardian.key().as_ref()], bump = guardian_info.bump )] - pub guardian_info: Account<'info, GuardianInfo>, - pub guardian: Signer<'info>, + guardian_info: Account<'info, GuardianInfo>, + + guardian: Signer<'info>, } pub fn pause(ctx: Context) -> Result<()> { - ctx.accounts.tbtc.paused = true; + ctx.accounts.config.paused = true; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs index 9fb2f1aea..777edf865 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs @@ -1,29 +1,33 @@ use crate::{ error::TbtcError, - state::{GuardianInfo, Tbtc}, + state::{Config, GuardianInfo}, }; use anchor_lang::prelude::*; #[derive(Accounts)] -#[instruction(guardian: Pubkey)] pub struct RemoveGuardian<'info> { #[account( mut, has_one = authority @ TbtcError::IsNotAuthority, )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, + config: Account<'info, Config>, + + authority: Signer<'info>, + #[account( mut, has_one = guardian, close = authority, - seeds = [GuardianInfo::SEED_PREFIX, tbtc.key().as_ref(), guardian.as_ref()], + seeds = [GuardianInfo::SEED_PREFIX, guardian.key().as_ref()], bump = guardian_info.bump, )] - pub guardian_info: Account<'info, GuardianInfo>, + guardian_info: Account<'info, GuardianInfo>, + + /// CHECK: Required authority to pause contract. This pubkey lives in `GuardianInfo`. + guardian: AccountInfo<'info>, } -pub fn remove_guardian(ctx: Context, _guardian: Pubkey) -> Result<()> { - ctx.accounts.tbtc.guardians -= 1; +pub fn remove_guardian(ctx: Context) -> Result<()> { + ctx.accounts.config.num_guardians -= 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs index 9ed557727..83aa5a07d 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs @@ -1,29 +1,35 @@ use crate::{ error::TbtcError, - state::{MinterInfo, Tbtc}, + state::{Config, MinterInfo}, }; use anchor_lang::prelude::*; #[derive(Accounts)] -#[instruction(minter: Pubkey)] pub struct RemoveMinter<'info> { #[account( mut, + seeds = [Config::SEED_PREFIX], + bump, has_one = authority @ TbtcError::IsNotAuthority )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, + config: Account<'info, Config>, + + authority: Signer<'info>, + #[account( mut, - constraint = minter_info.minter == minter, + has_one = minter, close = authority, - seeds = [MinterInfo::SEED_PREFIX, tbtc.key().as_ref(), minter.as_ref()], + seeds = [MinterInfo::SEED_PREFIX, minter.key().as_ref()], bump = minter_info.bump, )] - pub minter_info: Account<'info, MinterInfo>, + minter_info: Account<'info, MinterInfo>, + + /// CHECK: Required authority to mint tokens. This pubkey lives in `MinterInfo`. + minter: AccountInfo<'info>, } -pub fn remove_minter(ctx: Context, _minter: Pubkey) -> Result<()> { - ctx.accounts.tbtc.minters -= 1; +pub fn remove_minter(ctx: Context) -> Result<()> { + ctx.accounts.config.num_minters -= 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs index a8c46c759..024a20685 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs @@ -1,18 +1,21 @@ -use crate::{error::TbtcError, state::Tbtc}; +use crate::{error::TbtcError, state::Config}; use anchor_lang::prelude::*; #[derive(Accounts)] pub struct Unpause<'info> { #[account( mut, - constraint = tbtc.paused @ TbtcError::IsNotPaused, - has_one = authority @ TbtcError::IsNotAuthority + seeds = [Config::SEED_PREFIX], + bump, + has_one = authority @ TbtcError::IsNotAuthority, + constraint = config.paused @ TbtcError::IsNotPaused )] - pub tbtc: Account<'info, Tbtc>, - pub authority: Signer<'info>, + config: Account<'info, Config>, + + authority: Signer<'info>, } pub fn unpause(ctx: Context) -> Result<()> { - ctx.accounts.tbtc.paused = false; + ctx.accounts.config.paused = false; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs b/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs index aaf3517a9..c32ab15e5 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs @@ -1,73 +1,59 @@ use crate::{ constants::SEED_PREFIX_TBTC_MINT, error::TbtcError, - state::{MinterInfo, Tbtc}, + state::{Config, MinterInfo}, }; use anchor_lang::prelude::*; -use anchor_spl::{associated_token::AssociatedToken, token}; +use anchor_spl::token; #[derive(Accounts)] pub struct Mint<'info> { // Use the correct token mint for the program. #[account( mut, - seeds = [SEED_PREFIX_TBTC_MINT, tbtc.key().as_ref()], - bump = tbtc.token_bump, - mint::decimals = 9, - mint::authority = tbtc_mint, + seeds = [SEED_PREFIX_TBTC_MINT], + bump = config.mint_bump, + mint::authority = config, )] - pub tbtc_mint: Account<'info, token::Mint>, + mint: Account<'info, token::Mint>, // Can not mint when paused. #[account( - constraint = !tbtc.paused @ TbtcError::IsPaused + constraint = !config.paused @ TbtcError::IsPaused )] - pub tbtc: Account<'info, Tbtc>, + config: Account<'info, Config>, // Require the signing minter to match a valid minter info. #[account( has_one = minter, - seeds = [MinterInfo::SEED_PREFIX, tbtc.key().as_ref(), minter.key().as_ref()], + seeds = [MinterInfo::SEED_PREFIX, minter.key().as_ref()], bump = minter_info.bump, )] - pub minter_info: Account<'info, MinterInfo>, - pub minter: Signer<'info>, + minter_info: Account<'info, MinterInfo>, + minter: Signer<'info>, // Use the associated token account for the recipient. #[account( - init_if_needed, - payer = payer, - associated_token::mint = tbtc_mint, - associated_token::authority = recipient, + mut, + token::mint = mint, )] - pub recipient_account: Account<'info, token::TokenAccount>, - /// CHECK: the recipient doesn't need to sign the mint, - /// and it doesn't conform to any specific rules. - /// Validating the recipient is the minter's responsibility. - pub recipient: UncheckedAccount<'info>, - - #[account(mut)] - pub payer: Signer<'info>, + recipient_token: Account<'info, token::TokenAccount>, - pub token_program: Program<'info, token::Token>, - pub associated_token_program: Program<'info, AssociatedToken>, - pub system_program: Program<'info, System>, + token_program: Program<'info, token::Token>, + system_program: Program<'info, System>, } pub fn mint(ctx: Context, amount: u64) -> Result<()> { - let seed_prefix = SEED_PREFIX_TBTC_MINT; - let key_seed = ctx.accounts.tbtc.key(); - let mint_bump = ctx.accounts.tbtc.token_bump; - let signer: &[&[&[u8]]] = &[&[seed_prefix, key_seed.as_ref(), &[mint_bump]]]; - - let cpi_ctx = CpiContext::new_with_signer( - ctx.accounts.token_program.to_account_info(), - token::MintTo { - mint: ctx.accounts.tbtc_mint.to_account_info(), - to: ctx.accounts.recipient_account.to_account_info(), - authority: ctx.accounts.tbtc_mint.to_account_info(), - }, - signer, - ); - token::mint_to(cpi_ctx, amount) + token::mint_to( + CpiContext::new_with_signer( + ctx.accounts.token_program.to_account_info(), + token::MintTo { + mint: ctx.accounts.mint.to_account_info(), + to: ctx.accounts.recipient_token.to_account_info(), + authority: ctx.accounts.config.to_account_info(), + }, + &[&[Config::SEED_PREFIX, &[ctx.accounts.config.bump]]], + ), + amount, + ) } diff --git a/cross-chain/solana/programs/tbtc/src/state/config.rs b/cross-chain/solana/programs/tbtc/src/state/config.rs new file mode 100644 index 000000000..4dd81b69c --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/state/config.rs @@ -0,0 +1,23 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Debug, InitSpace)] +pub struct Config { + pub bump: u8, + + /// The authority over this program. + pub authority: Pubkey, + + // Mint info. + pub mint: Pubkey, + pub mint_bump: u8, + + // Admin info. + pub num_minters: u8, + pub num_guardians: u8, + pub paused: bool, +} + +impl Config { + pub const SEED_PREFIX: &'static [u8] = b"config"; +} diff --git a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs index 656b767bb..00364eac5 100644 --- a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs @@ -1,17 +1,12 @@ use anchor_lang::prelude::*; #[account] -#[derive(Default)] +#[derive(Debug, InitSpace)] pub struct GuardianInfo { pub guardian: Pubkey, pub bump: u8, } impl GuardianInfo { - pub fn is_guardian(&self, key: &Pubkey) -> bool { - self.guardian == *key - } - - pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; // discriminator + pubkey + bump pub const SEED_PREFIX: &'static [u8; 13] = b"guardian-info"; } diff --git a/cross-chain/solana/programs/tbtc/src/state/minter_info.rs b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs index 978f6ff9d..e8b6a6eeb 100644 --- a/cross-chain/solana/programs/tbtc/src/state/minter_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs @@ -1,17 +1,12 @@ use anchor_lang::prelude::*; #[account] -#[derive(Default)] +#[derive(Debug, InitSpace)] pub struct MinterInfo { pub minter: Pubkey, pub bump: u8, } impl MinterInfo { - pub fn is_minter(&self, key: &Pubkey) -> bool { - self.minter == *key - } - - pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; // discriminator + pubkey + bump - pub const SEED_PREFIX: &'static [u8; 11] = b"minter-info"; + pub const SEED_PREFIX: &'static [u8] = b"minter-info"; } diff --git a/cross-chain/solana/programs/tbtc/src/state/mod.rs b/cross-chain/solana/programs/tbtc/src/state/mod.rs index abfdadb81..dffd4099b 100644 --- a/cross-chain/solana/programs/tbtc/src/state/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/state/mod.rs @@ -1,7 +1,8 @@ +mod config; +pub use config::*; + +mod guardian_info; pub use guardian_info::*; -pub use minter_info::*; -pub use tbtc::*; -pub mod guardian_info; -pub mod minter_info; -pub mod tbtc; +mod minter_info; +pub use minter_info::*; diff --git a/cross-chain/solana/programs/tbtc/src/state/tbtc.rs b/cross-chain/solana/programs/tbtc/src/state/tbtc.rs deleted file mode 100644 index c5a3027b7..000000000 --- a/cross-chain/solana/programs/tbtc/src/state/tbtc.rs +++ /dev/null @@ -1,23 +0,0 @@ -use anchor_lang::prelude::*; - -#[account] -#[derive(Default)] -pub struct Tbtc { - pub authority: Pubkey, - pub token_mint: Pubkey, - pub token_bump: u8, - pub minters: u8, - pub guardians: u8, - pub paused: bool, -} - -impl Tbtc { - // 8 discriminator - // 32 pubkey - // 32 pubkey - // 1 u8 - // 1 u8 - // 1 u8 - // 1 bool - pub const MAXIMUM_SIZE: usize = 8 + 32 + 32 + 1 + 1 + 1 + 1; -} diff --git a/cross-chain/solana/tests/01__tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts index f5976b7e1..fad8af5da 100644 --- a/cross-chain/solana/tests/01__tbtc.ts +++ b/cross-chain/solana/tests/01__tbtc.ts @@ -4,6 +4,7 @@ import * as spl from "@solana/spl-token"; import * as web3 from '@solana/web3.js'; import { Tbtc } from "../target/types/tbtc"; import { expect } from 'chai'; +import { ASSOCIATED_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; function maybeAuthorityAnd( signer, @@ -14,53 +15,52 @@ function maybeAuthorityAnd( async function setup( program: Program, - tbtc, authority ) { - const [tbtcMintPDA, _] = getTokenPDA(program, tbtc); - + const [config,] = getConfigPDA(program); + const [tbtcMintPDA, _] = getTokenPDA(program); + await program.methods .initialize() .accounts({ - tbtcMint: tbtcMintPDA, - tbtc: tbtc.publicKey, + mint: tbtcMintPDA, + config, authority: authority.publicKey }) - .signers([tbtc]) .rpc(); } async function checkState( program: Program, - tbtc, expectedAuthority, expectedMinters, expectedGuardians, expectedTokensSupply ) { - let tbtcState = await program.account.tbtc.fetch(tbtc.publicKey); + const [config,] = getConfigPDA(program); + let configState = await program.account.config.fetch(config); - expect(tbtcState.authority).to.eql(expectedAuthority.publicKey); - expect(tbtcState.minters).to.equal(expectedMinters); - expect(tbtcState.guardians).to.equal(expectedGuardians); + expect(configState.authority).to.eql(expectedAuthority.publicKey); + expect(configState.numMinters).to.equal(expectedMinters); + expect(configState.numGuardians).to.equal(expectedGuardians); - let tbtcMint = tbtcState.tokenMint; + let tbtcMint = configState.mint; let mintState = await spl.getMint(program.provider.connection, tbtcMint); - expect(mintState.supply == expectedTokensSupply).to.be.true; + expect(mintState.supply).to.equal(BigInt(expectedTokensSupply)); } async function changeAuthority( program: Program, - tbtc, authority, newAuthority, ) { + const [config,] = getConfigPDA(program); await program.methods .changeAuthority() .accounts({ - tbtc: tbtc.publicKey, + config, authority: authority.publicKey, newAuthority: newAuthority.publicKey, }) @@ -70,21 +70,31 @@ async function changeAuthority( async function checkPaused( program: Program, - tbtc, paused: boolean ) { - let tbtcState = await program.account.tbtc.fetch(tbtc.publicKey); - expect(tbtcState.paused).to.equal(paused); + const [config,] = getConfigPDA(program); + let configState = await program.account.config.fetch(config); + expect(configState.paused).to.equal(paused); +} + + +function getConfigPDA( + program: Program, +): [anchor.web3.PublicKey, number] { + return web3.PublicKey.findProgramAddressSync( + [ + Buffer.from('config'), + ], + program.programId + ); } function getTokenPDA( program: Program, - tbtc, ): [anchor.web3.PublicKey, number] { return web3.PublicKey.findProgramAddressSync( [ - anchor.utils.bytes.utf8.encode('tbtc-mint'), - tbtc.publicKey.toBuffer(), + Buffer.from('tbtc-mint'), ], program.programId ); @@ -92,13 +102,11 @@ function getTokenPDA( function getMinterPDA( program: Program, - tbtc, minter ): [anchor.web3.PublicKey, number] { return web3.PublicKey.findProgramAddressSync( [ - anchor.utils.bytes.utf8.encode('minter-info'), - tbtc.publicKey.toBuffer(), + Buffer.from('minter-info'), minter.publicKey.toBuffer(), ], program.programId @@ -107,19 +115,18 @@ function getMinterPDA( async function addMinter( program: Program, - tbtc, authority, minter, payer ): Promise { - const [minterInfoPDA, _] = getMinterPDA(program, tbtc, minter); + const [config,] = getConfigPDA(program); + const [minterInfoPDA, _] = getMinterPDA(program, minter); await program.methods .addMinter() .accounts({ - tbtc: tbtc.publicKey, + config, authority: authority.publicKey, minter: minter.publicKey, - payer: payer.publicKey, minterInfo: minterInfoPDA, }) .signers(maybeAuthorityAnd(authority, [])) @@ -129,10 +136,9 @@ async function addMinter( async function checkMinter( program: Program, - tbtc, minter ) { - const [minterInfoPDA, bump] = getMinterPDA(program, tbtc, minter); + const [minterInfoPDA, bump] = getMinterPDA(program, minter); let minterInfo = await program.account.minterInfo.fetch(minterInfoPDA); expect(minterInfo.minter).to.eql(minter.publicKey); @@ -141,17 +147,18 @@ async function checkMinter( async function removeMinter( program: Program, - tbtc, authority, minter, minterInfo ) { + const [config,] = getConfigPDA(program); await program.methods - .removeMinter(minter.publicKey) + .removeMinter() .accounts({ - tbtc: tbtc.publicKey, + config, authority: authority.publicKey, minterInfo: minterInfo, + minter: minter.publicKey }) .signers(maybeAuthorityAnd(authority, [])) .rpc(); @@ -159,13 +166,11 @@ async function removeMinter( function getGuardianPDA( program: Program, - tbtc, guardian ): [anchor.web3.PublicKey, number] { return web3.PublicKey.findProgramAddressSync( [ - anchor.utils.bytes.utf8.encode('guardian-info'), - tbtc.publicKey.toBuffer(), + Buffer.from('guardian-info'), guardian.publicKey.toBuffer(), ], program.programId @@ -174,20 +179,19 @@ function getGuardianPDA( async function addGuardian( program: Program, - tbtc, authority, guardian, payer ): Promise { - const [guardianInfoPDA, _] = getGuardianPDA(program, tbtc, guardian); + const [config,] = getConfigPDA(program); + const [guardianInfoPDA, _] = getGuardianPDA(program, guardian); await program.methods .addGuardian() .accounts({ - tbtc: tbtc.publicKey, + config, authority: authority.publicKey, - guardian: guardian.publicKey, - payer: payer.publicKey, guardianInfo: guardianInfoPDA, + guardian: guardian.publicKey, }) .signers(maybeAuthorityAnd(authority, [])) .rpc(); @@ -196,10 +200,9 @@ async function addGuardian( async function checkGuardian( program: Program, - tbtc, guardian ) { - const [guardianInfoPDA, bump] = getGuardianPDA(program, tbtc, guardian); + const [guardianInfoPDA, bump] = getGuardianPDA(program, guardian); let guardianInfo = await program.account.guardianInfo.fetch(guardianInfoPDA); expect(guardianInfo.guardian).to.eql(guardian.publicKey); @@ -208,17 +211,18 @@ async function checkGuardian( async function removeGuardian( program: Program, - tbtc, authority, guardian, guardianInfo ) { + const [config,] = getConfigPDA(program); await program.methods - .removeGuardian(guardian.publicKey) + .removeGuardian() .accounts({ - tbtc: tbtc.publicKey, + config, authority: authority.publicKey, guardianInfo: guardianInfo, + guardian: guardian.publicKey }) .signers(maybeAuthorityAnd(authority, [])) .rpc(); @@ -226,14 +230,14 @@ async function removeGuardian( async function pause( program: Program, - tbtc, guardian ) { - const [guardianInfoPDA, _] = getGuardianPDA(program, tbtc, guardian); + const [config,] = getConfigPDA(program); + const [guardianInfoPDA, _] = getGuardianPDA(program, guardian); await program.methods .pause() .accounts({ - tbtc: tbtc.publicKey, + config, guardianInfo: guardianInfoPDA, guardian: guardian.publicKey }) @@ -243,13 +247,13 @@ async function pause( async function unpause( program: Program, - tbtc, authority ) { + const [config,] = getConfigPDA(program); await program.methods .unpause() .accounts({ - tbtc: tbtc.publicKey, + config, authority: authority.publicKey }) .signers(maybeAuthorityAnd(authority, [])) @@ -258,29 +262,50 @@ async function unpause( async function mint( program: Program, - tbtc, minter, minterInfoPDA, recipient, amount, payer, ) { - const [tbtcMintPDA, _] = getTokenPDA(program, tbtc); - const associatedTokenAccount = spl.getAssociatedTokenAddressSync( - tbtcMintPDA, - recipient.publicKey, - ); + const connection = program.provider.connection; + + const [config,] = getConfigPDA(program); + const [tbtcMintPDA, _] = getTokenPDA(program); + const recipientToken = spl.getAssociatedTokenAddressSync(tbtcMintPDA, recipient.publicKey); + + const tokenData = await spl.getAccount(connection, recipientToken).catch((err) => { + if (err instanceof spl.TokenAccountNotFoundError) { + return null; + } else { + throw err; + }; + }); + + if (tokenData === null) { + const tx = await web3.sendAndConfirmTransaction( + connection, + new web3.Transaction().add( + spl.createAssociatedTokenAccountIdempotentInstruction( + payer.publicKey, + recipientToken, + recipient.publicKey, + tbtcMintPDA, + ) + ), + [payer.payer] + ); + } + await program.methods .mint(new anchor.BN(amount)) .accounts({ - tbtcMint: tbtcMintPDA, - tbtc: tbtc.publicKey, + mint: tbtcMintPDA, + config, minterInfo: minterInfoPDA, minter: minter.publicKey, - recipientAccount: associatedTokenAccount, - recipient: recipient.publicKey, - payer: payer.publicKey, + recipientToken, }) .signers(maybeAuthorityAnd(payer, [minter])) .rpc(); @@ -292,8 +317,7 @@ describe("tbtc", () => { const program = anchor.workspace.Tbtc as Program; - - const authority = (program.provider as anchor.AnchorProvider).wallet; + const authority = (program.provider as anchor.AnchorProvider).wallet as anchor.Wallet; const newAuthority = anchor.web3.Keypair.generate(); const minterKeys = anchor.web3.Keypair.generate(); const minter2Keys = anchor.web3.Keypair.generate(); @@ -304,29 +328,39 @@ describe("tbtc", () => { const recipientKeys = anchor.web3.Keypair.generate(); it('setup', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); + await setup(program, authority); + await checkState(program, authority, 0, 0, 0); }); it('change authority', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - await changeAuthority(program, tbtcKeys, authority, newAuthority); - await checkState(program, tbtcKeys, newAuthority, 0, 0, 0); + await checkState(program, authority, 0, 0, 0); + await changeAuthority(program, authority, newAuthority); + await checkState(program, newAuthority, 0, 0, 0); + await changeAuthority(program, newAuthority, authority.payer); + await checkState(program, authority, 0, 0, 0); }) it('add minter', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - await addMinter(program, tbtcKeys, authority, minterKeys, authority); - await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, authority, 1, 0, 0); + await checkState(program, authority, 0, 0, 0); + await addMinter(program, authority, minterKeys, authority); + await checkMinter(program, minterKeys); + await checkState(program, authority, 1, 0, 0); + + // Transfer lamports to imposter. + await web3.sendAndConfirmTransaction( + program.provider.connection, + new web3.Transaction().add( + web3.SystemProgram.transfer({ + fromPubkey: authority.publicKey, + toPubkey: impostorKeys.publicKey, + lamports: 1000000000, + }) + ), + [authority.payer] + ); try { - await addMinter(program, tbtcKeys, impostorKeys, minter2Keys, authority); + await addMinter(program, impostorKeys, minter2Keys, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -337,31 +371,35 @@ describe("tbtc", () => { }); it('mint', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); - await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, authority, 1, 0, 0); + await checkState(program, authority, 1, 0, 0); + const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); + await checkMinter(program, minterKeys); - // await setupMint(program, tbtcKeys, authority, recipientKeys); - await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); + // await setupMint(program, authority, recipientKeys); + await mint(program, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); + + await checkState(program, authority, 1, 0, 1000); + + // // Burn for next test. + // const ix = spl.createBurnCheckedInstruction( + // account, // PublicKey of Owner's Associated Token Account + // new PublicKey(MINT_ADDRESS), // Public Key of the Token Mint Address + // WALLET.publicKey, // Public Key of Owner's Wallet + // BURN_QUANTITY * (10**MINT_DECIMALS), // Number of tokens to burn + // MINT_DECIMALS // Number of Decimals of the Token Mint + // ) - await checkState(program, tbtcKeys, authority, 1, 0, 1000); }); it('won\'t mint', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); - await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, authority, 1, 0, 0); + await checkState(program, authority, 1, 0, 1000); + const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); + await checkMinter(program, minterKeys); - // await setupMint(program, tbtcKeys, authority, recipientKeys); + // await setupMint(program, authority, recipientKeys); try { - await mint(program, tbtcKeys, impostorKeys, minterInfoPDA, recipientKeys, 1000, authority); + await mint(program, impostorKeys, minterInfoPDA, recipientKeys, 1000, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -372,19 +410,17 @@ describe("tbtc", () => { }); it('use two minters', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); - const minter2InfoPDA = await addMinter(program, tbtcKeys, authority, minter2Keys, authority); - await checkMinter(program, tbtcKeys, minterKeys); - await checkMinter(program, tbtcKeys, minter2Keys); - await checkState(program, tbtcKeys, authority, 2, 0, 0); - // await setupMint(program, tbtcKeys, authority, recipientKeys); + await checkState(program, authority, 1, 0, 1000); + const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); + await checkMinter(program, minterKeys); + const minter2InfoPDA = await addMinter(program, authority, minter2Keys, authority); + await checkMinter(program, minter2Keys); + await checkState(program, authority, 2, 0, 1000); + // await setupMint(program, authority, recipientKeys); // cannot mint with wrong keys try { - await mint(program, tbtcKeys, minter2Keys, minterInfoPDA, recipientKeys, 1000, authority); + await mint(program, minter2Keys, minterInfoPDA, recipientKeys, 1000, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -395,7 +431,7 @@ describe("tbtc", () => { // cannot remove minter with wrong keys try { - await removeMinter(program, tbtcKeys, authority, minter2Keys, minterInfoPDA); + await removeMinter(program, authority, minter2Keys, minterInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -404,31 +440,26 @@ describe("tbtc", () => { expect(err.program.equals(program.programId)).is.true; } - await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 500, authority); - await checkState(program, tbtcKeys, authority, 2, 0, 500); + await mint(program, minterKeys, minterInfoPDA, recipientKeys, 500, authority); + await checkState(program, authority, 2, 0, 1500); }); it('remove minter', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); - await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, authority, 1, 0, 0); - await removeMinter(program, tbtcKeys, authority, minterKeys, minterInfoPDA); - await checkState(program, tbtcKeys, authority, 0, 0, 0); + await checkState(program, authority, 2, 0, 1500); + const [minter2InfoPDA, _] = getMinterPDA(program, minter2Keys); + await checkMinter(program, minter2Keys); + await removeMinter(program, authority, minter2Keys, minter2InfoPDA); + await checkState(program, authority, 1, 0, 1500); }); it('won\'t remove minter', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); - await checkMinter(program, tbtcKeys, minterKeys); - await checkState(program, tbtcKeys, authority, 1, 0, 0); + await checkState(program, authority, 1, 0, 1500); + const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); + await checkMinter(program, minterKeys); try { - await removeMinter(program, tbtcKeys, impostorKeys, minterKeys, minterInfoPDA); + await removeMinter(program, impostorKeys, minterKeys, minterInfoPDA); + chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); const err: AnchorError = _err; @@ -436,11 +467,12 @@ describe("tbtc", () => { expect(err.program.equals(program.programId)).is.true; } - await removeMinter(program, tbtcKeys, authority, minterKeys, minterInfoPDA); - await checkState(program, tbtcKeys, authority, 0, 0, 0); + await removeMinter(program, authority, minterKeys, minterInfoPDA); + await checkState(program, authority, 0, 0, 1500); try { - await removeMinter(program, tbtcKeys, authority, minterKeys, minterInfoPDA); + await removeMinter(program, authority, minterKeys, minterInfoPDA); + chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); const err: AnchorError = _err; @@ -450,15 +482,13 @@ describe("tbtc", () => { }); it('add guardian', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); - await checkGuardian(program, tbtcKeys, guardianKeys); - await checkState(program, tbtcKeys, authority, 0, 1, 0); + await checkState(program, authority, 0, 0, 1500); + await addGuardian(program, authority, guardianKeys, authority); + await checkGuardian(program, guardianKeys); + await checkState(program, authority, 0, 1, 1500); try { - await addGuardian(program, tbtcKeys, impostorKeys, guardian2Keys, authority); + await addGuardian(program, impostorKeys, guardian2Keys, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -469,15 +499,12 @@ describe("tbtc", () => { }); it('remove guardian', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - const guardianInfoPDA = await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); - await checkGuardian(program, tbtcKeys, guardianKeys); - await checkState(program, tbtcKeys, authority, 0, 1, 0); + await checkState(program, authority, 0, 1, 1500); + const [guardianInfoPDA, _] = getGuardianPDA(program, guardianKeys); + await checkGuardian(program, guardianKeys); try { - await removeGuardian(program, tbtcKeys, impostorKeys, guardianKeys, guardianInfoPDA); + await removeGuardian(program, impostorKeys, guardianKeys, guardianInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -486,11 +513,11 @@ describe("tbtc", () => { expect(err.program.equals(program.programId)).is.true; } - await removeGuardian(program, tbtcKeys, authority, guardianKeys, guardianInfoPDA); - await checkState(program, tbtcKeys, authority, 0, 0, 0); + await removeGuardian(program, authority, guardianKeys, guardianInfoPDA); + await checkState(program, authority, 0, 0, 1500); try { - await removeGuardian(program, tbtcKeys, authority, guardianKeys, guardianInfoPDA); + await removeGuardian(program, authority, guardianKeys, guardianInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -501,26 +528,21 @@ describe("tbtc", () => { }); it('pause', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); - await checkPaused(program, tbtcKeys, false); - await pause(program, tbtcKeys, guardianKeys); - await checkPaused(program, tbtcKeys, true); + await checkState(program, authority, 0, 0, 1500); + await addGuardian(program, authority, guardianKeys, authority); + await checkPaused(program, false); + await pause(program, guardianKeys); + await checkPaused(program, true); }); it('unpause', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); - await checkPaused(program, tbtcKeys, false); - await pause(program, tbtcKeys, guardianKeys); - await checkPaused(program, tbtcKeys, true); - await unpause(program, tbtcKeys, authority); - await checkPaused(program, tbtcKeys, false); + await checkState(program, authority, 0, 1, 1500); + await checkPaused(program, true); + await unpause(program, authority); + await checkPaused(program, false); try { - await unpause(program, tbtcKeys, authority); + await unpause(program, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { @@ -532,16 +554,13 @@ describe("tbtc", () => { }); it('won\'t mint when paused', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - const minterInfoPDA = await addMinter(program, tbtcKeys, authority, minterKeys, authority); - await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); - await pause(program, tbtcKeys, guardianKeys); - // await setupMint(program, tbtcKeys, authority, recipientKeys); + await checkState(program, authority, 0, 1, 1500); + const minterInfoPDA = await addMinter(program, authority, minterKeys, authority); + await pause(program, guardianKeys); + // await setupMint(program, authority, recipientKeys); try { - await mint(program, tbtcKeys, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); - + await mint(program, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -549,22 +568,22 @@ describe("tbtc", () => { expect(err.error.errorCode.code).to.equal('IsPaused'); expect(err.program.equals(program.programId)).is.true; } + + await unpause(program, authority); + await checkPaused(program, false); }) it('use two guardians', async () => { - const tbtcKeys = anchor.web3.Keypair.generate(); - await setup(program, tbtcKeys, authority); - await checkState(program, tbtcKeys, authority, 0, 0, 0); - const guardianInfoPDA = await addGuardian(program, tbtcKeys, authority, guardianKeys, authority); - await addGuardian(program, tbtcKeys, authority, guardian2Keys, authority); - await checkGuardian(program, tbtcKeys, guardianKeys); - await checkGuardian(program, tbtcKeys, guardian2Keys); - await checkState(program, tbtcKeys, authority, 0, 2, 0); + await checkState(program, authority, 1, 1, 1500); + const [guardianInfoPDA, _] = getGuardianPDA(program, guardianKeys); + await checkGuardian(program, guardianKeys); + await addGuardian(program, authority, guardian2Keys, authority); + await checkGuardian(program, guardian2Keys); - await pause(program, tbtcKeys, guardianKeys); + await pause(program, guardianKeys); try { - await pause(program, tbtcKeys, guardian2Keys); + await pause(program, guardian2Keys); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -573,14 +592,14 @@ describe("tbtc", () => { expect(err.program.equals(program.programId)).is.true; } - await unpause(program, tbtcKeys, authority); - await pause(program, tbtcKeys, guardian2Keys); - await checkPaused(program, tbtcKeys, true); - await unpause(program, tbtcKeys, authority); + await unpause(program, authority); + await pause(program, guardian2Keys); + await checkPaused(program, true); + await unpause(program, authority); // cannot remove guardian with wrong keys try { - await removeGuardian(program, tbtcKeys, authority, guardian2Keys, guardianInfoPDA); + await removeGuardian(program, authority, guardian2Keys, guardianInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); From f58a45daf1de8aebf1835d4a712f5414c8d58fc7 Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Mon, 31 Jul 2023 17:33:25 -0500 Subject: [PATCH 031/205] checkpoint: wormhole gateway still broken --- cross-chain/solana/Cargo.lock | 11 ++ cross-chain/solana/programs/tbtc/src/lib.rs | 9 ++ .../tbtc/src/processor/admin/pause.rs | 10 +- .../tbtc/src/processor/admin/unpause.rs | 12 +- .../programs/tbtc/src/processor/mint/mint.rs | 16 +- .../programs/tbtc/src/state/guardian_info.rs | 2 +- .../programs/wormhole-gateway/Cargo.toml | 11 +- .../wormhole-gateway/src/constants.rs | 14 ++ .../programs/wormhole-gateway/src/error.rs | 19 ++- .../programs/wormhole-gateway/src/lib.rs | 29 ++-- .../src/processor/deposit_wormhole_tbtc.rs | 137 ++++++++++++------ .../src/processor/initialize.rs | 66 ++++++--- .../wormhole-gateway/src/processor/mod.rs | 10 +- .../src/processor/receive_tbtc.rs | 47 +++--- .../src/processor/send_tbtc.rs | 79 ---------- .../src/processor/send_tbtc_to_gateway.rs | 109 ++++++++++++++ .../src/processor/update_gateway_address.rs | 27 ++-- .../src/processor/update_minting_limit.rs | 18 +-- .../wormhole-gateway/src/state/custodian.rs | 18 +++ .../src/state/gateway_info.rs | 9 +- .../wormhole-gateway/src/state/mod.rs | 8 +- .../src/state/wormhole_gateway.rs | 22 --- 22 files changed, 431 insertions(+), 252 deletions(-) create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/constants.rs delete mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc_to_gateway.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs delete mode 100644 cross-chain/solana/programs/wormhole-gateway/src/state/wormhole_gateway.rs diff --git a/cross-chain/solana/Cargo.lock b/cross-chain/solana/Cargo.lock index 8aa7d04c6..b01fb264b 100644 --- a/cross-chain/solana/Cargo.lock +++ b/cross-chain/solana/Cargo.lock @@ -2066,6 +2066,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "wormhole-anchor-sdk" +version = "0.1.0" +source = "git+https://github.com/wormhole-foundation/wormhole-scaffolding?rev=f8d5ba04bfd449ab3693b15c818fd3e85e30f758#f8d5ba04bfd449ab3693b15c818fd3e85e30f758" +dependencies = [ + "anchor-lang", + "anchor-spl", + "cfg-if", +] + [[package]] name = "wormhole-gateway" version = "0.1.0" @@ -2073,6 +2083,7 @@ dependencies = [ "anchor-lang", "anchor-spl", "tbtc", + "wormhole-anchor-sdk", ] [[package]] diff --git a/cross-chain/solana/programs/tbtc/src/lib.rs b/cross-chain/solana/programs/tbtc/src/lib.rs index 5accd9bc8..593302351 100644 --- a/cross-chain/solana/programs/tbtc/src/lib.rs +++ b/cross-chain/solana/programs/tbtc/src/lib.rs @@ -13,6 +13,15 @@ use anchor_lang::prelude::*; declare_id!("HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG"); +#[derive(Clone)] +pub struct Tbtc; + +impl Id for Tbtc { + fn id() -> Pubkey { + ID + } +} + #[program] pub mod tbtc { use super::*; diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs index afa376f8a..239635a62 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/pause.rs @@ -10,7 +10,6 @@ pub struct Pause<'info> { mut, seeds = [Config::SEED_PREFIX], bump, - constraint = !config.paused @ TbtcError::IsPaused )] config: Account<'info, Config>, @@ -24,6 +23,15 @@ pub struct Pause<'info> { guardian: Signer<'info>, } +impl<'info> Pause<'info> { + fn constraints(ctx: &Context) -> Result<()> { + require!(!ctx.accounts.config.paused, TbtcError::IsPaused); + + Ok(()) + } +} + +#[access_control(Pause::constraints(&ctx))] pub fn pause(ctx: Context) -> Result<()> { ctx.accounts.config.paused = true; Ok(()) diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs index 024a20685..e5ce8fa25 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/unpause.rs @@ -5,16 +5,24 @@ use anchor_lang::prelude::*; pub struct Unpause<'info> { #[account( mut, + has_one = authority @ TbtcError::IsNotAuthority, seeds = [Config::SEED_PREFIX], bump, - has_one = authority @ TbtcError::IsNotAuthority, - constraint = config.paused @ TbtcError::IsNotPaused )] config: Account<'info, Config>, authority: Signer<'info>, } +impl<'info> Unpause<'info> { + fn constraints(ctx: &Context) -> Result<()> { + require!(ctx.accounts.config.paused, TbtcError::IsNotPaused); + + Ok(()) + } +} + +#[access_control(Unpause::constraints(&ctx))] pub fn unpause(ctx: Context) -> Result<()> { ctx.accounts.config.paused = false; Ok(()) diff --git a/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs b/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs index c32ab15e5..f64307754 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs @@ -17,9 +17,9 @@ pub struct Mint<'info> { )] mint: Account<'info, token::Mint>, - // Can not mint when paused. #[account( - constraint = !config.paused @ TbtcError::IsPaused + seeds = [Config::SEED_PREFIX], + bump = config.bump, )] config: Account<'info, Config>, @@ -30,6 +30,7 @@ pub struct Mint<'info> { bump = minter_info.bump, )] minter_info: Account<'info, MinterInfo>, + minter: Signer<'info>, // Use the associated token account for the recipient. @@ -40,9 +41,18 @@ pub struct Mint<'info> { recipient_token: Account<'info, token::TokenAccount>, token_program: Program<'info, token::Token>, - system_program: Program<'info, System>, } +impl<'info> Mint<'info> { + fn constraints(ctx: &Context) -> Result<()> { + // Can not mint when paused. + require!(!ctx.accounts.config.paused, TbtcError::IsPaused); + + Ok(()) + } +} + +#[access_control(Mint::constraints(&ctx))] pub fn mint(ctx: Context, amount: u64) -> Result<()> { token::mint_to( CpiContext::new_with_signer( diff --git a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs index 00364eac5..34f1492ba 100644 --- a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs @@ -8,5 +8,5 @@ pub struct GuardianInfo { } impl GuardianInfo { - pub const SEED_PREFIX: &'static [u8; 13] = b"guardian-info"; + pub const SEED_PREFIX: &'static [u8] = b"guardian-info"; } diff --git a/cross-chain/solana/programs/wormhole-gateway/Cargo.toml b/cross-chain/solana/programs/wormhole-gateway/Cargo.toml index 0df55d930..6df2961fc 100644 --- a/cross-chain/solana/programs/wormhole-gateway/Cargo.toml +++ b/cross-chain/solana/programs/wormhole-gateway/Cargo.toml @@ -9,13 +9,18 @@ crate-type = ["cdylib", "lib"] name = "wormhole_gateway" [features] +default = ["mainnet"] +mainnet = ["wormhole-anchor-sdk/mainnet"] +solana-devnet = ["wormhole-anchor-sdk/solana-devnet"] no-entrypoint = [] no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] -default = [] [dependencies] -anchor-lang = { version="0.28.0", features = ["init-if-needed"]} +anchor-lang = { version = "0.28.0", features = ["init-if-needed"]} anchor-spl = "0.28.0" -tbtc = { path = "../tbtc" } \ No newline at end of file + +wormhole-anchor-sdk = { git = "https://github.com/wormhole-foundation/wormhole-scaffolding", rev = "f8d5ba04bfd449ab3693b15c818fd3e85e30f758", features = ["token-bridge"], default-features = false } + +tbtc = { path = "../tbtc", features = ["cpi"] } \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/constants.rs b/cross-chain/solana/programs/wormhole-gateway/src/constants.rs new file mode 100644 index 000000000..7aea4b90d --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/constants.rs @@ -0,0 +1,14 @@ +pub const TBTC_FOREIGN_TOKEN_CHAIN: u8 = 2; + +#[cfg(feature = "mainnet")] +pub const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8d, 0xae, 0xba, 0xde, 0x92, 0x2d, + 0xf7, 0x35, 0xc3, 0x8c, 0x80, 0xc7, 0xeb, 0xd7, 0x08, 0xaf, 0x50, 0x81, 0x5f, 0xaa, +]; + +/// TODO: Fix this to reflect testnet contract address. +#[cfg(feature = "solana-devnet")] +pub const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8d, 0xae, 0xba, 0xde, 0x92, 0x2d, + 0xf7, 0x35, 0xc3, 0x8c, 0x80, 0xc7, 0xeb, 0xd7, 0x08, 0xaf, 0x50, 0x81, 0x5f, 0xaa, +]; diff --git a/cross-chain/solana/programs/wormhole-gateway/src/error.rs b/cross-chain/solana/programs/wormhole-gateway/src/error.rs index 9ebe15782..09a8b136c 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/error.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/error.rs @@ -2,6 +2,21 @@ use anchor_lang::prelude::error_code; #[error_code] pub enum WormholeGatewayError { - MintingLimitExceeded, - IsNotAuthority, + #[msg("Cannot mint more than the minting limit.")] + MintingLimitExceeded = 0x10, + + #[msg("Only custodian authority is permitted for this action.")] + IsNotAuthority = 0x20, + + #[msg("0x0 recipient not allowed")] + ZeroRecipient = 0x30, + + #[msg("Not enough wormhole tBTC in the gateway to bridge")] + NotEnoughWrappedTbtc = 0x40, + + #[msg("Amount must not be 0")] + ZeroAmount = 0x50, + + #[msg("Amount too low to bridge")] + TruncatedZeroAmount = 0x60, } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/lib.rs b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs index 4b3223473..3ee804192 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/lib.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs @@ -1,3 +1,6 @@ +mod constants; +pub use constants::*; + pub mod error; mod processor; @@ -22,35 +25,31 @@ pub mod wormhole_gateway { pub fn update_gateway_address( ctx: Context, chain_id: u16, - gateway_address: [u8; 32] + gateway_address: [u8; 32], ) -> Result<()> { processor::update_gateway_address(ctx, chain_id, gateway_address) } - pub fn update_minting_limit( - ctx: Context, - new_limit: u64, - ) -> Result<()> { + pub fn update_minting_limit(ctx: Context, new_limit: u64) -> Result<()> { processor::update_minting_limit(ctx, new_limit) } - pub fn receive_tbtc( - ctx: Context, - ) -> Result<()> { - processor::receive_tbtc(ctx) - } + // pub fn receive_tbtc(ctx: Context) -> Result<()> { + // processor::receive_tbtc(ctx) + // } - pub fn send_tbtc( - ctx: Context, - amount: u64, + pub fn send_tbtc_to_gateway( + ctx: Context, recipient_chain: u16, + recipient: [u8; 32], + amount: u64, arbiter_fee: u64, nonce: u32, ) -> Result<()> { - processor::send_tbtc(ctx, amount, recipient_chain, arbiter_fee, nonce) + processor::send_tbtc_to_gateway(ctx, recipient_chain, recipient, amount, arbiter_fee, nonce) } pub fn deposit_wormhole_tbtc(ctx: Context, amount: u64) -> Result<()> { processor::deposit_wormhole_tbtc(ctx, amount) } -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs index 0858c006f..24a263008 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs @@ -1,62 +1,103 @@ -use crate::{ - error::WormholeGatewayError, - state::WormholeGateway, -}; -use tbtc::{tbtc}; - +use crate::{error::WormholeGatewayError, state::Custodian}; use anchor_lang::prelude::*; use anchor_spl::token; #[derive(Accounts)] #[instruction(amount: u64)] pub struct DepositWormholeTbtc<'info> { + /// NOTE: This account also acts as a minter for the TBTC program. + #[account( + seeds = [Custodian::SEED_PREFIX], + bump = custodian.bump, + has_one = wrapped_tbtc_token, + has_one = wrapped_tbtc_mint, + has_one = tbtc_mint, + )] + custodian: Account<'info, Custodian>, + + /// This token account is owned by this program, whose mint is the wrapped TBTC mint. This PDA + /// address is stored in the custodian account. #[account(mut)] - pub tbtc_mint: Account<'info, token::Mint>, - pub tbtc: Account<'info, tbtc::Tbtc>, - pub minter_info: Account<'info, tbtc::MinterInfo>, + wrapped_tbtc_token: Account<'info, token::TokenAccount>, + + /// This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the + /// custodian account. + wrapped_tbtc_mint: Account<'info, token::Mint>, + + /// This mint is owned by the TBTC program. This PDA address is stored in the custodian account. + #[account(mut)] + tbtc_mint: Account<'info, token::Mint>, - // Use the associated token account for the recipient. #[account( - associated_token::mint = tbtc_mint, - associated_token::authority = recipient, + mut, + token::mint = wrapped_tbtc_mint, + token::authority = recipient )] - pub recipient_account: Account<'info, token::TokenAccount>, - pub recipient: Signer<'info>, + recipient_wrapped_token: Account<'info, token::TokenAccount>, + + // Use the associated token account for the recipient. #[account( - constraint = wormhole_gateway.minting_limit > wormhole_gateway.minted_amount + amount @ WormholeGatewayError::MintingLimitExceeded + mut, + token::mint = tbtc_mint, + token::authority = recipient, )] - pub wormhole_gateway: Account<'info, WormholeGateway>, + recipient_token: Account<'info, token::TokenAccount>, + + /// This program requires that the owner of the TBTC token account sign for TBTC being minted + /// into his account. + recipient: Signer<'info>, + + /// CHECK: TBTC program requires this account. + tbtc_config: UncheckedAccount<'info>, + + // CHECK: TBTC program requires this account. + minter_info: UncheckedAccount<'info>, + + token_program: Program<'info, token::Token>, + tbtc_program: Program<'info, tbtc::Tbtc>, } -pub fn deposit_wormhole_tbtc( - ctx: Context, - amount: u64, -) -> Result<()> { - ctx.accounts.wormhole_gateway.minted_amount += amount; - - let transfer_cpi_ctx = CpiContext::new_with_signer( - // - ); - // wormhole::transfer - - let seed_prefix = WormholeGateway::SEED_PREFIX; - let key_seed = ctx.accounts.wormhole_gateway.key(); - let gateway_bump = ctx.accounts.wormhole_gateway.self_bump; - - let signer: &[&[&[u8]]] = &[&[seed_prefix, key_seed.as_ref(), &[gateway_bump]]]; - - let mint_cpi_ctx = CpiContext::new_with_signer( - ctx.accounts.tbtc.to_account_info(), - tbtc::Mint { - tbtc_mint: ctx.accounts.tbtc_mint.to_account_info(), - tbtc: ctx.accounts.tbtc.to_account_info(), - minter_info: ctx.accounts.minter_info.to_account_info(), - minter: ctx.accounts.wormhole_gateway.to_account_info(), - recipient_account: ctx.accounts.recipient_account.to_account_info(), - recipient: ctx.accounts.recipient.to_account_info(), - payer: ctx.accounts.payer.to_account_info(), - }, - signer, - ); - tbtc::mint(mint_cpi_ctx, amount); -} \ No newline at end of file +impl<'info> DepositWormholeTbtc<'info> { + fn constraints(ctx: &Context, amount: u64) -> Result<()> { + require_gt!( + ctx.accounts.custodian.minting_limit, + ctx.accounts.tbtc_mint.supply.saturating_add(amount), + WormholeGatewayError::MintingLimitExceeded + ); + + Ok(()) + } +} + +#[access_control(DepositWormholeTbtc::constraints(&ctx, amount))] +pub fn deposit_wormhole_tbtc(ctx: Context, amount: u64) -> Result<()> { + // First transfer wrapped tokens to custody account. + token::transfer( + CpiContext::new( + ctx.accounts.token_program.to_account_info(), + token::Transfer { + from: ctx.accounts.recipient_wrapped_token.to_account_info(), + to: ctx.accounts.wrapped_tbtc_token.to_account_info(), + authority: ctx.accounts.recipient.to_account_info(), + }, + ), + amount, + )?; + + // Now mint. + tbtc::cpi::mint( + CpiContext::new_with_signer( + ctx.accounts.tbtc_program.to_account_info(), + tbtc::cpi::accounts::Mint { + mint: ctx.accounts.tbtc_mint.to_account_info(), + config: ctx.accounts.tbtc_config.to_account_info(), + minter_info: ctx.accounts.minter_info.to_account_info(), + minter: ctx.accounts.custodian.to_account_info(), + recipient_token: ctx.accounts.recipient_token.to_account_info(), + token_program: ctx.accounts.token_program.to_account_info(), + }, + &[&[Custodian::SEED_PREFIX, &[ctx.bumps["custodian"]]]], + ), + amount, + ) +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs index c971f30fb..cf6afc196 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs @@ -1,46 +1,68 @@ use crate::{ - state::WormholeGateway, + constants::{TBTC_FOREIGN_TOKEN_ADDRESS, TBTC_FOREIGN_TOKEN_CHAIN}, + state::Custodian, }; - use anchor_lang::prelude::*; use anchor_spl::token; +use wormhole_anchor_sdk::token_bridge; #[derive(Accounts)] pub struct Initialize<'info> { #[account( - seeds = [SEED_PREFIX_TBTC_MINT, tbtc.key().as_ref()], + init, + payer = authority, + space = 8 + Custodian::INIT_SPACE, + seeds = [Custodian::SEED_PREFIX], bump, - mint::decimals = 9, - mint::authority = tbtc_mint, )] - pub tbtc_mint: Account<'info, token::Mint>, - pub tbtc: Account<'info, tbtc::Tbtc>, + custodian: Account<'info, Custodian>, + /// TBTC Program's mint PDA address bump is saved in this program's config. Ordinarily, we would + /// not have to deserialize this account. But we do in this case to make sure the TBTC program + /// has been initialized before this program. #[account( - init, payer = authority, space = WormholeGateway::MAXIMUM_SIZE + seeds = [tbtc::SEED_PREFIX_TBTC_MINT], + bump, + seeds::program = tbtc::ID )] - pub wormhole_gateway: Account<'info, WormholeGateway>, + tbtc_mint: Account<'info, token::Mint>, - pub wormhole_token_bridge: Account<'info, _>, - pub wormhole_bridge_token_mint: Account<'info, token::Mint>, + #[account( + seeds = [ + token_bridge::WrappedMint::SEED_PREFIX, + &TBTC_FOREIGN_TOKEN_CHAIN.to_be_bytes(), + TBTC_FOREIGN_TOKEN_ADDRESS.as_ref() + ], + bump + )] + wrapped_tbtc_mint: Account<'info, token::Mint>, + + #[account( + init, + payer = authority, + token::mint = wrapped_tbtc_mint, + token::authority = authority, + seeds = [b"wrapped-token"], + bump + )] + wrapped_tbtc_token: Account<'info, token::TokenAccount>, #[account(mut)] - pub authority: Signer<'info>, + authority: Signer<'info>, - pub token_program: Program<'info, token::Token>, - pub system_program: Program<'info, System>, + system_program: Program<'info, System>, + token_program: Program<'info, token::Token>, } pub fn initialize(ctx: Context, minting_limit: u64) -> Result<()> { - ctx.accounts.wormhole_gateway.set_inner(WormholeGateway { + ctx.accounts.custodian.set_inner(Custodian { + bump: ctx.bumps["config"], authority: ctx.accounts.authority.key(), - wormhole_token_bridge: ctx.accounts.wormhole_token_bridge.key(), - wormhole_bridge_token_mint: ctx.accounts.wormhole_bridge_token_mint.key(), - tbtc: ctx.accounts.tbtc.key(), tbtc_mint: ctx.accounts.tbtc_mint.key(), - minting_limit: minting_limit, - minted_amount: 0, - self_bump: ctx.bumps.get("wormhole_gateway").unwrap(), + wrapped_tbtc_mint: ctx.accounts.wrapped_tbtc_mint.key(), + wrapped_tbtc_token: ctx.accounts.wrapped_tbtc_token.key(), + minting_limit, }); + Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs index 1481aefa2..d9cb203f3 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs @@ -4,14 +4,14 @@ pub use deposit_wormhole_tbtc::*; mod initialize; pub use initialize::*; -mod receive_tbtc; -pub use receive_tbtc::*; +// mod receive_tbtc; +// pub use receive_tbtc::*; -mod send_tbtc; -pub use send_tbtc::*; +mod send_tbtc_to_gateway; +pub use send_tbtc_to_gateway::*; mod update_gateway_address; pub use update_gateway_address::*; mod update_minting_limit; -pub use update_minting_limit::*; \ No newline at end of file +pub use update_minting_limit::*; diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs index cc9905c45..b3cc68d83 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs @@ -1,18 +1,31 @@ -use crate::{ - state::WormholeGateway, -}; - -use tbtc::{tbtc}; - +use crate::state::Custodian; use anchor_lang::prelude::*; use anchor_spl::token; #[derive(Accounts)] pub struct ReceiveTbtc<'info> { #[account(mut)] - pub tbtc_mint: Account<'info, token::Mint>, - pub tbtc: Account<'info, tbtc::Tbtc>, - pub minter_info: Account<'info, tbtc::MinterInfo>, + payer: Signer<'info>, + + /// NOTE: This account also acts as a minter for the TBTC program. + #[account( + seeds = [Custodian::SEED_PREFIX], + bump = custodian.bump, + has_one = wrapped_tbtc_token, + has_one = wrapped_tbtc_mint, + has_one = tbtc_mint, + )] + custodian: Account<'info, Custodian>, + + // TODO: posted_vaa + #[account(mut)] + tbtc_mint: Account<'info, token::Mint>, + + /// CHECK: This account is needed fot the TBTC program. + tbtc_config: UncheckedAccount<'info>, + + /// CHECK: This account is needed fot the TBTC program. + minter_info: UncheckedAccount<'info>, // Use the associated token account for the recipient. #[account( @@ -20,20 +33,14 @@ pub struct ReceiveTbtc<'info> { associated_token::authority = recipient, )] pub recipient_account: Account<'info, token::TokenAccount>, + /// CHECK: the recipient doesn't need to sign the mint, /// and it doesn't conform to any specific rules. /// Validating the recipient is the minter's responsibility. - pub recipient: UncheckedAccount<'info>, - - #[account(mut)] - pub payer: Signer<'info>, - - pub wormhole_gateway: Account<'info, WormholeGateway>, + recipient: AccountInfo<'info>, } -pub fn receive_tbtc( - ctx: Context, -) -> Result <()> { +pub fn receive_tbtc(ctx: Context) -> Result<()> { // get balance delta let amount = _; @@ -46,7 +53,7 @@ pub fn receive_tbtc( } else { ctx.accounts.wormhole_gateway.minted_amount += amount; - let seed_prefix = WormholeGateway::SEED_PREFIX; + let seed_prefix = Config::SEED_PREFIX; let key_seed = ctx.accounts.wormhole_gateway.key(); let gateway_bump = ctx.accounts.wormhole_gateway.self_bump; @@ -67,4 +74,4 @@ pub fn receive_tbtc( ); tbtc::mint(mint_cpi_ctx, amount) } -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc.rs deleted file mode 100644 index dd4b971c8..000000000 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc.rs +++ /dev/null @@ -1,79 +0,0 @@ -use crate::{ - state::{GatewayInfo, WormholeGateway}, -}; - -use tbtc::{tbtc}; - -use anchor_lang::prelude::*; -use anchor_spl::token; - -#[derive(Accounts)] -#[instruction(recipient_chain: u16)] -pub struct SendTbtc<'info> { - #[account( - mut, - seeds = [tbtc::SEED_PREFIX_TBTC_MINT, tbtc.key().as_ref()], - bump, - mint::decimals = 9, - mint::authority = tbtc_mint, - )] - pub tbtc_mint: Account<'info, token::Mint>, - pub tbtc: Account<'info, tbtc::Tbtc>, - - pub wormhole_gateway: Account<'info, WormholeGateway>, - - pub wormhole_token_bridge: Account<'info, _>, - pub wormhole_bridge_token_mint: Account<'info, token::Mint>, - - #[account( - seeds = [GatewayInfo::SEED_PREFIX, wormhole_gateway.key().as_ref(), recipient_chain], - bump = gateway_info.bump, - )] - pub gateway_info: Account<'info, GatewayInfo>, - - pub sender_account: Account<'info, token::TokenAccount>, - pub sender: Signer<'info>, - - pub token_program: Program<'info, token::Token>, -} - -pub fn send_tbtc( - ctx: Context, - amount: u64, - recipient_chain: u16, - arbiter_fee: u64, - nonce: u32, -) -> Result<()> { - let normalized_amount = normalize(amount); - - let gateway = ctx.accounts.gateway_info.gateway; - - ctx.accounts.wormhole_gateway.minted_amount -= normalized_amount; - - let seed_prefix = WormholeGateway::SEED_PREFIX; - let key_seed = ctx.accounts.wormhole_gateway.key(); - let gateway_bump = ctx.accounts.wormhole_gateway.self_bump; - - let signer: &[&[&[u8]]] = &[&[seed_prefix, key_seed.as_ref(), &[gateway_bump]]]; - - let burn_cpi_ctx = CpiContext::new_with_signer( - ctx.accounts.token_program.to_account_info(), - token::Burn { - mint: ctx.accounts.tbtc_mint.to_account_info(), - from: ctx.accounts.sender_account.to_account_info(), - authority: ctx.accounts.wormhole_gateway.to_account_info(), - }, - signer, - ); - token::burn(burn_cpi_ctx, amount) - - - // approve bridge token - // transfer tokens -} - -fn normalize(amount: u64) -> u64 { - let divAmount = amount / 10; - let normAmount = divAmount * 10; - normAmount -} \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc_to_gateway.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc_to_gateway.rs new file mode 100644 index 000000000..1b23b542d --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc_to_gateway.rs @@ -0,0 +1,109 @@ +use crate::{ + error::WormholeGatewayError, + state::{Custodian, GatewayInfo}, +}; +use anchor_lang::prelude::*; +use anchor_spl::token; +use wormhole_anchor_sdk::token_bridge::{self, program::TokenBridge}; + +#[derive(Accounts)] +#[instruction(recipient_chain: u16)] +pub struct SendTbtcToGateway<'info> { + #[account( + seeds = [Custodian::SEED_PREFIX], + bump = custodian.bump, + has_one = wrapped_tbtc_mint, + has_one = tbtc_mint, + )] + custodian: Account<'info, Custodian>, + + #[account( + seeds = [GatewayInfo::SEED_PREFIX, &recipient_chain.to_le_bytes()], + bump = gateway_info.bump, + )] + gateway_info: Account<'info, GatewayInfo>, + + /// Custody account. + wrapped_tbtc_token: Account<'info, token::TokenAccount>, + + /// CHECK: This account is needed for the Token Bridge program. + wrapped_tbtc_mint: UncheckedAccount<'info>, + + #[account(mut)] + tbtc_mint: Account<'info, token::Mint>, + + #[account( + mut, + token::mint = wrapped_tbtc_mint, + token::authority = sender + )] + sender_account: Account<'info, token::TokenAccount>, + + sender: Signer<'info>, + + /// Check: This account is needed for the Token Bridge program. + token_bridge_transfer_authority: UncheckedAccount<'info>, + + token_bridge_program: Program<'info, TokenBridge>, + token_program: Program<'info, token::Token>, +} + +pub fn send_tbtc_to_gateway( + ctx: Context, + recipient_chain: u16, + recipient: [u8; 32], + amount: u64, + arbiter_fee: u64, + nonce: u32, +) -> Result<()> { + require!(recipient != [0; 32], WormholeGatewayError::ZeroRecipient); + require_gt!(amount, 0, WormholeGatewayError::ZeroAmount); + + let norm_amount = 10 * (amount / 10); + require_gt!(norm_amount, 0, WormholeGatewayError::TruncatedZeroAmount); + + let gateway = ctx.accounts.gateway_info.gateway; + + ctx.accounts + .wrapped_tbtc_token + .amount + .checked_sub(norm_amount) + .ok_or_else(|| WormholeGatewayError::NotEnoughWrappedTbtc); + + let token_program = &ctx.accounts.token_program; + + // Burn TBTC mint. + token::burn( + CpiContext::new( + token_program.to_account_info(), + token::Burn { + mint: ctx.accounts.tbtc_mint.to_account_info(), + from: ctx.accounts.sender_account.to_account_info(), + authority: ctx.accounts.sender.to_account_info(), + }, + ), + amount, + )?; + + // Delegate authority to Token Bridge's transfer authority. + token::approve( + CpiContext::new_with_signer( + token_program.to_account_info(), + token::Approve { + to: ctx.accounts.wrapped_tbtc_token.to_account_info(), + delegate: ctx + .accounts + .token_bridge_transfer_authority + .to_account_info(), + authority: ctx.accounts.custodian.to_account_info(), + }, + &[&[Custodian::SEED_PREFIX, &[ctx.accounts.custodian.bump]]], + ), + amount, + )?; + + // TODO: Encode message with recipient. + // TODO: Transfer tokens with message. + + Ok(()) +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs index e0f3ef36d..25d8358e4 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs @@ -1,6 +1,6 @@ use crate::{ error::WormholeGatewayError, - state::{GatewayInfo, WormholeGateway}, + state::{Custodian, GatewayInfo}, }; use anchor_lang::prelude::*; @@ -8,20 +8,23 @@ use anchor_lang::prelude::*; #[instruction(chain_id: u16)] pub struct UpdateGatewayAddress<'info> { #[account( + seeds = [Custodian::SEED_PREFIX], + bump = custodian.bump, has_one = authority @ WormholeGatewayError::IsNotAuthority, )] - pub wormhole_gateway: Account<'info, WormholeGateway>, + pub custodian: Account<'info, Custodian>, + #[account( init_if_needed, - payer = payer, - space = GatewayInfo::MAXIMUM_SIZE, - seeds = [GatewayInfo::SEED_PREFIX, wormhole_gateway.key().as_ref(), chain_id], + payer = authority, + space = 8 + GatewayInfo::INIT_SPACE, + seeds = [GatewayInfo::SEED_PREFIX, &chain_id.to_le_bytes()], bump, )] pub gateway_info: Account<'info, GatewayInfo>, - pub authority: Signer<'info>, + #[account(mut)] - pub payer: Signer<'info>, + pub authority: Signer<'info>, pub system_program: Program<'info, System>, } @@ -29,8 +32,12 @@ pub struct UpdateGatewayAddress<'info> { pub fn update_gateway_address( ctx: Context, chain_id: u16, - gateway_address: [u8; 32], + gateway: [u8; 32], ) -> Result<()> { - ctx.accounts.gateway_info.gateway = gateway_address; + ctx.accounts.gateway_info.set_inner(GatewayInfo { + bump: ctx.bumps["gateway_info"], + gateway, + }); + Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs index 3553c818d..b52b72df4 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs @@ -1,22 +1,20 @@ -use crate::{ - error::WormholeGatewayError, - state::WormholeGateway, -}; +use crate::{error::WormholeGatewayError, state::Custodian}; use anchor_lang::prelude::*; #[derive(Accounts)] pub struct UpdateMintingLimit<'info> { #[account( mut, + seeds = [Custodian::SEED_PREFIX], + bump = custodian.bump, has_one = authority @ WormholeGatewayError::IsNotAuthority, )] - pub wormhole_gateway: Account<'info, WormholeGateway>, - pub authority: Signer<'info>, - #[account(mut)] - pub payer: Signer<'info>, + custodian: Account<'info, Custodian>, + + authority: Signer<'info>, } pub fn update_minting_limit(ctx: Context, new_limit: u64) -> Result<()> { - ctx.accounts.wormhole_gateway.minting_limit = new_limit; + ctx.accounts.custodian.minting_limit = new_limit; Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs new file mode 100644 index 000000000..fd0640913 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs @@ -0,0 +1,18 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Debug, InitSpace)] +pub struct Custodian { + pub bump: u8, + pub authority: Pubkey, + + pub tbtc_mint: Pubkey, + pub wrapped_tbtc_mint: Pubkey, + pub wrapped_tbtc_token: Pubkey, + + pub minting_limit: u64, +} + +impl Custodian { + pub const SEED_PREFIX: &'static [u8] = b"custodian"; +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs index 8e0867d3a..895343c8a 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs @@ -1,13 +1,12 @@ use anchor_lang::prelude::*; #[account] -#[derive(Default)] +#[derive(Debug, InitSpace)] pub struct GatewayInfo { - pub gateway: [u8; 32], pub bump: u8, + pub gateway: [u8; 32], } impl GatewayInfo { - pub const MAXIMUM_SIZE: usize = 8 + 32 + 1; - pub const SEED_PREFIX: &'static [u8; 12] = b"gateway-info"; -} \ No newline at end of file + pub const SEED_PREFIX: &'static [u8] = b"gateway-info"; +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/mod.rs index b7f0583ab..8b8779a6a 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/state/mod.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/state/mod.rs @@ -1,5 +1,5 @@ -pub use gateway_info::*; -pub use wormhole_gateway::*; +mod custodian; +pub use custodian::*; -pub mod gateway_info; -pub mod wormhole_gateway; \ No newline at end of file +mod gateway_info; +pub use gateway_info::*; diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/wormhole_gateway.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/wormhole_gateway.rs deleted file mode 100644 index 887f7f01e..000000000 --- a/cross-chain/solana/programs/wormhole-gateway/src/state/wormhole_gateway.rs +++ /dev/null @@ -1,22 +0,0 @@ -use anchor_lang::prelude::*; - -#[account] -#[derive(Default)] -pub struct WormholeGateway { - pub authority: Pubkey, - pub wormhole_token_bridge: Pubkey, - pub wormhole_bridge_token_mint: Pubkey, - pub tbtc: Pubkey, - pub tbtc_mint: Pubkey, - pub minting_limit: u64, - pub minted_amount: u64, - pub self_bump: u8, -} - -impl WormholeGateway { - // 8 discriminator - // 32 * 5 = 160 (5 pubkeys) - // 8 * 2 = 16 (2 u64s) - // 1 (bump) - pub const MAXIMUM_SIZE: usize = 8 + 160 + 16 + 1; -} \ No newline at end of file From 140a8cbb0f120d2c3410b29118d8005358e577d7 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Tue, 1 Aug 2023 12:13:39 +0200 Subject: [PATCH 032/205] Add BaseWormholeTBTC address for base mainnet This is address of the wrapped tBTC token on Base mainnet chain. tBTC token attestation on Ethereum: https://etherscan.io/tx/0x2df8d53251aff96b6341f3fffda03b46ff04c35edb8dff496962da73d19c04c7 Wrapped tBTC token creation on Base: https://basescan.org/tx/0x82af9e68b6be7db6b89cfb6e09368f524e04a317c938e367047f6467484e47a3 --- cross-chain/base/external/base/BaseWormholeTBTC.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-chain/base/external/base/BaseWormholeTBTC.json b/cross-chain/base/external/base/BaseWormholeTBTC.json index 27a670f17..e916972b1 100644 --- a/cross-chain/base/external/base/BaseWormholeTBTC.json +++ b/cross-chain/base/external/base/BaseWormholeTBTC.json @@ -1,3 +1,3 @@ { - "address": "0x0" + "address": "0x9EE95E6Bd1B3C5740F105d6fb06b8BDeF64Eec70" } From c9ba93ee69cbba966209278203f11338e87beabd Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Tue, 1 Aug 2023 13:43:03 +0200 Subject: [PATCH 033/205] Add Threshold Council multisig for base mainnet The Gnosis Safe wallet was set up on Base by the Threshold Council under https://app.safe.global/settings/setup?safe=base:0x518385dd31289F1000fE6382b0C65df4d1Cd3bfC --- cross-chain/base/hardhat.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cross-chain/base/hardhat.config.ts b/cross-chain/base/hardhat.config.ts index 8cd0291db..f7dada54c 100644 --- a/cross-chain/base/hardhat.config.ts +++ b/cross-chain/base/hardhat.config.ts @@ -140,8 +140,8 @@ const config: HardhatUserConfig = { default: 2, goerli: 0, baseGoerli: 0, - mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", - base: "", + mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", // Threshold Council + base: "0x518385dd31289F1000fE6382b0C65df4d1Cd3bfC", // Threshold Council }, }, mocha: { From 5d7877db649cf71e5e24c0d97afe82ee7da4ed26 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Tue, 1 Aug 2023 16:34:45 +0100 Subject: [PATCH 034/205] Add iteration for guardians --- .../tbtc/src/processor/admin/add_guardian.rs | 17 +++- .../src/processor/admin/remove_guardian.rs | 35 +++++++- .../programs/tbtc/src/state/guardian_index.rs | 12 +++ .../programs/tbtc/src/state/guardian_info.rs | 1 + .../solana/programs/tbtc/src/state/mod.rs | 3 + cross-chain/solana/tests/01__tbtc.ts | 81 +++++++++++++++---- 6 files changed, 131 insertions(+), 18 deletions(-) create mode 100644 cross-chain/solana/programs/tbtc/src/state/guardian_index.rs diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs index 422bac905..82e3d3380 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, GuardianInfo}, + state::{Config, GuardianIndex, GuardianInfo}, }; use anchor_lang::prelude::*; @@ -26,6 +26,15 @@ pub struct AddGuardian<'info> { )] guardian_info: Account<'info, GuardianInfo>, + #[account( + init, + payer = authority, + space = 8 + GuardianIndex::INIT_SPACE, + seeds = [GuardianIndex::SEED_PREFIX, &[config.num_guardians]], + bump + )] + guardian_index: Account<'info, GuardianIndex>, + /// CHECK: Required authority to pause contract. This pubkey lives in `GuardianInfo`. guardian: AccountInfo<'info>, @@ -35,9 +44,15 @@ pub struct AddGuardian<'info> { pub fn add_guardian(ctx: Context) -> Result<()> { ctx.accounts.guardian_info.set_inner(GuardianInfo { guardian: ctx.accounts.guardian.key(), + index: ctx.accounts.config.num_guardians, bump: ctx.bumps["guardian_info"], }); + ctx.accounts.guardian_index.set_inner(GuardianIndex { + guardian_info: ctx.accounts.guardian_info.key(), + bump: ctx.bumps["guardian_index"], + }); + ctx.accounts.config.num_guardians += 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs index 777edf865..9fb05b122 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, GuardianInfo}, + state::{Config, GuardianIndex, GuardianInfo}, }; use anchor_lang::prelude::*; @@ -14,6 +14,7 @@ pub struct RemoveGuardian<'info> { authority: Signer<'info>, + // the guardian info to remove #[account( mut, has_one = guardian, @@ -23,11 +24,43 @@ pub struct RemoveGuardian<'info> { )] guardian_info: Account<'info, GuardianInfo>, + // the guardian info at the last index. + // This gets its index swapped to the position of the removed guardian info. + #[account( + mut, + constraint = guardian_info_swap.index == config.num_guardians - 1, + seeds = [GuardianInfo::SEED_PREFIX, guardian_info_swap.guardian.as_ref()], + bump = guardian_info_swap.bump, + )] + guardian_info_swap: Account<'info, GuardianInfo>, + + // The index account of the guardian to remove. + // We replace guardian_info in this with guardian_info_swap. + #[account( + mut, + seeds = [GuardianIndex::SEED_PREFIX, &[guardian_info.index]], + bump = guardian_index_swap.bump, + )] + guardian_index_swap: Account<'info, GuardianIndex>, + + // The last guardian index account. + // This gets removed, and its guardian_info(_swap) gets put into guardian_index_swap instead. + #[account( + mut, + close = authority, + seeds = [GuardianIndex::SEED_PREFIX, &[config.num_guardians - 1]], + bump = guardian_index_tail.bump, + constraint = guardian_index_tail.guardian_info == guardian_info_swap.key(), + )] + guardian_index_tail: Account<'info, GuardianIndex>, + /// CHECK: Required authority to pause contract. This pubkey lives in `GuardianInfo`. guardian: AccountInfo<'info>, } pub fn remove_guardian(ctx: Context) -> Result<()> { + ctx.accounts.guardian_index_swap.guardian_info = ctx.accounts.guardian_index_tail.guardian_info; + ctx.accounts.guardian_info_swap.index = ctx.accounts.guardian_info.index; ctx.accounts.config.num_guardians -= 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/state/guardian_index.rs b/cross-chain/solana/programs/tbtc/src/state/guardian_index.rs new file mode 100644 index 000000000..d10bcc196 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/state/guardian_index.rs @@ -0,0 +1,12 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Debug, InitSpace)] +pub struct GuardianIndex { + pub guardian_info: Pubkey, + pub bump: u8, +} + +impl GuardianIndex { + pub const SEED_PREFIX: &'static [u8] = b"guardian-index"; +} diff --git a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs index 34f1492ba..697d5333e 100644 --- a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs @@ -4,6 +4,7 @@ use anchor_lang::prelude::*; #[derive(Debug, InitSpace)] pub struct GuardianInfo { pub guardian: Pubkey, + pub index: u8, pub bump: u8, } diff --git a/cross-chain/solana/programs/tbtc/src/state/mod.rs b/cross-chain/solana/programs/tbtc/src/state/mod.rs index dffd4099b..cb61742a2 100644 --- a/cross-chain/solana/programs/tbtc/src/state/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/state/mod.rs @@ -1,6 +1,9 @@ mod config; pub use config::*; +mod guardian_index; +pub use guardian_index::*; + mod guardian_info; pub use guardian_info::*; diff --git a/cross-chain/solana/tests/01__tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts index fad8af5da..bb94a5117 100644 --- a/cross-chain/solana/tests/01__tbtc.ts +++ b/cross-chain/solana/tests/01__tbtc.ts @@ -177,20 +177,39 @@ function getGuardianPDA( ); } +function getGuardianIndexPDA( + program: Program, + index +): [anchor.web3.PublicKey, number] { + let indexArr = new Uint8Array(1); + indexArr[0] = index; + return web3.PublicKey.findProgramAddressSync( + [ + Buffer.from('guardian-index'), + indexArr, + ], + program.programId + ); +} + async function addGuardian( program: Program, authority, - guardian, - payer + guardian ): Promise { const [config,] = getConfigPDA(program); const [guardianInfoPDA, _] = getGuardianPDA(program, guardian); + + let configState = await program.account.config.fetch(config); + + const [guardianIndexPDA, __] = getGuardianIndexPDA(program, configState.numGuardians); await program.methods .addGuardian() .accounts({ config, authority: authority.publicKey, guardianInfo: guardianInfoPDA, + guardianIndex: guardianIndexPDA, guardian: guardian.publicKey, }) .signers(maybeAuthorityAnd(authority, [])) @@ -200,13 +219,22 @@ async function addGuardian( async function checkGuardian( program: Program, - guardian + guardian, + expectedIndex ) { const [guardianInfoPDA, bump] = getGuardianPDA(program, guardian); let guardianInfo = await program.account.guardianInfo.fetch(guardianInfoPDA); + const [guardianIndexPDA, indexBump] = getGuardianIndexPDA(program, guardianInfo.index); + let guardianIndex = await program.account.guardianIndex.fetch(guardianIndexPDA); + expect(guardianInfo.guardian).to.eql(guardian.publicKey); expect(guardianInfo.bump).to.equal(bump); + + expect(guardianIndex.guardianInfo).to.eql(guardianInfoPDA); + expect(guardianIndex.bump).to.equal(indexBump); + + expect(guardianInfo.index).to.equal(expectedIndex); } async function removeGuardian( @@ -216,12 +244,24 @@ async function removeGuardian( guardianInfo ) { const [config,] = getConfigPDA(program); + const configState = await program.account.config.fetch(config); + const guardianInfoState = await program.account.guardianInfo.fetch(guardianInfo); + + const [lastIndex,] = getGuardianIndexPDA(program, configState.numGuardians - 1); + const [swapIndex,] = getGuardianIndexPDA(program, guardianInfoState.index); + + const lastIndexState = await program.account.guardianIndex.fetch(lastIndex); + const swapInfo = lastIndexState.guardianInfo; + await program.methods .removeGuardian() .accounts({ config, authority: authority.publicKey, guardianInfo: guardianInfo, + guardianInfoSwap: swapInfo, + guardianIndexSwap: swapIndex, + guardianIndexTail: lastIndex, guardian: guardian.publicKey }) .signers(maybeAuthorityAnd(authority, [])) @@ -483,12 +523,12 @@ describe("tbtc", () => { it('add guardian', async () => { await checkState(program, authority, 0, 0, 1500); - await addGuardian(program, authority, guardianKeys, authority); - await checkGuardian(program, guardianKeys); + await addGuardian(program, authority, guardianKeys); + await checkGuardian(program, guardianKeys, 0); await checkState(program, authority, 0, 1, 1500); try { - await addGuardian(program, impostorKeys, guardian2Keys, authority); + await addGuardian(program, impostorKeys, guardian2Keys); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -500,8 +540,8 @@ describe("tbtc", () => { it('remove guardian', async () => { await checkState(program, authority, 0, 1, 1500); - const [guardianInfoPDA, _] = getGuardianPDA(program, guardianKeys); - await checkGuardian(program, guardianKeys); + const [guardianInfoPDA,] = getGuardianPDA(program, guardianKeys); + await checkGuardian(program, guardianKeys, 0); try { await removeGuardian(program, impostorKeys, guardianKeys, guardianInfoPDA); @@ -520,16 +560,25 @@ describe("tbtc", () => { await removeGuardian(program, authority, guardianKeys, guardianInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('AccountNotInitialized'); - expect(err.program.equals(program.programId)).is.true; + expect(_err.message).to.include('Account does not exist or has no data'); } + + await addGuardian(program, authority, guardian2Keys); + await addGuardian(program, authority, guardianKeys); + await checkGuardian(program, guardian2Keys, 0); + await checkGuardian(program, guardianKeys, 1); + + const [guardian2InfoPDA,] = getGuardianPDA(program, guardian2Keys); + await removeGuardian(program, authority, guardian2Keys, guardian2InfoPDA); + + await checkGuardian(program, guardianKeys, 0); + + await removeGuardian(program, authority, guardianKeys, guardianInfoPDA); }); it('pause', async () => { await checkState(program, authority, 0, 0, 1500); - await addGuardian(program, authority, guardianKeys, authority); + await addGuardian(program, authority, guardianKeys); await checkPaused(program, false); await pause(program, guardianKeys); await checkPaused(program, true); @@ -576,9 +625,9 @@ describe("tbtc", () => { it('use two guardians', async () => { await checkState(program, authority, 1, 1, 1500); const [guardianInfoPDA, _] = getGuardianPDA(program, guardianKeys); - await checkGuardian(program, guardianKeys); - await addGuardian(program, authority, guardian2Keys, authority); - await checkGuardian(program, guardian2Keys); + await checkGuardian(program, guardianKeys, 0); + await addGuardian(program, authority, guardian2Keys); + await checkGuardian(program, guardian2Keys, 1); await pause(program, guardianKeys); From 73964de86ff702b48b6f7988567d0df27b18e1f7 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Tue, 1 Aug 2023 16:55:34 +0100 Subject: [PATCH 035/205] Add iteration of minters --- .../tbtc/src/processor/admin/add_minter.rs | 17 ++++- .../tbtc/src/processor/admin/remove_minter.rs | 32 +++++++- .../programs/tbtc/src/state/minter_index.rs | 12 +++ .../programs/tbtc/src/state/minter_info.rs | 1 + .../solana/programs/tbtc/src/state/mod.rs | 3 + cross-chain/solana/tests/01__tbtc.ts | 76 ++++++++++++++----- 6 files changed, 120 insertions(+), 21 deletions(-) create mode 100644 cross-chain/solana/programs/tbtc/src/state/minter_index.rs diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs index ccb8620cb..b99925e85 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, MinterInfo}, + state::{Config, MinterIndex, MinterInfo}, }; use anchor_lang::prelude::*; @@ -26,6 +26,15 @@ pub struct AddMinter<'info> { )] minter_info: Account<'info, MinterInfo>, + #[account( + init, + payer = authority, + space = 8 + MinterIndex::INIT_SPACE, + seeds = [MinterIndex::SEED_PREFIX, &[config.num_minters]], + bump + )] + minter_index: Account<'info, MinterIndex>, + /// CHECK: Required authority to mint tokens. This pubkey lives in `MinterInfo`. minter: AccountInfo<'info>, @@ -35,9 +44,15 @@ pub struct AddMinter<'info> { pub fn add_minter(ctx: Context) -> Result<()> { ctx.accounts.minter_info.set_inner(MinterInfo { minter: ctx.accounts.minter.key(), + index: ctx.accounts.config.num_minters, bump: ctx.bumps["minter_info"], }); + ctx.accounts.minter_index.set_inner(MinterIndex { + minter_info: ctx.accounts.minter_info.key(), + bump: ctx.bumps["minter_index"], + }); + ctx.accounts.config.num_minters += 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs index 83aa5a07d..dcb037708 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, MinterInfo}, + state::{Config, MinterIndex, MinterInfo}, }; use anchor_lang::prelude::*; @@ -25,6 +25,36 @@ pub struct RemoveMinter<'info> { )] minter_info: Account<'info, MinterInfo>, + // the minter info at the last index. + // This gets its index swapped to the position of the removed minter info. + #[account( + mut, + constraint = minter_info_swap.index == config.num_minters - 1, + seeds = [MinterInfo::SEED_PREFIX, minter_info_swap.minter.as_ref()], + bump = minter_info_swap.bump, + )] + minter_info_swap: Account<'info, MinterInfo>, + + // The index account of the minter to remove. + // We replace minter_info in this with minter_info_swap. + #[account( + mut, + seeds = [MinterIndex::SEED_PREFIX, &[minter_info.index]], + bump = minter_index_swap.bump, + )] + minter_index_swap: Account<'info, MinterIndex>, + + // The last minter index account. + // This gets removed, and its minter_info(_swap) gets put into minter_index_swap instead. + #[account( + mut, + close = authority, + seeds = [MinterIndex::SEED_PREFIX, &[config.num_minters - 1]], + bump = minter_index_tail.bump, + constraint = minter_index_tail.minter_info == minter_info_swap.key(), + )] + minter_index_tail: Account<'info, MinterIndex>, + /// CHECK: Required authority to mint tokens. This pubkey lives in `MinterInfo`. minter: AccountInfo<'info>, } diff --git a/cross-chain/solana/programs/tbtc/src/state/minter_index.rs b/cross-chain/solana/programs/tbtc/src/state/minter_index.rs new file mode 100644 index 000000000..b24cac001 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/state/minter_index.rs @@ -0,0 +1,12 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Debug, InitSpace)] +pub struct MinterIndex { + pub minter_info: Pubkey, + pub bump: u8, +} + +impl MinterIndex { + pub const SEED_PREFIX: &'static [u8] = b"minter-index"; +} diff --git a/cross-chain/solana/programs/tbtc/src/state/minter_info.rs b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs index e8b6a6eeb..89717df2c 100644 --- a/cross-chain/solana/programs/tbtc/src/state/minter_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs @@ -4,6 +4,7 @@ use anchor_lang::prelude::*; #[derive(Debug, InitSpace)] pub struct MinterInfo { pub minter: Pubkey, + pub index: u8, pub bump: u8, } diff --git a/cross-chain/solana/programs/tbtc/src/state/mod.rs b/cross-chain/solana/programs/tbtc/src/state/mod.rs index cb61742a2..d54275df4 100644 --- a/cross-chain/solana/programs/tbtc/src/state/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/state/mod.rs @@ -7,5 +7,8 @@ pub use guardian_index::*; mod guardian_info; pub use guardian_info::*; +mod minter_index; +pub use minter_index::*; + mod minter_info; pub use minter_info::*; diff --git a/cross-chain/solana/tests/01__tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts index bb94a5117..0b549f1e8 100644 --- a/cross-chain/solana/tests/01__tbtc.ts +++ b/cross-chain/solana/tests/01__tbtc.ts @@ -113,21 +113,41 @@ function getMinterPDA( ); } +function getMinterIndexPDA( + program: Program, + index +): [anchor.web3.PublicKey, number] { + let indexArr = new Uint8Array(1); + indexArr[0] = index; + return web3.PublicKey.findProgramAddressSync( + [ + Buffer.from('minter-index'), + indexArr, + ], + program.programId + ); +} + async function addMinter( program: Program, authority, - minter, - payer + minter ): Promise { const [config,] = getConfigPDA(program); const [minterInfoPDA, _] = getMinterPDA(program, minter); + + let configState = await program.account.config.fetch(config); + + const [minterIndexPDA, __] = getMinterIndexPDA(program, configState.numMinters); + await program.methods .addMinter() .accounts({ config, authority: authority.publicKey, - minter: minter.publicKey, minterInfo: minterInfoPDA, + minterIndex: minterIndexPDA, + minter: minter.publicKey, }) .signers(maybeAuthorityAnd(authority, [])) .rpc(); @@ -136,13 +156,22 @@ async function addMinter( async function checkMinter( program: Program, - minter + minter, + expectedIndex ) { const [minterInfoPDA, bump] = getMinterPDA(program, minter); let minterInfo = await program.account.minterInfo.fetch(minterInfoPDA); + const [minterIndexPDA, indexBump] = getMinterIndexPDA(program, minterInfo.index); + let minterIndex = await program.account.minterIndex.fetch(minterIndexPDA); + expect(minterInfo.minter).to.eql(minter.publicKey); expect(minterInfo.bump).to.equal(bump); + + expect(minterIndex.minterInfo).to.eql(minterInfoPDA); + expect(minterIndex.bump).to.equal(indexBump); + + expect(minterInfo.index).to.equal(expectedIndex); } async function removeMinter( @@ -152,12 +181,24 @@ async function removeMinter( minterInfo ) { const [config,] = getConfigPDA(program); + const configState = await program.account.config.fetch(config); + const minterInfoState = await program.account.minterInfo.fetch(minterInfo); + + const [lastIndex,] = getMinterIndexPDA(program, configState.numMinters - 1); + const [swapIndex,] = getMinterIndexPDA(program, minterInfoState.index); + + const lastIndexState = await program.account.minterIndex.fetch(lastIndex); + const swapInfo = lastIndexState.minterInfo; + await program.methods .removeMinter() .accounts({ config, authority: authority.publicKey, minterInfo: minterInfo, + minterInfoSwap: swapInfo, + minterIndexSwap: swapIndex, + minterIndexTail: lastIndex, minter: minter.publicKey }) .signers(maybeAuthorityAnd(authority, [])) @@ -382,8 +423,8 @@ describe("tbtc", () => { it('add minter', async () => { await checkState(program, authority, 0, 0, 0); - await addMinter(program, authority, minterKeys, authority); - await checkMinter(program, minterKeys); + await addMinter(program, authority, minterKeys); + await checkMinter(program, minterKeys, 0); await checkState(program, authority, 1, 0, 0); // Transfer lamports to imposter. @@ -400,7 +441,7 @@ describe("tbtc", () => { ); try { - await addMinter(program, impostorKeys, minter2Keys, authority); + await addMinter(program, impostorKeys, minter2Keys); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -413,7 +454,7 @@ describe("tbtc", () => { it('mint', async () => { await checkState(program, authority, 1, 0, 0); const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys); + await checkMinter(program, minterKeys, 0); // await setupMint(program, authority, recipientKeys); await mint(program, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); @@ -434,7 +475,7 @@ describe("tbtc", () => { it('won\'t mint', async () => { await checkState(program, authority, 1, 0, 1000); const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys); + await checkMinter(program, minterKeys, 0); // await setupMint(program, authority, recipientKeys); @@ -452,9 +493,9 @@ describe("tbtc", () => { it('use two minters', async () => { await checkState(program, authority, 1, 0, 1000); const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys); - const minter2InfoPDA = await addMinter(program, authority, minter2Keys, authority); - await checkMinter(program, minter2Keys); + await checkMinter(program, minterKeys, 0); + const minter2InfoPDA = await addMinter(program, authority, minter2Keys); + await checkMinter(program, minter2Keys, 1); await checkState(program, authority, 2, 0, 1000); // await setupMint(program, authority, recipientKeys); @@ -487,7 +528,7 @@ describe("tbtc", () => { it('remove minter', async () => { await checkState(program, authority, 2, 0, 1500); const [minter2InfoPDA, _] = getMinterPDA(program, minter2Keys); - await checkMinter(program, minter2Keys); + await checkMinter(program, minter2Keys, 1); await removeMinter(program, authority, minter2Keys, minter2InfoPDA); await checkState(program, authority, 1, 0, 1500); }); @@ -495,7 +536,7 @@ describe("tbtc", () => { it('won\'t remove minter', async () => { await checkState(program, authority, 1, 0, 1500); const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys); + await checkMinter(program, minterKeys, 0); try { await removeMinter(program, impostorKeys, minterKeys, minterInfoPDA); @@ -514,10 +555,7 @@ describe("tbtc", () => { await removeMinter(program, authority, minterKeys, minterInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('AccountNotInitialized'); - expect(err.program.equals(program.programId)).is.true; + expect(_err.message).to.include('Account does not exist or has no data'); } }); @@ -604,7 +642,7 @@ describe("tbtc", () => { it('won\'t mint when paused', async () => { await checkState(program, authority, 0, 1, 1500); - const minterInfoPDA = await addMinter(program, authority, minterKeys, authority); + const minterInfoPDA = await addMinter(program, authority, minterKeys); await pause(program, guardianKeys); // await setupMint(program, authority, recipientKeys); From 34a7b099fb9b5d48fce402652b8e1daae1ff0b2c Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 1 Aug 2023 18:17:05 +0200 Subject: [PATCH 036/205] Expose past redemption requested events getter Here we expose the `Bridge.getRedemptionRequestedEvents` method that allows fetching past redemption requested events from the `Bridge` contract. --- typescript/src/bitcoin.ts | 40 ++++++++++++++++++++++++++++ typescript/src/chain.ts | 8 +++++- typescript/src/ethereum.ts | 39 ++++++++++++++++++++++++++- typescript/src/redemption.ts | 16 ++++++++++- typescript/test/bitcoin.test.ts | 38 ++++++++++++++++++++++++++ typescript/test/utils/mock-bridge.ts | 9 ++++++- 6 files changed, 146 insertions(+), 4 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 3d7c32585..a46a4792b 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -639,3 +639,43 @@ export function createAddressFromOutputScript( .getAddress() ?.toString(toBcoinNetwork(network)) } + +/** + * Reads the leading compact size uint from the provided variable length data. + * + * WARNING: CURRENTLY, THIS FUNCTION SUPPORTS ONLY 1-BYTE COMPACT SIZE UINTS + * AND WILL THROW ON COMPACT SIZE UINTS OF DIFFERENT BYTE LENGTH. + * + * @param varLenData Variable length data preceded by a compact size uint. + * @returns An object holding the value of the compact size uint along with the + * compact size uint byte length. + */ +export function readCompactSizeUint(varLenData: Hex): { + value: number + byteLength: number +} { + // The varLenData is prefixed with the compact size uint. According to the docs + // (https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers) + // a compact size uint can be 1, 3, 5 or 9 bytes. To determine the exact length, + // we need to look at the discriminant byte which is always the first byte of + // the compact size uint. + const discriminant = varLenData.toString().slice(0, 2) + + switch (discriminant) { + case "ff": + case "fe": + case "fd": { + throw new Error( + "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + ) + } + default: { + // The discriminant tells the compact size uint is 1 byte. That means + // the discriminant represent the value itself. + return { + value: parseInt(discriminant, 16), + byteLength: 1, + } + } + } +} diff --git a/typescript/src/chain.ts b/typescript/src/chain.ts index 5b6f619e6..3b4686dc5 100644 --- a/typescript/src/chain.ts +++ b/typescript/src/chain.ts @@ -17,7 +17,7 @@ import { OptimisticMintingRequestedEvent, } from "./optimistic-minting" import { Hex } from "./hex" -import { RedemptionRequest } from "./redemption" +import { RedemptionRequest, RedemptionRequestedEvent } from "./redemption" import { DkgResultApprovedEvent, DkgResultChallengedEvent, @@ -260,6 +260,12 @@ export interface Bridge { * @returns The hash of the UTXO. */ buildUtxoHash(utxo: UnspentTransactionOutput): Hex + + /** + * Get emitted RedemptionRequested events. + * @see GetEventsFunction + */ + getRedemptionRequestedEvents: GetEvents.Function } /** diff --git a/typescript/src/ethereum.ts b/typescript/src/ethereum.ts index 60490f906..f86c80798 100644 --- a/typescript/src/ethereum.ts +++ b/typescript/src/ethereum.ts @@ -27,12 +27,13 @@ import { DepositRevealedEvent, } from "./deposit" import { getEvents, sendWithRetry } from "./ethereum-helpers" -import { RedemptionRequest } from "./redemption" +import { RedemptionRequest, RedemptionRequestedEvent } from "./redemption" import { compressPublicKey, computeHash160, DecomposedRawTransaction, Proof, + readCompactSizeUint, TransactionHash, UnspentTransactionOutput, } from "./bitcoin" @@ -762,6 +763,42 @@ export class Bridge ) ) } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#getDepositRevealedEvents} + */ + async getRedemptionRequestedEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + const events: EthersEvent[] = await this.getEvents( + "RedemptionRequested", + options, + ...filterArgs + ) + + return events.map((event) => { + const prefixedRedeemerOutputScript = Hex.from( + event.args!.redeemerOutputScript + ) + const redeemerOutputScript = prefixedRedeemerOutputScript + .toString() + .slice(readCompactSizeUint(prefixedRedeemerOutputScript).byteLength * 2) + + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + walletPublicKeyHash: Hex.from(event.args!.walletPubKeyHash).toString(), + redeemer: new Address(event.args!.redeemer), + redeemerOutputScript: redeemerOutputScript, + requestedAmount: BigNumber.from(event.args!.requestedAmount), + treasuryFee: BigNumber.from(event.args!.treasuryFee), + txMaxFee: BigNumber.from(event.args!.txMaxFee), + } + }) + } } /** diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index f3b2474a0..ab713199a 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -8,7 +8,7 @@ import { Client as BitcoinClient, TransactionHash, } from "./bitcoin" -import { Bridge, Identifier, TBTCToken } from "./chain" +import { Bridge, Event, Identifier, TBTCToken } from "./chain" import { assembleTransactionProof } from "./proof" import { determineWalletMainUtxo, WalletState } from "./wallet" import { BitcoinNetwork } from "./bitcoin-network" @@ -56,6 +56,20 @@ export interface RedemptionRequest { requestedAt: number } +/** + * Represents an event emitted on redemption request. + */ +export type RedemptionRequestedEvent = Omit< + RedemptionRequest, + "requestedAt" +> & { + /** + * Public key hash of the wallet that is meant to handle the redemption. Must + * be an unprefixed hex string (without 0x prefix). + */ + walletPublicKeyHash: string +} & Event + /** * Requests a redemption of tBTC into BTC. * @param walletPublicKey - The Bitcoin public key of the wallet. Must be in the diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 27ce2861f..748e39004 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -13,6 +13,7 @@ import { targetToDifficulty, createOutputScriptFromAddress, createAddressFromOutputScript, + readCompactSizeUint, } from "../src/bitcoin" import { calculateDepositRefundLocktime } from "../src/deposit" import { BitcoinNetwork } from "../src/bitcoin-network" @@ -506,4 +507,41 @@ describe("Bitcoin", () => { }) }) }) + + describe("readCompactSizeUint", () => { + context("when the compact size uint is 1-byte", () => { + it("should return the the uint value and byte length", () => { + expect(readCompactSizeUint(Hex.from("bb"))).to.be.eql({ + value: 187, + byteLength: 1, + }) + }) + }) + + context("when the compact size uint is 3-byte", () => { + it("should throw", () => { + expect(() => readCompactSizeUint(Hex.from("fd0302"))).to.throw( + "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + ) + }) + }) + + context("when the compact size uint is 5-byte", () => { + it("should throw", () => { + expect(() => readCompactSizeUint(Hex.from("fe703a0f00"))).to.throw( + "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + ) + }) + }) + + context("when the compact size uint is 9-byte", () => { + it("should throw", () => { + expect(() => { + return readCompactSizeUint(Hex.from("ff57284e56dab40000")) + }).to.throw( + "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + ) + }) + }) + }) }) diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index 6a429c655..c18c0909f 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -5,7 +5,7 @@ import { UnspentTransactionOutput, } from "../../src/bitcoin" import { BigNumberish, BigNumber, utils, constants } from "ethers" -import { RedemptionRequest } from "../redemption" +import { RedemptionRequest, RedemptionRequestedEvent } from "../redemption" import { Deposit, DepositRevealedEvent, @@ -365,4 +365,11 @@ export class MockBridge implements Bridge { ) ) } + + getRedemptionRequestedEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + throw new Error("not implemented") + } } From 5c0016517739e6ae43cb7bf9bea30d86343183cc Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Tue, 1 Aug 2023 17:37:23 +0100 Subject: [PATCH 037/205] Two-stage authority change --- cross-chain/solana/programs/tbtc/src/error.rs | 2 + cross-chain/solana/programs/tbtc/src/lib.rs | 8 ++ .../admin/cancel_authority_change.rs | 22 ++++ .../src/processor/admin/change_authority.rs | 5 +- .../tbtc/src/processor/admin/initialize.rs | 1 + .../programs/tbtc/src/processor/admin/mod.rs | 6 ++ .../src/processor/admin/take_authority.rs | 24 +++++ .../solana/programs/tbtc/src/state/config.rs | 1 + cross-chain/solana/tests/01__tbtc.ts | 101 +++++++++++++++++- 9 files changed, 167 insertions(+), 3 deletions(-) create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/cancel_authority_change.rs create mode 100644 cross-chain/solana/programs/tbtc/src/processor/admin/take_authority.rs diff --git a/cross-chain/solana/programs/tbtc/src/error.rs b/cross-chain/solana/programs/tbtc/src/error.rs index 434c27b05..5e1b279d5 100644 --- a/cross-chain/solana/programs/tbtc/src/error.rs +++ b/cross-chain/solana/programs/tbtc/src/error.rs @@ -5,4 +5,6 @@ pub enum TbtcError { IsPaused, IsNotPaused, IsNotAuthority, + IsNotPendingAuthority, + NoPendingAuthorityChange, } diff --git a/cross-chain/solana/programs/tbtc/src/lib.rs b/cross-chain/solana/programs/tbtc/src/lib.rs index 593302351..daa07cdd7 100644 --- a/cross-chain/solana/programs/tbtc/src/lib.rs +++ b/cross-chain/solana/programs/tbtc/src/lib.rs @@ -34,6 +34,14 @@ pub mod tbtc { processor::change_authority(ctx) } + pub fn cancel_authority_change(ctx: Context) -> Result<()> { + processor::cancel_authority_change(ctx) + } + + pub fn take_authority(ctx: Context) -> Result<()> { + processor::take_authority(ctx) + } + pub fn add_minter(ctx: Context) -> Result<()> { processor::add_minter(ctx) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/cancel_authority_change.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/cancel_authority_change.rs new file mode 100644 index 000000000..92000cca0 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/cancel_authority_change.rs @@ -0,0 +1,22 @@ +use crate::{error::TbtcError, state::Config}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] + +pub struct CancelAuthorityChange<'info> { + #[account( + mut, + seeds = [Config::SEED_PREFIX], + bump, + has_one = authority @ TbtcError::IsNotAuthority, + constraint = config.pending_authority.is_some() @ TbtcError::NoPendingAuthorityChange + )] + config: Account<'info, Config>, + + authority: Signer<'info>, +} + +pub fn cancel_authority_change(ctx: Context) -> Result<()> { + ctx.accounts.config.pending_authority = None; + Ok(()) +} diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs index d2d0d1669..0581396c0 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/change_authority.rs @@ -13,10 +13,11 @@ pub struct ChangeAuthority<'info> { authority: Signer<'info>, - new_authority: Signer<'info>, + /// CHECK: New authority. + new_authority: AccountInfo<'info>, } pub fn change_authority(ctx: Context) -> Result<()> { - ctx.accounts.config.authority = ctx.accounts.new_authority.key(); + ctx.accounts.config.pending_authority = Some(ctx.accounts.new_authority.key()); Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs index 9b418ddfd..e32ebc5bb 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs @@ -36,6 +36,7 @@ pub fn initialize(ctx: Context) -> Result<()> { ctx.accounts.config.set_inner(Config { bump: ctx.bumps["config"], authority: ctx.accounts.authority.key(), + pending_authority: None, mint: ctx.accounts.mint.key(), mint_bump: ctx.bumps["mint"], num_minters: 0, diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs index bc1f98170..4e9b75a5c 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/mod.rs @@ -4,6 +4,9 @@ pub use add_guardian::*; mod add_minter; pub use add_minter::*; +mod cancel_authority_change; +pub use cancel_authority_change::*; + mod change_authority; pub use change_authority::*; @@ -19,5 +22,8 @@ pub use remove_guardian::*; mod remove_minter; pub use remove_minter::*; +mod take_authority; +pub use take_authority::*; + mod unpause; pub use unpause::*; diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/take_authority.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/take_authority.rs new file mode 100644 index 000000000..292d2d726 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/take_authority.rs @@ -0,0 +1,24 @@ +use crate::{error::TbtcError, state::Config}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct TakeAuthority<'info> { + #[account( + mut, + seeds = [Config::SEED_PREFIX], + bump, + constraint = config.pending_authority.is_some() @ TbtcError::NoPendingAuthorityChange + )] + config: Account<'info, Config>, + + #[account( + constraint = pending_authority.key() == config.pending_authority.unwrap() @ TbtcError::IsNotPendingAuthority + )] + pending_authority: Signer<'info>, +} + +pub fn take_authority(ctx: Context) -> Result<()> { + ctx.accounts.config.authority = ctx.accounts.pending_authority.key(); + ctx.accounts.config.pending_authority = None; + Ok(()) +} \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/src/state/config.rs b/cross-chain/solana/programs/tbtc/src/state/config.rs index 4dd81b69c..497200848 100644 --- a/cross-chain/solana/programs/tbtc/src/state/config.rs +++ b/cross-chain/solana/programs/tbtc/src/state/config.rs @@ -7,6 +7,7 @@ pub struct Config { /// The authority over this program. pub authority: Pubkey, + pub pending_authority: Option, // Mint info. pub mint: Pubkey, diff --git a/cross-chain/solana/tests/01__tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts index 0b549f1e8..bca0fd8ac 100644 --- a/cross-chain/solana/tests/01__tbtc.ts +++ b/cross-chain/solana/tests/01__tbtc.ts @@ -64,10 +64,57 @@ async function changeAuthority( authority: authority.publicKey, newAuthority: newAuthority.publicKey, }) - .signers(maybeAuthorityAnd(authority, [newAuthority])) + .signers(maybeAuthorityAnd(authority, [])) .rpc(); } +async function takeAuthority( + program: Program, + newAuthority, +) { + const [config,] = getConfigPDA(program); + await program.methods + .takeAuthority() + .accounts({ + config, + pendingAuthority: newAuthority.publicKey, + }) + .signers(maybeAuthorityAnd(newAuthority, [])) + .rpc(); +} + +async function cancelAuthorityChange( + program: Program, + authority, +) { + const [config,] = getConfigPDA(program); + await program.methods + .cancelAuthorityChange() + .accounts({ + config, + authority: authority.publicKey, + }) + .signers(maybeAuthorityAnd(authority, [])) + .rpc(); +} + +async function checkPendingAuthority( + program: Program, + pendingAuthority, +) { + const [config,] = getConfigPDA(program); + let configState = await program.account.config.fetch(config); + expect(configState.pendingAuthority).to.eql(pendingAuthority.publicKey); +} + +async function checkNoPendingAuthority( + program: Program, +) { + const [config,] = getConfigPDA(program); + let configState = await program.account.config.fetch(config); + expect(configState.pendingAuthority).to.equal(null); +} + async function checkPaused( program: Program, paused: boolean @@ -415,9 +462,61 @@ describe("tbtc", () => { it('change authority', async () => { await checkState(program, authority, 0, 0, 0); + await checkNoPendingAuthority(program); + try { + await cancelAuthorityChange(program, authority); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('NoPendingAuthorityChange'); + expect(err.program.equals(program.programId)).is.true; + } + try { + await takeAuthority(program, newAuthority); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('NoPendingAuthorityChange'); + expect(err.program.equals(program.programId)).is.true; + } + await changeAuthority(program, authority, newAuthority); + await checkPendingAuthority(program, newAuthority); + await takeAuthority(program, newAuthority); + await checkNoPendingAuthority(program); await checkState(program, newAuthority, 0, 0, 0); await changeAuthority(program, newAuthority, authority.payer); + try { + await takeAuthority(program, impostorKeys); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsNotPendingAuthority'); + expect(err.program.equals(program.programId)).is.true; + } + try { + await takeAuthority(program, newAuthority); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsNotPendingAuthority'); + expect(err.program.equals(program.programId)).is.true; + } + try { + await cancelAuthorityChange(program, authority); + chai.assert(false, "should've failed but didn't"); + } catch (_err) { + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('IsNotAuthority'); + expect(err.program.equals(program.programId)).is.true; + } + await takeAuthority(program, authority); + await checkState(program, authority, 0, 0, 0); }) From 7a6df17da1afb9da9258e85df580b69f7920a4e3 Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Tue, 1 Aug 2023 18:08:39 +0100 Subject: [PATCH 038/205] Revert "Add iteration of minters" This reverts commit 73964de86ff702b48b6f7988567d0df27b18e1f7. --- .../tbtc/src/processor/admin/add_minter.rs | 17 +---- .../tbtc/src/processor/admin/remove_minter.rs | 32 +------- .../programs/tbtc/src/state/minter_index.rs | 12 --- .../programs/tbtc/src/state/minter_info.rs | 1 - .../solana/programs/tbtc/src/state/mod.rs | 3 - cross-chain/solana/tests/01__tbtc.ts | 76 +++++-------------- 6 files changed, 21 insertions(+), 120 deletions(-) delete mode 100644 cross-chain/solana/programs/tbtc/src/state/minter_index.rs diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs index b99925e85..ccb8620cb 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, MinterIndex, MinterInfo}, + state::{Config, MinterInfo}, }; use anchor_lang::prelude::*; @@ -26,15 +26,6 @@ pub struct AddMinter<'info> { )] minter_info: Account<'info, MinterInfo>, - #[account( - init, - payer = authority, - space = 8 + MinterIndex::INIT_SPACE, - seeds = [MinterIndex::SEED_PREFIX, &[config.num_minters]], - bump - )] - minter_index: Account<'info, MinterIndex>, - /// CHECK: Required authority to mint tokens. This pubkey lives in `MinterInfo`. minter: AccountInfo<'info>, @@ -44,15 +35,9 @@ pub struct AddMinter<'info> { pub fn add_minter(ctx: Context) -> Result<()> { ctx.accounts.minter_info.set_inner(MinterInfo { minter: ctx.accounts.minter.key(), - index: ctx.accounts.config.num_minters, bump: ctx.bumps["minter_info"], }); - ctx.accounts.minter_index.set_inner(MinterIndex { - minter_info: ctx.accounts.minter_info.key(), - bump: ctx.bumps["minter_index"], - }); - ctx.accounts.config.num_minters += 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs index dcb037708..83aa5a07d 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, MinterIndex, MinterInfo}, + state::{Config, MinterInfo}, }; use anchor_lang::prelude::*; @@ -25,36 +25,6 @@ pub struct RemoveMinter<'info> { )] minter_info: Account<'info, MinterInfo>, - // the minter info at the last index. - // This gets its index swapped to the position of the removed minter info. - #[account( - mut, - constraint = minter_info_swap.index == config.num_minters - 1, - seeds = [MinterInfo::SEED_PREFIX, minter_info_swap.minter.as_ref()], - bump = minter_info_swap.bump, - )] - minter_info_swap: Account<'info, MinterInfo>, - - // The index account of the minter to remove. - // We replace minter_info in this with minter_info_swap. - #[account( - mut, - seeds = [MinterIndex::SEED_PREFIX, &[minter_info.index]], - bump = minter_index_swap.bump, - )] - minter_index_swap: Account<'info, MinterIndex>, - - // The last minter index account. - // This gets removed, and its minter_info(_swap) gets put into minter_index_swap instead. - #[account( - mut, - close = authority, - seeds = [MinterIndex::SEED_PREFIX, &[config.num_minters - 1]], - bump = minter_index_tail.bump, - constraint = minter_index_tail.minter_info == minter_info_swap.key(), - )] - minter_index_tail: Account<'info, MinterIndex>, - /// CHECK: Required authority to mint tokens. This pubkey lives in `MinterInfo`. minter: AccountInfo<'info>, } diff --git a/cross-chain/solana/programs/tbtc/src/state/minter_index.rs b/cross-chain/solana/programs/tbtc/src/state/minter_index.rs deleted file mode 100644 index b24cac001..000000000 --- a/cross-chain/solana/programs/tbtc/src/state/minter_index.rs +++ /dev/null @@ -1,12 +0,0 @@ -use anchor_lang::prelude::*; - -#[account] -#[derive(Debug, InitSpace)] -pub struct MinterIndex { - pub minter_info: Pubkey, - pub bump: u8, -} - -impl MinterIndex { - pub const SEED_PREFIX: &'static [u8] = b"minter-index"; -} diff --git a/cross-chain/solana/programs/tbtc/src/state/minter_info.rs b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs index 89717df2c..e8b6a6eeb 100644 --- a/cross-chain/solana/programs/tbtc/src/state/minter_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/minter_info.rs @@ -4,7 +4,6 @@ use anchor_lang::prelude::*; #[derive(Debug, InitSpace)] pub struct MinterInfo { pub minter: Pubkey, - pub index: u8, pub bump: u8, } diff --git a/cross-chain/solana/programs/tbtc/src/state/mod.rs b/cross-chain/solana/programs/tbtc/src/state/mod.rs index d54275df4..cb61742a2 100644 --- a/cross-chain/solana/programs/tbtc/src/state/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/state/mod.rs @@ -7,8 +7,5 @@ pub use guardian_index::*; mod guardian_info; pub use guardian_info::*; -mod minter_index; -pub use minter_index::*; - mod minter_info; pub use minter_info::*; diff --git a/cross-chain/solana/tests/01__tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts index bca0fd8ac..f50e193f3 100644 --- a/cross-chain/solana/tests/01__tbtc.ts +++ b/cross-chain/solana/tests/01__tbtc.ts @@ -160,41 +160,21 @@ function getMinterPDA( ); } -function getMinterIndexPDA( - program: Program, - index -): [anchor.web3.PublicKey, number] { - let indexArr = new Uint8Array(1); - indexArr[0] = index; - return web3.PublicKey.findProgramAddressSync( - [ - Buffer.from('minter-index'), - indexArr, - ], - program.programId - ); -} - async function addMinter( program: Program, authority, - minter + minter, + payer ): Promise { const [config,] = getConfigPDA(program); const [minterInfoPDA, _] = getMinterPDA(program, minter); - - let configState = await program.account.config.fetch(config); - - const [minterIndexPDA, __] = getMinterIndexPDA(program, configState.numMinters); - await program.methods .addMinter() .accounts({ config, authority: authority.publicKey, - minterInfo: minterInfoPDA, - minterIndex: minterIndexPDA, minter: minter.publicKey, + minterInfo: minterInfoPDA, }) .signers(maybeAuthorityAnd(authority, [])) .rpc(); @@ -203,22 +183,13 @@ async function addMinter( async function checkMinter( program: Program, - minter, - expectedIndex + minter ) { const [minterInfoPDA, bump] = getMinterPDA(program, minter); let minterInfo = await program.account.minterInfo.fetch(minterInfoPDA); - const [minterIndexPDA, indexBump] = getMinterIndexPDA(program, minterInfo.index); - let minterIndex = await program.account.minterIndex.fetch(minterIndexPDA); - expect(minterInfo.minter).to.eql(minter.publicKey); expect(minterInfo.bump).to.equal(bump); - - expect(minterIndex.minterInfo).to.eql(minterInfoPDA); - expect(minterIndex.bump).to.equal(indexBump); - - expect(minterInfo.index).to.equal(expectedIndex); } async function removeMinter( @@ -228,24 +199,12 @@ async function removeMinter( minterInfo ) { const [config,] = getConfigPDA(program); - const configState = await program.account.config.fetch(config); - const minterInfoState = await program.account.minterInfo.fetch(minterInfo); - - const [lastIndex,] = getMinterIndexPDA(program, configState.numMinters - 1); - const [swapIndex,] = getMinterIndexPDA(program, minterInfoState.index); - - const lastIndexState = await program.account.minterIndex.fetch(lastIndex); - const swapInfo = lastIndexState.minterInfo; - await program.methods .removeMinter() .accounts({ config, authority: authority.publicKey, minterInfo: minterInfo, - minterInfoSwap: swapInfo, - minterIndexSwap: swapIndex, - minterIndexTail: lastIndex, minter: minter.publicKey }) .signers(maybeAuthorityAnd(authority, [])) @@ -522,8 +481,8 @@ describe("tbtc", () => { it('add minter', async () => { await checkState(program, authority, 0, 0, 0); - await addMinter(program, authority, minterKeys); - await checkMinter(program, minterKeys, 0); + await addMinter(program, authority, minterKeys, authority); + await checkMinter(program, minterKeys); await checkState(program, authority, 1, 0, 0); // Transfer lamports to imposter. @@ -540,7 +499,7 @@ describe("tbtc", () => { ); try { - await addMinter(program, impostorKeys, minter2Keys); + await addMinter(program, impostorKeys, minter2Keys, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -553,7 +512,7 @@ describe("tbtc", () => { it('mint', async () => { await checkState(program, authority, 1, 0, 0); const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys, 0); + await checkMinter(program, minterKeys); // await setupMint(program, authority, recipientKeys); await mint(program, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); @@ -574,7 +533,7 @@ describe("tbtc", () => { it('won\'t mint', async () => { await checkState(program, authority, 1, 0, 1000); const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys, 0); + await checkMinter(program, minterKeys); // await setupMint(program, authority, recipientKeys); @@ -592,9 +551,9 @@ describe("tbtc", () => { it('use two minters', async () => { await checkState(program, authority, 1, 0, 1000); const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys, 0); - const minter2InfoPDA = await addMinter(program, authority, minter2Keys); - await checkMinter(program, minter2Keys, 1); + await checkMinter(program, minterKeys); + const minter2InfoPDA = await addMinter(program, authority, minter2Keys, authority); + await checkMinter(program, minter2Keys); await checkState(program, authority, 2, 0, 1000); // await setupMint(program, authority, recipientKeys); @@ -627,7 +586,7 @@ describe("tbtc", () => { it('remove minter', async () => { await checkState(program, authority, 2, 0, 1500); const [minter2InfoPDA, _] = getMinterPDA(program, minter2Keys); - await checkMinter(program, minter2Keys, 1); + await checkMinter(program, minter2Keys); await removeMinter(program, authority, minter2Keys, minter2InfoPDA); await checkState(program, authority, 1, 0, 1500); }); @@ -635,7 +594,7 @@ describe("tbtc", () => { it('won\'t remove minter', async () => { await checkState(program, authority, 1, 0, 1500); const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys, 0); + await checkMinter(program, minterKeys); try { await removeMinter(program, impostorKeys, minterKeys, minterInfoPDA); @@ -654,7 +613,10 @@ describe("tbtc", () => { await removeMinter(program, authority, minterKeys, minterInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { - expect(_err.message).to.include('Account does not exist or has no data'); + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('AccountNotInitialized'); + expect(err.program.equals(program.programId)).is.true; } }); @@ -741,7 +703,7 @@ describe("tbtc", () => { it('won\'t mint when paused', async () => { await checkState(program, authority, 0, 1, 1500); - const minterInfoPDA = await addMinter(program, authority, minterKeys); + const minterInfoPDA = await addMinter(program, authority, minterKeys, authority); await pause(program, guardianKeys); // await setupMint(program, authority, recipientKeys); From 23bfffc7abbd8ab3b3ff93c9a3a09b908fbc0bdc Mon Sep 17 00:00:00 2001 From: Promethea Raschke Date: Tue, 1 Aug 2023 18:08:50 +0100 Subject: [PATCH 039/205] Revert "Add iteration for guardians" This reverts commit 5d7877db649cf71e5e24c0d97afe82ee7da4ed26. --- .../tbtc/src/processor/admin/add_guardian.rs | 17 +--- .../src/processor/admin/remove_guardian.rs | 35 +------- .../programs/tbtc/src/state/guardian_index.rs | 12 --- .../programs/tbtc/src/state/guardian_info.rs | 1 - .../solana/programs/tbtc/src/state/mod.rs | 3 - cross-chain/solana/tests/01__tbtc.ts | 81 ++++--------------- 6 files changed, 18 insertions(+), 131 deletions(-) delete mode 100644 cross-chain/solana/programs/tbtc/src/state/guardian_index.rs diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs index 82e3d3380..422bac905 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, GuardianIndex, GuardianInfo}, + state::{Config, GuardianInfo}, }; use anchor_lang::prelude::*; @@ -26,15 +26,6 @@ pub struct AddGuardian<'info> { )] guardian_info: Account<'info, GuardianInfo>, - #[account( - init, - payer = authority, - space = 8 + GuardianIndex::INIT_SPACE, - seeds = [GuardianIndex::SEED_PREFIX, &[config.num_guardians]], - bump - )] - guardian_index: Account<'info, GuardianIndex>, - /// CHECK: Required authority to pause contract. This pubkey lives in `GuardianInfo`. guardian: AccountInfo<'info>, @@ -44,15 +35,9 @@ pub struct AddGuardian<'info> { pub fn add_guardian(ctx: Context) -> Result<()> { ctx.accounts.guardian_info.set_inner(GuardianInfo { guardian: ctx.accounts.guardian.key(), - index: ctx.accounts.config.num_guardians, bump: ctx.bumps["guardian_info"], }); - ctx.accounts.guardian_index.set_inner(GuardianIndex { - guardian_info: ctx.accounts.guardian_info.key(), - bump: ctx.bumps["guardian_index"], - }); - ctx.accounts.config.num_guardians += 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs index 9fb05b122..777edf865 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, GuardianIndex, GuardianInfo}, + state::{Config, GuardianInfo}, }; use anchor_lang::prelude::*; @@ -14,7 +14,6 @@ pub struct RemoveGuardian<'info> { authority: Signer<'info>, - // the guardian info to remove #[account( mut, has_one = guardian, @@ -24,43 +23,11 @@ pub struct RemoveGuardian<'info> { )] guardian_info: Account<'info, GuardianInfo>, - // the guardian info at the last index. - // This gets its index swapped to the position of the removed guardian info. - #[account( - mut, - constraint = guardian_info_swap.index == config.num_guardians - 1, - seeds = [GuardianInfo::SEED_PREFIX, guardian_info_swap.guardian.as_ref()], - bump = guardian_info_swap.bump, - )] - guardian_info_swap: Account<'info, GuardianInfo>, - - // The index account of the guardian to remove. - // We replace guardian_info in this with guardian_info_swap. - #[account( - mut, - seeds = [GuardianIndex::SEED_PREFIX, &[guardian_info.index]], - bump = guardian_index_swap.bump, - )] - guardian_index_swap: Account<'info, GuardianIndex>, - - // The last guardian index account. - // This gets removed, and its guardian_info(_swap) gets put into guardian_index_swap instead. - #[account( - mut, - close = authority, - seeds = [GuardianIndex::SEED_PREFIX, &[config.num_guardians - 1]], - bump = guardian_index_tail.bump, - constraint = guardian_index_tail.guardian_info == guardian_info_swap.key(), - )] - guardian_index_tail: Account<'info, GuardianIndex>, - /// CHECK: Required authority to pause contract. This pubkey lives in `GuardianInfo`. guardian: AccountInfo<'info>, } pub fn remove_guardian(ctx: Context) -> Result<()> { - ctx.accounts.guardian_index_swap.guardian_info = ctx.accounts.guardian_index_tail.guardian_info; - ctx.accounts.guardian_info_swap.index = ctx.accounts.guardian_info.index; ctx.accounts.config.num_guardians -= 1; Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/state/guardian_index.rs b/cross-chain/solana/programs/tbtc/src/state/guardian_index.rs deleted file mode 100644 index d10bcc196..000000000 --- a/cross-chain/solana/programs/tbtc/src/state/guardian_index.rs +++ /dev/null @@ -1,12 +0,0 @@ -use anchor_lang::prelude::*; - -#[account] -#[derive(Debug, InitSpace)] -pub struct GuardianIndex { - pub guardian_info: Pubkey, - pub bump: u8, -} - -impl GuardianIndex { - pub const SEED_PREFIX: &'static [u8] = b"guardian-index"; -} diff --git a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs index 697d5333e..34f1492ba 100644 --- a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs @@ -4,7 +4,6 @@ use anchor_lang::prelude::*; #[derive(Debug, InitSpace)] pub struct GuardianInfo { pub guardian: Pubkey, - pub index: u8, pub bump: u8, } diff --git a/cross-chain/solana/programs/tbtc/src/state/mod.rs b/cross-chain/solana/programs/tbtc/src/state/mod.rs index cb61742a2..dffd4099b 100644 --- a/cross-chain/solana/programs/tbtc/src/state/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/state/mod.rs @@ -1,9 +1,6 @@ mod config; pub use config::*; -mod guardian_index; -pub use guardian_index::*; - mod guardian_info; pub use guardian_info::*; diff --git a/cross-chain/solana/tests/01__tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts index f50e193f3..f69c0a820 100644 --- a/cross-chain/solana/tests/01__tbtc.ts +++ b/cross-chain/solana/tests/01__tbtc.ts @@ -224,39 +224,20 @@ function getGuardianPDA( ); } -function getGuardianIndexPDA( - program: Program, - index -): [anchor.web3.PublicKey, number] { - let indexArr = new Uint8Array(1); - indexArr[0] = index; - return web3.PublicKey.findProgramAddressSync( - [ - Buffer.from('guardian-index'), - indexArr, - ], - program.programId - ); -} - async function addGuardian( program: Program, authority, - guardian + guardian, + payer ): Promise { const [config,] = getConfigPDA(program); const [guardianInfoPDA, _] = getGuardianPDA(program, guardian); - - let configState = await program.account.config.fetch(config); - - const [guardianIndexPDA, __] = getGuardianIndexPDA(program, configState.numGuardians); await program.methods .addGuardian() .accounts({ config, authority: authority.publicKey, guardianInfo: guardianInfoPDA, - guardianIndex: guardianIndexPDA, guardian: guardian.publicKey, }) .signers(maybeAuthorityAnd(authority, [])) @@ -266,22 +247,13 @@ async function addGuardian( async function checkGuardian( program: Program, - guardian, - expectedIndex + guardian ) { const [guardianInfoPDA, bump] = getGuardianPDA(program, guardian); let guardianInfo = await program.account.guardianInfo.fetch(guardianInfoPDA); - const [guardianIndexPDA, indexBump] = getGuardianIndexPDA(program, guardianInfo.index); - let guardianIndex = await program.account.guardianIndex.fetch(guardianIndexPDA); - expect(guardianInfo.guardian).to.eql(guardian.publicKey); expect(guardianInfo.bump).to.equal(bump); - - expect(guardianIndex.guardianInfo).to.eql(guardianInfoPDA); - expect(guardianIndex.bump).to.equal(indexBump); - - expect(guardianInfo.index).to.equal(expectedIndex); } async function removeGuardian( @@ -291,24 +263,12 @@ async function removeGuardian( guardianInfo ) { const [config,] = getConfigPDA(program); - const configState = await program.account.config.fetch(config); - const guardianInfoState = await program.account.guardianInfo.fetch(guardianInfo); - - const [lastIndex,] = getGuardianIndexPDA(program, configState.numGuardians - 1); - const [swapIndex,] = getGuardianIndexPDA(program, guardianInfoState.index); - - const lastIndexState = await program.account.guardianIndex.fetch(lastIndex); - const swapInfo = lastIndexState.guardianInfo; - await program.methods .removeGuardian() .accounts({ config, authority: authority.publicKey, guardianInfo: guardianInfo, - guardianInfoSwap: swapInfo, - guardianIndexSwap: swapIndex, - guardianIndexTail: lastIndex, guardian: guardian.publicKey }) .signers(maybeAuthorityAnd(authority, [])) @@ -622,12 +582,12 @@ describe("tbtc", () => { it('add guardian', async () => { await checkState(program, authority, 0, 0, 1500); - await addGuardian(program, authority, guardianKeys); - await checkGuardian(program, guardianKeys, 0); + await addGuardian(program, authority, guardianKeys, authority); + await checkGuardian(program, guardianKeys); await checkState(program, authority, 0, 1, 1500); try { - await addGuardian(program, impostorKeys, guardian2Keys); + await addGuardian(program, impostorKeys, guardian2Keys, authority); chai.assert(false, "should've failed but didn't"); } catch (_err) { expect(_err).to.be.instanceOf(AnchorError); @@ -639,8 +599,8 @@ describe("tbtc", () => { it('remove guardian', async () => { await checkState(program, authority, 0, 1, 1500); - const [guardianInfoPDA,] = getGuardianPDA(program, guardianKeys); - await checkGuardian(program, guardianKeys, 0); + const [guardianInfoPDA, _] = getGuardianPDA(program, guardianKeys); + await checkGuardian(program, guardianKeys); try { await removeGuardian(program, impostorKeys, guardianKeys, guardianInfoPDA); @@ -659,25 +619,16 @@ describe("tbtc", () => { await removeGuardian(program, authority, guardianKeys, guardianInfoPDA); chai.assert(false, "should've failed but didn't"); } catch (_err) { - expect(_err.message).to.include('Account does not exist or has no data'); + expect(_err).to.be.instanceOf(AnchorError); + const err: AnchorError = _err; + expect(err.error.errorCode.code).to.equal('AccountNotInitialized'); + expect(err.program.equals(program.programId)).is.true; } - - await addGuardian(program, authority, guardian2Keys); - await addGuardian(program, authority, guardianKeys); - await checkGuardian(program, guardian2Keys, 0); - await checkGuardian(program, guardianKeys, 1); - - const [guardian2InfoPDA,] = getGuardianPDA(program, guardian2Keys); - await removeGuardian(program, authority, guardian2Keys, guardian2InfoPDA); - - await checkGuardian(program, guardianKeys, 0); - - await removeGuardian(program, authority, guardianKeys, guardianInfoPDA); }); it('pause', async () => { await checkState(program, authority, 0, 0, 1500); - await addGuardian(program, authority, guardianKeys); + await addGuardian(program, authority, guardianKeys, authority); await checkPaused(program, false); await pause(program, guardianKeys); await checkPaused(program, true); @@ -724,9 +675,9 @@ describe("tbtc", () => { it('use two guardians', async () => { await checkState(program, authority, 1, 1, 1500); const [guardianInfoPDA, _] = getGuardianPDA(program, guardianKeys); - await checkGuardian(program, guardianKeys, 0); - await addGuardian(program, authority, guardian2Keys); - await checkGuardian(program, guardian2Keys, 1); + await checkGuardian(program, guardianKeys); + await addGuardian(program, authority, guardian2Keys, authority); + await checkGuardian(program, guardian2Keys); await pause(program, guardianKeys); From 8e1f06e0c675856573a19b8940aa371b9c49eae3 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 1 Aug 2023 19:46:43 +0200 Subject: [PATCH 040/205] Basic redemptions monitoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changeset adds redemptions to the monitoring system. Specifically, two new system events are supported now: ### Redemption requested An *informational system event* indicating that a new redemption was requested from the on-chain Bridge contract. This event is directly sent to Discord as a notification that does not require any action. ### Large redemption requested A *warning system event* indicating that a large redemption was requested from the on-chain Bridge contract. This event is sent to Sentry hub and should get team’s attention. The default action is making sure that the redemption is not a result of a malicious action, and if not, that the redemption is handled correctly by the system. --- monitoring/README.adoc | 2 + monitoring/docs/monitoring-and-telemetry.adoc | 16 ++++ monitoring/src/block-explorer.ts | 23 +++++ monitoring/src/context.ts | 2 + monitoring/src/deposit-monitor.ts | 35 ++------ monitoring/src/index.ts | 2 + monitoring/src/redemption-monitor.ts | 88 +++++++++++++++++++ 7 files changed, 140 insertions(+), 28 deletions(-) create mode 100644 monitoring/src/block-explorer.ts create mode 100644 monitoring/src/redemption-monitor.ts diff --git a/monitoring/README.adoc b/monitoring/README.adoc index db0300d48..826c8a809 100644 --- a/monitoring/README.adoc +++ b/monitoring/README.adoc @@ -158,6 +158,8 @@ The behavior can be configured using the following env variables: |*LARGE_DEPOSIT_THRESHOLD_SAT* |Satoshi threshold used to determine which deposits are large. Default: _1000000000_ |No +|*LARGE_REDEMPTION_THRESHOLD_SAT* |Satoshi threshold used to determine which redemptions are large. Default: _1000000000_ |No + |*DATA_DIR_PATH* |Directory used to persist processing data. Default: _./data_ |No |*SENTRY_DSN* |DSN of the Sentry receiver. If not set, events are not dispatched to Sentry |No diff --git a/monitoring/docs/monitoring-and-telemetry.adoc b/monitoring/docs/monitoring-and-telemetry.adoc index 2f369af2e..a1a8c52ad 100644 --- a/monitoring/docs/monitoring-and-telemetry.adoc +++ b/monitoring/docs/monitoring-and-telemetry.adoc @@ -111,11 +111,13 @@ are propagated to the Sentry hub that decides about next steps. Specific system events produced by the monitoring component are: * deposit revealed, +* redemption requested, * wallet registered, * DKG result submitted, * DKG result approved, * DKG result challenged, * large deposit revealed, +* large redemption requested, * optimistic minting canceled, * optimistic minting requested too early, * optimistic minting requested for undetermined Bitcoin transaction, @@ -131,6 +133,12 @@ An *informational system event* indicating that a new deposit was revealed to the on-chain Bridge contract. This event is directly sent to Discord as a notification that does not require any action. +==== Redemption requested + +An *informational system event* indicating that a new redemption was requested +from the on-chain Bridge contract. This event is directly sent to Discord as a +notification that does not require any action. + ==== Wallet registered An *informational system event* indicating that a new wallet was registered @@ -164,6 +172,14 @@ on-chain Bridge contract. This event is sent to Sentry hub and should get team’s attention. The default action is making sure that the deposit is handled correctly by the system. +==== Large redemption requested + +A *warning system event* indicating that a large redemption was requested from +the on-chain Bridge contract. This event is sent to Sentry hub and should get +team’s attention. The default action is making sure that the redemption is +not a result of a malicious action, and if not, that the redemption is +handled correctly by the system. + ==== Optimistic minting cancelled A *warning system event* indicating that an optimistic minting request was diff --git a/monitoring/src/block-explorer.ts b/monitoring/src/block-explorer.ts new file mode 100644 index 000000000..21847a761 --- /dev/null +++ b/monitoring/src/block-explorer.ts @@ -0,0 +1,23 @@ +import { context, Environment } from "./context" + +import type { BitcoinTransactionHash, Hex } from "@keep-network/tbtc-v2.ts" + +const ethTxUrlPrefixMapping = { + [Environment.Mainnet]: "https://etherscan.io/tx", + [Environment.Testnet]: "https://goerli.etherscan.io/tx", +} + +export function createEthTxUrl(txHash: Hex) { + return `${ + ethTxUrlPrefixMapping[context.environment] + }/${txHash.toPrefixedString()}` +} + +const btcTxUrlPrefixMapping = { + [Environment.Mainnet]: "https://mempool.space/tx", + [Environment.Testnet]: "https://mempool.space/testnet/tx", +} + +export function createBtcTxUrl(txHash: BitcoinTransactionHash) { + return `${btcTxUrlPrefixMapping[context.environment]}/${txHash.toString()}` +} diff --git a/monitoring/src/context.ts b/monitoring/src/context.ts index 57e6af324..a153d5abf 100644 --- a/monitoring/src/context.ts +++ b/monitoring/src/context.ts @@ -4,6 +4,7 @@ const { ETHEREUM_URL, ELECTRUM_URL, LARGE_DEPOSIT_THRESHOLD_SAT, + LARGE_REDEMPTION_THRESHOLD_SAT, DATA_DIR_PATH, SENTRY_DSN, DISCORD_WEBHOOK_URL, @@ -52,6 +53,7 @@ export const context = { ethereumUrl: resolveEthereumUrl(), electrumUrl: resolveElectrumUrl(), largeDepositThresholdSat: LARGE_DEPOSIT_THRESHOLD_SAT ?? 1000000000, // 10 BTC by default + largeRedemptionThresholdSat: LARGE_REDEMPTION_THRESHOLD_SAT ?? 1000000000, // 10 BTC by default dataDirPath: DATA_DIR_PATH ?? "./data", sentryDsn: SENTRY_DSN, discordWebhookUrl: DISCORD_WEBHOOK_URL, diff --git a/monitoring/src/deposit-monitor.ts b/monitoring/src/deposit-monitor.ts index 751ffbd10..f11a1e8e2 100644 --- a/monitoring/src/deposit-monitor.ts +++ b/monitoring/src/deposit-monitor.ts @@ -1,43 +1,21 @@ import { BigNumber } from "ethers" import { SystemEventType } from "./system-event" -import { context, Environment } from "./context" +import { context } from "./context" +import { createBtcTxUrl, createEthTxUrl } from "./block-explorer" import type { SystemEvent, Monitor as SystemEventMonitor } from "./system-event" import type { DepositRevealedEvent as DepositRevealedChainEvent } from "@keep-network/tbtc-v2.ts/dist/src/deposit" import type { Bridge } from "@keep-network/tbtc-v2.ts/dist/src/chain" -const satsToRoundedBTC = (sats: BigNumber): string => +export const satsToRoundedBTC = (sats: BigNumber): string => (sats.div(BigNumber.from(1e6)).toNumber() / 100).toFixed(2) -const hashUrls = (chainEvent: DepositRevealedChainEvent) => { - let fundingHashUrlPrefix = "" - let revealHashUrlPrefix = "" - switch (context.environment) { - case Environment.Mainnet: { - fundingHashUrlPrefix = "https://mempool.space/tx/" - revealHashUrlPrefix = "https://etherscan.io/tx/" - break - } - case Environment.Testnet: { - fundingHashUrlPrefix = "https://mempool.space/testnet/tx/" - revealHashUrlPrefix = "https://goerli.etherscan.io/tx/" - break - } - } - - const fundingHash = chainEvent.fundingTxHash.toString() - const transactionHash = chainEvent.transactionHash.toPrefixedString() - return { - btcFundingTxHashURL: fundingHashUrlPrefix + fundingHash, - ethRevealTxHashURL: revealHashUrlPrefix + transactionHash, - } -} - const DepositRevealed = ( chainEvent: DepositRevealedChainEvent ): SystemEvent => { - const { btcFundingTxHashURL, ethRevealTxHashURL } = hashUrls(chainEvent) + const btcFundingTxHashURL = createBtcTxUrl(chainEvent.fundingTxHash) + const ethRevealTxHashURL = createEthTxUrl(chainEvent.transactionHash) return { title: "Deposit revealed", @@ -57,7 +35,8 @@ const DepositRevealed = ( const LargeDepositRevealed = ( chainEvent: DepositRevealedChainEvent ): SystemEvent => { - const { btcFundingTxHashURL, ethRevealTxHashURL } = hashUrls(chainEvent) + const btcFundingTxHashURL = createBtcTxUrl(chainEvent.fundingTxHash) + const ethRevealTxHashURL = createEthTxUrl(chainEvent.transactionHash) return { title: "Large deposit revealed", diff --git a/monitoring/src/index.ts b/monitoring/src/index.ts index 900c48f36..a382e3b19 100644 --- a/monitoring/src/index.ts +++ b/monitoring/src/index.ts @@ -13,6 +13,7 @@ import { context } from "./context" import { MintingMonitor } from "./minting-monitor" import { WalletMonitor } from "./wallet-monitor" import { SupplyMonitor } from "./supply-monitor" +import { RedemptionMonitor } from "./redemption-monitor" import type { Client as BitcoinClient } from "@keep-network/tbtc-v2.ts/dist/src/bitcoin" import type { @@ -27,6 +28,7 @@ const monitors: SystemEventMonitor[] = [ new MintingMonitor(contracts.bridge, contracts.tbtcVault, btcClient), new SupplyMonitor(contracts.tbtcToken, new SupplyMonitorFilePersistence()), new WalletMonitor(contracts.bridge), + new RedemptionMonitor(contracts.bridge), ] const receivers: SystemEventReceiver[] = ((): SystemEventReceiver[] => { diff --git a/monitoring/src/redemption-monitor.ts b/monitoring/src/redemption-monitor.ts new file mode 100644 index 000000000..45048cf4d --- /dev/null +++ b/monitoring/src/redemption-monitor.ts @@ -0,0 +1,88 @@ +import { BigNumber } from "ethers" + +import { context } from "./context" +import { SystemEventType } from "./system-event" +import { satsToRoundedBTC } from "./deposit-monitor" +import { createEthTxUrl } from "./block-explorer" + +import type { RedemptionRequestedEvent as RedemptionRequestedChainEvent } from "@keep-network/tbtc-v2.ts/dist/src/redemption" +import type { Bridge } from "@keep-network/tbtc-v2.ts/dist/src/chain" +import type { Monitor as SystemEventMonitor, SystemEvent } from "./system-event" + +const RedemptionRequested = ( + chainEvent: RedemptionRequestedChainEvent +): SystemEvent => { + const ethRequestTxHashURL = createEthTxUrl(chainEvent.transactionHash) + + return { + title: "Redemption requested", + type: SystemEventType.Informational, + data: { + walletPublicKeyHash: chainEvent.walletPublicKeyHash, + redeemerOutputScript: chainEvent.redeemerOutputScript, + requestedAmountBTC: satsToRoundedBTC(chainEvent.requestedAmount), + ethRequestTxHash: chainEvent.transactionHash.toPrefixedString(), + ethRequestTxHashURL, + }, + block: chainEvent.blockNumber, + } +} + +const LargeRedemptionRequested = ( + chainEvent: RedemptionRequestedChainEvent +): SystemEvent => { + const ethRequestTxHashURL = createEthTxUrl(chainEvent.transactionHash) + + return { + title: "Large redemption requested", + type: SystemEventType.Warning, + data: { + walletPublicKeyHash: chainEvent.walletPublicKeyHash, + redeemerOutputScript: chainEvent.redeemerOutputScript, + requestedAmountBTC: satsToRoundedBTC(chainEvent.requestedAmount), + ethRequestTxHash: chainEvent.transactionHash.toPrefixedString(), + ethRequestTxHashURL, + }, + block: chainEvent.blockNumber, + } +} + +export class RedemptionMonitor implements SystemEventMonitor { + private bridge: Bridge + + constructor(bridge: Bridge) { + this.bridge = bridge + } + + async check(fromBlock: number, toBlock: number): Promise { + // eslint-disable-next-line no-console + console.log("running redemption monitor check") + + const chainEvents = await this.bridge.getRedemptionRequestedEvents({ + fromBlock, + toBlock, + }) + + const systemEvents: SystemEvent[] = [] + + // eslint-disable-next-line no-plusplus + for (let i = 0; i < chainEvents.length; i++) { + const chainEvent = chainEvents[i] + + systemEvents.push(RedemptionRequested(chainEvent)) + + if ( + chainEvent.requestedAmount.gt( + BigNumber.from(context.largeRedemptionThresholdSat) + ) + ) { + systemEvents.push(LargeRedemptionRequested(chainEvent)) + } + } + + // eslint-disable-next-line no-console + console.log("completed redemption monitor check") + + return systemEvents + } +} From 9fbab8ad0dc0cc9658697b0df5a5e29341b5c25a Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Tue, 1 Aug 2023 12:02:25 -0500 Subject: [PATCH 041/205] solana: clean up tbtc directory --- cross-chain/solana/programs/tbtc/src/lib.rs | 2 ++ .../solana/programs/tbtc/src/processor/{mint => }/mint.rs | 0 cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-) rename cross-chain/solana/programs/tbtc/src/processor/{mint => }/mint.rs (100%) delete mode 100644 cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs diff --git a/cross-chain/solana/programs/tbtc/src/lib.rs b/cross-chain/solana/programs/tbtc/src/lib.rs index daa07cdd7..f2604b0f9 100644 --- a/cross-chain/solana/programs/tbtc/src/lib.rs +++ b/cross-chain/solana/programs/tbtc/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(clippy::result_large_err)] + mod constants; pub use constants::*; diff --git a/cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs b/cross-chain/solana/programs/tbtc/src/processor/mint.rs similarity index 100% rename from cross-chain/solana/programs/tbtc/src/processor/mint/mint.rs rename to cross-chain/solana/programs/tbtc/src/processor/mint.rs diff --git a/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs b/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs deleted file mode 100644 index 21177667f..000000000 --- a/cross-chain/solana/programs/tbtc/src/processor/mint/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod mint; -pub use mint::*; From 3a45a46e4eec628b164c628fda84f60b5d0de908 Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Tue, 1 Aug 2023 12:02:45 -0500 Subject: [PATCH 042/205] solana: add token bridge cpi --- .../wormhole-gateway/src/constants.rs | 14 -- .../programs/wormhole-gateway/src/lib.rs | 36 ++-- .../src/processor/deposit_wormhole_tbtc.rs | 10 +- .../src/processor/initialize.rs | 44 ++++- .../wormhole-gateway/src/processor/mod.rs | 4 +- .../src/processor/send_tbtc/gateway.rs | 187 ++++++++++++++++++ .../src/processor/send_tbtc/mod.rs | 82 ++++++++ .../src/processor/send_tbtc/wrapped.rs | 179 +++++++++++++++++ .../src/processor/send_tbtc_to_gateway.rs | 109 ---------- .../src/processor/update_gateway_address.rs | 25 ++- .../wormhole-gateway/src/state/custodian.rs | 4 + .../src/state/gateway_info.rs | 2 +- 12 files changed, 537 insertions(+), 159 deletions(-) delete mode 100644 cross-chain/solana/programs/wormhole-gateway/src/constants.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs delete mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc_to_gateway.rs diff --git a/cross-chain/solana/programs/wormhole-gateway/src/constants.rs b/cross-chain/solana/programs/wormhole-gateway/src/constants.rs deleted file mode 100644 index 7aea4b90d..000000000 --- a/cross-chain/solana/programs/wormhole-gateway/src/constants.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub const TBTC_FOREIGN_TOKEN_CHAIN: u8 = 2; - -#[cfg(feature = "mainnet")] -pub const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8d, 0xae, 0xba, 0xde, 0x92, 0x2d, - 0xf7, 0x35, 0xc3, 0x8c, 0x80, 0xc7, 0xeb, 0xd7, 0x08, 0xaf, 0x50, 0x81, 0x5f, 0xaa, -]; - -/// TODO: Fix this to reflect testnet contract address. -#[cfg(feature = "solana-devnet")] -pub const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8d, 0xae, 0xba, 0xde, 0x92, 0x2d, - 0xf7, 0x35, 0xc3, 0x8c, 0x80, 0xc7, 0xeb, 0xd7, 0x08, 0xaf, 0x50, 0x81, 0x5f, 0xaa, -]; diff --git a/cross-chain/solana/programs/wormhole-gateway/src/lib.rs b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs index 3ee804192..b58d6d681 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/lib.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs @@ -1,5 +1,4 @@ -mod constants; -pub use constants::*; +#![allow(clippy::result_large_err)] pub mod error; @@ -13,6 +12,15 @@ use anchor_lang::prelude::*; declare_id!("8H9F5JGbEMyERycwaGuzLS5MQnV7dn2wm2h6egJ3Leiu"); +#[derive(Clone)] +pub struct WormholeGateway; + +impl Id for WormholeGateway { + fn id() -> Pubkey { + ID + } +} + #[program] pub mod wormhole_gateway { @@ -24,10 +32,9 @@ pub mod wormhole_gateway { pub fn update_gateway_address( ctx: Context, - chain_id: u16, - gateway_address: [u8; 32], + args: UpdateGatewayAddressArgs, ) -> Result<()> { - processor::update_gateway_address(ctx, chain_id, gateway_address) + processor::update_gateway_address(ctx, args) } pub fn update_minting_limit(ctx: Context, new_limit: u64) -> Result<()> { @@ -38,15 +45,18 @@ pub mod wormhole_gateway { // processor::receive_tbtc(ctx) // } - pub fn send_tbtc_to_gateway( - ctx: Context, - recipient_chain: u16, - recipient: [u8; 32], - amount: u64, - arbiter_fee: u64, - nonce: u32, + pub fn send_tbtc_gateway( + ctx: Context, + args: SendTbtcGatewayArgs, + ) -> Result<()> { + processor::send_tbtc_gateway(ctx, args) + } + + pub fn send_tbtc_wrapped( + ctx: Context, + args: SendTbtcWrappedArgs, ) -> Result<()> { - processor::send_tbtc_to_gateway(ctx, recipient_chain, recipient, amount, arbiter_fee, nonce) + processor::send_tbtc_wrapped(ctx, args) } pub fn deposit_wormhole_tbtc(ctx: Context, amount: u64) -> Result<()> { diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs index 24a263008..c36fb3e93 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs @@ -18,11 +18,11 @@ pub struct DepositWormholeTbtc<'info> { /// This token account is owned by this program, whose mint is the wrapped TBTC mint. This PDA /// address is stored in the custodian account. #[account(mut)] - wrapped_tbtc_token: Account<'info, token::TokenAccount>, + wrapped_tbtc_token: Box>, /// This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the /// custodian account. - wrapped_tbtc_mint: Account<'info, token::Mint>, + wrapped_tbtc_mint: Box>, /// This mint is owned by the TBTC program. This PDA address is stored in the custodian account. #[account(mut)] @@ -33,7 +33,7 @@ pub struct DepositWormholeTbtc<'info> { token::mint = wrapped_tbtc_mint, token::authority = recipient )] - recipient_wrapped_token: Account<'info, token::TokenAccount>, + recipient_wrapped_token: Box>, // Use the associated token account for the recipient. #[account( @@ -41,7 +41,7 @@ pub struct DepositWormholeTbtc<'info> { token::mint = tbtc_mint, token::authority = recipient, )] - recipient_token: Account<'info, token::TokenAccount>, + recipient_token: Box>, /// This program requires that the owner of the TBTC token account sign for TBTC being minted /// into his account. @@ -50,7 +50,7 @@ pub struct DepositWormholeTbtc<'info> { /// CHECK: TBTC program requires this account. tbtc_config: UncheckedAccount<'info>, - // CHECK: TBTC program requires this account. + /// CHECK: TBTC program requires this account. minter_info: UncheckedAccount<'info>, token_program: Program<'info, token::Token>, diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs index cf6afc196..c26b191d2 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs @@ -1,13 +1,28 @@ -use crate::{ - constants::{TBTC_FOREIGN_TOKEN_ADDRESS, TBTC_FOREIGN_TOKEN_CHAIN}, - state::Custodian, -}; +use crate::state::Custodian; use anchor_lang::prelude::*; use anchor_spl::token; use wormhole_anchor_sdk::token_bridge; +const TBTC_FOREIGN_TOKEN_CHAIN: u8 = 2; + +#[cfg(feature = "mainnet")] +const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8d, 0xae, 0xba, 0xde, 0x92, 0x2d, + 0xf7, 0x35, 0xc3, 0x8c, 0x80, 0xc7, 0xeb, 0xd7, 0x08, 0xaf, 0x50, 0x81, 0x5f, 0xaa, +]; + +/// TODO: Fix this to reflect testnet contract address. +#[cfg(feature = "solana-devnet")] +const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8d, 0xae, 0xba, 0xde, 0x92, 0x2d, + 0xf7, 0x35, 0xc3, 0x8c, 0x80, 0xc7, 0xeb, 0xd7, 0x08, 0xaf, 0x50, 0x81, 0x5f, 0xaa, +]; + #[derive(Accounts)] pub struct Initialize<'info> { + #[account(mut)] + authority: Signer<'info>, + #[account( init, payer = authority, @@ -47,8 +62,21 @@ pub struct Initialize<'info> { )] wrapped_tbtc_token: Account<'info, token::TokenAccount>, - #[account(mut)] - authority: Signer<'info>, + /// CHECK: This account is needed for the Token Bridge program. This PDA is specifically used to + /// sign for transferring via Token Bridge program with a message. + #[account( + seeds = [token_bridge::SEED_PREFIX_SENDER], + bump, + )] + token_bridge_sender: AccountInfo<'info>, + + /// CHECK: This account is needed for the Token Bridge program. This PDA is specifically used to + /// sign for transferring via Token Bridge program with a message. + #[account( + seeds = [token_bridge::SEED_PREFIX_REDEEMER], + bump, + )] + token_bridge_redeemer: AccountInfo<'info>, system_program: Program<'info, System>, token_program: Program<'info, token::Token>, @@ -61,6 +89,10 @@ pub fn initialize(ctx: Context, minting_limit: u64) -> Result<()> { tbtc_mint: ctx.accounts.tbtc_mint.key(), wrapped_tbtc_mint: ctx.accounts.wrapped_tbtc_mint.key(), wrapped_tbtc_token: ctx.accounts.wrapped_tbtc_token.key(), + token_bridge_sender: ctx.accounts.token_bridge_sender.key(), + token_bridge_sender_bump: ctx.bumps["token_bridge_sender"], + token_bridge_redeemer: ctx.accounts.token_bridge_sender.key(), + token_bridge_redeemer_bump: ctx.bumps["token_bridge_redeemer"], minting_limit, }); diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs index d9cb203f3..8948c9b82 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs @@ -7,8 +7,8 @@ pub use initialize::*; // mod receive_tbtc; // pub use receive_tbtc::*; -mod send_tbtc_to_gateway; -pub use send_tbtc_to_gateway::*; +mod send_tbtc; +pub use send_tbtc::*; mod update_gateway_address; pub use update_gateway_address::*; diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs new file mode 100644 index 000000000..babd8a490 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs @@ -0,0 +1,187 @@ +use crate::state::{Custodian, GatewayInfo}; +use anchor_lang::prelude::*; +use anchor_spl::token; +use wormhole_anchor_sdk::{ + token_bridge::{self, program::TokenBridge}, + wormhole::{self as core_bridge, program::Wormhole as CoreBridge}, +}; + +#[derive(Accounts)] +#[instruction(args: SendTbtcGatewayArgs)] +pub struct SendTbtcGateway<'info> { + #[account( + seeds = [Custodian::SEED_PREFIX], + bump = custodian.bump, + has_one = wrapped_tbtc_token, + has_one = wrapped_tbtc_mint, + has_one = tbtc_mint, + has_one = token_bridge_sender, + )] + custodian: Account<'info, Custodian>, + + #[account( + seeds = [GatewayInfo::SEED_PREFIX, &args.recipient_chain.to_le_bytes()], + bump = gateway_info.bump, + )] + gateway_info: Account<'info, GatewayInfo>, + + /// Custody account. + wrapped_tbtc_token: Box>, + + /// CHECK: This account is needed for the Token Bridge program. + wrapped_tbtc_mint: UncheckedAccount<'info>, + + #[account(mut)] + tbtc_mint: Box>, + + #[account( + mut, + token::mint = tbtc_mint, + token::authority = sender + )] + sender_token: Box>, + + #[account(mut)] + sender: Signer<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_config: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_wrapped_asset: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_transfer_authority: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + #[account(mut)] + core_bridge: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + #[account( + mut, + seeds = [b"msg", &core_emitter_sequence.value().to_le_bytes()], + bump, + )] + core_message: AccountInfo<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_core_emitter: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + #[account(mut)] + core_emitter_sequence: Account<'info, core_bridge::SequenceTracker>, + + /// CHECK: This account is needed for the Token Bridge program. + #[account(mut)] + core_fee_collector: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + clock: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. This PDA is specifically used to + /// sign for transferring via Token Bridge program with a message. + token_bridge_sender: AccountInfo<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + rent: UncheckedAccount<'info>, + + token_bridge_program: Program<'info, TokenBridge>, + core_bridge_program: Program<'info, CoreBridge>, + token_program: Program<'info, token::Token>, + system_program: Program<'info, System>, +} + +impl<'info> SendTbtcGateway<'info> { + fn constraints(ctx: &Context, args: &SendTbtcGatewayArgs) -> Result<()> { + super::validate_send( + &ctx.accounts.wrapped_tbtc_token, + &args.recipient, + args.amount, + ) + } +} + +#[derive(Debug, Clone, AnchorSerialize, AnchorDeserialize)] +pub struct SendTbtcGatewayArgs { + amount: u64, + recipient_chain: u16, + recipient: [u8; 32], + nonce: u32, +} + +#[access_control(SendTbtcGateway::constraints(&ctx, &args))] +pub fn send_tbtc_gateway(ctx: Context, args: SendTbtcGatewayArgs) -> Result<()> { + let SendTbtcGatewayArgs { + amount, + recipient_chain, + recipient, + nonce, + } = args; + + let sender = &ctx.accounts.sender; + let custodian = &ctx.accounts.custodian; + let wrapped_tbtc_token = &ctx.accounts.wrapped_tbtc_token; + let token_bridge_transfer_authority = &ctx.accounts.token_bridge_transfer_authority; + let token_program = &ctx.accounts.token_program; + + // Prepare for wrapped tBTC transfer (this method also truncates the amount to prevent having to + // handle dust since tBTC has >8 decimals). + let amount = super::burn_and_prepare_transfer( + super::PrepareTransfer { + custodian, + tbtc_mint: &ctx.accounts.tbtc_mint, + sender_token: &ctx.accounts.sender_token, + sender, + wrapped_tbtc_token, + token_bridge_transfer_authority, + token_program, + }, + amount, + )?; + + // Finally transfer wrapped tBTC with the recipient encoded as this transfer's message. + token_bridge::transfer_wrapped_with_payload( + CpiContext::new_with_signer( + ctx.accounts.token_bridge_program.to_account_info(), + token_bridge::TransferWrappedWithPayload { + payer: sender.to_account_info(), + config: ctx.accounts.token_bridge_config.to_account_info(), + from: wrapped_tbtc_token.to_account_info(), + from_owner: custodian.to_account_info(), + wrapped_mint: ctx.accounts.wrapped_tbtc_mint.to_account_info(), + wrapped_metadata: ctx.accounts.token_bridge_wrapped_asset.to_account_info(), + authority_signer: token_bridge_transfer_authority.to_account_info(), + wormhole_bridge: ctx.accounts.core_bridge.to_account_info(), + wormhole_message: ctx.accounts.core_message.to_account_info(), + wormhole_emitter: ctx.accounts.token_bridge_core_emitter.to_account_info(), + wormhole_sequence: ctx.accounts.core_emitter_sequence.to_account_info(), + wormhole_fee_collector: ctx.accounts.core_fee_collector.to_account_info(), + clock: ctx.accounts.clock.to_account_info(), + sender: ctx.accounts.token_bridge_sender.to_account_info(), + rent: ctx.accounts.rent.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + token_program: token_program.to_account_info(), + wormhole_program: ctx.accounts.core_bridge_program.to_account_info(), + }, + &[ + &[Custodian::SEED_PREFIX, &[custodian.bump]], + &[ + token_bridge::SEED_PREFIX_SENDER, + &[ctx.accounts.custodian.token_bridge_sender_bump], + ], + &[ + b"msg", + &ctx.accounts.core_emitter_sequence.value().to_le_bytes(), + &[ctx.bumps["core_message"]], + ], + ], + ), + nonce, + amount, + ctx.accounts.gateway_info.address, + recipient_chain, + recipient.to_vec(), + &crate::ID, + ) +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs new file mode 100644 index 000000000..a1b89550f --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs @@ -0,0 +1,82 @@ +mod gateway; +pub use gateway::*; + +mod wrapped; +pub use wrapped::*; + +use crate::error::WormholeGatewayError; +use crate::state::Custodian; +use anchor_lang::prelude::*; +use anchor_spl::token; + +pub fn validate_send( + wrapped_tbtc_token: &Account<'_, token::TokenAccount>, + recipient: &[u8; 32], + amount: u64, +) -> Result<()> { + require!(*recipient != [0; 32], WormholeGatewayError::ZeroRecipient); + require_gt!(amount, 0, WormholeGatewayError::ZeroAmount); + + // Check that the wrapped tBTC in custody is at least enough to bridge out. + require_gte!( + wrapped_tbtc_token.amount, + amount, + WormholeGatewayError::NotEnoughWrappedTbtc + ); + + Ok(()) +} + +pub struct PrepareTransfer<'ctx, 'info> { + custodian: &'ctx Account<'info, Custodian>, + tbtc_mint: &'ctx Account<'info, token::Mint>, + sender_token: &'ctx Account<'info, token::TokenAccount>, + sender: &'ctx Signer<'info>, + wrapped_tbtc_token: &'ctx Account<'info, token::TokenAccount>, + token_bridge_transfer_authority: &'ctx AccountInfo<'info>, + token_program: &'ctx Program<'info, token::Token>, +} + +pub fn burn_and_prepare_transfer(prepare_transfer: PrepareTransfer, amount: u64) -> Result { + let PrepareTransfer { + custodian, + tbtc_mint, + sender_token, + sender, + wrapped_tbtc_token, + token_bridge_transfer_authority, + token_program, + } = prepare_transfer; + + let truncated = 10 * (amount / 10); + require_gt!(truncated, 0, WormholeGatewayError::TruncatedZeroAmount); + + // Burn TBTC mint. + token::burn( + CpiContext::new( + token_program.to_account_info(), + token::Burn { + mint: tbtc_mint.to_account_info(), + from: sender_token.to_account_info(), + authority: sender.to_account_info(), + }, + ), + amount, + )?; + + // Delegate authority to Token Bridge's transfer authority. + token::approve( + CpiContext::new_with_signer( + token_program.to_account_info(), + token::Approve { + to: wrapped_tbtc_token.to_account_info(), + delegate: token_bridge_transfer_authority.to_account_info(), + authority: custodian.to_account_info(), + }, + &[&[Custodian::SEED_PREFIX, &[custodian.bump]]], + ), + truncated, + )?; + + Ok(truncated) +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs new file mode 100644 index 000000000..37ba459c5 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs @@ -0,0 +1,179 @@ +use crate::state::Custodian; +use anchor_lang::{prelude::*, solana_program}; +use anchor_spl::token; +use wormhole_anchor_sdk::{ + token_bridge::{self, program::TokenBridge}, + wormhole::{self as core_bridge, program::Wormhole as CoreBridge}, +}; + +#[derive(Accounts)] +#[instruction(args: SendTbtcWrappedArgs)] +pub struct SendTbtcWrapped<'info> { + #[account( + seeds = [Custodian::SEED_PREFIX], + bump = custodian.bump, + has_one = wrapped_tbtc_token, + has_one = wrapped_tbtc_mint, + has_one = tbtc_mint, + )] + custodian: Account<'info, Custodian>, + + /// Custody account. + wrapped_tbtc_token: Box>, + + /// CHECK: This account is needed for the Token Bridge program. + wrapped_tbtc_mint: UncheckedAccount<'info>, + + #[account(mut)] + tbtc_mint: Box>, + + #[account( + mut, + token::mint = tbtc_mint, + token::authority = sender + )] + sender_token: Box>, + + #[account(mut)] + sender: Signer<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_config: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_wrapped_asset: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_transfer_authority: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + #[account(mut)] + core_bridge: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + #[account( + mut, + seeds = [b"msg", &core_emitter_sequence.value().to_le_bytes()], + bump, + )] + core_message: AccountInfo<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_core_emitter: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + #[account(mut)] + core_emitter_sequence: Account<'info, core_bridge::SequenceTracker>, + + /// CHECK: This account is needed for the Token Bridge program. + #[account(mut)] + core_fee_collector: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + clock: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + rent: UncheckedAccount<'info>, + + token_bridge_program: Program<'info, TokenBridge>, + core_bridge_program: Program<'info, CoreBridge>, + token_program: Program<'info, token::Token>, + system_program: Program<'info, System>, +} + +impl<'info> SendTbtcWrapped<'info> { + fn constraints(ctx: &Context, args: &SendTbtcWrappedArgs) -> Result<()> { + super::validate_send( + &ctx.accounts.wrapped_tbtc_token, + &args.recipient, + args.amount, + ) + } +} + +#[derive(Debug, Clone, AnchorSerialize, AnchorDeserialize)] +pub struct SendTbtcWrappedArgs { + amount: u64, + recipient_chain: u16, + recipient: [u8; 32], + arbiter_fee: u64, + nonce: u32, +} + +#[access_control(SendTbtcWrapped::constraints(&ctx, &args))] +pub fn send_tbtc_wrapped(ctx: Context, args: SendTbtcWrappedArgs) -> Result<()> { + let SendTbtcWrappedArgs { + amount, + recipient_chain, + recipient, + arbiter_fee, + nonce, + } = args; + + let sender = &ctx.accounts.sender; + let custodian = &ctx.accounts.custodian; + let wrapped_tbtc_token = &ctx.accounts.wrapped_tbtc_token; + let token_bridge_transfer_authority = &ctx.accounts.token_bridge_transfer_authority; + let token_program = &ctx.accounts.token_program; + + // Prepare for wrapped tBTC transfer. + let amount = super::burn_and_prepare_transfer( + super::PrepareTransfer { + custodian, + tbtc_mint: &ctx.accounts.tbtc_mint, + sender_token: &ctx.accounts.sender_token, + sender, + wrapped_tbtc_token, + token_bridge_transfer_authority, + token_program, + }, + amount, + )?; + + // Because the wormhole-anchor-sdk does not support relayable transfers (i.e. payload ID == 1), + // we need to construct the instruction from scratch and invoke it. + let ix = solana_program::instruction::Instruction { + program_id: ctx.accounts.token_bridge_program.key(), + accounts: vec![ + AccountMeta::new(sender.key(), true), + AccountMeta::new_readonly(ctx.accounts.token_bridge_config.key(), false), + AccountMeta::new(wrapped_tbtc_token.key(), false), + AccountMeta::new_readonly(custodian.key(), false), + AccountMeta::new(ctx.accounts.wrapped_tbtc_mint.key(), false), + AccountMeta::new_readonly(ctx.accounts.token_bridge_wrapped_asset.key(), false), + AccountMeta::new_readonly(token_bridge_transfer_authority.key(), false), + AccountMeta::new(ctx.accounts.core_bridge.key(), false), + AccountMeta::new(ctx.accounts.core_message.key(), true), + AccountMeta::new_readonly(ctx.accounts.token_bridge_core_emitter.key(), false), + AccountMeta::new(ctx.accounts.core_emitter_sequence.key(), false), + AccountMeta::new(ctx.accounts.core_fee_collector.key(), false), + AccountMeta::new_readonly(ctx.accounts.clock.key(), false), + AccountMeta::new_readonly(ctx.accounts.rent.key(), false), + AccountMeta::new_readonly(ctx.accounts.system_program.key(), false), + AccountMeta::new_readonly(ctx.accounts.core_bridge_program.key(), false), + AccountMeta::new_readonly(token_program.key(), false), + ], + data: token_bridge::Instruction::TransferWrapped { + batch_id: nonce, + amount, + fee: arbiter_fee, + recipient_address: recipient, + recipient_chain, + } + .try_to_vec()?, + }; + + solana_program::program::invoke_signed( + &ix, + &ctx.accounts.to_account_infos(), + &[ + &[Custodian::SEED_PREFIX, &[custodian.bump]], + &[ + b"msg", + &ctx.accounts.core_emitter_sequence.value().to_le_bytes(), + &[ctx.bumps["core_message"]], + ], + ], + ) + .map_err(Into::into) +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc_to_gateway.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc_to_gateway.rs deleted file mode 100644 index 1b23b542d..000000000 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc_to_gateway.rs +++ /dev/null @@ -1,109 +0,0 @@ -use crate::{ - error::WormholeGatewayError, - state::{Custodian, GatewayInfo}, -}; -use anchor_lang::prelude::*; -use anchor_spl::token; -use wormhole_anchor_sdk::token_bridge::{self, program::TokenBridge}; - -#[derive(Accounts)] -#[instruction(recipient_chain: u16)] -pub struct SendTbtcToGateway<'info> { - #[account( - seeds = [Custodian::SEED_PREFIX], - bump = custodian.bump, - has_one = wrapped_tbtc_mint, - has_one = tbtc_mint, - )] - custodian: Account<'info, Custodian>, - - #[account( - seeds = [GatewayInfo::SEED_PREFIX, &recipient_chain.to_le_bytes()], - bump = gateway_info.bump, - )] - gateway_info: Account<'info, GatewayInfo>, - - /// Custody account. - wrapped_tbtc_token: Account<'info, token::TokenAccount>, - - /// CHECK: This account is needed for the Token Bridge program. - wrapped_tbtc_mint: UncheckedAccount<'info>, - - #[account(mut)] - tbtc_mint: Account<'info, token::Mint>, - - #[account( - mut, - token::mint = wrapped_tbtc_mint, - token::authority = sender - )] - sender_account: Account<'info, token::TokenAccount>, - - sender: Signer<'info>, - - /// Check: This account is needed for the Token Bridge program. - token_bridge_transfer_authority: UncheckedAccount<'info>, - - token_bridge_program: Program<'info, TokenBridge>, - token_program: Program<'info, token::Token>, -} - -pub fn send_tbtc_to_gateway( - ctx: Context, - recipient_chain: u16, - recipient: [u8; 32], - amount: u64, - arbiter_fee: u64, - nonce: u32, -) -> Result<()> { - require!(recipient != [0; 32], WormholeGatewayError::ZeroRecipient); - require_gt!(amount, 0, WormholeGatewayError::ZeroAmount); - - let norm_amount = 10 * (amount / 10); - require_gt!(norm_amount, 0, WormholeGatewayError::TruncatedZeroAmount); - - let gateway = ctx.accounts.gateway_info.gateway; - - ctx.accounts - .wrapped_tbtc_token - .amount - .checked_sub(norm_amount) - .ok_or_else(|| WormholeGatewayError::NotEnoughWrappedTbtc); - - let token_program = &ctx.accounts.token_program; - - // Burn TBTC mint. - token::burn( - CpiContext::new( - token_program.to_account_info(), - token::Burn { - mint: ctx.accounts.tbtc_mint.to_account_info(), - from: ctx.accounts.sender_account.to_account_info(), - authority: ctx.accounts.sender.to_account_info(), - }, - ), - amount, - )?; - - // Delegate authority to Token Bridge's transfer authority. - token::approve( - CpiContext::new_with_signer( - token_program.to_account_info(), - token::Approve { - to: ctx.accounts.wrapped_tbtc_token.to_account_info(), - delegate: ctx - .accounts - .token_bridge_transfer_authority - .to_account_info(), - authority: ctx.accounts.custodian.to_account_info(), - }, - &[&[Custodian::SEED_PREFIX, &[ctx.accounts.custodian.bump]]], - ), - amount, - )?; - - // TODO: Encode message with recipient. - // TODO: Transfer tokens with message. - - Ok(()) -} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs index 25d8358e4..6fcfbfed2 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs @@ -5,38 +5,45 @@ use crate::{ use anchor_lang::prelude::*; #[derive(Accounts)] -#[instruction(chain_id: u16)] +#[instruction(args: UpdateGatewayAddressArgs)] pub struct UpdateGatewayAddress<'info> { #[account( seeds = [Custodian::SEED_PREFIX], bump = custodian.bump, has_one = authority @ WormholeGatewayError::IsNotAuthority, )] - pub custodian: Account<'info, Custodian>, + custodian: Account<'info, Custodian>, #[account( init_if_needed, payer = authority, space = 8 + GatewayInfo::INIT_SPACE, - seeds = [GatewayInfo::SEED_PREFIX, &chain_id.to_le_bytes()], + seeds = [GatewayInfo::SEED_PREFIX, &args.chain.to_le_bytes()], bump, )] - pub gateway_info: Account<'info, GatewayInfo>, + gateway_info: Account<'info, GatewayInfo>, #[account(mut)] - pub authority: Signer<'info>, + authority: Signer<'info>, - pub system_program: Program<'info, System>, + system_program: Program<'info, System>, +} + +#[derive(Debug, Clone, AnchorSerialize, AnchorDeserialize)] +pub struct UpdateGatewayAddressArgs { + chain: u16, + address: [u8; 32], } pub fn update_gateway_address( ctx: Context, - chain_id: u16, - gateway: [u8; 32], + args: UpdateGatewayAddressArgs, ) -> Result<()> { + let UpdateGatewayAddressArgs { address, .. } = args; + ctx.accounts.gateway_info.set_inner(GatewayInfo { bump: ctx.bumps["gateway_info"], - gateway, + address, }); Ok(()) diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs index fd0640913..72882128d 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs @@ -9,6 +9,10 @@ pub struct Custodian { pub tbtc_mint: Pubkey, pub wrapped_tbtc_mint: Pubkey, pub wrapped_tbtc_token: Pubkey, + pub token_bridge_sender: Pubkey, + pub token_bridge_sender_bump: u8, + pub token_bridge_redeemer: Pubkey, + pub token_bridge_redeemer_bump: u8, pub minting_limit: u64, } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs index 895343c8a..3d1171d3b 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/state/gateway_info.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; #[derive(Debug, InitSpace)] pub struct GatewayInfo { pub bump: u8, - pub gateway: [u8; 32], + pub address: [u8; 32], } impl GatewayInfo { From 17ae475b97dce26cc3e2f2c6d05705dfb05cf024 Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Tue, 1 Aug 2023 14:14:47 -0500 Subject: [PATCH 043/205] solana: remove yarn.lock; add package-lock.json; add wormhole sdk --- cross-chain/solana/package-lock.json | 5504 ++++++++++++++++++++++++++ cross-chain/solana/package.json | 1 + cross-chain/solana/yarn.lock | 2493 ------------ 3 files changed, 5505 insertions(+), 2493 deletions(-) create mode 100644 cross-chain/solana/package-lock.json delete mode 100644 cross-chain/solana/yarn.lock diff --git a/cross-chain/solana/package-lock.json b/cross-chain/solana/package-lock.json new file mode 100644 index 000000000..e0307d458 --- /dev/null +++ b/cross-chain/solana/package-lock.json @@ -0,0 +1,5504 @@ +{ + "name": "solana", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "@coral-xyz/anchor": "^0.28.0" + }, + "devDependencies": { + "@certusone/wormhole-sdk": "^0.9.22", + "@solana/spl-token": "^0.3.8", + "@solana/web3.js": "^1.77.3", + "@types/bn.js": "^5.1.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.0.0", + "chai": "^4.3.4", + "mocha": "^9.0.3", + "prettier": "^2.6.2", + "ts-mocha": "^10.0.0", + "typescript": "^4.3.5" + } + }, + "node_modules/@apollo/client": { + "version": "3.7.17", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@graphql-typed-document-node/core": "^3.1.1", + "@wry/context": "^0.7.0", + "@wry/equality": "^0.5.0", + "@wry/trie": "^0.4.0", + "graphql-tag": "^2.12.6", + "hoist-non-react-statics": "^3.3.2", + "optimism": "^0.16.2", + "prop-types": "^15.7.2", + "response-iterator": "^0.2.6", + "symbol-observable": "^4.0.0", + "ts-invariant": "^0.10.3", + "tslib": "^2.3.0", + "zen-observable-ts": "^1.2.5" + }, + "peerDependencies": { + "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0", + "graphql-ws": "^5.5.5", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", + "subscriptions-transport-ws": "^0.9.0 || ^0.11.0" + }, + "peerDependenciesMeta": { + "graphql-ws": { + "optional": true + }, + "react": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "subscriptions-transport-ws": { + "optional": true + } + } + }, + "node_modules/@babel/runtime": { + "version": "7.22.6", + "license": "MIT", + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@certusone/wormhole-sdk": { + "version": "0.9.22", + "resolved": "https://registry.npmjs.org/@certusone/wormhole-sdk/-/wormhole-sdk-0.9.22.tgz", + "integrity": "sha512-4wZFyqqSQBtTq5S42TCrTAircnRjd0t0OZnFRyMe5qtqk96l5iDwIztKBaIccUW+XDXoGfBhSGooW15tH/IpIQ==", + "dev": true, + "dependencies": { + "@certusone/wormhole-sdk-proto-web": "0.0.6", + "@certusone/wormhole-sdk-wasm": "^0.0.1", + "@coral-xyz/borsh": "0.2.6", + "@mysten/sui.js": "0.32.2", + "@project-serum/anchor": "^0.25.0", + "@solana/spl-token": "^0.3.5", + "@solana/web3.js": "^1.66.2", + "@terra-money/terra.js": "3.1.9", + "@xpla/xpla.js": "^0.2.1", + "algosdk": "^1.15.0", + "aptos": "1.5.0", + "axios": "^0.24.0", + "bech32": "^2.0.0", + "binary-parser": "^2.2.1", + "bs58": "^4.0.1", + "elliptic": "^6.5.4", + "js-base64": "^3.6.1", + "near-api-js": "^1.0.0" + }, + "optionalDependencies": { + "@injectivelabs/networks": "1.10.12", + "@injectivelabs/sdk-ts": "1.10.72", + "@injectivelabs/utils": "1.10.12" + } + }, + "node_modules/@certusone/wormhole-sdk-proto-web": { + "version": "0.0.6", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@improbable-eng/grpc-web": "^0.15.0", + "protobufjs": "^7.0.0", + "rxjs": "^7.5.6" + } + }, + "node_modules/@certusone/wormhole-sdk-proto-web/node_modules/@improbable-eng/grpc-web": { + "version": "0.15.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "browser-headers": "^0.4.1" + }, + "peerDependencies": { + "google-protobuf": "^3.14.0" + } + }, + "node_modules/@certusone/wormhole-sdk-proto-web/node_modules/long": { + "version": "5.2.3", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@certusone/wormhole-sdk-proto-web/node_modules/protobufjs": { + "version": "7.2.4", + "dev": true, + "hasInstallScript": true, + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@certusone/wormhole-sdk-wasm": { + "version": "0.0.1", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/long": "^4.0.2", + "@types/node": "^18.0.3" + } + }, + "node_modules/@certusone/wormhole-sdk-wasm/node_modules/@types/node": { + "version": "18.17.1", + "dev": true, + "license": "MIT" + }, + "node_modules/@certusone/wormhole-sdk/node_modules/@injectivelabs/networks": { + "version": "1.10.12", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@injectivelabs/exceptions": "^1.10.12", + "@injectivelabs/ts-types": "^1.10.12", + "@injectivelabs/utils": "^1.10.12", + "link-module-alias": "^1.2.0", + "shx": "^0.3.2" + } + }, + "node_modules/@certusone/wormhole-sdk/node_modules/@injectivelabs/networks/dist": { + "extraneous": true + }, + "node_modules/@certusone/wormhole-sdk/node_modules/@injectivelabs/networks/node_modules/@injectivelabs/utils": { + "version": "1.11.0", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@injectivelabs/exceptions": "^1.11.0", + "@injectivelabs/ts-types": "^1.11.0", + "axios": "^0.21.1", + "bignumber.js": "^9.0.1", + "http-status-codes": "^2.2.0", + "link-module-alias": "^1.2.0", + "shx": "^0.3.2", + "snakecase-keys": "^5.1.2", + "store2": "^2.12.0" + } + }, + "node_modules/@certusone/wormhole-sdk/node_modules/@injectivelabs/networks/node_modules/@injectivelabs/utils/dist": { + "extraneous": true + }, + "node_modules/@certusone/wormhole-sdk/node_modules/@injectivelabs/networks/node_modules/axios": { + "version": "0.21.4", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/@certusone/wormhole-sdk/node_modules/@injectivelabs/utils": { + "version": "1.10.12", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@injectivelabs/exceptions": "^1.10.12", + "@injectivelabs/ts-types": "^1.10.12", + "axios": "^0.21.1", + "bignumber.js": "^9.0.1", + "http-status-codes": "^2.2.0", + "link-module-alias": "^1.2.0", + "shx": "^0.3.2", + "snakecase-keys": "^5.1.2", + "store2": "^2.12.0" + } + }, + "node_modules/@certusone/wormhole-sdk/node_modules/@injectivelabs/utils/dist": { + "extraneous": true + }, + "node_modules/@certusone/wormhole-sdk/node_modules/@injectivelabs/utils/node_modules/axios": { + "version": "0.21.4", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/@certusone/wormhole-sdk/node_modules/axios": { + "version": "0.24.0", + "dev": true, + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.4" + } + }, + "node_modules/@classic-terra/terra.proto": { + "version": "1.1.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@improbable-eng/grpc-web": "^0.14.1", + "google-protobuf": "^3.17.3", + "long": "^4.0.0", + "protobufjs": "~6.11.2" + } + }, + "node_modules/@confio/ics23": { + "version": "0.6.8", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@noble/hashes": "^1.0.0", + "protobufjs": "^6.8.8" + } + }, + "node_modules/@coral-xyz/anchor": { + "version": "0.28.0", + "license": "(MIT OR Apache-2.0)", + "dependencies": { + "@coral-xyz/borsh": "^0.28.0", + "@solana/web3.js": "^1.68.0", + "base64-js": "^1.5.1", + "bn.js": "^5.1.2", + "bs58": "^4.0.1", + "buffer-layout": "^1.2.2", + "camelcase": "^6.3.0", + "cross-fetch": "^3.1.5", + "crypto-hash": "^1.3.0", + "eventemitter3": "^4.0.7", + "js-sha256": "^0.9.0", + "pako": "^2.0.3", + "snake-case": "^3.0.4", + "superstruct": "^0.15.4", + "toml": "^3.0.0" + }, + "engines": { + "node": ">=11" + } + }, + "node_modules/@coral-xyz/anchor/node_modules/@coral-xyz/borsh": { + "version": "0.28.0", + "license": "Apache-2.0", + "dependencies": { + "bn.js": "^5.1.2", + "buffer-layout": "^1.2.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@solana/web3.js": "^1.68.0" + } + }, + "node_modules/@coral-xyz/borsh": { + "version": "0.2.6", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bn.js": "^5.1.2", + "buffer-layout": "^1.2.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@solana/web3.js": "^1.2.0" + } + }, + "node_modules/@cosmjs/amino": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@cosmjs/crypto": "^0.30.1", + "@cosmjs/encoding": "^0.30.1", + "@cosmjs/math": "^0.30.1", + "@cosmjs/utils": "^0.30.1" + } + }, + "node_modules/@cosmjs/crypto": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@cosmjs/encoding": "^0.30.1", + "@cosmjs/math": "^0.30.1", + "@cosmjs/utils": "^0.30.1", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.4", + "libsodium-wrappers": "^0.7.6" + } + }, + "node_modules/@cosmjs/encoding": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "base64-js": "^1.3.0", + "bech32": "^1.1.4", + "readonly-date": "^1.0.0" + } + }, + "node_modules/@cosmjs/encoding/node_modules/bech32": { + "version": "1.1.4", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@cosmjs/json-rpc": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@cosmjs/stream": "^0.30.1", + "xstream": "^11.14.0" + } + }, + "node_modules/@cosmjs/math": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "bn.js": "^5.2.0" + } + }, + "node_modules/@cosmjs/proto-signing": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@cosmjs/amino": "^0.30.1", + "@cosmjs/crypto": "^0.30.1", + "@cosmjs/encoding": "^0.30.1", + "@cosmjs/math": "^0.30.1", + "@cosmjs/utils": "^0.30.1", + "cosmjs-types": "^0.7.1", + "long": "^4.0.0" + } + }, + "node_modules/@cosmjs/socket": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@cosmjs/stream": "^0.30.1", + "isomorphic-ws": "^4.0.1", + "ws": "^7", + "xstream": "^11.14.0" + } + }, + "node_modules/@cosmjs/stargate": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@confio/ics23": "^0.6.8", + "@cosmjs/amino": "^0.30.1", + "@cosmjs/encoding": "^0.30.1", + "@cosmjs/math": "^0.30.1", + "@cosmjs/proto-signing": "^0.30.1", + "@cosmjs/stream": "^0.30.1", + "@cosmjs/tendermint-rpc": "^0.30.1", + "@cosmjs/utils": "^0.30.1", + "cosmjs-types": "^0.7.1", + "long": "^4.0.0", + "protobufjs": "~6.11.3", + "xstream": "^11.14.0" + } + }, + "node_modules/@cosmjs/stream": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "xstream": "^11.14.0" + } + }, + "node_modules/@cosmjs/tendermint-rpc": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@cosmjs/crypto": "^0.30.1", + "@cosmjs/encoding": "^0.30.1", + "@cosmjs/json-rpc": "^0.30.1", + "@cosmjs/math": "^0.30.1", + "@cosmjs/socket": "^0.30.1", + "@cosmjs/stream": "^0.30.1", + "@cosmjs/utils": "^0.30.1", + "axios": "^0.21.2", + "readonly-date": "^1.0.0", + "xstream": "^11.14.0" + } + }, + "node_modules/@cosmjs/utils": { + "version": "0.30.1", + "dev": true, + "license": "Apache-2.0", + "optional": true + }, + "node_modules/@ethereumjs/common": { + "version": "2.6.5", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "crc-32": "^1.2.0", + "ethereumjs-util": "^7.1.5" + } + }, + "node_modules/@ethereumjs/tx": { + "version": "3.5.2", + "dev": true, + "license": "MPL-2.0", + "optional": true, + "dependencies": { + "@ethereumjs/common": "^2.6.4", + "ethereumjs-util": "^7.1.5" + } + }, + "node_modules/@ethersproject/abi": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@ethersproject/abstract-provider": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0" + } + }, + "node_modules/@ethersproject/abstract-signer": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0" + } + }, + "node_modules/@ethersproject/address": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/rlp": "^5.7.0" + } + }, + "node_modules/@ethersproject/base64": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0" + } + }, + "node_modules/@ethersproject/basex": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/properties": "^5.7.0" + } + }, + "node_modules/@ethersproject/bignumber": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "bn.js": "^5.2.1" + } + }, + "node_modules/@ethersproject/bytes": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "dependencies": { + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/constants": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bignumber": "^5.7.0" + } + }, + "node_modules/@ethersproject/contracts": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/abi": "^5.7.0", + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0" + } + }, + "node_modules/@ethersproject/hash": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@ethersproject/hdnode": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/pbkdf2": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wordlists": "^5.7.0" + } + }, + "node_modules/@ethersproject/json-wallets": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hdnode": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/pbkdf2": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "aes-js": "3.0.0", + "scrypt-js": "3.0.1" + } + }, + "node_modules/@ethersproject/keccak256": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "js-sha3": "0.8.0" + } + }, + "node_modules/@ethersproject/logger": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT" + }, + "node_modules/@ethersproject/networks": { + "version": "5.7.1", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/pbkdf2": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/sha2": "^5.7.0" + } + }, + "node_modules/@ethersproject/properties": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "dependencies": { + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/providers": { + "version": "5.7.2", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/basex": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0", + "bech32": "1.1.4", + "ws": "7.4.6" + } + }, + "node_modules/@ethersproject/providers/node_modules/bech32": { + "version": "1.1.4", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@ethersproject/providers/node_modules/ws": { + "version": "7.4.6", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/@ethersproject/random": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/rlp": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/sha2": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "hash.js": "1.1.7" + } + }, + "node_modules/@ethersproject/signing-key": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "bn.js": "^5.2.1", + "elliptic": "6.5.4", + "hash.js": "1.1.7" + } + }, + "node_modules/@ethersproject/solidity": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/sha2": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@ethersproject/strings": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/transactions": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0" + } + }, + "node_modules/@ethersproject/units": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/wallet": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/hdnode": "^5.7.0", + "@ethersproject/json-wallets": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/random": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/wordlists": "^5.7.0" + } + }, + "node_modules/@ethersproject/web": { + "version": "5.7.1", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@ethersproject/wordlists": { + "version": "5.7.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/hash": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@graphql-typed-document-node/core": { + "version": "3.2.0", + "dev": true, + "license": "MIT", + "optional": true, + "peerDependencies": { + "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" + } + }, + "node_modules/@improbable-eng/grpc-web": { + "version": "0.14.1", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "browser-headers": "^0.4.1" + }, + "peerDependencies": { + "google-protobuf": "^3.14.0" + } + }, + "node_modules/@injectivelabs/core-proto-ts": { + "version": "0.0.14", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@injectivelabs/grpc-web": "^0.0.1", + "google-protobuf": "^3.14.0", + "protobufjs": "^7.0.0", + "rxjs": "^7.4.0" + } + }, + "node_modules/@injectivelabs/core-proto-ts/node_modules/long": { + "version": "5.2.3", + "dev": true, + "license": "Apache-2.0", + "optional": true + }, + "node_modules/@injectivelabs/core-proto-ts/node_modules/protobufjs": { + "version": "7.2.4", + "dev": true, + "hasInstallScript": true, + "license": "BSD-3-Clause", + "optional": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@injectivelabs/exceptions": { + "version": "1.11.0", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@injectivelabs/grpc-web": "^0.0.1", + "@injectivelabs/ts-types": "^1.11.0", + "http-status-codes": "^2.2.0", + "link-module-alias": "^1.2.0", + "shx": "^0.3.2" + } + }, + "node_modules/@injectivelabs/exceptions/dist": { + "extraneous": true + }, + "node_modules/@injectivelabs/grpc-web": { + "version": "0.0.1", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "browser-headers": "^0.4.1" + }, + "peerDependencies": { + "google-protobuf": "^3.14.0" + } + }, + "node_modules/@injectivelabs/grpc-web-node-http-transport": { + "version": "0.0.2", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "peerDependencies": { + "@injectivelabs/grpc-web": ">=0.0.1" + } + }, + "node_modules/@injectivelabs/grpc-web-react-native-transport": { + "version": "0.0.2", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "peerDependencies": { + "@injectivelabs/grpc-web": ">=0.0.1" + } + }, + "node_modules/@injectivelabs/indexer-proto-ts": { + "version": "1.10.8-rc.4", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@injectivelabs/grpc-web": "^0.0.1", + "google-protobuf": "^3.14.0", + "protobufjs": "^7.0.0", + "rxjs": "^7.4.0" + } + }, + "node_modules/@injectivelabs/indexer-proto-ts/node_modules/long": { + "version": "5.2.3", + "dev": true, + "license": "Apache-2.0", + "optional": true + }, + "node_modules/@injectivelabs/indexer-proto-ts/node_modules/protobufjs": { + "version": "7.2.4", + "dev": true, + "hasInstallScript": true, + "license": "BSD-3-Clause", + "optional": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@injectivelabs/mito-proto-ts": { + "version": "1.0.9", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@injectivelabs/grpc-web": "^0.0.1", + "google-protobuf": "^3.14.0", + "protobufjs": "^7.0.0", + "rxjs": "^7.4.0" + } + }, + "node_modules/@injectivelabs/mito-proto-ts/node_modules/long": { + "version": "5.2.3", + "dev": true, + "license": "Apache-2.0", + "optional": true + }, + "node_modules/@injectivelabs/mito-proto-ts/node_modules/protobufjs": { + "version": "7.2.4", + "dev": true, + "hasInstallScript": true, + "license": "BSD-3-Clause", + "optional": true, + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@injectivelabs/networks": { + "version": "1.11.0", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@injectivelabs/exceptions": "^1.11.0", + "@injectivelabs/ts-types": "^1.11.0", + "@injectivelabs/utils": "^1.11.0", + "link-module-alias": "^1.2.0", + "shx": "^0.3.2" + } + }, + "node_modules/@injectivelabs/networks/dist": { + "extraneous": true + }, + "node_modules/@injectivelabs/sdk-ts": { + "version": "1.10.72", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@apollo/client": "^3.5.8", + "@cosmjs/amino": "^0.30.1", + "@cosmjs/proto-signing": "^0.30.1", + "@cosmjs/stargate": "^0.30.1", + "@ethersproject/bytes": "^5.7.0", + "@injectivelabs/core-proto-ts": "^0.0.14", + "@injectivelabs/exceptions": "^1.10.12", + "@injectivelabs/grpc-web": "^0.0.1", + "@injectivelabs/grpc-web-node-http-transport": "^0.0.2", + "@injectivelabs/grpc-web-react-native-transport": "^0.0.2", + "@injectivelabs/indexer-proto-ts": "1.10.8-rc.4", + "@injectivelabs/mito-proto-ts": "1.0.9", + "@injectivelabs/networks": "^1.10.12", + "@injectivelabs/test-utils": "^1.10.12", + "@injectivelabs/token-metadata": "^1.10.42", + "@injectivelabs/ts-types": "^1.10.12", + "@injectivelabs/utils": "^1.10.12", + "@metamask/eth-sig-util": "^4.0.0", + "axios": "^0.27.2", + "bech32": "^2.0.0", + "bip39": "^3.0.4", + "cosmjs-types": "^0.7.1", + "eth-crypto": "^2.6.0", + "ethereumjs-util": "^7.1.4", + "ethers": "^5.7.2", + "google-protobuf": "^3.21.0", + "graphql": "^16.3.0", + "http-status-codes": "^2.2.0", + "js-sha3": "^0.8.0", + "jscrypto": "^1.0.3", + "keccak256": "^1.0.6", + "link-module-alias": "^1.2.0", + "rxjs": "^7.8.0", + "secp256k1": "^4.0.3", + "shx": "^0.3.2", + "snakecase-keys": "^5.4.1" + } + }, + "node_modules/@injectivelabs/sdk-ts/dist": { + "extraneous": true + }, + "node_modules/@injectivelabs/sdk-ts/node_modules/axios": { + "version": "0.27.2", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/@injectivelabs/test-utils": { + "version": "1.11.0", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "axios": "^0.21.1", + "bignumber.js": "^9.0.1", + "link-module-alias": "^1.2.0", + "shx": "^0.3.2", + "snakecase-keys": "^5.1.2", + "store2": "^2.12.0" + } + }, + "node_modules/@injectivelabs/test-utils/dist": { + "extraneous": true + }, + "node_modules/@injectivelabs/token-metadata": { + "version": "1.11.0", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@injectivelabs/exceptions": "^1.11.0", + "@injectivelabs/networks": "^1.11.0", + "@injectivelabs/ts-types": "^1.11.0", + "@injectivelabs/utils": "^1.11.0", + "@types/lodash.values": "^4.3.6", + "copyfiles": "^2.4.1", + "jsonschema": "^1.4.0", + "link-module-alias": "^1.2.0", + "lodash": "^4.17.21", + "lodash.values": "^4.3.0", + "shx": "^0.3.2" + } + }, + "node_modules/@injectivelabs/token-metadata/dist": { + "extraneous": true + }, + "node_modules/@injectivelabs/ts-types": { + "version": "1.11.0", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "link-module-alias": "^1.2.0", + "shx": "^0.3.2" + } + }, + "node_modules/@injectivelabs/ts-types/dist": { + "extraneous": true + }, + "node_modules/@injectivelabs/utils": { + "version": "1.11.0", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "@injectivelabs/exceptions": "^1.11.0", + "@injectivelabs/ts-types": "^1.11.0", + "axios": "^0.21.1", + "bignumber.js": "^9.0.1", + "http-status-codes": "^2.2.0", + "link-module-alias": "^1.2.0", + "shx": "^0.3.2", + "snakecase-keys": "^5.1.2", + "store2": "^2.12.0" + } + }, + "node_modules/@injectivelabs/utils/dist": { + "extraneous": true + }, + "node_modules/@metamask/eth-sig-util": { + "version": "4.0.1", + "dev": true, + "license": "ISC", + "optional": true, + "dependencies": { + "ethereumjs-abi": "^0.6.8", + "ethereumjs-util": "^6.2.1", + "ethjs-util": "^0.1.6", + "tweetnacl": "^1.0.3", + "tweetnacl-util": "^0.15.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@metamask/eth-sig-util/node_modules/@types/bn.js": { + "version": "4.11.6", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@metamask/eth-sig-util/node_modules/bn.js": { + "version": "4.12.0", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@metamask/eth-sig-util/node_modules/ethereumjs-util": { + "version": "6.2.1", + "dev": true, + "license": "MPL-2.0", + "optional": true, + "dependencies": { + "@types/bn.js": "^4.11.3", + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "elliptic": "^6.5.2", + "ethereum-cryptography": "^0.1.3", + "ethjs-util": "0.1.6", + "rlp": "^2.2.3" + } + }, + "node_modules/@mysten/bcs": { + "version": "0.7.1", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bs58": "^5.0.0" + } + }, + "node_modules/@mysten/bcs/node_modules/base-x": { + "version": "4.0.0", + "dev": true, + "license": "MIT" + }, + "node_modules/@mysten/bcs/node_modules/bs58": { + "version": "5.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "base-x": "^4.0.0" + } + }, + "node_modules/@mysten/sui.js": { + "version": "0.32.2", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@mysten/bcs": "0.7.1", + "@noble/curves": "^1.0.0", + "@noble/hashes": "^1.3.0", + "@scure/bip32": "^1.3.0", + "@scure/bip39": "^1.2.0", + "@suchipi/femver": "^1.0.0", + "jayson": "^4.0.0", + "rpc-websockets": "^7.5.1", + "superstruct": "^1.0.3", + "tweetnacl": "^1.0.3" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@mysten/sui.js/node_modules/@scure/bip39": { + "version": "1.2.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@noble/hashes": "~1.3.0", + "@scure/base": "~1.1.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@mysten/sui.js/node_modules/superstruct": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@noble/curves": { + "version": "1.1.0", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.3.1" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.3.1", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@project-serum/anchor": { + "version": "0.25.0", + "dev": true, + "license": "(MIT OR Apache-2.0)", + "dependencies": { + "@project-serum/borsh": "^0.2.5", + "@solana/web3.js": "^1.36.0", + "base64-js": "^1.5.1", + "bn.js": "^5.1.2", + "bs58": "^4.0.1", + "buffer-layout": "^1.2.2", + "camelcase": "^5.3.1", + "cross-fetch": "^3.1.5", + "crypto-hash": "^1.3.0", + "eventemitter3": "^4.0.7", + "js-sha256": "^0.9.0", + "pako": "^2.0.3", + "snake-case": "^3.0.4", + "superstruct": "^0.15.4", + "toml": "^3.0.0" + }, + "engines": { + "node": ">=11" + } + }, + "node_modules/@project-serum/anchor/node_modules/camelcase": { + "version": "5.3.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/@project-serum/borsh": { + "version": "0.2.5", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "bn.js": "^5.1.2", + "buffer-layout": "^1.2.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@solana/web3.js": "^1.2.0" + } + }, + "node_modules/@protobufjs/aspromise": { + "version": "1.1.2", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/base64": { + "version": "1.1.2", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/codegen": { + "version": "2.0.4", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/eventemitter": { + "version": "1.1.0", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/fetch": { + "version": "1.1.0", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "node_modules/@protobufjs/float": { + "version": "1.0.2", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/inquire": { + "version": "1.1.0", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/path": { + "version": "1.1.2", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/pool": { + "version": "1.1.0", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/utf8": { + "version": "1.1.0", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@scure/base": { + "version": "1.1.1", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "license": "MIT" + }, + "node_modules/@scure/bip32": { + "version": "1.3.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@noble/curves": "~1.1.0", + "@noble/hashes": "~1.3.1", + "@scure/base": "~1.1.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39": { + "version": "1.1.0", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "license": "MIT", + "dependencies": { + "@noble/hashes": "~1.1.1", + "@scure/base": "~1.1.0" + } + }, + "node_modules/@scure/bip39/node_modules/@noble/hashes": { + "version": "1.1.5", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "license": "MIT" + }, + "node_modules/@solana/buffer-layout": { + "version": "4.0.1", + "license": "MIT", + "dependencies": { + "buffer": "~6.0.3" + }, + "engines": { + "node": ">=5.10" + } + }, + "node_modules/@solana/buffer-layout-utils": { + "version": "0.2.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@solana/buffer-layout": "^4.0.0", + "@solana/web3.js": "^1.32.0", + "bigint-buffer": "^1.1.5", + "bignumber.js": "^9.0.1" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@solana/spl-token": { + "version": "0.3.8", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@solana/buffer-layout": "^4.0.0", + "@solana/buffer-layout-utils": "^0.2.0", + "buffer": "^6.0.3" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.47.4" + } + }, + "node_modules/@solana/web3.js": { + "version": "1.78.2", + "license": "MIT", + "dependencies": { + "@babel/runtime": "^7.22.6", + "@noble/curves": "^1.0.0", + "@noble/hashes": "^1.3.0", + "@solana/buffer-layout": "^4.0.0", + "agentkeepalive": "^4.2.1", + "bigint-buffer": "^1.1.5", + "bn.js": "^5.2.1", + "borsh": "^0.7.0", + "bs58": "^4.0.1", + "buffer": "6.0.3", + "fast-stable-stringify": "^1.0.0", + "jayson": "^4.1.0", + "node-fetch": "^2.6.12", + "rpc-websockets": "^7.5.1", + "superstruct": "^0.14.2" + } + }, + "node_modules/@solana/web3.js/node_modules/superstruct": { + "version": "0.14.2", + "license": "MIT" + }, + "node_modules/@suchipi/femver": { + "version": "1.0.0", + "dev": true, + "license": "MIT" + }, + "node_modules/@terra-money/legacy.proto": { + "name": "@terra-money/terra.proto", + "version": "0.1.7", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "google-protobuf": "^3.17.3", + "long": "^4.0.0", + "protobufjs": "~6.11.2" + } + }, + "node_modules/@terra-money/terra.js": { + "version": "3.1.9", + "dev": true, + "license": "MIT", + "dependencies": { + "@classic-terra/terra.proto": "^1.1.0", + "@terra-money/terra.proto": "^2.1.0", + "axios": "^0.27.2", + "bech32": "^2.0.0", + "bip32": "^2.0.6", + "bip39": "^3.0.3", + "bufferutil": "^4.0.3", + "decimal.js": "^10.2.1", + "jscrypto": "^1.0.1", + "readable-stream": "^3.6.0", + "secp256k1": "^4.0.2", + "tmp": "^0.2.1", + "utf-8-validate": "^5.0.5", + "ws": "^7.5.9" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@terra-money/terra.js/node_modules/axios": { + "version": "0.27.2", + "dev": true, + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/@terra-money/terra.proto": { + "version": "2.1.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@improbable-eng/grpc-web": "^0.14.1", + "google-protobuf": "^3.17.3", + "long": "^4.0.0", + "protobufjs": "~6.11.2" + } + }, + "node_modules/@types/bn.js": { + "version": "5.1.1", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/chai": { + "version": "4.3.5", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/connect": { + "version": "3.4.35", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/json5": { + "version": "0.0.29", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@types/lodash": { + "version": "4.14.196", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/@types/lodash.values": { + "version": "4.3.7", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@types/lodash": "*" + } + }, + "node_modules/@types/long": { + "version": "4.0.2", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/mocha": { + "version": "9.1.1", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "20.4.5", + "license": "MIT" + }, + "node_modules/@types/pbkdf2": { + "version": "3.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/secp256k1": { + "version": "4.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/ws": { + "version": "7.4.7", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@ungap/promise-all-settled": { + "version": "1.1.2", + "dev": true, + "license": "ISC" + }, + "node_modules/@wry/context": { + "version": "0.7.3", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wry/equality": { + "version": "0.5.6", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wry/trie": { + "version": "0.4.3", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@xpla/xpla.js": { + "version": "0.2.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@ethersproject/bytes": "^5.6.1", + "@ethersproject/keccak256": "^5.6.1", + "@ethersproject/signing-key": "^5.6.2", + "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", + "@terra-money/terra.proto": "^2.1.0", + "axios": "^0.26.1", + "bech32": "^2.0.0", + "bip32": "^2.0.6", + "bip39": "^3.0.3", + "bufferutil": "^4.0.3", + "crypto-addr-codec": "^0.1.7", + "decimal.js": "^10.2.1", + "elliptic": "^6.5.4", + "ethereumjs-util": "^7.1.5", + "jscrypto": "^1.0.1", + "readable-stream": "^3.6.0", + "secp256k1": "^4.0.2", + "tmp": "^0.2.1", + "utf-8-validate": "^5.0.5", + "ws": "^7.5.8" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@xpla/xpla.js/node_modules/axios": { + "version": "0.26.1", + "dev": true, + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.8" + } + }, + "node_modules/acorn": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", + "dev": true, + "optional": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/aes-js": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/agentkeepalive": { + "version": "4.3.0", + "license": "MIT", + "dependencies": { + "debug": "^4.1.0", + "depd": "^2.0.0", + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/agentkeepalive/node_modules/debug": { + "version": "4.3.4", + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/algo-msgpack-with-bigint": { + "version": "2.1.1", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 10" + } + }, + "node_modules/algosdk": { + "version": "1.24.1", + "dev": true, + "license": "MIT", + "dependencies": { + "algo-msgpack-with-bigint": "^2.1.1", + "buffer": "^6.0.2", + "cross-fetch": "^3.1.5", + "hi-base32": "^0.5.1", + "js-sha256": "^0.9.0", + "js-sha3": "^0.8.0", + "js-sha512": "^0.8.0", + "json-bigint": "^1.0.0", + "tweetnacl": "^1.0.3", + "vlq": "^2.0.4" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/aptos": { + "version": "1.5.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@noble/hashes": "1.1.3", + "@scure/bip39": "1.1.0", + "axios": "0.27.2", + "form-data": "4.0.0", + "tweetnacl": "1.0.3" + }, + "engines": { + "node": ">=11.0.0" + } + }, + "node_modules/aptos/node_modules/@noble/hashes": { + "version": "1.1.3", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "license": "MIT" + }, + "node_modules/aptos/node_modules/axios": { + "version": "0.27.2", + "dev": true, + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/arrify": { + "version": "1.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "dev": true, + "license": "MIT" + }, + "node_modules/axios": { + "version": "0.21.4", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "follow-redirects": "^1.14.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "dev": true, + "license": "MIT" + }, + "node_modules/base-x": { + "version": "3.0.9", + "license": "MIT", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/bech32": { + "version": "2.0.0", + "dev": true, + "license": "MIT" + }, + "node_modules/big-integer": { + "version": "1.6.36", + "dev": true, + "license": "Unlicense", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/bigint-buffer": { + "version": "1.1.5", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "bindings": "^1.3.0" + }, + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/bignumber.js": { + "version": "9.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/binary-parser": { + "version": "2.2.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/bindings": { + "version": "1.5.0", + "license": "MIT", + "dependencies": { + "file-uri-to-path": "1.0.0" + } + }, + "node_modules/bip32": { + "version": "2.0.6", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "10.12.18", + "bs58check": "^2.1.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "tiny-secp256k1": "^1.1.3", + "typeforce": "^1.11.5", + "wif": "^2.0.6" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/bip32/node_modules/@types/node": { + "version": "10.12.18", + "dev": true, + "license": "MIT" + }, + "node_modules/bip39": { + "version": "3.1.0", + "dev": true, + "license": "ISC", + "dependencies": { + "@noble/hashes": "^1.2.0" + } + }, + "node_modules/bip66": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", + "integrity": "sha512-nemMHz95EmS38a26XbbdxIYj5csHd3RMP3H5bwQknX0WYHF01qhpufP42mLOwVICuH2JmhIhXiWs89MfUGL7Xw==", + "dev": true, + "optional": true, + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/blakejs": { + "version": "1.2.1", + "dev": true, + "license": "MIT" + }, + "node_modules/bn.js": { + "version": "5.2.1", + "license": "MIT" + }, + "node_modules/borsh": { + "version": "0.7.0", + "license": "Apache-2.0", + "dependencies": { + "bn.js": "^5.2.0", + "bs58": "^4.0.0", + "text-encoding-utf-8": "^1.0.2" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/brorand": { + "version": "1.1.0", + "dev": true, + "license": "MIT" + }, + "node_modules/browser-headers": { + "version": "0.4.1", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "dev": true, + "license": "ISC" + }, + "node_modules/browserify-aes": { + "version": "1.2.0", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/bs58": { + "version": "4.0.1", + "license": "MIT", + "dependencies": { + "base-x": "^3.0.2" + } + }, + "node_modules/bs58check": { + "version": "2.1.2", + "dev": true, + "license": "MIT", + "dependencies": { + "bs58": "^4.0.0", + "create-hash": "^1.1.0", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/buffer": { + "version": "6.0.3", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "dev": true, + "license": "MIT" + }, + "node_modules/buffer-layout": { + "version": "1.2.2", + "license": "MIT", + "engines": { + "node": ">=4.5" + } + }, + "node_modules/buffer-xor": { + "version": "1.0.3", + "dev": true, + "license": "MIT" + }, + "node_modules/bufferutil": { + "version": "4.0.7", + "devOptional": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/camelcase": { + "version": "6.3.0", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/capability": { + "version": "0.2.5", + "dev": true, + "license": "MIT" + }, + "node_modules/chai": { + "version": "4.3.7", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^1.1.0", + "check-error": "^1.0.2", + "deep-eql": "^4.1.2", + "get-func-name": "^2.0.0", + "loupe": "^2.3.1", + "pathval": "^1.1.1", + "type-detect": "^4.0.5" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk": { + "version": "2.4.2", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk/node_modules/ansi-styles": { + "version": "3.2.1", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk/node_modules/color-convert": { + "version": "1.9.3", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/chalk/node_modules/color-name": { + "version": "1.1.3", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/chalk/node_modules/escape-string-regexp": { + "version": "1.0.5", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/chalk/node_modules/has-flag": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "5.5.0", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/check-error": { + "version": "1.0.2", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/chokidar": { + "version": "3.5.3", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/cipher-base": { + "version": "1.0.4", + "dev": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/cliui": { + "version": "7.0.4", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "dev": true, + "license": "MIT" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "dev": true, + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "2.20.3", + "license": "MIT" + }, + "node_modules/concat-map": { + "version": "0.0.1", + "dev": true, + "license": "MIT" + }, + "node_modules/copyfiles": { + "version": "2.4.1", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "glob": "^7.0.5", + "minimatch": "^3.0.3", + "mkdirp": "^1.0.4", + "noms": "0.0.0", + "through2": "^2.0.1", + "untildify": "^4.0.0", + "yargs": "^16.1.0" + }, + "bin": { + "copyfiles": "copyfiles", + "copyup": "copyfiles" + } + }, + "node_modules/copyfiles/node_modules/mkdirp": { + "version": "1.0.4", + "dev": true, + "license": "MIT", + "optional": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/cosmjs-types": { + "version": "0.7.2", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "dependencies": { + "long": "^4.0.0", + "protobufjs": "~6.11.2" + } + }, + "node_modules/crc-32": { + "version": "1.2.2", + "dev": true, + "license": "Apache-2.0", + "optional": true, + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/create-hash": { + "version": "1.2.0", + "dev": true, + "license": "MIT", + "dependencies": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" + } + }, + "node_modules/create-hmac": { + "version": "1.1.7", + "dev": true, + "license": "MIT", + "dependencies": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "node_modules/cross-fetch": { + "version": "3.1.8", + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.12" + } + }, + "node_modules/crypto-addr-codec": { + "version": "0.1.7", + "dev": true, + "license": "MIT", + "dependencies": { + "base-x": "^3.0.8", + "big-integer": "1.6.36", + "blakejs": "^1.1.0", + "bs58": "^4.0.1", + "ripemd160-min": "0.0.6", + "safe-buffer": "^5.2.0", + "sha3": "^2.1.1" + } + }, + "node_modules/crypto-hash": { + "version": "1.3.0", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/debug": { + "version": "4.3.3", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/decimal.js": { + "version": "10.4.3", + "dev": true, + "license": "MIT" + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "dev": true, + "license": "MIT", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/define-properties": { + "version": "1.2.0", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delay": { + "version": "5.0.0", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/diff": { + "version": "5.0.0", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/dot-case": { + "version": "3.0.4", + "license": "MIT", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/drbg.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", + "integrity": "sha512-F4wZ06PvqxYLFEZKkFxTDcns9oFNk34hvmJSEwdzsxVQ8YI5YaxtACgQatkYgv2VI2CFkUd2Y+xosPQnHv809g==", + "dev": true, + "optional": true, + "dependencies": { + "browserify-aes": "^1.0.6", + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/eccrypto": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/eccrypto/-/eccrypto-1.1.6.tgz", + "integrity": "sha512-d78ivVEzu7Tn0ZphUUaL43+jVPKTMPFGtmgtz1D0LrFn7cY3K8CdrvibuLz2AAkHBLKZtR8DMbB2ukRYFk987A==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "dependencies": { + "acorn": "7.1.1", + "elliptic": "6.5.4", + "es6-promise": "4.2.8", + "nan": "2.14.0" + }, + "optionalDependencies": { + "secp256k1": "3.7.1" + } + }, + "node_modules/eccrypto/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true, + "optional": true + }, + "node_modules/eccrypto/node_modules/nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true, + "optional": true + }, + "node_modules/eccrypto/node_modules/secp256k1": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.7.1.tgz", + "integrity": "sha512-1cf8sbnRreXrQFdH6qsg2H71Xw91fCCS9Yp021GnUNJzWJS/py96fS4lHbnTnouLp08Xj6jBoBB6V78Tdbdu5g==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "dependencies": { + "bindings": "^1.5.0", + "bip66": "^1.1.5", + "bn.js": "^4.11.8", + "create-hash": "^1.2.0", + "drbg.js": "^1.0.1", + "elliptic": "^6.4.1", + "nan": "^2.14.0", + "safe-buffer": "^5.1.2" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/elliptic": { + "version": "6.5.4", + "dev": true, + "license": "MIT", + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "dev": true, + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "dev": true, + "license": "MIT" + }, + "node_modules/error-polyfill": { + "version": "0.1.3", + "dev": true, + "license": "MIT", + "dependencies": { + "capability": "^0.2.5", + "o3": "^1.0.3", + "u3": "^0.1.1" + } + }, + "node_modules/es6-promise": { + "version": "4.2.8", + "license": "MIT" + }, + "node_modules/es6-promisify": { + "version": "5.0.0", + "license": "MIT", + "dependencies": { + "es6-promise": "^4.0.3" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eth-crypto": { + "version": "2.6.0", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@babel/runtime": "7.20.13", + "@ethereumjs/tx": "3.5.2", + "@types/bn.js": "5.1.1", + "eccrypto": "1.1.6", + "ethereumjs-util": "7.1.5", + "ethers": "5.7.2", + "secp256k1": "5.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/pubkey" + } + }, + "node_modules/eth-crypto/node_modules/@babel/runtime": { + "version": "7.20.13", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/eth-crypto/node_modules/node-addon-api": { + "version": "5.1.0", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/eth-crypto/node_modules/secp256k1": { + "version": "5.0.0", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "dependencies": { + "elliptic": "^6.5.4", + "node-addon-api": "^5.0.0", + "node-gyp-build": "^4.2.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/ethereum-cryptography": { + "version": "0.1.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/pbkdf2": "^3.0.0", + "@types/secp256k1": "^4.0.1", + "blakejs": "^1.1.0", + "browserify-aes": "^1.2.0", + "bs58check": "^2.1.2", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "hash.js": "^1.1.7", + "keccak": "^3.0.0", + "pbkdf2": "^3.0.17", + "randombytes": "^2.1.0", + "safe-buffer": "^5.1.2", + "scrypt-js": "^3.0.0", + "secp256k1": "^4.0.1", + "setimmediate": "^1.0.5" + } + }, + "node_modules/ethereumjs-abi": { + "version": "0.6.8", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "bn.js": "^4.11.8", + "ethereumjs-util": "^6.0.0" + } + }, + "node_modules/ethereumjs-abi/node_modules/@types/bn.js": { + "version": "4.11.6", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/ethereumjs-abi/node_modules/bn.js": { + "version": "4.12.0", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/ethereumjs-abi/node_modules/ethereumjs-util": { + "version": "6.2.1", + "dev": true, + "license": "MPL-2.0", + "optional": true, + "dependencies": { + "@types/bn.js": "^4.11.3", + "bn.js": "^4.11.0", + "create-hash": "^1.1.2", + "elliptic": "^6.5.2", + "ethereum-cryptography": "^0.1.3", + "ethjs-util": "0.1.6", + "rlp": "^2.2.3" + } + }, + "node_modules/ethereumjs-util": { + "version": "7.1.5", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "@types/bn.js": "^5.1.0", + "bn.js": "^5.1.2", + "create-hash": "^1.1.2", + "ethereum-cryptography": "^0.1.3", + "rlp": "^2.2.4" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/ethers": { + "version": "5.7.2", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@ethersproject/abi": "5.7.0", + "@ethersproject/abstract-provider": "5.7.0", + "@ethersproject/abstract-signer": "5.7.0", + "@ethersproject/address": "5.7.0", + "@ethersproject/base64": "5.7.0", + "@ethersproject/basex": "5.7.0", + "@ethersproject/bignumber": "5.7.0", + "@ethersproject/bytes": "5.7.0", + "@ethersproject/constants": "5.7.0", + "@ethersproject/contracts": "5.7.0", + "@ethersproject/hash": "5.7.0", + "@ethersproject/hdnode": "5.7.0", + "@ethersproject/json-wallets": "5.7.0", + "@ethersproject/keccak256": "5.7.0", + "@ethersproject/logger": "5.7.0", + "@ethersproject/networks": "5.7.1", + "@ethersproject/pbkdf2": "5.7.0", + "@ethersproject/properties": "5.7.0", + "@ethersproject/providers": "5.7.2", + "@ethersproject/random": "5.7.0", + "@ethersproject/rlp": "5.7.0", + "@ethersproject/sha2": "5.7.0", + "@ethersproject/signing-key": "5.7.0", + "@ethersproject/solidity": "5.7.0", + "@ethersproject/strings": "5.7.0", + "@ethersproject/transactions": "5.7.0", + "@ethersproject/units": "5.7.0", + "@ethersproject/wallet": "5.7.0", + "@ethersproject/web": "5.7.1", + "@ethersproject/wordlists": "5.7.0" + } + }, + "node_modules/ethjs-util": { + "version": "0.1.6", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "is-hex-prefixed": "1.0.0", + "strip-hex-prefix": "1.0.0" + }, + "engines": { + "node": ">=6.5.0", + "npm": ">=3" + } + }, + "node_modules/eventemitter3": { + "version": "4.0.7", + "license": "MIT" + }, + "node_modules/evp_bytestokey": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/eyes": { + "version": "0.1.8", + "engines": { + "node": "> 0.1.90" + } + }, + "node_modules/fast-stable-stringify": { + "version": "1.0.0", + "license": "MIT" + }, + "node_modules/file-uri-to-path": { + "version": "1.0.0", + "license": "MIT" + }, + "node_modules/fill-range": { + "version": "7.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat": { + "version": "5.0.2", + "dev": true, + "license": "BSD-3-Clause", + "bin": { + "flat": "cli.js" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "dev": true, + "license": "ISC" + }, + "node_modules/function-bind": { + "version": "1.1.1", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-func-name": { + "version": "2.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.1", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globalthis": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/google-protobuf": { + "version": "3.21.2", + "dev": true, + "license": "(BSD-3-Clause AND Apache-2.0)" + }, + "node_modules/graphql": { + "version": "16.7.1", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } + }, + "node_modules/graphql-tag": { + "version": "2.12.6", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" + } + }, + "node_modules/growl": { + "version": "1.10.5", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4.x" + } + }, + "node_modules/has": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "get-intrinsic": "^1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hash-base": { + "version": "3.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/hash.js": { + "version": "1.1.7", + "dev": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "node_modules/he": { + "version": "1.2.0", + "dev": true, + "license": "MIT", + "bin": { + "he": "bin/he" + } + }, + "node_modules/hi-base32": { + "version": "0.5.1", + "dev": true, + "license": "MIT" + }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "dev": true, + "license": "BSD-3-Clause", + "optional": true, + "dependencies": { + "react-is": "^16.7.0" + } + }, + "node_modules/http-errors": { + "version": "1.8.1", + "dev": true, + "license": "MIT", + "dependencies": { + "depd": "~1.1.2", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/http-errors/node_modules/depd": { + "version": "1.1.2", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/http-status-codes": { + "version": "2.2.0", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/humanize-ms": { + "version": "1.2.1", + "license": "MIT", + "dependencies": { + "ms": "^2.0.0" + } + }, + "node_modules/humanize-ms/node_modules/ms": { + "version": "2.1.3", + "license": "MIT" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/inflight": { + "version": "1.0.6", + "dev": true, + "license": "ISC", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "dev": true, + "license": "ISC" + }, + "node_modules/interpret": { + "version": "1.4.0", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-core-module": { + "version": "2.12.1", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-hex-prefixed": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=6.5.0", + "npm": ">=3" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-unicode-supported": { + "version": "0.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isarray": { + "version": "0.0.1", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/isexe": { + "version": "2.0.0", + "dev": true, + "license": "ISC" + }, + "node_modules/isomorphic-ws": { + "version": "4.0.1", + "license": "MIT", + "peerDependencies": { + "ws": "*" + } + }, + "node_modules/jayson": { + "version": "4.1.0", + "license": "MIT", + "dependencies": { + "@types/connect": "^3.4.33", + "@types/node": "^12.12.54", + "@types/ws": "^7.4.4", + "commander": "^2.20.3", + "delay": "^5.0.0", + "es6-promisify": "^5.0.0", + "eyes": "^0.1.8", + "isomorphic-ws": "^4.0.1", + "json-stringify-safe": "^5.0.1", + "JSONStream": "^1.3.5", + "uuid": "^8.3.2", + "ws": "^7.4.5" + }, + "bin": { + "jayson": "bin/jayson.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jayson/node_modules/@types/node": { + "version": "12.20.55", + "license": "MIT" + }, + "node_modules/js-base64": { + "version": "3.7.5", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/js-sha256": { + "version": "0.9.0", + "license": "MIT" + }, + "node_modules/js-sha3": { + "version": "0.8.0", + "dev": true, + "license": "MIT" + }, + "node_modules/js-sha512": { + "version": "0.8.0", + "dev": true, + "license": "MIT" + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jscrypto": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "bin": { + "jscrypto": "bin/cli.js" + } + }, + "node_modules/json-bigint": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "bignumber.js": "^9.0.0" + } + }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "license": "ISC" + }, + "node_modules/json5": { + "version": "1.0.2", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "minimist": "^1.2.0" + }, + "bin": { + "json5": "lib/cli.js" + } + }, + "node_modules/jsonparse": { + "version": "1.3.1", + "engines": [ + "node >= 0.2.0" + ], + "license": "MIT" + }, + "node_modules/jsonschema": { + "version": "1.4.1", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": "*" + } + }, + "node_modules/JSONStream": { + "version": "1.3.5", + "license": "(MIT OR Apache-2.0)", + "dependencies": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + }, + "bin": { + "JSONStream": "bin.js" + }, + "engines": { + "node": "*" + } + }, + "node_modules/keccak": { + "version": "3.0.3", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/keccak256": { + "version": "1.0.6", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "bn.js": "^5.2.0", + "buffer": "^6.0.3", + "keccak": "^3.0.2" + } + }, + "node_modules/libsodium": { + "version": "0.7.11", + "dev": true, + "license": "ISC", + "optional": true + }, + "node_modules/libsodium-wrappers": { + "version": "0.7.11", + "dev": true, + "license": "ISC", + "optional": true, + "dependencies": { + "libsodium": "^0.7.11" + } + }, + "node_modules/link-module-alias": { + "version": "1.2.0", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "chalk": "^2.4.1" + }, + "bin": { + "link-module-alias": "index.js" + }, + "engines": { + "node": "> 8.0.0" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/lodash.values": { + "version": "4.3.0", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/log-symbols": { + "version": "4.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "^4.1.0", + "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/log-symbols/node_modules/chalk": { + "version": "4.1.2", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/log-symbols/node_modules/supports-color": { + "version": "7.2.0", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/long": { + "version": "4.0.0", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/loupe": { + "version": "2.3.6", + "dev": true, + "license": "MIT", + "dependencies": { + "get-func-name": "^2.0.0" + } + }, + "node_modules/lower-case": { + "version": "2.0.2", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "dev": true, + "license": "ISC" + }, + "node_modules/map-obj": { + "version": "4.3.0", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/md5.js": { + "version": "1.3.5", + "dev": true, + "license": "MIT", + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "dev": true, + "license": "ISC" + }, + "node_modules/minimalistic-crypto-utils": { + "version": "1.0.1", + "dev": true, + "license": "MIT" + }, + "node_modules/minimatch": { + "version": "3.1.2", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "dev": true, + "license": "MIT", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/mocha": { + "version": "9.2.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@ungap/promise-all-settled": "1.1.2", + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.3", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "growl": "1.10.5", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "4.2.1", + "ms": "2.1.3", + "nanoid": "3.3.1", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "which": "2.0.2", + "workerpool": "6.2.0", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/mocha/node_modules/glob": { + "version": "7.2.0", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "4.2.1", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/ms": { + "version": "2.1.3", + "dev": true, + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.1.2", + "license": "MIT" + }, + "node_modules/mustache": { + "version": "4.2.0", + "dev": true, + "license": "MIT", + "bin": { + "mustache": "bin/mustache" + } + }, + "node_modules/nan": { + "version": "2.17.0", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.1", + "dev": true, + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/near-api-js": { + "version": "1.1.0", + "dev": true, + "license": "(MIT AND Apache-2.0)", + "dependencies": { + "bn.js": "5.2.1", + "borsh": "^0.7.0", + "bs58": "^4.0.0", + "depd": "^2.0.0", + "error-polyfill": "^0.1.3", + "http-errors": "^1.7.2", + "js-sha256": "^0.9.0", + "mustache": "^4.0.0", + "node-fetch": "^2.6.1", + "text-encoding-utf-8": "^1.0.2", + "tweetnacl": "^1.0.1" + } + }, + "node_modules/no-case": { + "version": "3.0.4", + "license": "MIT", + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, + "node_modules/node-addon-api": { + "version": "2.0.2", + "dev": true, + "license": "MIT" + }, + "node_modules/node-fetch": { + "version": "2.6.12", + "license": "MIT", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-gyp-build": { + "version": "4.6.0", + "devOptional": true, + "license": "MIT", + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, + "node_modules/noms": { + "version": "0.0.0", + "dev": true, + "license": "ISC", + "optional": true, + "dependencies": { + "inherits": "^2.0.1", + "readable-stream": "~1.0.31" + } + }, + "node_modules/noms/node_modules/readable-stream": { + "version": "1.0.34", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "node_modules/noms/node_modules/string_decoder": { + "version": "0.10.31", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/o3": { + "version": "1.0.3", + "dev": true, + "license": "MIT", + "dependencies": { + "capability": "^0.2.5" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/once": { + "version": "1.4.0", + "dev": true, + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optimism": { + "version": "0.16.2", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@wry/context": "^0.7.0", + "@wry/trie": "^0.3.0" + } + }, + "node_modules/optimism/node_modules/@wry/trie": { + "version": "0.3.2", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pako": { + "version": "2.1.0", + "license": "(MIT AND Zlib)" + }, + "node_modules/path-exists": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/pathval": { + "version": "1.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/pbkdf2": { + "version": "3.1.2", + "dev": true, + "license": "MIT", + "dependencies": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/prettier": { + "version": "2.8.8", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/prop-types": { + "version": "15.8.1", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/protobufjs": { + "version": "6.11.3", + "dev": true, + "hasInstallScript": true, + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/long": "^4.0.1", + "@types/node": ">=13.7.0", + "long": "^4.0.0" + }, + "bin": { + "pbjs": "bin/pbjs", + "pbts": "bin/pbts" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/react-is": { + "version": "16.13.1", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "dev": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/readonly-date": { + "version": "1.0.0", + "dev": true, + "license": "Apache-2.0", + "optional": true + }, + "node_modules/rechoir": { + "version": "0.6.2", + "dev": true, + "optional": true, + "dependencies": { + "resolve": "^1.1.6" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.11", + "license": "MIT" + }, + "node_modules/require-directory": { + "version": "2.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.2", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "is-core-module": "^2.11.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/response-iterator": { + "version": "0.2.6", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "dev": true, + "license": "ISC", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/ripemd160": { + "version": "2.0.2", + "dev": true, + "license": "MIT", + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, + "node_modules/ripemd160-min": { + "version": "0.0.6", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/rlp": { + "version": "2.2.7", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "bn.js": "^5.2.0" + }, + "bin": { + "rlp": "bin/rlp" + } + }, + "node_modules/rpc-websockets": { + "version": "7.5.1", + "license": "LGPL-3.0-only", + "dependencies": { + "@babel/runtime": "^7.17.2", + "eventemitter3": "^4.0.7", + "uuid": "^8.3.2", + "ws": "^8.5.0" + }, + "funding": { + "type": "paypal", + "url": "https://paypal.me/kozjak" + }, + "optionalDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + } + }, + "node_modules/rpc-websockets/node_modules/ws": { + "version": "8.13.0", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/rxjs": { + "version": "7.8.1", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/scrypt-js": { + "version": "3.0.1", + "dev": true, + "license": "MIT" + }, + "node_modules/secp256k1": { + "version": "4.0.3", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "elliptic": "^6.5.4", + "node-addon-api": "^2.0.0", + "node-gyp-build": "^4.2.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/setimmediate": { + "version": "1.0.5", + "dev": true, + "license": "MIT" + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "dev": true, + "license": "ISC" + }, + "node_modules/sha.js": { + "version": "2.4.11", + "dev": true, + "license": "(MIT AND BSD-3-Clause)", + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" + } + }, + "node_modules/sha3": { + "version": "2.1.4", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer": "6.0.3" + } + }, + "node_modules/shelljs": { + "version": "0.8.5", + "dev": true, + "license": "BSD-3-Clause", + "optional": true, + "dependencies": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + }, + "bin": { + "shjs": "bin/shjs" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/shx": { + "version": "0.3.4", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "minimist": "^1.2.3", + "shelljs": "^0.8.5" + }, + "bin": { + "shx": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/snake-case": { + "version": "3.0.4", + "license": "MIT", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/snakecase-keys": { + "version": "5.4.6", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "map-obj": "^4.1.0", + "snake-case": "^3.0.4", + "type-fest": "^2.5.2" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/statuses": { + "version": "1.5.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/store2": { + "version": "2.14.2", + "dev": true, + "license": "(MIT OR GPL-3.0)", + "optional": true + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-hex-prefix": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "is-hex-prefixed": "1.0.0" + }, + "engines": { + "node": ">=6.5.0", + "npm": ">=3" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/superstruct": { + "version": "0.15.5", + "license": "MIT" + }, + "node_modules/supports-color": { + "version": "8.1.1", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/symbol-observable": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/text-encoding-utf-8": { + "version": "1.0.2" + }, + "node_modules/through": { + "version": "2.3.8", + "license": "MIT" + }, + "node_modules/through2": { + "version": "2.0.5", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + }, + "node_modules/through2/node_modules/isarray": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/through2/node_modules/readable-stream": { + "version": "2.3.8", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/through2/node_modules/safe-buffer": { + "version": "5.1.2", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/through2/node_modules/string_decoder": { + "version": "1.1.1", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/tiny-secp256k1": { + "version": "1.1.6", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "bindings": "^1.3.0", + "bn.js": "^4.11.8", + "create-hmac": "^1.1.7", + "elliptic": "^6.4.0", + "nan": "^2.13.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/tiny-secp256k1/node_modules/bn.js": { + "version": "4.12.0", + "dev": true, + "license": "MIT" + }, + "node_modules/tmp": { + "version": "0.2.1", + "dev": true, + "license": "MIT", + "dependencies": { + "rimraf": "^3.0.0" + }, + "engines": { + "node": ">=8.17.0" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/toml": { + "version": "3.0.0", + "license": "MIT" + }, + "node_modules/tr46": { + "version": "0.0.3", + "license": "MIT" + }, + "node_modules/ts-invariant": { + "version": "0.10.3", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/ts-mocha": { + "version": "10.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "ts-node": "7.0.1" + }, + "bin": { + "ts-mocha": "bin/ts-mocha" + }, + "engines": { + "node": ">= 6.X.X" + }, + "optionalDependencies": { + "tsconfig-paths": "^3.5.0" + }, + "peerDependencies": { + "mocha": "^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X" + } + }, + "node_modules/ts-node": { + "version": "7.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "arrify": "^1.0.0", + "buffer-from": "^1.1.0", + "diff": "^3.1.0", + "make-error": "^1.1.1", + "minimist": "^1.2.0", + "mkdirp": "^0.5.1", + "source-map-support": "^0.5.6", + "yn": "^2.0.0" + }, + "bin": { + "ts-node": "dist/bin.js" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "3.5.0", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/tsconfig-paths": { + "version": "3.14.2", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@types/json5": "^0.0.29", + "json5": "^1.0.2", + "minimist": "^1.2.6", + "strip-bom": "^3.0.0" + } + }, + "node_modules/tslib": { + "version": "2.6.1", + "license": "0BSD" + }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "dev": true, + "license": "Unlicense" + }, + "node_modules/tweetnacl-util": { + "version": "0.15.1", + "dev": true, + "license": "Unlicense", + "optional": true + }, + "node_modules/type-detect": { + "version": "4.0.8", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "2.19.0", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "optional": true, + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typeforce": { + "version": "1.18.0", + "dev": true, + "license": "MIT" + }, + "node_modules/typescript": { + "version": "4.9.5", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/u3": { + "version": "0.1.1", + "dev": true, + "license": "MIT" + }, + "node_modules/untildify": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/utf-8-validate": { + "version": "5.0.10", + "devOptional": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "node-gyp-build": "^4.3.0" + }, + "engines": { + "node": ">=6.14.2" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "dev": true, + "license": "MIT" + }, + "node_modules/uuid": { + "version": "8.3.2", + "license": "MIT", + "bin": { + "uuid": "dist/bin/uuid" + } + }, + "node_modules/vlq": { + "version": "2.0.4", + "dev": true, + "license": "MIT" + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "license": "MIT", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wif": { + "version": "2.0.6", + "dev": true, + "license": "MIT", + "dependencies": { + "bs58check": "<3.0.0" + } + }, + "node_modules/workerpool": { + "version": "6.2.0", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "dev": true, + "license": "ISC" + }, + "node_modules/ws": { + "version": "7.5.9", + "license": "MIT", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xstream": { + "version": "11.14.0", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "globalthis": "^1.0.1", + "symbol-observable": "^2.0.3" + } + }, + "node_modules/xstream/node_modules/symbol-observable": { + "version": "2.0.3", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "16.2.0", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.4", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs/node_modules/yargs-parser": { + "version": "20.2.9", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yn": { + "version": "2.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/zen-observable": { + "version": "0.8.15", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/zen-observable-ts": { + "version": "1.2.5", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "zen-observable": "0.8.15" + } + } + } +} diff --git a/cross-chain/solana/package.json b/cross-chain/solana/package.json index 4a866202d..a18adfd59 100644 --- a/cross-chain/solana/package.json +++ b/cross-chain/solana/package.json @@ -7,6 +7,7 @@ "@coral-xyz/anchor": "^0.28.0" }, "devDependencies": { + "@certusone/wormhole-sdk": "^0.9.22", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.77.3", "@types/bn.js": "^5.1.0", diff --git a/cross-chain/solana/yarn.lock b/cross-chain/solana/yarn.lock deleted file mode 100644 index 581984048..000000000 --- a/cross-chain/solana/yarn.lock +++ /dev/null @@ -1,2493 +0,0 @@ -# This file is generated by running "yarn install" inside your project. -# Manual changes might be lost - proceed with caution! - -__metadata: - version: 6 - cacheKey: 8 - -"@babel/runtime@npm:^7.17.2, @babel/runtime@npm:^7.22.6": - version: 7.22.6 - resolution: "@babel/runtime@npm:7.22.6" - dependencies: - regenerator-runtime: ^0.13.11 - checksum: e585338287c4514a713babf4fdb8fc2a67adcebab3e7723a739fc62c79cfda875b314c90fd25f827afb150d781af97bc16c85bfdbfa2889f06053879a1ddb597 - languageName: node - linkType: hard - -"@coral-xyz/anchor@npm:^0.28.0": - version: 0.28.0 - resolution: "@coral-xyz/anchor@npm:0.28.0" - dependencies: - "@coral-xyz/borsh": ^0.28.0 - "@solana/web3.js": ^1.68.0 - base64-js: ^1.5.1 - bn.js: ^5.1.2 - bs58: ^4.0.1 - buffer-layout: ^1.2.2 - camelcase: ^6.3.0 - cross-fetch: ^3.1.5 - crypto-hash: ^1.3.0 - eventemitter3: ^4.0.7 - js-sha256: ^0.9.0 - pako: ^2.0.3 - snake-case: ^3.0.4 - superstruct: ^0.15.4 - toml: ^3.0.0 - checksum: 58b3677b5b2ce2c779045184ce4a0ef696966a6a58f41c1c56f6f178db0491acecb6ec677ce0502f0b382a2c724f9c2860d82cc88601784d556d95fbeda415e5 - languageName: node - linkType: hard - -"@coral-xyz/borsh@npm:^0.28.0": - version: 0.28.0 - resolution: "@coral-xyz/borsh@npm:0.28.0" - dependencies: - bn.js: ^5.1.2 - buffer-layout: ^1.2.0 - peerDependencies: - "@solana/web3.js": ^1.68.0 - checksum: bc2b06b777f9ed43d3b886d2350826bd44d5b932c4fd4471af5956e8755236f5854938c890ee4986d88f61d1439e1d84e715c43dcb6dca4e76198c1ce8dc7a58 - languageName: node - linkType: hard - -"@isaacs/cliui@npm:^8.0.2": - version: 8.0.2 - resolution: "@isaacs/cliui@npm:8.0.2" - dependencies: - string-width: ^5.1.2 - string-width-cjs: "npm:string-width@^4.2.0" - strip-ansi: ^7.0.1 - strip-ansi-cjs: "npm:strip-ansi@^6.0.1" - wrap-ansi: ^8.1.0 - wrap-ansi-cjs: "npm:wrap-ansi@^7.0.0" - checksum: 4a473b9b32a7d4d3cfb7a614226e555091ff0c5a29a1734c28c72a182c2f6699b26fc6b5c2131dfd841e86b185aea714c72201d7c98c2fba5f17709333a67aeb - languageName: node - linkType: hard - -"@noble/curves@npm:^1.0.0": - version: 1.1.0 - resolution: "@noble/curves@npm:1.1.0" - dependencies: - "@noble/hashes": 1.3.1 - checksum: 2658cdd3f84f71079b4e3516c47559d22cf4b55c23ac8ee9d2b1f8e5b72916d9689e59820e0f9d9cb4a46a8423af5b56dc6bb7782405c88be06a015180508db5 - languageName: node - linkType: hard - -"@noble/hashes@npm:1.3.1, @noble/hashes@npm:^1.3.0": - version: 1.3.1 - resolution: "@noble/hashes@npm:1.3.1" - checksum: 7fdefc0f7a0c1ec27acc6ff88841793e3f93ec4ce6b8a6a12bfc0dd70ae6b7c4c82fe305fdfeda1735d5ad4a9eebe761e6693b3d355689c559e91242f4bc95b1 - languageName: node - linkType: hard - -"@npmcli/fs@npm:^3.1.0": - version: 3.1.0 - resolution: "@npmcli/fs@npm:3.1.0" - dependencies: - semver: ^7.3.5 - checksum: a50a6818de5fc557d0b0e6f50ec780a7a02ab8ad07e5ac8b16bf519e0ad60a144ac64f97d05c443c3367235d337182e1d012bbac0eb8dbae8dc7b40b193efd0e - languageName: node - linkType: hard - -"@pkgjs/parseargs@npm:^0.11.0": - version: 0.11.0 - resolution: "@pkgjs/parseargs@npm:0.11.0" - checksum: 6ad6a00fc4f2f2cfc6bff76fb1d88b8ee20bc0601e18ebb01b6d4be583733a860239a521a7fbca73b612e66705078809483549d2b18f370eb346c5155c8e4a0f - languageName: node - linkType: hard - -"@solana/buffer-layout-utils@npm:^0.2.0": - version: 0.2.0 - resolution: "@solana/buffer-layout-utils@npm:0.2.0" - dependencies: - "@solana/buffer-layout": ^4.0.0 - "@solana/web3.js": ^1.32.0 - bigint-buffer: ^1.1.5 - bignumber.js: ^9.0.1 - checksum: 9284242245b18b49577195ba7548263850be865a4a2d183944fa01bb76382039db589aab8473698e9bb734b515ada9b4d70db0a72e341c5d567c59b83d6d0840 - languageName: node - linkType: hard - -"@solana/buffer-layout@npm:^4.0.0": - version: 4.0.1 - resolution: "@solana/buffer-layout@npm:4.0.1" - dependencies: - buffer: ~6.0.3 - checksum: bf846888e813187243d4008a7a9f58b49d16cbd995b9d7f1b72898aa510ed77b1ce5e8468e7b2fd26dd81e557a4e74a666e21fccb95f123c1f740d41138bbacd - languageName: node - linkType: hard - -"@solana/spl-token@npm:^0.3.8": - version: 0.3.8 - resolution: "@solana/spl-token@npm:0.3.8" - dependencies: - "@solana/buffer-layout": ^4.0.0 - "@solana/buffer-layout-utils": ^0.2.0 - buffer: ^6.0.3 - peerDependencies: - "@solana/web3.js": ^1.47.4 - checksum: 01f4f87112b0ad277701a3bcb8e03069b69449b92724b17959107686731082bfd3475b5f105e1e8f04badd2e810a43d5ef811744ced5178eea1232de8fd75147 - languageName: node - linkType: hard - -"@solana/web3.js@npm:^1.32.0, @solana/web3.js@npm:^1.68.0, @solana/web3.js@npm:^1.77.3": - version: 1.78.1 - resolution: "@solana/web3.js@npm:1.78.1" - dependencies: - "@babel/runtime": ^7.22.6 - "@noble/curves": ^1.0.0 - "@noble/hashes": ^1.3.0 - "@solana/buffer-layout": ^4.0.0 - agentkeepalive: ^4.2.1 - bigint-buffer: ^1.1.5 - bn.js: ^5.0.0 - borsh: ^0.7.0 - bs58: ^4.0.1 - buffer: 6.0.3 - fast-stable-stringify: ^1.0.0 - jayson: ^4.1.0 - node-fetch: ^2.6.12 - rpc-websockets: ^7.5.1 - superstruct: ^0.14.2 - checksum: cf3b139fd9be47d1ed5d1df301729b722f6f53b8afe3ce33d17575e9753c153bfc2ad655582e3a4df1683977bbb26ac7808fc09cae3e61084e7506b6ef2ab51e - languageName: node - linkType: hard - -"@tootallnate/once@npm:2": - version: 2.0.0 - resolution: "@tootallnate/once@npm:2.0.0" - checksum: ad87447820dd3f24825d2d947ebc03072b20a42bfc96cbafec16bff8bbda6c1a81fcb0be56d5b21968560c5359a0af4038a68ba150c3e1694fe4c109a063bed8 - languageName: node - linkType: hard - -"@types/bn.js@npm:^5.1.0": - version: 5.1.1 - resolution: "@types/bn.js@npm:5.1.1" - dependencies: - "@types/node": "*" - checksum: e50ed2dd3abe997e047caf90e0352c71e54fc388679735217978b4ceb7e336e51477791b715f49fd77195ac26dd296c7bad08a3be9750e235f9b2e1edb1b51c2 - languageName: node - linkType: hard - -"@types/chai@npm:^4.3.0": - version: 4.3.5 - resolution: "@types/chai@npm:4.3.5" - checksum: c8f26a88c6b5b53a3275c7f5ff8f107028e3cbb9ff26795fff5f3d9dea07106a54ce9e2dce5e40347f7c4cc35657900aaf0c83934a25a1ae12e61e0f5516e431 - languageName: node - linkType: hard - -"@types/connect@npm:^3.4.33": - version: 3.4.35 - resolution: "@types/connect@npm:3.4.35" - dependencies: - "@types/node": "*" - checksum: fe81351470f2d3165e8b12ce33542eef89ea893e36dd62e8f7d72566dfb7e448376ae962f9f3ea888547ce8b55a40020ca0e01d637fab5d99567673084542641 - languageName: node - linkType: hard - -"@types/json5@npm:^0.0.29": - version: 0.0.29 - resolution: "@types/json5@npm:0.0.29" - checksum: e60b153664572116dfea673c5bda7778dbff150498f44f998e34b5886d8afc47f16799280e4b6e241c0472aef1bc36add771c569c68fc5125fc2ae519a3eb9ac - languageName: node - linkType: hard - -"@types/mocha@npm:^9.0.0": - version: 9.1.1 - resolution: "@types/mocha@npm:9.1.1" - checksum: 516077c0acd9806dc78317f88aaac0df5aaf0bdc2f63dfdadeabdf0b0137953b6ca65472e6ff7c30bc93ce4e0ae76eae70e8d46764b9a8eae4877a928b6ef49a - languageName: node - linkType: hard - -"@types/node@npm:*": - version: 20.4.5 - resolution: "@types/node@npm:20.4.5" - checksum: 36a0304a8dc346a1b2d2edac4c4633eecf70875793d61a5274d0df052d7a7af7a8e34f29884eac4fbd094c4f0201477dcb39c0ecd3307ca141688806538d1138 - languageName: node - linkType: hard - -"@types/node@npm:^12.12.54": - version: 12.20.55 - resolution: "@types/node@npm:12.20.55" - checksum: e4f86785f4092706e0d3b0edff8dca5a13b45627e4b36700acd8dfe6ad53db71928c8dee914d4276c7fd3b6ccd829aa919811c9eb708a2c8e4c6eb3701178c37 - languageName: node - linkType: hard - -"@types/ws@npm:^7.4.4": - version: 7.4.7 - resolution: "@types/ws@npm:7.4.7" - dependencies: - "@types/node": "*" - checksum: b4c9b8ad209620c9b21e78314ce4ff07515c0cadab9af101c1651e7bfb992d7fd933bd8b9c99d110738fd6db523ed15f82f29f50b45510288da72e964dedb1a3 - languageName: node - linkType: hard - -"@ungap/promise-all-settled@npm:1.1.2": - version: 1.1.2 - resolution: "@ungap/promise-all-settled@npm:1.1.2" - checksum: 08d37fdfa23a6fe8139f1305313562ebad973f3fac01bcce2773b2bda5bcb0146dfdcf3cb6a722cf0a5f2ca0bc56a827eac8f1e7b3beddc548f654addf1fc34c - languageName: node - linkType: hard - -"JSONStream@npm:^1.3.5": - version: 1.3.5 - resolution: "JSONStream@npm:1.3.5" - dependencies: - jsonparse: ^1.2.0 - through: ">=2.2.7 <3" - bin: - JSONStream: ./bin.js - checksum: 2605fa124260c61bad38bb65eba30d2f72216a78e94d0ab19b11b4e0327d572b8d530c0c9cc3b0764f727ad26d39e00bf7ebad57781ca6368394d73169c59e46 - languageName: node - linkType: hard - -"abbrev@npm:^1.0.0": - version: 1.1.1 - resolution: "abbrev@npm:1.1.1" - checksum: a4a97ec07d7ea112c517036882b2ac22f3109b7b19077dc656316d07d308438aac28e4d9746dc4d84bf6b1e75b4a7b0a5f3cb30592419f128ca9a8cee3bcfa17 - languageName: node - linkType: hard - -"agent-base@npm:6, agent-base@npm:^6.0.2": - version: 6.0.2 - resolution: "agent-base@npm:6.0.2" - dependencies: - debug: 4 - checksum: f52b6872cc96fd5f622071b71ef200e01c7c4c454ee68bc9accca90c98cfb39f2810e3e9aa330435835eedc8c23f4f8a15267f67c6e245d2b33757575bdac49d - languageName: node - linkType: hard - -"agentkeepalive@npm:^4.2.1": - version: 4.3.0 - resolution: "agentkeepalive@npm:4.3.0" - dependencies: - debug: ^4.1.0 - depd: ^2.0.0 - humanize-ms: ^1.2.1 - checksum: 982453aa44c11a06826c836025e5162c846e1200adb56f2d075400da7d32d87021b3b0a58768d949d824811f5654223d5a8a3dad120921a2439625eb847c6260 - languageName: node - linkType: hard - -"aggregate-error@npm:^3.0.0": - version: 3.1.0 - resolution: "aggregate-error@npm:3.1.0" - dependencies: - clean-stack: ^2.0.0 - indent-string: ^4.0.0 - checksum: 1101a33f21baa27a2fa8e04b698271e64616b886795fd43c31068c07533c7b3facfcaf4e9e0cab3624bd88f729a592f1c901a1a229c9e490eafce411a8644b79 - languageName: node - linkType: hard - -"ansi-colors@npm:4.1.1": - version: 4.1.1 - resolution: "ansi-colors@npm:4.1.1" - checksum: 138d04a51076cb085da0a7e2d000c5c0bb09f6e772ed5c65c53cb118d37f6c5f1637506d7155fb5f330f0abcf6f12fa2e489ac3f8cdab9da393bf1bb4f9a32b0 - languageName: node - linkType: hard - -"ansi-regex@npm:^5.0.1": - version: 5.0.1 - resolution: "ansi-regex@npm:5.0.1" - checksum: 2aa4bb54caf2d622f1afdad09441695af2a83aa3fe8b8afa581d205e57ed4261c183c4d3877cee25794443fde5876417d859c108078ab788d6af7e4fe52eb66b - languageName: node - linkType: hard - -"ansi-regex@npm:^6.0.1": - version: 6.0.1 - resolution: "ansi-regex@npm:6.0.1" - checksum: 1ff8b7667cded1de4fa2c9ae283e979fc87036864317da86a2e546725f96406746411d0d85e87a2d12fa5abd715d90006de7fa4fa0477c92321ad3b4c7d4e169 - languageName: node - linkType: hard - -"ansi-styles@npm:^4.0.0, ansi-styles@npm:^4.1.0": - version: 4.3.0 - resolution: "ansi-styles@npm:4.3.0" - dependencies: - color-convert: ^2.0.1 - checksum: 513b44c3b2105dd14cc42a19271e80f386466c4be574bccf60b627432f9198571ebf4ab1e4c3ba17347658f4ee1711c163d574248c0c1cdc2d5917a0ad582ec4 - languageName: node - linkType: hard - -"ansi-styles@npm:^6.1.0": - version: 6.2.1 - resolution: "ansi-styles@npm:6.2.1" - checksum: ef940f2f0ced1a6347398da88a91da7930c33ecac3c77b72c5905f8b8fe402c52e6fde304ff5347f616e27a742da3f1dc76de98f6866c69251ad0b07a66776d9 - languageName: node - linkType: hard - -"anymatch@npm:~3.1.2": - version: 3.1.3 - resolution: "anymatch@npm:3.1.3" - dependencies: - normalize-path: ^3.0.0 - picomatch: ^2.0.4 - checksum: 3e044fd6d1d26545f235a9fe4d7a534e2029d8e59fa7fd9f2a6eb21230f6b5380ea1eaf55136e60cbf8e613544b3b766e7a6fa2102e2a3a117505466e3025dc2 - languageName: node - linkType: hard - -"aproba@npm:^1.0.3 || ^2.0.0": - version: 2.0.0 - resolution: "aproba@npm:2.0.0" - checksum: 5615cadcfb45289eea63f8afd064ab656006361020e1735112e346593856f87435e02d8dcc7ff0d11928bc7d425f27bc7c2a84f6c0b35ab0ff659c814c138a24 - languageName: node - linkType: hard - -"are-we-there-yet@npm:^3.0.0": - version: 3.0.1 - resolution: "are-we-there-yet@npm:3.0.1" - dependencies: - delegates: ^1.0.0 - readable-stream: ^3.6.0 - checksum: 52590c24860fa7173bedeb69a4c05fb573473e860197f618b9a28432ee4379049336727ae3a1f9c4cb083114601c1140cee578376164d0e651217a9843f9fe83 - languageName: node - linkType: hard - -"argparse@npm:^2.0.1": - version: 2.0.1 - resolution: "argparse@npm:2.0.1" - checksum: 83644b56493e89a254bae05702abf3a1101b4fa4d0ca31df1c9985275a5a5bd47b3c27b7fa0b71098d41114d8ca000e6ed90cad764b306f8a503665e4d517ced - languageName: node - linkType: hard - -"arrify@npm:^1.0.0": - version: 1.0.1 - resolution: "arrify@npm:1.0.1" - checksum: 745075dd4a4624ff0225c331dacb99be501a515d39bcb7c84d24660314a6ec28e68131b137e6f7e16318170842ce97538cd298fc4cd6b2cc798e0b957f2747e7 - languageName: node - linkType: hard - -"assertion-error@npm:^1.1.0": - version: 1.1.0 - resolution: "assertion-error@npm:1.1.0" - checksum: fd9429d3a3d4fd61782eb3962ae76b6d08aa7383123fca0596020013b3ebd6647891a85b05ce821c47d1471ed1271f00b0545cf6a4326cf2fc91efcc3b0fbecf - languageName: node - linkType: hard - -"balanced-match@npm:^1.0.0": - version: 1.0.2 - resolution: "balanced-match@npm:1.0.2" - checksum: 9706c088a283058a8a99e0bf91b0a2f75497f185980d9ffa8b304de1d9e58ebda7c72c07ebf01dadedaac5b2907b2c6f566f660d62bd336c3468e960403b9d65 - languageName: node - linkType: hard - -"base-x@npm:^3.0.2": - version: 3.0.9 - resolution: "base-x@npm:3.0.9" - dependencies: - safe-buffer: ^5.0.1 - checksum: 957101d6fd09e1903e846fd8f69fd7e5e3e50254383e61ab667c725866bec54e5ece5ba49ce385128ae48f9ec93a26567d1d5ebb91f4d56ef4a9cc0d5a5481e8 - languageName: node - linkType: hard - -"base64-js@npm:^1.3.1, base64-js@npm:^1.5.1": - version: 1.5.1 - resolution: "base64-js@npm:1.5.1" - checksum: 669632eb3745404c2f822a18fc3a0122d2f9a7a13f7fb8b5823ee19d1d2ff9ee5b52c53367176ea4ad093c332fd5ab4bd0ebae5a8e27917a4105a4cfc86b1005 - languageName: node - linkType: hard - -"bigint-buffer@npm:^1.1.5": - version: 1.1.5 - resolution: "bigint-buffer@npm:1.1.5" - dependencies: - bindings: ^1.3.0 - node-gyp: latest - checksum: d010c9f57758bcdaccb435d88b483ffcc95fe8bbc6e7fb3a44fb5221f29c894ffaf4a3c5a4a530e0e7d6608203c2cde9b79ee4f2386cd6d4462d1070bc8c9f4e - languageName: node - linkType: hard - -"bignumber.js@npm:^9.0.1": - version: 9.1.1 - resolution: "bignumber.js@npm:9.1.1" - checksum: ad243b7e2f9120b112d670bb3d674128f0bd2ca1745b0a6c9df0433bd2c0252c43e6315d944c2ac07b4c639e7496b425e46842773cf89c6a2dcd4f31e5c4b11e - languageName: node - linkType: hard - -"binary-extensions@npm:^2.0.0": - version: 2.2.0 - resolution: "binary-extensions@npm:2.2.0" - checksum: ccd267956c58d2315f5d3ea6757cf09863c5fc703e50fbeb13a7dc849b812ef76e3cf9ca8f35a0c48498776a7478d7b4a0418e1e2b8cb9cb9731f2922aaad7f8 - languageName: node - linkType: hard - -"bindings@npm:^1.3.0": - version: 1.5.0 - resolution: "bindings@npm:1.5.0" - dependencies: - file-uri-to-path: 1.0.0 - checksum: 65b6b48095717c2e6105a021a7da4ea435aa8d3d3cd085cb9e85bcb6e5773cf318c4745c3f7c504412855940b585bdf9b918236612a1c7a7942491de176f1ae7 - languageName: node - linkType: hard - -"bn.js@npm:^5.0.0, bn.js@npm:^5.1.2, bn.js@npm:^5.2.0": - version: 5.2.1 - resolution: "bn.js@npm:5.2.1" - checksum: 3dd8c8d38055fedfa95c1d5fc3c99f8dd547b36287b37768db0abab3c239711f88ff58d18d155dd8ad902b0b0cee973747b7ae20ea12a09473272b0201c9edd3 - languageName: node - linkType: hard - -"borsh@npm:^0.7.0": - version: 0.7.0 - resolution: "borsh@npm:0.7.0" - dependencies: - bn.js: ^5.2.0 - bs58: ^4.0.0 - text-encoding-utf-8: ^1.0.2 - checksum: e98bfb5f7cfb820819c2870b884dac58dd4b4ce6a86c286c8fbf5c9ca582e73a8c6094df67e81a28c418ff07a309c6b118b2e27fdfea83fd92b8100c741da0b5 - languageName: node - linkType: hard - -"brace-expansion@npm:^1.1.7": - version: 1.1.11 - resolution: "brace-expansion@npm:1.1.11" - dependencies: - balanced-match: ^1.0.0 - concat-map: 0.0.1 - checksum: faf34a7bb0c3fcf4b59c7808bc5d2a96a40988addf2e7e09dfbb67a2251800e0d14cd2bfc1aa79174f2f5095c54ff27f46fb1289fe2d77dac755b5eb3434cc07 - languageName: node - linkType: hard - -"brace-expansion@npm:^2.0.1": - version: 2.0.1 - resolution: "brace-expansion@npm:2.0.1" - dependencies: - balanced-match: ^1.0.0 - checksum: a61e7cd2e8a8505e9f0036b3b6108ba5e926b4b55089eeb5550cd04a471fe216c96d4fe7e4c7f995c728c554ae20ddfc4244cad10aef255e72b62930afd233d1 - languageName: node - linkType: hard - -"braces@npm:~3.0.2": - version: 3.0.2 - resolution: "braces@npm:3.0.2" - dependencies: - fill-range: ^7.0.1 - checksum: e2a8e769a863f3d4ee887b5fe21f63193a891c68b612ddb4b68d82d1b5f3ff9073af066c343e9867a393fe4c2555dcb33e89b937195feb9c1613d259edfcd459 - languageName: node - linkType: hard - -"browser-stdout@npm:1.3.1": - version: 1.3.1 - resolution: "browser-stdout@npm:1.3.1" - checksum: b717b19b25952dd6af483e368f9bcd6b14b87740c3d226c2977a65e84666ffd67000bddea7d911f111a9b6ddc822b234de42d52ab6507bce4119a4cc003ef7b3 - languageName: node - linkType: hard - -"bs58@npm:^4.0.0, bs58@npm:^4.0.1": - version: 4.0.1 - resolution: "bs58@npm:4.0.1" - dependencies: - base-x: ^3.0.2 - checksum: b3c5365bb9e0c561e1a82f1a2d809a1a692059fae016be233a6127ad2f50a6b986467c3a50669ce4c18929dcccb297c5909314dd347a25a68c21b68eb3e95ac2 - languageName: node - linkType: hard - -"buffer-from@npm:^1.0.0, buffer-from@npm:^1.1.0": - version: 1.1.2 - resolution: "buffer-from@npm:1.1.2" - checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb - languageName: node - linkType: hard - -"buffer-layout@npm:^1.2.0, buffer-layout@npm:^1.2.2": - version: 1.2.2 - resolution: "buffer-layout@npm:1.2.2" - checksum: e5809ba275530bf4e52fd09558b7c2111fbda5b405124f581acf364261d9c154e271800271898cd40473f9bcbb42c31584efb04219bde549d3460ca4bafeaa07 - languageName: node - linkType: hard - -"buffer@npm:6.0.3, buffer@npm:^6.0.3, buffer@npm:~6.0.3": - version: 6.0.3 - resolution: "buffer@npm:6.0.3" - dependencies: - base64-js: ^1.3.1 - ieee754: ^1.2.1 - checksum: 5ad23293d9a731e4318e420025800b42bf0d264004c0286c8cc010af7a270c7a0f6522e84f54b9ad65cbd6db20b8badbfd8d2ebf4f80fa03dab093b89e68c3f9 - languageName: node - linkType: hard - -"bufferutil@npm:^4.0.1": - version: 4.0.7 - resolution: "bufferutil@npm:4.0.7" - dependencies: - node-gyp: latest - node-gyp-build: ^4.3.0 - checksum: f75aa87e3d1b99b87a95f60a855e63f70af07b57fb8443e75a2ddfef2e47788d130fdd46e3a78fd7e0c10176082b26dfbed970c5b8632e1cc299cafa0e93ce45 - languageName: node - linkType: hard - -"cacache@npm:^17.0.0": - version: 17.1.3 - resolution: "cacache@npm:17.1.3" - dependencies: - "@npmcli/fs": ^3.1.0 - fs-minipass: ^3.0.0 - glob: ^10.2.2 - lru-cache: ^7.7.1 - minipass: ^5.0.0 - minipass-collect: ^1.0.2 - minipass-flush: ^1.0.5 - minipass-pipeline: ^1.2.4 - p-map: ^4.0.0 - ssri: ^10.0.0 - tar: ^6.1.11 - unique-filename: ^3.0.0 - checksum: 385756781e1e21af089160d89d7462b7ed9883c978e848c7075b90b73cb823680e66092d61513050164588387d2ca87dd6d910e28d64bc13a9ac82cd8580c796 - languageName: node - linkType: hard - -"camelcase@npm:^6.0.0, camelcase@npm:^6.3.0": - version: 6.3.0 - resolution: "camelcase@npm:6.3.0" - checksum: 8c96818a9076434998511251dcb2761a94817ea17dbdc37f47ac080bd088fc62c7369429a19e2178b993497132c8cbcf5cc1f44ba963e76782ba469c0474938d - languageName: node - linkType: hard - -"chai@npm:^4.3.4": - version: 4.3.7 - resolution: "chai@npm:4.3.7" - dependencies: - assertion-error: ^1.1.0 - check-error: ^1.0.2 - deep-eql: ^4.1.2 - get-func-name: ^2.0.0 - loupe: ^2.3.1 - pathval: ^1.1.1 - type-detect: ^4.0.5 - checksum: 0bba7d267848015246a66995f044ce3f0ebc35e530da3cbdf171db744e14cbe301ab913a8d07caf7952b430257ccbb1a4a983c570a7c5748dc537897e5131f7c - languageName: node - linkType: hard - -"chalk@npm:^4.1.0": - version: 4.1.2 - resolution: "chalk@npm:4.1.2" - dependencies: - ansi-styles: ^4.1.0 - supports-color: ^7.1.0 - checksum: fe75c9d5c76a7a98d45495b91b2172fa3b7a09e0cc9370e5c8feb1c567b85c4288e2b3fded7cfdd7359ac28d6b3844feb8b82b8686842e93d23c827c417e83fc - languageName: node - linkType: hard - -"check-error@npm:^1.0.2": - version: 1.0.2 - resolution: "check-error@npm:1.0.2" - checksum: d9d106504404b8addd1ee3f63f8c0eaa7cd962a1a28eb9c519b1c4a1dc7098be38007fc0060f045ee00f075fbb7a2a4f42abcf61d68323677e11ab98dc16042e - languageName: node - linkType: hard - -"chokidar@npm:3.5.3": - version: 3.5.3 - resolution: "chokidar@npm:3.5.3" - dependencies: - anymatch: ~3.1.2 - braces: ~3.0.2 - fsevents: ~2.3.2 - glob-parent: ~5.1.2 - is-binary-path: ~2.1.0 - is-glob: ~4.0.1 - normalize-path: ~3.0.0 - readdirp: ~3.6.0 - dependenciesMeta: - fsevents: - optional: true - checksum: b49fcde40176ba007ff361b198a2d35df60d9bb2a5aab228279eb810feae9294a6b4649ab15981304447afe1e6ffbf4788ad5db77235dc770ab777c6e771980c - languageName: node - linkType: hard - -"chownr@npm:^2.0.0": - version: 2.0.0 - resolution: "chownr@npm:2.0.0" - checksum: c57cf9dd0791e2f18a5ee9c1a299ae6e801ff58fee96dc8bfd0dcb4738a6ce58dd252a3605b1c93c6418fe4f9d5093b28ffbf4d66648cb2a9c67eaef9679be2f - languageName: node - linkType: hard - -"clean-stack@npm:^2.0.0": - version: 2.2.0 - resolution: "clean-stack@npm:2.2.0" - checksum: 2ac8cd2b2f5ec986a3c743935ec85b07bc174d5421a5efc8017e1f146a1cf5f781ae962618f416352103b32c9cd7e203276e8c28241bbe946160cab16149fb68 - languageName: node - linkType: hard - -"cliui@npm:^7.0.2": - version: 7.0.4 - resolution: "cliui@npm:7.0.4" - dependencies: - string-width: ^4.2.0 - strip-ansi: ^6.0.0 - wrap-ansi: ^7.0.0 - checksum: ce2e8f578a4813806788ac399b9e866297740eecd4ad1823c27fd344d78b22c5f8597d548adbcc46f0573e43e21e751f39446c5a5e804a12aace402b7a315d7f - languageName: node - linkType: hard - -"color-convert@npm:^2.0.1": - version: 2.0.1 - resolution: "color-convert@npm:2.0.1" - dependencies: - color-name: ~1.1.4 - checksum: 79e6bdb9fd479a205c71d89574fccfb22bd9053bd98c6c4d870d65c132e5e904e6034978e55b43d69fcaa7433af2016ee203ce76eeba9cfa554b373e7f7db336 - languageName: node - linkType: hard - -"color-name@npm:~1.1.4": - version: 1.1.4 - resolution: "color-name@npm:1.1.4" - checksum: b0445859521eb4021cd0fb0cc1a75cecf67fceecae89b63f62b201cca8d345baf8b952c966862a9d9a2632987d4f6581f0ec8d957dfacece86f0a7919316f610 - languageName: node - linkType: hard - -"color-support@npm:^1.1.3": - version: 1.1.3 - resolution: "color-support@npm:1.1.3" - bin: - color-support: bin.js - checksum: 9b7356817670b9a13a26ca5af1c21615463b500783b739b7634a0c2047c16cef4b2865d7576875c31c3cddf9dd621fa19285e628f20198b233a5cfdda6d0793b - languageName: node - linkType: hard - -"commander@npm:^2.20.3": - version: 2.20.3 - resolution: "commander@npm:2.20.3" - checksum: ab8c07884e42c3a8dbc5dd9592c606176c7eb5c1ca5ff274bcf907039b2c41de3626f684ea75ccf4d361ba004bbaff1f577d5384c155f3871e456bdf27becf9e - languageName: node - linkType: hard - -"concat-map@npm:0.0.1": - version: 0.0.1 - resolution: "concat-map@npm:0.0.1" - checksum: 902a9f5d8967a3e2faf138d5cb784b9979bad2e6db5357c5b21c568df4ebe62bcb15108af1b2253744844eb964fc023fbd9afbbbb6ddd0bcc204c6fb5b7bf3af - languageName: node - linkType: hard - -"console-control-strings@npm:^1.1.0": - version: 1.1.0 - resolution: "console-control-strings@npm:1.1.0" - checksum: 8755d76787f94e6cf79ce4666f0c5519906d7f5b02d4b884cf41e11dcd759ed69c57da0670afd9236d229a46e0f9cf519db0cd829c6dca820bb5a5c3def584ed - languageName: node - linkType: hard - -"cross-fetch@npm:^3.1.5": - version: 3.1.8 - resolution: "cross-fetch@npm:3.1.8" - dependencies: - node-fetch: ^2.6.12 - checksum: 78f993fa099eaaa041122ab037fe9503ecbbcb9daef234d1d2e0b9230a983f64d645d088c464e21a247b825a08dc444a6e7064adfa93536d3a9454b4745b3632 - languageName: node - linkType: hard - -"cross-spawn@npm:^7.0.0": - version: 7.0.3 - resolution: "cross-spawn@npm:7.0.3" - dependencies: - path-key: ^3.1.0 - shebang-command: ^2.0.0 - which: ^2.0.1 - checksum: 671cc7c7288c3a8406f3c69a3ae2fc85555c04169e9d611def9a675635472614f1c0ed0ef80955d5b6d4e724f6ced67f0ad1bb006c2ea643488fcfef994d7f52 - languageName: node - linkType: hard - -"crypto-hash@npm:^1.3.0": - version: 1.3.0 - resolution: "crypto-hash@npm:1.3.0" - checksum: a3a507e0d2b18fbd2da8088a1c62d0c53c009a99bbfa6d851cac069734ffa546922fa51bdd776d006459701cdda873463e5059ece3431aca048fd99e7573d138 - languageName: node - linkType: hard - -"debug@npm:4, debug@npm:^4.1.0, debug@npm:^4.3.3": - version: 4.3.4 - resolution: "debug@npm:4.3.4" - dependencies: - ms: 2.1.2 - peerDependenciesMeta: - supports-color: - optional: true - checksum: 3dbad3f94ea64f34431a9cbf0bafb61853eda57bff2880036153438f50fb5a84f27683ba0d8e5426bf41a8c6ff03879488120cf5b3a761e77953169c0600a708 - languageName: node - linkType: hard - -"debug@npm:4.3.3": - version: 4.3.3 - resolution: "debug@npm:4.3.3" - dependencies: - ms: 2.1.2 - peerDependenciesMeta: - supports-color: - optional: true - checksum: 14472d56fe4a94dbcfaa6dbed2dd3849f1d72ba78104a1a328047bb564643ca49df0224c3a17fa63533fd11dd3d4c8636cd861191232a2c6735af00cc2d4de16 - languageName: node - linkType: hard - -"decamelize@npm:^4.0.0": - version: 4.0.0 - resolution: "decamelize@npm:4.0.0" - checksum: b7d09b82652c39eead4d6678bb578e3bebd848add894b76d0f6b395bc45b2d692fb88d977e7cfb93c4ed6c119b05a1347cef261174916c2e75c0a8ca57da1809 - languageName: node - linkType: hard - -"deep-eql@npm:^4.1.2": - version: 4.1.3 - resolution: "deep-eql@npm:4.1.3" - dependencies: - type-detect: ^4.0.0 - checksum: 7f6d30cb41c713973dc07eaadded848b2ab0b835e518a88b91bea72f34e08c4c71d167a722a6f302d3a6108f05afd8e6d7650689a84d5d29ec7fe6220420397f - languageName: node - linkType: hard - -"delay@npm:^5.0.0": - version: 5.0.0 - resolution: "delay@npm:5.0.0" - checksum: 62f151151ecfde0d9afbb8a6be37a6d103c4cb24f35a20ef3fe56f920b0d0d0bb02bc9c0a3084d0179ef669ca332b91155f2ee4d9854622cd2cdba5fc95285f9 - languageName: node - linkType: hard - -"delegates@npm:^1.0.0": - version: 1.0.0 - resolution: "delegates@npm:1.0.0" - checksum: a51744d9b53c164ba9c0492471a1a2ffa0b6727451bdc89e31627fdf4adda9d51277cfcbfb20f0a6f08ccb3c436f341df3e92631a3440226d93a8971724771fd - languageName: node - linkType: hard - -"depd@npm:^2.0.0": - version: 2.0.0 - resolution: "depd@npm:2.0.0" - checksum: abbe19c768c97ee2eed6282d8ce3031126662252c58d711f646921c9623f9052e3e1906443066beec1095832f534e57c523b7333f8e7e0d93051ab6baef5ab3a - languageName: node - linkType: hard - -"diff@npm:5.0.0": - version: 5.0.0 - resolution: "diff@npm:5.0.0" - checksum: f19fe29284b633afdb2725c2a8bb7d25761ea54d321d8e67987ac851c5294be4afeab532bd84531e02583a3fe7f4014aa314a3eda84f5590e7a9e6b371ef3b46 - languageName: node - linkType: hard - -"diff@npm:^3.1.0": - version: 3.5.0 - resolution: "diff@npm:3.5.0" - checksum: 00842950a6551e26ce495bdbce11047e31667deea546527902661f25cc2e73358967ebc78cf86b1a9736ec3e14286433225f9970678155753a6291c3bca5227b - languageName: node - linkType: hard - -"dot-case@npm:^3.0.4": - version: 3.0.4 - resolution: "dot-case@npm:3.0.4" - dependencies: - no-case: ^3.0.4 - tslib: ^2.0.3 - checksum: a65e3519414856df0228b9f645332f974f2bf5433370f544a681122eab59e66038fc3349b4be1cdc47152779dac71a5864f1ccda2f745e767c46e9c6543b1169 - languageName: node - linkType: hard - -"eastasianwidth@npm:^0.2.0": - version: 0.2.0 - resolution: "eastasianwidth@npm:0.2.0" - checksum: 7d00d7cd8e49b9afa762a813faac332dee781932d6f2c848dc348939c4253f1d4564341b7af1d041853bc3f32c2ef141b58e0a4d9862c17a7f08f68df1e0f1ed - languageName: node - linkType: hard - -"emoji-regex@npm:^8.0.0": - version: 8.0.0 - resolution: "emoji-regex@npm:8.0.0" - checksum: d4c5c39d5a9868b5fa152f00cada8a936868fd3367f33f71be515ecee4c803132d11b31a6222b2571b1e5f7e13890156a94880345594d0ce7e3c9895f560f192 - languageName: node - linkType: hard - -"emoji-regex@npm:^9.2.2": - version: 9.2.2 - resolution: "emoji-regex@npm:9.2.2" - checksum: 8487182da74aabd810ac6d6f1994111dfc0e331b01271ae01ec1eb0ad7b5ecc2bbbbd2f053c05cb55a1ac30449527d819bbfbf0e3de1023db308cbcb47f86601 - languageName: node - linkType: hard - -"encoding@npm:^0.1.13": - version: 0.1.13 - resolution: "encoding@npm:0.1.13" - dependencies: - iconv-lite: ^0.6.2 - checksum: bb98632f8ffa823996e508ce6a58ffcf5856330fde839ae42c9e1f436cc3b5cc651d4aeae72222916545428e54fd0f6aa8862fd8d25bdbcc4589f1e3f3715e7f - languageName: node - linkType: hard - -"env-paths@npm:^2.2.0": - version: 2.2.1 - resolution: "env-paths@npm:2.2.1" - checksum: 65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e - languageName: node - linkType: hard - -"err-code@npm:^2.0.2": - version: 2.0.3 - resolution: "err-code@npm:2.0.3" - checksum: 8b7b1be20d2de12d2255c0bc2ca638b7af5171142693299416e6a9339bd7d88fc8d7707d913d78e0993176005405a236b066b45666b27b797252c771156ace54 - languageName: node - linkType: hard - -"es6-promise@npm:^4.0.3": - version: 4.2.8 - resolution: "es6-promise@npm:4.2.8" - checksum: 95614a88873611cb9165a85d36afa7268af5c03a378b35ca7bda9508e1d4f1f6f19a788d4bc755b3fd37c8ebba40782018e02034564ff24c9d6fa37e959ad57d - languageName: node - linkType: hard - -"es6-promisify@npm:^5.0.0": - version: 5.0.0 - resolution: "es6-promisify@npm:5.0.0" - dependencies: - es6-promise: ^4.0.3 - checksum: fbed9d791598831413be84a5374eca8c24800ec71a16c1c528c43a98e2dadfb99331483d83ae6094ddb9b87e6f799a15d1553cebf756047e0865c753bc346b92 - languageName: node - linkType: hard - -"escalade@npm:^3.1.1": - version: 3.1.1 - resolution: "escalade@npm:3.1.1" - checksum: a3e2a99f07acb74b3ad4989c48ca0c3140f69f923e56d0cba0526240ee470b91010f9d39001f2a4a313841d237ede70a729e92125191ba5d21e74b106800b133 - languageName: node - linkType: hard - -"escape-string-regexp@npm:4.0.0": - version: 4.0.0 - resolution: "escape-string-regexp@npm:4.0.0" - checksum: 98b48897d93060f2322108bf29db0feba7dd774be96cd069458d1453347b25ce8682ecc39859d4bca2203cc0ab19c237bcc71755eff49a0f8d90beadeeba5cc5 - languageName: node - linkType: hard - -"eventemitter3@npm:^4.0.7": - version: 4.0.7 - resolution: "eventemitter3@npm:4.0.7" - checksum: 1875311c42fcfe9c707b2712c32664a245629b42bb0a5a84439762dd0fd637fc54d078155ea83c2af9e0323c9ac13687e03cfba79b03af9f40c89b4960099374 - languageName: node - linkType: hard - -"exponential-backoff@npm:^3.1.1": - version: 3.1.1 - resolution: "exponential-backoff@npm:3.1.1" - checksum: 3d21519a4f8207c99f7457287291316306255a328770d320b401114ec8481986e4e467e854cb9914dd965e0a1ca810a23ccb559c642c88f4c7f55c55778a9b48 - languageName: node - linkType: hard - -"eyes@npm:^0.1.8": - version: 0.1.8 - resolution: "eyes@npm:0.1.8" - checksum: c31703a92bf36ba75ee8d379ee7985c24ee6149f3a6175f44cec7a05b178c38bce9836d3ca48c9acb0329a960ac2c4b2ead4e60cdd4fe6e8c92cad7cd6913687 - languageName: node - linkType: hard - -"fast-stable-stringify@npm:^1.0.0": - version: 1.0.0 - resolution: "fast-stable-stringify@npm:1.0.0" - checksum: ef1203d246a7e8ac15e2bfbda0a89fa375947bccf9f7910be0ea759856dbe8ea5024a0d8cc2cceabe18a9cb67e95927b78bb6173a3ae37ec55a518cf36e5244b - languageName: node - linkType: hard - -"file-uri-to-path@npm:1.0.0": - version: 1.0.0 - resolution: "file-uri-to-path@npm:1.0.0" - checksum: b648580bdd893a008c92c7ecc96c3ee57a5e7b6c4c18a9a09b44fb5d36d79146f8e442578bc0e173dc027adf3987e254ba1dfd6e3ec998b7c282873010502144 - languageName: node - linkType: hard - -"fill-range@npm:^7.0.1": - version: 7.0.1 - resolution: "fill-range@npm:7.0.1" - dependencies: - to-regex-range: ^5.0.1 - checksum: cc283f4e65b504259e64fd969bcf4def4eb08d85565e906b7d36516e87819db52029a76b6363d0f02d0d532f0033c9603b9e2d943d56ee3b0d4f7ad3328ff917 - languageName: node - linkType: hard - -"find-up@npm:5.0.0": - version: 5.0.0 - resolution: "find-up@npm:5.0.0" - dependencies: - locate-path: ^6.0.0 - path-exists: ^4.0.0 - checksum: 07955e357348f34660bde7920783204ff5a26ac2cafcaa28bace494027158a97b9f56faaf2d89a6106211a8174db650dd9f503f9c0d526b1202d5554a00b9095 - languageName: node - linkType: hard - -"flat@npm:^5.0.2": - version: 5.0.2 - resolution: "flat@npm:5.0.2" - bin: - flat: cli.js - checksum: 12a1536ac746db74881316a181499a78ef953632ddd28050b7a3a43c62ef5462e3357c8c29d76072bb635f147f7a9a1f0c02efef6b4be28f8db62ceb3d5c7f5d - languageName: node - linkType: hard - -"foreground-child@npm:^3.1.0": - version: 3.1.1 - resolution: "foreground-child@npm:3.1.1" - dependencies: - cross-spawn: ^7.0.0 - signal-exit: ^4.0.1 - checksum: 139d270bc82dc9e6f8bc045fe2aae4001dc2472157044fdfad376d0a3457f77857fa883c1c8b21b491c6caade9a926a4bed3d3d2e8d3c9202b151a4cbbd0bcd5 - languageName: node - linkType: hard - -"fs-minipass@npm:^2.0.0": - version: 2.1.0 - resolution: "fs-minipass@npm:2.1.0" - dependencies: - minipass: ^3.0.0 - checksum: 1b8d128dae2ac6cc94230cc5ead341ba3e0efaef82dab46a33d171c044caaa6ca001364178d42069b2809c35a1c3c35079a32107c770e9ffab3901b59af8c8b1 - languageName: node - linkType: hard - -"fs-minipass@npm:^3.0.0": - version: 3.0.2 - resolution: "fs-minipass@npm:3.0.2" - dependencies: - minipass: ^5.0.0 - checksum: e9cc0e1f2d01c6f6f62f567aee59530aba65c6c7b2ae88c5027bc34c711ebcfcfaefd0caf254afa6adfe7d1fba16bc2537508a6235196bac7276747d078aef0a - languageName: node - linkType: hard - -"fs.realpath@npm:^1.0.0": - version: 1.0.0 - resolution: "fs.realpath@npm:1.0.0" - checksum: 99ddea01a7e75aa276c250a04eedeffe5662bce66c65c07164ad6264f9de18fb21be9433ead460e54cff20e31721c811f4fb5d70591799df5f85dce6d6746fd0 - languageName: node - linkType: hard - -"fsevents@npm:~2.3.2": - version: 2.3.2 - resolution: "fsevents@npm:2.3.2" - dependencies: - node-gyp: latest - checksum: 97ade64e75091afee5265e6956cb72ba34db7819b4c3e94c431d4be2b19b8bb7a2d4116da417950c3425f17c8fe693d25e20212cac583ac1521ad066b77ae31f - conditions: os=darwin - languageName: node - linkType: hard - -"fsevents@patch:fsevents@~2.3.2#~builtin": - version: 2.3.2 - resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" - dependencies: - node-gyp: latest - conditions: os=darwin - languageName: node - linkType: hard - -"gauge@npm:^4.0.3": - version: 4.0.4 - resolution: "gauge@npm:4.0.4" - dependencies: - aproba: ^1.0.3 || ^2.0.0 - color-support: ^1.1.3 - console-control-strings: ^1.1.0 - has-unicode: ^2.0.1 - signal-exit: ^3.0.7 - string-width: ^4.2.3 - strip-ansi: ^6.0.1 - wide-align: ^1.1.5 - checksum: 788b6bfe52f1dd8e263cda800c26ac0ca2ff6de0b6eee2fe0d9e3abf15e149b651bd27bf5226be10e6e3edb5c4e5d5985a5a1a98137e7a892f75eff76467ad2d - languageName: node - linkType: hard - -"get-caller-file@npm:^2.0.5": - version: 2.0.5 - resolution: "get-caller-file@npm:2.0.5" - checksum: b9769a836d2a98c3ee734a88ba712e62703f1df31b94b784762c433c27a386dd6029ff55c2a920c392e33657d80191edbf18c61487e198844844516f843496b9 - languageName: node - linkType: hard - -"get-func-name@npm:^2.0.0": - version: 2.0.0 - resolution: "get-func-name@npm:2.0.0" - checksum: 8d82e69f3e7fab9e27c547945dfe5cc0c57fc0adf08ce135dddb01081d75684a03e7a0487466f478872b341d52ac763ae49e660d01ab83741f74932085f693c3 - languageName: node - linkType: hard - -"glob-parent@npm:~5.1.2": - version: 5.1.2 - resolution: "glob-parent@npm:5.1.2" - dependencies: - is-glob: ^4.0.1 - checksum: f4f2bfe2425296e8a47e36864e4f42be38a996db40420fe434565e4480e3322f18eb37589617a98640c5dc8fdec1a387007ee18dbb1f3f5553409c34d17f425e - languageName: node - linkType: hard - -"glob@npm:7.2.0": - version: 7.2.0 - resolution: "glob@npm:7.2.0" - dependencies: - fs.realpath: ^1.0.0 - inflight: ^1.0.4 - inherits: 2 - minimatch: ^3.0.4 - once: ^1.3.0 - path-is-absolute: ^1.0.0 - checksum: 78a8ea942331f08ed2e055cb5b9e40fe6f46f579d7fd3d694f3412fe5db23223d29b7fee1575440202e9a7ff9a72ab106a39fee39934c7bedafe5e5f8ae20134 - languageName: node - linkType: hard - -"glob@npm:^10.2.2": - version: 10.3.3 - resolution: "glob@npm:10.3.3" - dependencies: - foreground-child: ^3.1.0 - jackspeak: ^2.0.3 - minimatch: ^9.0.1 - minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 - path-scurry: ^1.10.1 - bin: - glob: dist/cjs/src/bin.js - checksum: 29190d3291f422da0cb40b77a72fc8d2c51a36524e99b8bf412548b7676a6627489528b57250429612b6eec2e6fe7826d328451d3e694a9d15e575389308ec53 - languageName: node - linkType: hard - -"glob@npm:^7.1.3, glob@npm:^7.1.4": - version: 7.2.3 - resolution: "glob@npm:7.2.3" - dependencies: - fs.realpath: ^1.0.0 - inflight: ^1.0.4 - inherits: 2 - minimatch: ^3.1.1 - once: ^1.3.0 - path-is-absolute: ^1.0.0 - checksum: 29452e97b38fa704dabb1d1045350fb2467cf0277e155aa9ff7077e90ad81d1ea9d53d3ee63bd37c05b09a065e90f16aec4a65f5b8de401d1dac40bc5605d133 - languageName: node - linkType: hard - -"graceful-fs@npm:^4.2.6": - version: 4.2.11 - resolution: "graceful-fs@npm:4.2.11" - checksum: ac85f94da92d8eb6b7f5a8b20ce65e43d66761c55ce85ac96df6865308390da45a8d3f0296dd3a663de65d30ba497bd46c696cc1e248c72b13d6d567138a4fc7 - languageName: node - linkType: hard - -"growl@npm:1.10.5": - version: 1.10.5 - resolution: "growl@npm:1.10.5" - checksum: 4b86685de6831cebcbb19f93870bea624afee61124b0a20c49017013987cd129e73a8c4baeca295728f41d21265e1f859d25ef36731b142ca59c655fea94bb1a - languageName: node - linkType: hard - -"has-flag@npm:^4.0.0": - version: 4.0.0 - resolution: "has-flag@npm:4.0.0" - checksum: 261a1357037ead75e338156b1f9452c016a37dcd3283a972a30d9e4a87441ba372c8b81f818cd0fbcd9c0354b4ae7e18b9e1afa1971164aef6d18c2b6095a8ad - languageName: node - linkType: hard - -"has-unicode@npm:^2.0.1": - version: 2.0.1 - resolution: "has-unicode@npm:2.0.1" - checksum: 1eab07a7436512db0be40a710b29b5dc21fa04880b7f63c9980b706683127e3c1b57cb80ea96d47991bdae2dfe479604f6a1ba410106ee1046a41d1bd0814400 - languageName: node - linkType: hard - -"he@npm:1.2.0": - version: 1.2.0 - resolution: "he@npm:1.2.0" - bin: - he: bin/he - checksum: 3d4d6babccccd79c5c5a3f929a68af33360d6445587d628087f39a965079d84f18ce9c3d3f917ee1e3978916fc833bb8b29377c3b403f919426f91bc6965e7a7 - languageName: node - linkType: hard - -"http-cache-semantics@npm:^4.1.1": - version: 4.1.1 - resolution: "http-cache-semantics@npm:4.1.1" - checksum: 83ac0bc60b17a3a36f9953e7be55e5c8f41acc61b22583060e8dedc9dd5e3607c823a88d0926f9150e571f90946835c7fe150732801010845c72cd8bbff1a236 - languageName: node - linkType: hard - -"http-proxy-agent@npm:^5.0.0": - version: 5.0.0 - resolution: "http-proxy-agent@npm:5.0.0" - dependencies: - "@tootallnate/once": 2 - agent-base: 6 - debug: 4 - checksum: e2ee1ff1656a131953839b2a19cd1f3a52d97c25ba87bd2559af6ae87114abf60971e498021f9b73f9fd78aea8876d1fb0d4656aac8a03c6caa9fc175f22b786 - languageName: node - linkType: hard - -"https-proxy-agent@npm:^5.0.0": - version: 5.0.1 - resolution: "https-proxy-agent@npm:5.0.1" - dependencies: - agent-base: 6 - debug: 4 - checksum: 571fccdf38184f05943e12d37d6ce38197becdd69e58d03f43637f7fa1269cf303a7d228aa27e5b27bbd3af8f09fd938e1c91dcfefff2df7ba77c20ed8dfc765 - languageName: node - linkType: hard - -"humanize-ms@npm:^1.2.1": - version: 1.2.1 - resolution: "humanize-ms@npm:1.2.1" - dependencies: - ms: ^2.0.0 - checksum: 9c7a74a2827f9294c009266c82031030eae811ca87b0da3dceb8d6071b9bde22c9f3daef0469c3c533cc67a97d8a167cd9fc0389350e5f415f61a79b171ded16 - languageName: node - linkType: hard - -"iconv-lite@npm:^0.6.2": - version: 0.6.3 - resolution: "iconv-lite@npm:0.6.3" - dependencies: - safer-buffer: ">= 2.1.2 < 3.0.0" - checksum: 3f60d47a5c8fc3313317edfd29a00a692cc87a19cac0159e2ce711d0ebc9019064108323b5e493625e25594f11c6236647d8e256fbe7a58f4a3b33b89e6d30bf - languageName: node - linkType: hard - -"ieee754@npm:^1.2.1": - version: 1.2.1 - resolution: "ieee754@npm:1.2.1" - checksum: 5144c0c9815e54ada181d80a0b810221a253562422e7c6c3a60b1901154184f49326ec239d618c416c1c5945a2e197107aee8d986a3dd836b53dffefd99b5e7e - languageName: node - linkType: hard - -"imurmurhash@npm:^0.1.4": - version: 0.1.4 - resolution: "imurmurhash@npm:0.1.4" - checksum: 7cae75c8cd9a50f57dadd77482359f659eaebac0319dd9368bcd1714f55e65badd6929ca58569da2b6494ef13fdd5598cd700b1eba23f8b79c5f19d195a3ecf7 - languageName: node - linkType: hard - -"indent-string@npm:^4.0.0": - version: 4.0.0 - resolution: "indent-string@npm:4.0.0" - checksum: 824cfb9929d031dabf059bebfe08cf3137365e112019086ed3dcff6a0a7b698cb80cf67ccccde0e25b9e2d7527aa6cc1fed1ac490c752162496caba3e6699612 - languageName: node - linkType: hard - -"inflight@npm:^1.0.4": - version: 1.0.6 - resolution: "inflight@npm:1.0.6" - dependencies: - once: ^1.3.0 - wrappy: 1 - checksum: f4f76aa072ce19fae87ce1ef7d221e709afb59d445e05d47fba710e85470923a75de35bfae47da6de1b18afc3ce83d70facf44cfb0aff89f0a3f45c0a0244dfd - languageName: node - linkType: hard - -"inherits@npm:2, inherits@npm:^2.0.3": - version: 2.0.4 - resolution: "inherits@npm:2.0.4" - checksum: 4a48a733847879d6cf6691860a6b1e3f0f4754176e4d71494c41f3475553768b10f84b5ce1d40fbd0e34e6bfbb864ee35858ad4dd2cf31e02fc4a154b724d7f1 - languageName: node - linkType: hard - -"ip@npm:^2.0.0": - version: 2.0.0 - resolution: "ip@npm:2.0.0" - checksum: cfcfac6b873b701996d71ec82a7dd27ba92450afdb421e356f44044ed688df04567344c36cbacea7d01b1c39a4c732dc012570ebe9bebfb06f27314bca625349 - languageName: node - linkType: hard - -"is-binary-path@npm:~2.1.0": - version: 2.1.0 - resolution: "is-binary-path@npm:2.1.0" - dependencies: - binary-extensions: ^2.0.0 - checksum: 84192eb88cff70d320426f35ecd63c3d6d495da9d805b19bc65b518984b7c0760280e57dbf119b7e9be6b161784a5a673ab2c6abe83abb5198a432232ad5b35c - languageName: node - linkType: hard - -"is-extglob@npm:^2.1.1": - version: 2.1.1 - resolution: "is-extglob@npm:2.1.1" - checksum: df033653d06d0eb567461e58a7a8c9f940bd8c22274b94bf7671ab36df5719791aae15eef6d83bbb5e23283967f2f984b8914559d4449efda578c775c4be6f85 - languageName: node - linkType: hard - -"is-fullwidth-code-point@npm:^3.0.0": - version: 3.0.0 - resolution: "is-fullwidth-code-point@npm:3.0.0" - checksum: 44a30c29457c7fb8f00297bce733f0a64cd22eca270f83e58c105e0d015e45c019491a4ab2faef91ab51d4738c670daff901c799f6a700e27f7314029e99e348 - languageName: node - linkType: hard - -"is-glob@npm:^4.0.1, is-glob@npm:~4.0.1": - version: 4.0.3 - resolution: "is-glob@npm:4.0.3" - dependencies: - is-extglob: ^2.1.1 - checksum: d381c1319fcb69d341cc6e6c7cd588e17cd94722d9a32dbd60660b993c4fb7d0f19438674e68dfec686d09b7c73139c9166b47597f846af387450224a8101ab4 - languageName: node - linkType: hard - -"is-lambda@npm:^1.0.1": - version: 1.0.1 - resolution: "is-lambda@npm:1.0.1" - checksum: 93a32f01940220532e5948538699ad610d5924ac86093fcee83022252b363eb0cc99ba53ab084a04e4fb62bf7b5731f55496257a4c38adf87af9c4d352c71c35 - languageName: node - linkType: hard - -"is-number@npm:^7.0.0": - version: 7.0.0 - resolution: "is-number@npm:7.0.0" - checksum: 456ac6f8e0f3111ed34668a624e45315201dff921e5ac181f8ec24923b99e9f32ca1a194912dc79d539c97d33dba17dc635202ff0b2cf98326f608323276d27a - languageName: node - linkType: hard - -"is-plain-obj@npm:^2.1.0": - version: 2.1.0 - resolution: "is-plain-obj@npm:2.1.0" - checksum: cec9100678b0a9fe0248a81743041ed990c2d4c99f893d935545cfbc42876cbe86d207f3b895700c690ad2fa520e568c44afc1605044b535a7820c1d40e38daa - languageName: node - linkType: hard - -"is-unicode-supported@npm:^0.1.0": - version: 0.1.0 - resolution: "is-unicode-supported@npm:0.1.0" - checksum: a2aab86ee7712f5c2f999180daaba5f361bdad1efadc9610ff5b8ab5495b86e4f627839d085c6530363c6d6d4ecbde340fb8e54bdb83da4ba8e0865ed5513c52 - languageName: node - linkType: hard - -"isexe@npm:^2.0.0": - version: 2.0.0 - resolution: "isexe@npm:2.0.0" - checksum: 26bf6c5480dda5161c820c5b5c751ae1e766c587b1f951ea3fcfc973bafb7831ae5b54a31a69bd670220e42e99ec154475025a468eae58ea262f813fdc8d1c62 - languageName: node - linkType: hard - -"isomorphic-ws@npm:^4.0.1": - version: 4.0.1 - resolution: "isomorphic-ws@npm:4.0.1" - peerDependencies: - ws: "*" - checksum: d7190eadefdc28bdb93d67b5f0c603385aaf87724fa2974abb382ac1ec9756ed2cfb27065cbe76122879c2d452e2982bc4314317f3d6c737ddda6c047328771a - languageName: node - linkType: hard - -"jackspeak@npm:^2.0.3": - version: 2.2.2 - resolution: "jackspeak@npm:2.2.2" - dependencies: - "@isaacs/cliui": ^8.0.2 - "@pkgjs/parseargs": ^0.11.0 - dependenciesMeta: - "@pkgjs/parseargs": - optional: true - checksum: 7b1468dd910afc00642db87448f24b062346570b8b47531409aa9012bcb95fdf7ec2b1c48edbb8b57a938c08391f8cc01b5034fc335aa3a2e74dbcc0ee5c555a - languageName: node - linkType: hard - -"jayson@npm:^4.1.0": - version: 4.1.0 - resolution: "jayson@npm:4.1.0" - dependencies: - "@types/connect": ^3.4.33 - "@types/node": ^12.12.54 - "@types/ws": ^7.4.4 - JSONStream: ^1.3.5 - commander: ^2.20.3 - delay: ^5.0.0 - es6-promisify: ^5.0.0 - eyes: ^0.1.8 - isomorphic-ws: ^4.0.1 - json-stringify-safe: ^5.0.1 - uuid: ^8.3.2 - ws: ^7.4.5 - bin: - jayson: bin/jayson.js - checksum: 86464322fbdc6db65d2bb4fc278cb6c86fad5c2a506065490d39459f09ba0d30f2b4fb740b33828a1424791419b6c8bd295dc54d361a4ad959bf70cc62b1ca7e - languageName: node - linkType: hard - -"js-sha256@npm:^0.9.0": - version: 0.9.0 - resolution: "js-sha256@npm:0.9.0" - checksum: ffad54b3373f81581e245866abfda50a62c483803a28176dd5c28fd2d313e0bdf830e77dac7ff8afd193c53031618920f3d98daf21cbbe80082753ab639c0365 - languageName: node - linkType: hard - -"js-yaml@npm:4.1.0": - version: 4.1.0 - resolution: "js-yaml@npm:4.1.0" - dependencies: - argparse: ^2.0.1 - bin: - js-yaml: bin/js-yaml.js - checksum: c7830dfd456c3ef2c6e355cc5a92e6700ceafa1d14bba54497b34a99f0376cecbb3e9ac14d3e5849b426d5a5140709a66237a8c991c675431271c4ce5504151a - languageName: node - linkType: hard - -"json-stringify-safe@npm:^5.0.1": - version: 5.0.1 - resolution: "json-stringify-safe@npm:5.0.1" - checksum: 48ec0adad5280b8a96bb93f4563aa1667fd7a36334f79149abd42446d0989f2ddc58274b479f4819f1f00617957e6344c886c55d05a4e15ebb4ab931e4a6a8ee - languageName: node - linkType: hard - -"json5@npm:^1.0.2": - version: 1.0.2 - resolution: "json5@npm:1.0.2" - dependencies: - minimist: ^1.2.0 - bin: - json5: lib/cli.js - checksum: 866458a8c58a95a49bef3adba929c625e82532bcff1fe93f01d29cb02cac7c3fe1f4b79951b7792c2da9de0b32871a8401a6e3c5b36778ad852bf5b8a61165d7 - languageName: node - linkType: hard - -"jsonparse@npm:^1.2.0": - version: 1.3.1 - resolution: "jsonparse@npm:1.3.1" - checksum: 6514a7be4674ebf407afca0eda3ba284b69b07f9958a8d3113ef1005f7ec610860c312be067e450c569aab8b89635e332cee3696789c750692bb60daba627f4d - languageName: node - linkType: hard - -"locate-path@npm:^6.0.0": - version: 6.0.0 - resolution: "locate-path@npm:6.0.0" - dependencies: - p-locate: ^5.0.0 - checksum: 72eb661788a0368c099a184c59d2fee760b3831c9c1c33955e8a19ae4a21b4116e53fa736dc086cdeb9fce9f7cc508f2f92d2d3aae516f133e16a2bb59a39f5a - languageName: node - linkType: hard - -"log-symbols@npm:4.1.0": - version: 4.1.0 - resolution: "log-symbols@npm:4.1.0" - dependencies: - chalk: ^4.1.0 - is-unicode-supported: ^0.1.0 - checksum: fce1497b3135a0198803f9f07464165e9eb83ed02ceb2273930a6f8a508951178d8cf4f0378e9d28300a2ed2bc49050995d2bd5f53ab716bb15ac84d58c6ef74 - languageName: node - linkType: hard - -"loupe@npm:^2.3.1": - version: 2.3.6 - resolution: "loupe@npm:2.3.6" - dependencies: - get-func-name: ^2.0.0 - checksum: cc83f1b124a1df7384601d72d8d1f5fe95fd7a8185469fec48bb2e4027e45243949e7a013e8d91051a138451ff0552310c32aa9786e60b6a30d1e801bdc2163f - languageName: node - linkType: hard - -"lower-case@npm:^2.0.2": - version: 2.0.2 - resolution: "lower-case@npm:2.0.2" - dependencies: - tslib: ^2.0.3 - checksum: 83a0a5f159ad7614bee8bf976b96275f3954335a84fad2696927f609ddae902802c4f3312d86668722e668bef41400254807e1d3a7f2e8c3eede79691aa1f010 - languageName: node - linkType: hard - -"lru-cache@npm:^6.0.0": - version: 6.0.0 - resolution: "lru-cache@npm:6.0.0" - dependencies: - yallist: ^4.0.0 - checksum: f97f499f898f23e4585742138a22f22526254fdba6d75d41a1c2526b3b6cc5747ef59c5612ba7375f42aca4f8461950e925ba08c991ead0651b4918b7c978297 - languageName: node - linkType: hard - -"lru-cache@npm:^7.7.1": - version: 7.18.3 - resolution: "lru-cache@npm:7.18.3" - checksum: e550d772384709deea3f141af34b6d4fa392e2e418c1498c078de0ee63670f1f46f5eee746e8ef7e69e1c895af0d4224e62ee33e66a543a14763b0f2e74c1356 - languageName: node - linkType: hard - -"lru-cache@npm:^9.1.1 || ^10.0.0": - version: 10.0.0 - resolution: "lru-cache@npm:10.0.0" - checksum: 18f101675fe283bc09cda0ef1e3cc83781aeb8373b439f086f758d1d91b28730950db785999cd060d3c825a8571c03073e8c14512b6655af2188d623031baf50 - languageName: node - linkType: hard - -"make-error@npm:^1.1.1": - version: 1.3.6 - resolution: "make-error@npm:1.3.6" - checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 - languageName: node - linkType: hard - -"make-fetch-happen@npm:^11.0.3": - version: 11.1.1 - resolution: "make-fetch-happen@npm:11.1.1" - dependencies: - agentkeepalive: ^4.2.1 - cacache: ^17.0.0 - http-cache-semantics: ^4.1.1 - http-proxy-agent: ^5.0.0 - https-proxy-agent: ^5.0.0 - is-lambda: ^1.0.1 - lru-cache: ^7.7.1 - minipass: ^5.0.0 - minipass-fetch: ^3.0.0 - minipass-flush: ^1.0.5 - minipass-pipeline: ^1.2.4 - negotiator: ^0.6.3 - promise-retry: ^2.0.1 - socks-proxy-agent: ^7.0.0 - ssri: ^10.0.0 - checksum: 7268bf274a0f6dcf0343829489a4506603ff34bd0649c12058753900b0eb29191dce5dba12680719a5d0a983d3e57810f594a12f3c18494e93a1fbc6348a4540 - languageName: node - linkType: hard - -"minimatch@npm:4.2.1": - version: 4.2.1 - resolution: "minimatch@npm:4.2.1" - dependencies: - brace-expansion: ^1.1.7 - checksum: 2b1514e3d0f29a549912f0db7ae7b82c5cab4a8f2dd0369f1c6451a325b3f12b2cf473c95873b6157bb8df183d6cf6db82ff03614b6adaaf1d7e055beccdfd01 - languageName: node - linkType: hard - -"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1": - version: 3.1.2 - resolution: "minimatch@npm:3.1.2" - dependencies: - brace-expansion: ^1.1.7 - checksum: c154e566406683e7bcb746e000b84d74465b3a832c45d59912b9b55cd50dee66e5c4b1e5566dba26154040e51672f9aa450a9aef0c97cfc7336b78b7afb9540a - languageName: node - linkType: hard - -"minimatch@npm:^9.0.1": - version: 9.0.3 - resolution: "minimatch@npm:9.0.3" - dependencies: - brace-expansion: ^2.0.1 - checksum: 253487976bf485b612f16bf57463520a14f512662e592e95c571afdab1442a6a6864b6c88f248ce6fc4ff0b6de04ac7aa6c8bb51e868e99d1d65eb0658a708b5 - languageName: node - linkType: hard - -"minimist@npm:^1.2.0, minimist@npm:^1.2.6": - version: 1.2.8 - resolution: "minimist@npm:1.2.8" - checksum: 75a6d645fb122dad29c06a7597bddea977258957ed88d7a6df59b5cd3fe4a527e253e9bbf2e783e4b73657f9098b96a5fe96ab8a113655d4109108577ecf85b0 - languageName: node - linkType: hard - -"minipass-collect@npm:^1.0.2": - version: 1.0.2 - resolution: "minipass-collect@npm:1.0.2" - dependencies: - minipass: ^3.0.0 - checksum: 14df761028f3e47293aee72888f2657695ec66bd7d09cae7ad558da30415fdc4752bbfee66287dcc6fd5e6a2fa3466d6c484dc1cbd986525d9393b9523d97f10 - languageName: node - linkType: hard - -"minipass-fetch@npm:^3.0.0": - version: 3.0.3 - resolution: "minipass-fetch@npm:3.0.3" - dependencies: - encoding: ^0.1.13 - minipass: ^5.0.0 - minipass-sized: ^1.0.3 - minizlib: ^2.1.2 - dependenciesMeta: - encoding: - optional: true - checksum: af5ab2552a16fcf505d35fd7ffb84b57f4a0eeb269e6e1d9a2a75824dda48b36e527083250b7cca4a4def21d9544e2ade441e4730e233c0bc2133f6abda31e18 - languageName: node - linkType: hard - -"minipass-flush@npm:^1.0.5": - version: 1.0.5 - resolution: "minipass-flush@npm:1.0.5" - dependencies: - minipass: ^3.0.0 - checksum: 56269a0b22bad756a08a94b1ffc36b7c9c5de0735a4dd1ab2b06c066d795cfd1f0ac44a0fcae13eece5589b908ecddc867f04c745c7009be0b566421ea0944cf - languageName: node - linkType: hard - -"minipass-pipeline@npm:^1.2.4": - version: 1.2.4 - resolution: "minipass-pipeline@npm:1.2.4" - dependencies: - minipass: ^3.0.0 - checksum: b14240dac0d29823c3d5911c286069e36d0b81173d7bdf07a7e4a91ecdef92cdff4baaf31ea3746f1c61e0957f652e641223970870e2353593f382112257971b - languageName: node - linkType: hard - -"minipass-sized@npm:^1.0.3": - version: 1.0.3 - resolution: "minipass-sized@npm:1.0.3" - dependencies: - minipass: ^3.0.0 - checksum: 79076749fcacf21b5d16dd596d32c3b6bf4d6e62abb43868fac21674078505c8b15eaca4e47ed844985a4514854f917d78f588fcd029693709417d8f98b2bd60 - languageName: node - linkType: hard - -"minipass@npm:^3.0.0": - version: 3.3.6 - resolution: "minipass@npm:3.3.6" - dependencies: - yallist: ^4.0.0 - checksum: a30d083c8054cee83cdcdc97f97e4641a3f58ae743970457b1489ce38ee1167b3aaf7d815cd39ec7a99b9c40397fd4f686e83750e73e652b21cb516f6d845e48 - languageName: node - linkType: hard - -"minipass@npm:^5.0.0": - version: 5.0.0 - resolution: "minipass@npm:5.0.0" - checksum: 425dab288738853fded43da3314a0b5c035844d6f3097a8e3b5b29b328da8f3c1af6fc70618b32c29ff906284cf6406b6841376f21caaadd0793c1d5a6a620ea - languageName: node - linkType: hard - -"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0": - version: 7.0.2 - resolution: "minipass@npm:7.0.2" - checksum: 46776de732eb7cef2c7404a15fb28c41f5c54a22be50d47b03c605bf21f5c18d61a173c0a20b49a97e7a65f78d887245066410642551e45fffe04e9ac9e325bc - languageName: node - linkType: hard - -"minizlib@npm:^2.1.1, minizlib@npm:^2.1.2": - version: 2.1.2 - resolution: "minizlib@npm:2.1.2" - dependencies: - minipass: ^3.0.0 - yallist: ^4.0.0 - checksum: f1fdeac0b07cf8f30fcf12f4b586795b97be856edea22b5e9072707be51fc95d41487faec3f265b42973a304fe3a64acd91a44a3826a963e37b37bafde0212c3 - languageName: node - linkType: hard - -"mkdirp@npm:^0.5.1": - version: 0.5.6 - resolution: "mkdirp@npm:0.5.6" - dependencies: - minimist: ^1.2.6 - bin: - mkdirp: bin/cmd.js - checksum: 0c91b721bb12c3f9af4b77ebf73604baf350e64d80df91754dc509491ae93bf238581e59c7188360cec7cb62fc4100959245a42cfe01834efedc5e9d068376c2 - languageName: node - linkType: hard - -"mkdirp@npm:^1.0.3": - version: 1.0.4 - resolution: "mkdirp@npm:1.0.4" - bin: - mkdirp: bin/cmd.js - checksum: a96865108c6c3b1b8e1d5e9f11843de1e077e57737602de1b82030815f311be11f96f09cce59bd5b903d0b29834733e5313f9301e3ed6d6f6fba2eae0df4298f - languageName: node - linkType: hard - -"mocha@npm:^9.0.3": - version: 9.2.2 - resolution: "mocha@npm:9.2.2" - dependencies: - "@ungap/promise-all-settled": 1.1.2 - ansi-colors: 4.1.1 - browser-stdout: 1.3.1 - chokidar: 3.5.3 - debug: 4.3.3 - diff: 5.0.0 - escape-string-regexp: 4.0.0 - find-up: 5.0.0 - glob: 7.2.0 - growl: 1.10.5 - he: 1.2.0 - js-yaml: 4.1.0 - log-symbols: 4.1.0 - minimatch: 4.2.1 - ms: 2.1.3 - nanoid: 3.3.1 - serialize-javascript: 6.0.0 - strip-json-comments: 3.1.1 - supports-color: 8.1.1 - which: 2.0.2 - workerpool: 6.2.0 - yargs: 16.2.0 - yargs-parser: 20.2.4 - yargs-unparser: 2.0.0 - bin: - _mocha: bin/_mocha - mocha: bin/mocha - checksum: 4d5ca4ce33fc66627e63acdf09a634e2358c9a00f61de7788b1091b6aad430da04f97f9ecb82d56dc034b623cb833b65576136fd010d77679c03fcea5bc1e12d - languageName: node - linkType: hard - -"ms@npm:2.1.2": - version: 2.1.2 - resolution: "ms@npm:2.1.2" - checksum: 673cdb2c3133eb050c745908d8ce632ed2c02d85640e2edb3ace856a2266a813b30c613569bf3354fdf4ea7d1a1494add3bfa95e2713baa27d0c2c71fc44f58f - languageName: node - linkType: hard - -"ms@npm:2.1.3, ms@npm:^2.0.0": - version: 2.1.3 - resolution: "ms@npm:2.1.3" - checksum: aa92de608021b242401676e35cfa5aa42dd70cbdc082b916da7fb925c542173e36bce97ea3e804923fe92c0ad991434e4a38327e15a1b5b5f945d66df615ae6d - languageName: node - linkType: hard - -"nanoid@npm:3.3.1": - version: 3.3.1 - resolution: "nanoid@npm:3.3.1" - bin: - nanoid: bin/nanoid.cjs - checksum: 4ef0969e1bbe866fc223eb32276cbccb0961900bfe79104fa5abe34361979dead8d0e061410a5c03bc3d47455685adf32c09d6f27790f4a6898fb51f7df7ec86 - languageName: node - linkType: hard - -"negotiator@npm:^0.6.3": - version: 0.6.3 - resolution: "negotiator@npm:0.6.3" - checksum: b8ffeb1e262eff7968fc90a2b6767b04cfd9842582a9d0ece0af7049537266e7b2506dfb1d107a32f06dd849ab2aea834d5830f7f4d0e5cb7d36e1ae55d021d9 - languageName: node - linkType: hard - -"no-case@npm:^3.0.4": - version: 3.0.4 - resolution: "no-case@npm:3.0.4" - dependencies: - lower-case: ^2.0.2 - tslib: ^2.0.3 - checksum: 0b2ebc113dfcf737d48dde49cfebf3ad2d82a8c3188e7100c6f375e30eafbef9e9124aadc3becef237b042fd5eb0aad2fd78669c20972d045bbe7fea8ba0be5c - languageName: node - linkType: hard - -"node-fetch@npm:^2.6.12": - version: 2.6.12 - resolution: "node-fetch@npm:2.6.12" - dependencies: - whatwg-url: ^5.0.0 - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - checksum: 3bc1655203d47ee8e313c0d96664b9673a3d4dd8002740318e9d27d14ef306693a4b2ef8d6525775056fd912a19e23f3ac0d7111ad8925877b7567b29a625592 - languageName: node - linkType: hard - -"node-gyp-build@npm:^4.3.0": - version: 4.6.0 - resolution: "node-gyp-build@npm:4.6.0" - bin: - node-gyp-build: bin.js - node-gyp-build-optional: optional.js - node-gyp-build-test: build-test.js - checksum: 25d78c5ef1f8c24291f4a370c47ba52fcea14f39272041a90a7894cd50d766f7c8cb8fb06c0f42bf6f69b204b49d9be3c8fc344aac09714d5bdb95965499eb15 - languageName: node - linkType: hard - -"node-gyp@npm:latest": - version: 9.4.0 - resolution: "node-gyp@npm:9.4.0" - dependencies: - env-paths: ^2.2.0 - exponential-backoff: ^3.1.1 - glob: ^7.1.4 - graceful-fs: ^4.2.6 - make-fetch-happen: ^11.0.3 - nopt: ^6.0.0 - npmlog: ^6.0.0 - rimraf: ^3.0.2 - semver: ^7.3.5 - tar: ^6.1.2 - which: ^2.0.2 - bin: - node-gyp: bin/node-gyp.js - checksum: 78b404e2e0639d64e145845f7f5a3cb20c0520cdaf6dda2f6e025e9b644077202ea7de1232396ba5bde3fee84cdc79604feebe6ba3ec84d464c85d407bb5da99 - languageName: node - linkType: hard - -"nopt@npm:^6.0.0": - version: 6.0.0 - resolution: "nopt@npm:6.0.0" - dependencies: - abbrev: ^1.0.0 - bin: - nopt: bin/nopt.js - checksum: 82149371f8be0c4b9ec2f863cc6509a7fd0fa729929c009f3a58e4eb0c9e4cae9920e8f1f8eb46e7d032fec8fb01bede7f0f41a67eb3553b7b8e14fa53de1dac - languageName: node - linkType: hard - -"normalize-path@npm:^3.0.0, normalize-path@npm:~3.0.0": - version: 3.0.0 - resolution: "normalize-path@npm:3.0.0" - checksum: 88eeb4da891e10b1318c4b2476b6e2ecbeb5ff97d946815ffea7794c31a89017c70d7f34b3c2ebf23ef4e9fc9fb99f7dffe36da22011b5b5c6ffa34f4873ec20 - languageName: node - linkType: hard - -"npmlog@npm:^6.0.0": - version: 6.0.2 - resolution: "npmlog@npm:6.0.2" - dependencies: - are-we-there-yet: ^3.0.0 - console-control-strings: ^1.1.0 - gauge: ^4.0.3 - set-blocking: ^2.0.0 - checksum: ae238cd264a1c3f22091cdd9e2b106f684297d3c184f1146984ecbe18aaa86343953f26b9520dedd1b1372bc0316905b736c1932d778dbeb1fcf5a1001390e2a - languageName: node - linkType: hard - -"once@npm:^1.3.0": - version: 1.4.0 - resolution: "once@npm:1.4.0" - dependencies: - wrappy: 1 - checksum: cd0a88501333edd640d95f0d2700fbde6bff20b3d4d9bdc521bdd31af0656b5706570d6c6afe532045a20bb8dc0849f8332d6f2a416e0ba6d3d3b98806c7db68 - languageName: node - linkType: hard - -"p-limit@npm:^3.0.2": - version: 3.1.0 - resolution: "p-limit@npm:3.1.0" - dependencies: - yocto-queue: ^0.1.0 - checksum: 7c3690c4dbf62ef625671e20b7bdf1cbc9534e83352a2780f165b0d3ceba21907e77ad63401708145ca4e25bfc51636588d89a8c0aeb715e6c37d1c066430360 - languageName: node - linkType: hard - -"p-locate@npm:^5.0.0": - version: 5.0.0 - resolution: "p-locate@npm:5.0.0" - dependencies: - p-limit: ^3.0.2 - checksum: 1623088f36cf1cbca58e9b61c4e62bf0c60a07af5ae1ca99a720837356b5b6c5ba3eb1b2127e47a06865fee59dd0453cad7cc844cda9d5a62ac1a5a51b7c86d3 - languageName: node - linkType: hard - -"p-map@npm:^4.0.0": - version: 4.0.0 - resolution: "p-map@npm:4.0.0" - dependencies: - aggregate-error: ^3.0.0 - checksum: cb0ab21ec0f32ddffd31dfc250e3afa61e103ef43d957cc45497afe37513634589316de4eb88abdfd969fe6410c22c0b93ab24328833b8eb1ccc087fc0442a1c - languageName: node - linkType: hard - -"pako@npm:^2.0.3": - version: 2.1.0 - resolution: "pako@npm:2.1.0" - checksum: 71666548644c9a4d056bcaba849ca6fd7242c6cf1af0646d3346f3079a1c7f4a66ffec6f7369ee0dc88f61926c10d6ab05da3e1fca44b83551839e89edd75a3e - languageName: node - linkType: hard - -"path-exists@npm:^4.0.0": - version: 4.0.0 - resolution: "path-exists@npm:4.0.0" - checksum: 505807199dfb7c50737b057dd8d351b82c033029ab94cb10a657609e00c1bc53b951cfdbccab8de04c5584d5eff31128ce6afd3db79281874a5ef2adbba55ed1 - languageName: node - linkType: hard - -"path-is-absolute@npm:^1.0.0": - version: 1.0.1 - resolution: "path-is-absolute@npm:1.0.1" - checksum: 060840f92cf8effa293bcc1bea81281bd7d363731d214cbe5c227df207c34cd727430f70c6037b5159c8a870b9157cba65e775446b0ab06fd5ecc7e54615a3b8 - languageName: node - linkType: hard - -"path-key@npm:^3.1.0": - version: 3.1.1 - resolution: "path-key@npm:3.1.1" - checksum: 55cd7a9dd4b343412a8386a743f9c746ef196e57c823d90ca3ab917f90ab9f13dd0ded27252ba49dbdfcab2b091d998bc446f6220cd3cea65db407502a740020 - languageName: node - linkType: hard - -"path-scurry@npm:^1.10.1": - version: 1.10.1 - resolution: "path-scurry@npm:1.10.1" - dependencies: - lru-cache: ^9.1.1 || ^10.0.0 - minipass: ^5.0.0 || ^6.0.2 || ^7.0.0 - checksum: e2557cff3a8fb8bc07afdd6ab163a92587884f9969b05bbbaf6fe7379348bfb09af9ed292af12ed32398b15fb443e81692047b786d1eeb6d898a51eb17ed7d90 - languageName: node - linkType: hard - -"pathval@npm:^1.1.1": - version: 1.1.1 - resolution: "pathval@npm:1.1.1" - checksum: 090e3147716647fb7fb5b4b8c8e5b55e5d0a6086d085b6cd23f3d3c01fcf0ff56fd3cc22f2f4a033bd2e46ed55d61ed8379e123b42afe7d531a2a5fc8bb556d6 - languageName: node - linkType: hard - -"picomatch@npm:^2.0.4, picomatch@npm:^2.2.1": - version: 2.3.1 - resolution: "picomatch@npm:2.3.1" - checksum: 050c865ce81119c4822c45d3c84f1ced46f93a0126febae20737bd05ca20589c564d6e9226977df859ed5e03dc73f02584a2b0faad36e896936238238b0446cf - languageName: node - linkType: hard - -"prettier@npm:^2.6.2": - version: 2.8.8 - resolution: "prettier@npm:2.8.8" - bin: - prettier: bin-prettier.js - checksum: b49e409431bf129dd89238d64299ba80717b57ff5a6d1c1a8b1a28b590d998a34e083fa13573bc732bb8d2305becb4c9a4407f8486c81fa7d55100eb08263cf8 - languageName: node - linkType: hard - -"promise-retry@npm:^2.0.1": - version: 2.0.1 - resolution: "promise-retry@npm:2.0.1" - dependencies: - err-code: ^2.0.2 - retry: ^0.12.0 - checksum: f96a3f6d90b92b568a26f71e966cbbc0f63ab85ea6ff6c81284dc869b41510e6cdef99b6b65f9030f0db422bf7c96652a3fff9f2e8fb4a0f069d8f4430359429 - languageName: node - linkType: hard - -"randombytes@npm:^2.1.0": - version: 2.1.0 - resolution: "randombytes@npm:2.1.0" - dependencies: - safe-buffer: ^5.1.0 - checksum: d779499376bd4cbb435ef3ab9a957006c8682f343f14089ed5f27764e4645114196e75b7f6abf1cbd84fd247c0cb0651698444df8c9bf30e62120fbbc52269d6 - languageName: node - linkType: hard - -"readable-stream@npm:^3.6.0": - version: 3.6.2 - resolution: "readable-stream@npm:3.6.2" - dependencies: - inherits: ^2.0.3 - string_decoder: ^1.1.1 - util-deprecate: ^1.0.1 - checksum: bdcbe6c22e846b6af075e32cf8f4751c2576238c5043169a1c221c92ee2878458a816a4ea33f4c67623c0b6827c8a400409bfb3cf0bf3381392d0b1dfb52ac8d - languageName: node - linkType: hard - -"readdirp@npm:~3.6.0": - version: 3.6.0 - resolution: "readdirp@npm:3.6.0" - dependencies: - picomatch: ^2.2.1 - checksum: 1ced032e6e45670b6d7352d71d21ce7edf7b9b928494dcaba6f11fba63180d9da6cd7061ebc34175ffda6ff529f481818c962952004d273178acd70f7059b320 - languageName: node - linkType: hard - -"regenerator-runtime@npm:^0.13.11": - version: 0.13.11 - resolution: "regenerator-runtime@npm:0.13.11" - checksum: 27481628d22a1c4e3ff551096a683b424242a216fee44685467307f14d58020af1e19660bf2e26064de946bad7eff28950eae9f8209d55723e2d9351e632bbb4 - languageName: node - linkType: hard - -"require-directory@npm:^2.1.1": - version: 2.1.1 - resolution: "require-directory@npm:2.1.1" - checksum: fb47e70bf0001fdeabdc0429d431863e9475e7e43ea5f94ad86503d918423c1543361cc5166d713eaa7029dd7a3d34775af04764bebff99ef413111a5af18c80 - languageName: node - linkType: hard - -"retry@npm:^0.12.0": - version: 0.12.0 - resolution: "retry@npm:0.12.0" - checksum: 623bd7d2e5119467ba66202d733ec3c2e2e26568074923bc0585b6b99db14f357e79bdedb63cab56cec47491c4a0da7e6021a7465ca6dc4f481d3898fdd3158c - languageName: node - linkType: hard - -"rimraf@npm:^3.0.2": - version: 3.0.2 - resolution: "rimraf@npm:3.0.2" - dependencies: - glob: ^7.1.3 - bin: - rimraf: bin.js - checksum: 87f4164e396f0171b0a3386cc1877a817f572148ee13a7e113b238e48e8a9f2f31d009a92ec38a591ff1567d9662c6b67fd8818a2dbbaed74bc26a87a2a4a9a0 - languageName: node - linkType: hard - -"root-workspace-0b6124@workspace:.": - version: 0.0.0-use.local - resolution: "root-workspace-0b6124@workspace:." - dependencies: - "@coral-xyz/anchor": ^0.28.0 - "@solana/spl-token": ^0.3.8 - "@solana/web3.js": ^1.77.3 - "@types/bn.js": ^5.1.0 - "@types/chai": ^4.3.0 - "@types/mocha": ^9.0.0 - chai: ^4.3.4 - mocha: ^9.0.3 - prettier: ^2.6.2 - ts-mocha: ^10.0.0 - typescript: ^4.3.5 - languageName: unknown - linkType: soft - -"rpc-websockets@npm:^7.5.1": - version: 7.5.1 - resolution: "rpc-websockets@npm:7.5.1" - dependencies: - "@babel/runtime": ^7.17.2 - bufferutil: ^4.0.1 - eventemitter3: ^4.0.7 - utf-8-validate: ^5.0.2 - uuid: ^8.3.2 - ws: ^8.5.0 - dependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 9dda8c63a1d3e85e11597e1c364835ec6aa9a8de1b5cfb1629d0eafc3ae04509011d485025ed4f717c0b1dd048e2aafdd75080e866540b93e55fd8a2cd91bcfe - languageName: node - linkType: hard - -"safe-buffer@npm:^5.0.1, safe-buffer@npm:^5.1.0, safe-buffer@npm:~5.2.0": - version: 5.2.1 - resolution: "safe-buffer@npm:5.2.1" - checksum: b99c4b41fdd67a6aaf280fcd05e9ffb0813654894223afb78a31f14a19ad220bba8aba1cb14eddce1fcfb037155fe6de4e861784eb434f7d11ed58d1e70dd491 - languageName: node - linkType: hard - -"safer-buffer@npm:>= 2.1.2 < 3.0.0": - version: 2.1.2 - resolution: "safer-buffer@npm:2.1.2" - checksum: cab8f25ae6f1434abee8d80023d7e72b598cf1327164ddab31003c51215526801e40b66c5e65d658a0af1e9d6478cadcb4c745f4bd6751f97d8644786c0978b0 - languageName: node - linkType: hard - -"semver@npm:^7.3.5": - version: 7.5.4 - resolution: "semver@npm:7.5.4" - dependencies: - lru-cache: ^6.0.0 - bin: - semver: bin/semver.js - checksum: 12d8ad952fa353b0995bf180cdac205a4068b759a140e5d3c608317098b3575ac2f1e09182206bf2eb26120e1c0ed8fb92c48c592f6099680de56bb071423ca3 - languageName: node - linkType: hard - -"serialize-javascript@npm:6.0.0": - version: 6.0.0 - resolution: "serialize-javascript@npm:6.0.0" - dependencies: - randombytes: ^2.1.0 - checksum: 56f90b562a1bdc92e55afb3e657c6397c01a902c588c0fe3d4c490efdcc97dcd2a3074ba12df9e94630f33a5ce5b76a74784a7041294628a6f4306e0ec84bf93 - languageName: node - linkType: hard - -"set-blocking@npm:^2.0.0": - version: 2.0.0 - resolution: "set-blocking@npm:2.0.0" - checksum: 6e65a05f7cf7ebdf8b7c75b101e18c0b7e3dff4940d480efed8aad3a36a4005140b660fa1d804cb8bce911cac290441dc728084a30504d3516ac2ff7ad607b02 - languageName: node - linkType: hard - -"shebang-command@npm:^2.0.0": - version: 2.0.0 - resolution: "shebang-command@npm:2.0.0" - dependencies: - shebang-regex: ^3.0.0 - checksum: 6b52fe87271c12968f6a054e60f6bde5f0f3d2db483a1e5c3e12d657c488a15474121a1d55cd958f6df026a54374ec38a4a963988c213b7570e1d51575cea7fa - languageName: node - linkType: hard - -"shebang-regex@npm:^3.0.0": - version: 3.0.0 - resolution: "shebang-regex@npm:3.0.0" - checksum: 1a2bcae50de99034fcd92ad4212d8e01eedf52c7ec7830eedcf886622804fe36884278f2be8be0ea5fde3fd1c23911643a4e0f726c8685b61871c8908af01222 - languageName: node - linkType: hard - -"signal-exit@npm:^3.0.7": - version: 3.0.7 - resolution: "signal-exit@npm:3.0.7" - checksum: a2f098f247adc367dffc27845853e9959b9e88b01cb301658cfe4194352d8d2bb32e18467c786a7fe15f1d44b233ea35633d076d5e737870b7139949d1ab6318 - languageName: node - linkType: hard - -"signal-exit@npm:^4.0.1": - version: 4.1.0 - resolution: "signal-exit@npm:4.1.0" - checksum: 64c757b498cb8629ffa5f75485340594d2f8189e9b08700e69199069c8e3070fb3e255f7ab873c05dc0b3cec412aea7402e10a5990cb6a050bd33ba062a6c549 - languageName: node - linkType: hard - -"smart-buffer@npm:^4.2.0": - version: 4.2.0 - resolution: "smart-buffer@npm:4.2.0" - checksum: b5167a7142c1da704c0e3af85c402002b597081dd9575031a90b4f229ca5678e9a36e8a374f1814c8156a725d17008ae3bde63b92f9cfd132526379e580bec8b - languageName: node - linkType: hard - -"snake-case@npm:^3.0.4": - version: 3.0.4 - resolution: "snake-case@npm:3.0.4" - dependencies: - dot-case: ^3.0.4 - tslib: ^2.0.3 - checksum: 0a7a79900bbb36f8aaa922cf111702a3647ac6165736d5dc96d3ef367efc50465cac70c53cd172c382b022dac72ec91710608e5393de71f76d7142e6fd80e8a3 - languageName: node - linkType: hard - -"socks-proxy-agent@npm:^7.0.0": - version: 7.0.0 - resolution: "socks-proxy-agent@npm:7.0.0" - dependencies: - agent-base: ^6.0.2 - debug: ^4.3.3 - socks: ^2.6.2 - checksum: 720554370154cbc979e2e9ce6a6ec6ced205d02757d8f5d93fe95adae454fc187a5cbfc6b022afab850a5ce9b4c7d73e0f98e381879cf45f66317a4895953846 - languageName: node - linkType: hard - -"socks@npm:^2.6.2": - version: 2.7.1 - resolution: "socks@npm:2.7.1" - dependencies: - ip: ^2.0.0 - smart-buffer: ^4.2.0 - checksum: 259d9e3e8e1c9809a7f5c32238c3d4d2a36b39b83851d0f573bfde5f21c4b1288417ce1af06af1452569cd1eb0841169afd4998f0e04ba04656f6b7f0e46d748 - languageName: node - linkType: hard - -"source-map-support@npm:^0.5.6": - version: 0.5.21 - resolution: "source-map-support@npm:0.5.21" - dependencies: - buffer-from: ^1.0.0 - source-map: ^0.6.0 - checksum: 43e98d700d79af1d36f859bdb7318e601dfc918c7ba2e98456118ebc4c4872b327773e5a1df09b0524e9e5063bb18f0934538eace60cca2710d1fa687645d137 - languageName: node - linkType: hard - -"source-map@npm:^0.6.0": - version: 0.6.1 - resolution: "source-map@npm:0.6.1" - checksum: 59ce8640cf3f3124f64ac289012c2b8bd377c238e316fb323ea22fbfe83da07d81e000071d7242cad7a23cd91c7de98e4df8830ec3f133cb6133a5f6e9f67bc2 - languageName: node - linkType: hard - -"ssri@npm:^10.0.0": - version: 10.0.4 - resolution: "ssri@npm:10.0.4" - dependencies: - minipass: ^5.0.0 - checksum: fb14da9f8a72b04eab163eb13a9dda11d5962cd2317f85457c4e0b575e9a6e0e3a6a87b5bf122c75cb36565830cd5f263fb457571bf6f1587eb5f95d095d6165 - languageName: node - linkType: hard - -"string-width-cjs@npm:string-width@^4.2.0, string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.1.0, string-width@npm:^4.2.0, string-width@npm:^4.2.3": - version: 4.2.3 - resolution: "string-width@npm:4.2.3" - dependencies: - emoji-regex: ^8.0.0 - is-fullwidth-code-point: ^3.0.0 - strip-ansi: ^6.0.1 - checksum: e52c10dc3fbfcd6c3a15f159f54a90024241d0f149cf8aed2982a2d801d2e64df0bf1dc351cf8e95c3319323f9f220c16e740b06faecd53e2462df1d2b5443fb - languageName: node - linkType: hard - -"string-width@npm:^5.0.1, string-width@npm:^5.1.2": - version: 5.1.2 - resolution: "string-width@npm:5.1.2" - dependencies: - eastasianwidth: ^0.2.0 - emoji-regex: ^9.2.2 - strip-ansi: ^7.0.1 - checksum: 7369deaa29f21dda9a438686154b62c2c5f661f8dda60449088f9f980196f7908fc39fdd1803e3e01541970287cf5deae336798337e9319a7055af89dafa7193 - languageName: node - linkType: hard - -"string_decoder@npm:^1.1.1": - version: 1.3.0 - resolution: "string_decoder@npm:1.3.0" - dependencies: - safe-buffer: ~5.2.0 - checksum: 8417646695a66e73aefc4420eb3b84cc9ffd89572861fe004e6aeb13c7bc00e2f616247505d2dbbef24247c372f70268f594af7126f43548565c68c117bdeb56 - languageName: node - linkType: hard - -"strip-ansi-cjs@npm:strip-ansi@^6.0.1, strip-ansi@npm:^6.0.0, strip-ansi@npm:^6.0.1": - version: 6.0.1 - resolution: "strip-ansi@npm:6.0.1" - dependencies: - ansi-regex: ^5.0.1 - checksum: f3cd25890aef3ba6e1a74e20896c21a46f482e93df4a06567cebf2b57edabb15133f1f94e57434e0a958d61186087b1008e89c94875d019910a213181a14fc8c - languageName: node - linkType: hard - -"strip-ansi@npm:^7.0.1": - version: 7.1.0 - resolution: "strip-ansi@npm:7.1.0" - dependencies: - ansi-regex: ^6.0.1 - checksum: 859c73fcf27869c22a4e4d8c6acfe690064659e84bef9458aa6d13719d09ca88dcfd40cbf31fd0be63518ea1a643fe070b4827d353e09533a5b0b9fd4553d64d - languageName: node - linkType: hard - -"strip-bom@npm:^3.0.0": - version: 3.0.0 - resolution: "strip-bom@npm:3.0.0" - checksum: 8d50ff27b7ebe5ecc78f1fe1e00fcdff7af014e73cf724b46fb81ef889eeb1015fc5184b64e81a2efe002180f3ba431bdd77e300da5c6685d702780fbf0c8d5b - languageName: node - linkType: hard - -"strip-json-comments@npm:3.1.1": - version: 3.1.1 - resolution: "strip-json-comments@npm:3.1.1" - checksum: 492f73e27268f9b1c122733f28ecb0e7e8d8a531a6662efbd08e22cccb3f9475e90a1b82cab06a392f6afae6d2de636f977e231296400d0ec5304ba70f166443 - languageName: node - linkType: hard - -"superstruct@npm:^0.14.2": - version: 0.14.2 - resolution: "superstruct@npm:0.14.2" - checksum: c5c4840f432da82125b923ec45faca5113217e83ae416e314d80eae012b8bb603d2e745025d173450758d116348820bc7028157f8c9a72b6beae879f94b837c0 - languageName: node - linkType: hard - -"superstruct@npm:^0.15.4": - version: 0.15.5 - resolution: "superstruct@npm:0.15.5" - checksum: 6d1f5249fee789424b7178fa0a1ffb2ace629c5480c39505885bd8c0046a4ff8b267569a3442fa53b8c560a7ba6599cf3f8af94225aebeb2cf6023f7dd911050 - languageName: node - linkType: hard - -"supports-color@npm:8.1.1": - version: 8.1.1 - resolution: "supports-color@npm:8.1.1" - dependencies: - has-flag: ^4.0.0 - checksum: c052193a7e43c6cdc741eb7f378df605636e01ad434badf7324f17fb60c69a880d8d8fcdcb562cf94c2350e57b937d7425ab5b8326c67c2adc48f7c87c1db406 - languageName: node - linkType: hard - -"supports-color@npm:^7.1.0": - version: 7.2.0 - resolution: "supports-color@npm:7.2.0" - dependencies: - has-flag: ^4.0.0 - checksum: 3dda818de06ebbe5b9653e07842d9479f3555ebc77e9a0280caf5a14fb877ffee9ed57007c3b78f5a6324b8dbeec648d9e97a24e2ed9fdb81ddc69ea07100f4a - languageName: node - linkType: hard - -"tar@npm:^6.1.11, tar@npm:^6.1.2": - version: 6.1.15 - resolution: "tar@npm:6.1.15" - dependencies: - chownr: ^2.0.0 - fs-minipass: ^2.0.0 - minipass: ^5.0.0 - minizlib: ^2.1.1 - mkdirp: ^1.0.3 - yallist: ^4.0.0 - checksum: f23832fceeba7578bf31907aac744ae21e74a66f4a17a9e94507acf460e48f6db598c7023882db33bab75b80e027c21f276d405e4a0322d58f51c7088d428268 - languageName: node - linkType: hard - -"text-encoding-utf-8@npm:^1.0.2": - version: 1.0.2 - resolution: "text-encoding-utf-8@npm:1.0.2" - checksum: ec4c15d50e738c5dba7327ad432ebf0725ec75d4d69c0bd55609254c5a3bc5341272d7003691084a0a73d60d981c8eb0e87603676fdb6f3fed60f4c9192309f9 - languageName: node - linkType: hard - -"through@npm:>=2.2.7 <3": - version: 2.3.8 - resolution: "through@npm:2.3.8" - checksum: a38c3e059853c494af95d50c072b83f8b676a9ba2818dcc5b108ef252230735c54e0185437618596c790bbba8fcdaef5b290405981ffa09dce67b1f1bf190cbd - languageName: node - linkType: hard - -"to-regex-range@npm:^5.0.1": - version: 5.0.1 - resolution: "to-regex-range@npm:5.0.1" - dependencies: - is-number: ^7.0.0 - checksum: f76fa01b3d5be85db6a2a143e24df9f60dd047d151062d0ba3df62953f2f697b16fe5dad9b0ac6191c7efc7b1d9dcaa4b768174b7b29da89d4428e64bc0a20ed - languageName: node - linkType: hard - -"toml@npm:^3.0.0": - version: 3.0.0 - resolution: "toml@npm:3.0.0" - checksum: 5d7f1d8413ad7780e9bdecce8ea4c3f5130dd53b0a4f2e90b93340979a137739879d7b9ce2ce05c938b8cc828897fe9e95085197342a1377dd8850bf5125f15f - languageName: node - linkType: hard - -"tr46@npm:~0.0.3": - version: 0.0.3 - resolution: "tr46@npm:0.0.3" - checksum: 726321c5eaf41b5002e17ffbd1fb7245999a073e8979085dacd47c4b4e8068ff5777142fc6726d6ca1fd2ff16921b48788b87225cbc57c72636f6efa8efbffe3 - languageName: node - linkType: hard - -"ts-mocha@npm:^10.0.0": - version: 10.0.0 - resolution: "ts-mocha@npm:10.0.0" - dependencies: - ts-node: 7.0.1 - tsconfig-paths: ^3.5.0 - peerDependencies: - mocha: ^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X - dependenciesMeta: - tsconfig-paths: - optional: true - bin: - ts-mocha: bin/ts-mocha - checksum: b11f2a8ceecf195b0db724da429159982fef12e4357088fe900289223587217e8c126ead7929679edd58bf19ad96c5da5911535d26f535386632e18fbff10c40 - languageName: node - linkType: hard - -"ts-node@npm:7.0.1": - version: 7.0.1 - resolution: "ts-node@npm:7.0.1" - dependencies: - arrify: ^1.0.0 - buffer-from: ^1.1.0 - diff: ^3.1.0 - make-error: ^1.1.1 - minimist: ^1.2.0 - mkdirp: ^0.5.1 - source-map-support: ^0.5.6 - yn: ^2.0.0 - bin: - ts-node: dist/bin.js - checksum: 07ed6ea1805361828737a767cfd6c57ea6e267ee8679282afb933610af02405e1a87c1f2aea1d38ed8e66b34fcbf6272b6021ab95d78849105d2e57fc283870b - languageName: node - linkType: hard - -"tsconfig-paths@npm:^3.5.0": - version: 3.14.2 - resolution: "tsconfig-paths@npm:3.14.2" - dependencies: - "@types/json5": ^0.0.29 - json5: ^1.0.2 - minimist: ^1.2.6 - strip-bom: ^3.0.0 - checksum: a6162eaa1aed680537f93621b82399c7856afd10ec299867b13a0675e981acac4e0ec00896860480efc59fc10fd0b16fdc928c0b885865b52be62cadac692447 - languageName: node - linkType: hard - -"tslib@npm:^2.0.3": - version: 2.6.1 - resolution: "tslib@npm:2.6.1" - checksum: b0d176d176487905b66ae4d5856647df50e37beea7571c53b8d10ba9222c074b81f1410fb91da13debaf2cbc970663609068bdebafa844ea9d69b146527c38fe - languageName: node - linkType: hard - -"type-detect@npm:^4.0.0, type-detect@npm:^4.0.5": - version: 4.0.8 - resolution: "type-detect@npm:4.0.8" - checksum: 62b5628bff67c0eb0b66afa371bd73e230399a8d2ad30d852716efcc4656a7516904570cd8631a49a3ce57c10225adf5d0cbdcb47f6b0255fe6557c453925a15 - languageName: node - linkType: hard - -"typescript@npm:^4.3.5": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db - languageName: node - linkType: hard - -"typescript@patch:typescript@^4.3.5#~builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=289587" - bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 1f8f3b6aaea19f0f67cba79057674ba580438a7db55057eb89cc06950483c5d632115c14077f6663ea76fd09fce3c190e6414bb98582ec80aa5a4eaf345d5b68 - languageName: node - linkType: hard - -"unique-filename@npm:^3.0.0": - version: 3.0.0 - resolution: "unique-filename@npm:3.0.0" - dependencies: - unique-slug: ^4.0.0 - checksum: 8e2f59b356cb2e54aab14ff98a51ac6c45781d15ceaab6d4f1c2228b780193dc70fae4463ce9e1df4479cb9d3304d7c2043a3fb905bdeca71cc7e8ce27e063df - languageName: node - linkType: hard - -"unique-slug@npm:^4.0.0": - version: 4.0.0 - resolution: "unique-slug@npm:4.0.0" - dependencies: - imurmurhash: ^0.1.4 - checksum: 0884b58365af59f89739e6f71e3feacb5b1b41f2df2d842d0757933620e6de08eff347d27e9d499b43c40476cbaf7988638d3acb2ffbcb9d35fd035591adfd15 - languageName: node - linkType: hard - -"utf-8-validate@npm:^5.0.2": - version: 5.0.10 - resolution: "utf-8-validate@npm:5.0.10" - dependencies: - node-gyp: latest - node-gyp-build: ^4.3.0 - checksum: 5579350a023c66a2326752b6c8804cc7b39dcd251bb088241da38db994b8d78352e388dcc24ad398ab98385ba3c5ffcadb6b5b14b2637e43f767869055e46ba6 - languageName: node - linkType: hard - -"util-deprecate@npm:^1.0.1": - version: 1.0.2 - resolution: "util-deprecate@npm:1.0.2" - checksum: 474acf1146cb2701fe3b074892217553dfcf9a031280919ba1b8d651a068c9b15d863b7303cb15bd00a862b498e6cf4ad7b4a08fb134edd5a6f7641681cb54a2 - languageName: node - linkType: hard - -"uuid@npm:^8.3.2": - version: 8.3.2 - resolution: "uuid@npm:8.3.2" - bin: - uuid: dist/bin/uuid - checksum: 5575a8a75c13120e2f10e6ddc801b2c7ed7d8f3c8ac22c7ed0c7b2ba6383ec0abda88c905085d630e251719e0777045ae3236f04c812184b7c765f63a70e58df - languageName: node - linkType: hard - -"webidl-conversions@npm:^3.0.0": - version: 3.0.1 - resolution: "webidl-conversions@npm:3.0.1" - checksum: c92a0a6ab95314bde9c32e1d0a6dfac83b578f8fa5f21e675bc2706ed6981bc26b7eb7e6a1fab158e5ce4adf9caa4a0aee49a52505d4d13c7be545f15021b17c - languageName: node - linkType: hard - -"whatwg-url@npm:^5.0.0": - version: 5.0.0 - resolution: "whatwg-url@npm:5.0.0" - dependencies: - tr46: ~0.0.3 - webidl-conversions: ^3.0.0 - checksum: b8daed4ad3356cc4899048a15b2c143a9aed0dfae1f611ebd55073310c7b910f522ad75d727346ad64203d7e6c79ef25eafd465f4d12775ca44b90fa82ed9e2c - languageName: node - linkType: hard - -"which@npm:2.0.2, which@npm:^2.0.1, which@npm:^2.0.2": - version: 2.0.2 - resolution: "which@npm:2.0.2" - dependencies: - isexe: ^2.0.0 - bin: - node-which: ./bin/node-which - checksum: 1a5c563d3c1b52d5f893c8b61afe11abc3bab4afac492e8da5bde69d550de701cf9806235f20a47b5c8fa8a1d6a9135841de2596535e998027a54589000e66d1 - languageName: node - linkType: hard - -"wide-align@npm:^1.1.5": - version: 1.1.5 - resolution: "wide-align@npm:1.1.5" - dependencies: - string-width: ^1.0.2 || 2 || 3 || 4 - checksum: d5fc37cd561f9daee3c80e03b92ed3e84d80dde3365a8767263d03dacfc8fa06b065ffe1df00d8c2a09f731482fcacae745abfbb478d4af36d0a891fad4834d3 - languageName: node - linkType: hard - -"workerpool@npm:6.2.0": - version: 6.2.0 - resolution: "workerpool@npm:6.2.0" - checksum: 3493b4f0ef979a23d2c1583d7ef85f62fc9463cc02f82829d3e7e663b517f8ae9707da0249b382e46ac58986deb0ca2232ee1081713741211bda9254b429c9bb - languageName: node - linkType: hard - -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0, wrap-ansi@npm:^7.0.0": - version: 7.0.0 - resolution: "wrap-ansi@npm:7.0.0" - dependencies: - ansi-styles: ^4.0.0 - string-width: ^4.1.0 - strip-ansi: ^6.0.0 - checksum: a790b846fd4505de962ba728a21aaeda189b8ee1c7568ca5e817d85930e06ef8d1689d49dbf0e881e8ef84436af3a88bc49115c2e2788d841ff1b8b5b51a608b - languageName: node - linkType: hard - -"wrap-ansi@npm:^8.1.0": - version: 8.1.0 - resolution: "wrap-ansi@npm:8.1.0" - dependencies: - ansi-styles: ^6.1.0 - string-width: ^5.0.1 - strip-ansi: ^7.0.1 - checksum: 371733296dc2d616900ce15a0049dca0ef67597d6394c57347ba334393599e800bab03c41d4d45221b6bc967b8c453ec3ae4749eff3894202d16800fdfe0e238 - languageName: node - linkType: hard - -"wrappy@npm:1": - version: 1.0.2 - resolution: "wrappy@npm:1.0.2" - checksum: 159da4805f7e84a3d003d8841557196034155008f817172d4e986bd591f74aa82aa7db55929a54222309e01079a65a92a9e6414da5a6aa4b01ee44a511ac3ee5 - languageName: node - linkType: hard - -"ws@npm:^7.4.5": - version: 7.5.9 - resolution: "ws@npm:7.5.9" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: c3c100a181b731f40b7f2fddf004aa023f79d64f489706a28bc23ff88e87f6a64b3c6651fbec3a84a53960b75159574d7a7385709847a62ddb7ad6af76f49138 - languageName: node - linkType: hard - -"ws@npm:^8.5.0": - version: 8.13.0 - resolution: "ws@npm:8.13.0" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 53e991bbf928faf5dc6efac9b8eb9ab6497c69feeb94f963d648b7a3530a720b19ec2e0ec037344257e05a4f35bd9ad04d9de6f289615ffb133282031b18c61c - languageName: node - linkType: hard - -"y18n@npm:^5.0.5": - version: 5.0.8 - resolution: "y18n@npm:5.0.8" - checksum: 54f0fb95621ee60898a38c572c515659e51cc9d9f787fb109cef6fde4befbe1c4602dc999d30110feee37456ad0f1660fa2edcfde6a9a740f86a290999550d30 - languageName: node - linkType: hard - -"yallist@npm:^4.0.0": - version: 4.0.0 - resolution: "yallist@npm:4.0.0" - checksum: 343617202af32df2a15a3be36a5a8c0c8545208f3d3dfbc6bb7c3e3b7e8c6f8e7485432e4f3b88da3031a6e20afa7c711eded32ddfb122896ac5d914e75848d5 - languageName: node - linkType: hard - -"yargs-parser@npm:20.2.4": - version: 20.2.4 - resolution: "yargs-parser@npm:20.2.4" - checksum: d251998a374b2743a20271c2fd752b9fbef24eb881d53a3b99a7caa5e8227fcafd9abf1f345ac5de46435821be25ec12189a11030c12ee6481fef6863ed8b924 - languageName: node - linkType: hard - -"yargs-parser@npm:^20.2.2": - version: 20.2.9 - resolution: "yargs-parser@npm:20.2.9" - checksum: 8bb69015f2b0ff9e17b2c8e6bfe224ab463dd00ca211eece72a4cd8a906224d2703fb8a326d36fdd0e68701e201b2a60ed7cf81ce0fd9b3799f9fe7745977ae3 - languageName: node - linkType: hard - -"yargs-unparser@npm:2.0.0": - version: 2.0.0 - resolution: "yargs-unparser@npm:2.0.0" - dependencies: - camelcase: ^6.0.0 - decamelize: ^4.0.0 - flat: ^5.0.2 - is-plain-obj: ^2.1.0 - checksum: 68f9a542c6927c3768c2f16c28f71b19008710abd6b8f8efbac6dcce26bbb68ab6503bed1d5994bdbc2df9a5c87c161110c1dfe04c6a3fe5c6ad1b0e15d9a8a3 - languageName: node - linkType: hard - -"yargs@npm:16.2.0": - version: 16.2.0 - resolution: "yargs@npm:16.2.0" - dependencies: - cliui: ^7.0.2 - escalade: ^3.1.1 - get-caller-file: ^2.0.5 - require-directory: ^2.1.1 - string-width: ^4.2.0 - y18n: ^5.0.5 - yargs-parser: ^20.2.2 - checksum: b14afbb51e3251a204d81937c86a7e9d4bdbf9a2bcee38226c900d00f522969ab675703bee2a6f99f8e20103f608382936034e64d921b74df82b63c07c5e8f59 - languageName: node - linkType: hard - -"yn@npm:^2.0.0": - version: 2.0.0 - resolution: "yn@npm:2.0.0" - checksum: 9d49527cb3e9a0948cc057223810bf30607bf04b9ff7666cc1681a6501d660b60d90000c16f9e29311b0f28d8a06222ada565ccdca5f1049cdfefb1908217572 - languageName: node - linkType: hard - -"yocto-queue@npm:^0.1.0": - version: 0.1.0 - resolution: "yocto-queue@npm:0.1.0" - checksum: f77b3d8d00310def622123df93d4ee654fc6a0096182af8bd60679ddcdfb3474c56c6c7190817c84a2785648cdee9d721c0154eb45698c62176c322fb46fc700 - languageName: node - linkType: hard From 290a22a0843cb9164e39ed7f4c023cb9084edc18 Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Tue, 1 Aug 2023 19:10:48 -0500 Subject: [PATCH 044/205] solana: wormhole-gatway tests in progress --- cross-chain/solana/.gitignore | 3 +- cross-chain/solana/.yarnrc.yml | 1 - cross-chain/solana/Anchor.toml | 70 ++++++++++- cross-chain/solana/Makefile | 26 ++++ cross-chain/solana/package-lock.json | 3 +- cross-chain/solana/programs/tbtc/Cargo.toml | 4 +- .../src/processor/deposit_wormhole_tbtc.rs | 6 +- .../src/processor/initialize.rs | 8 +- cross-chain/solana/tests/01__tbtc.ts | 24 ++-- .../solana/tests/02__wormholeGateway.ts | 116 ++++++++++++++++++ .../solana/tests/accounts/core_bridge.json | 13 ++ .../tests/accounts/core_emitter_sequence.json | 13 ++ .../tests/accounts/core_fee_collector.json | 13 ++ .../tests/accounts/core_guardian_set.json | 13 ++ .../tests/accounts/ethereum_token_bridge.json | 13 ++ .../tests/accounts/token_bridge_config.json | 13 ++ .../tests/accounts/wrapped_tbtc_asset.json | 13 ++ .../tests/accounts/wrapped_tbtc_mint.json | 13 ++ cross-chain/solana/tests/helpers/utils.ts | 53 ++++++++ 19 files changed, 395 insertions(+), 23 deletions(-) delete mode 100644 cross-chain/solana/.yarnrc.yml create mode 100644 cross-chain/solana/Makefile create mode 100644 cross-chain/solana/tests/02__wormholeGateway.ts create mode 100644 cross-chain/solana/tests/accounts/core_bridge.json create mode 100644 cross-chain/solana/tests/accounts/core_emitter_sequence.json create mode 100644 cross-chain/solana/tests/accounts/core_fee_collector.json create mode 100644 cross-chain/solana/tests/accounts/core_guardian_set.json create mode 100644 cross-chain/solana/tests/accounts/ethereum_token_bridge.json create mode 100644 cross-chain/solana/tests/accounts/token_bridge_config.json create mode 100644 cross-chain/solana/tests/accounts/wrapped_tbtc_asset.json create mode 100644 cross-chain/solana/tests/accounts/wrapped_tbtc_mint.json create mode 100644 cross-chain/solana/tests/helpers/utils.ts diff --git a/cross-chain/solana/.gitignore b/cross-chain/solana/.gitignore index 8d401163f..3db15d86f 100644 --- a/cross-chain/solana/.gitignore +++ b/cross-chain/solana/.gitignore @@ -5,4 +5,5 @@ target **/*.rs.bk node_modules test-ledger -.yarn +artifacts-mainnet +artifacts-testnet \ No newline at end of file diff --git a/cross-chain/solana/.yarnrc.yml b/cross-chain/solana/.yarnrc.yml deleted file mode 100644 index 3186f3f07..000000000 --- a/cross-chain/solana/.yarnrc.yml +++ /dev/null @@ -1 +0,0 @@ -nodeLinker: node-modules diff --git a/cross-chain/solana/Anchor.toml b/cross-chain/solana/Anchor.toml index 789ca54fd..6025a94f1 100644 --- a/cross-chain/solana/Anchor.toml +++ b/cross-chain/solana/Anchor.toml @@ -1,6 +1,14 @@ [features] seeds = false skip-lint = false + +[workspace] +members = [ + "programs/tbtc", + "programs/wormhole-gateway", +] + + [programs.localnet] tbtc = "HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG" wormhole-gateway = "8H9F5JGbEMyERycwaGuzLS5MQnV7dn2wm2h6egJ3Leiu" @@ -10,7 +18,65 @@ url = "https://api.apr.dev" [provider] cluster = "Localnet" -wallet = "/home/eth/.config/solana/id.json" +wallet = "~/.config/solana/id.json" [scripts] -test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" +test = "npx ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" + +[test] +startup_wait = 10000 + +[test.validator] +url = "https://api.mainnet-beta.solana.com" + +### MPL Token Metadata +[[test.validator.clone]] +address = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" + +### Wormhole Core Bridge +[[test.validator.clone]] +address = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth" + +### Wormhole Token Bridge +[[test.validator.clone]] +address = "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb" + +### Token Bridge -- Wrapped tBTC Mint +[[test.validator.account]] +address = "25rXTx9zDZcHyTav5sRqM6YBvTGu9pPH9yv83uAEqbgG" +filename = "tests/accounts/wrapped_tbtc_mint.json" + +### Token Bridge -- Wrapped tBTC Asset +[[test.validator.account]] +address = "5LEUZpBxUQmoxoNGqmYmFEGAPDuhWbAY5CGt519UixLo" +filename = "tests/accounts/wrapped_tbtc_asset.json" + +### Token Bridge -- Ethereum Foreign Endpoint +[[test.validator.account]] +address = "DujfLgMKW71CT2W8pxknf42FT86VbcK5PjQ6LsutjWKC" +filename = "tests/accounts/ethereum_token_bridge.json" + +### Token Bridge -- Config +[[test.validator.account]] +address = "DapiQYH3BGonhN8cngWcXQ6SrqSm3cwysoznoHr6Sbsx" +filename = "tests/accounts/token_bridge_config.json" + +### Core Bridge -- Bridge +[[test.validator.clone]] +address = "2yVjuQwpsvdsrywzsJJVs9Ueh4zayyo5DYJbBNc3DDpn" +filename = "tests/accounts/core_bridge.json" + +### Core Bridge -- Emitter Sequence (Token Bridge's) +[[test.validator.account]] +address = "GF2ghkjwsR9CHkGk1RvuZrApPZGBZynxMm817VNi51Nf" +filename = "tests/accounts/core_emitter_sequence.json" + +### Core Bridge -- Fee Collector +[[test.validator.account]] +address = "9bFNrXNb2WTx8fMHXCheaZqkLZ3YCCaiqTftHxeintHy" +filename = "tests/accounts/core_fee_collector.json" + +### Core Bridge -- Guardian Set (index == 3) +[[test.validator.account]] +address = "6d3w8mGjJauf6gCAg7WfLezbaPmUHYGuoNutnfYF1RYM" +filename = "tests/accounts/core_guardian_set.json" diff --git a/cross-chain/solana/Makefile b/cross-chain/solana/Makefile new file mode 100644 index 000000000..6fe96802c --- /dev/null +++ b/cross-chain/solana/Makefile @@ -0,0 +1,26 @@ + +out_solana-devnet=artifacts-testnet +out_mainnet=artifacts-mainnet + +.PHONY: all clean build test + +all: test + +clean: + anchor clean + rm -rf node_modules artifacts-mainnet artifacts-testnet + +node_modules: + npm ci + +build: $(out_$(NETWORK)) + +$(out_$(NETWORK)): +ifdef out_$(NETWORK) + anchor build --arch sbf -- --features "$(NETWORK)" -- --no-default-features + mkdir -p $(out_$(NETWORK)) + cp target/deploy/*.so $(out_$(NETWORK))/ +endif + +test: node_modules + anchor test --arch sbf diff --git a/cross-chain/solana/package-lock.json b/cross-chain/solana/package-lock.json index e0307d458..ddcd6cb2d 100644 --- a/cross-chain/solana/package-lock.json +++ b/cross-chain/solana/package-lock.json @@ -1861,8 +1861,9 @@ }, "node_modules/@solana/spl-token": { "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.3.8.tgz", + "integrity": "sha512-ogwGDcunP9Lkj+9CODOWMiVJEdRtqHAtX2rWF62KxnnSWtMZtV9rDhTrZFshiyJmxDnRL/1nKE1yJHg4jjs3gg==", "dev": true, - "license": "Apache-2.0", "dependencies": { "@solana/buffer-layout": "^4.0.0", "@solana/buffer-layout-utils": "^0.2.0", diff --git a/cross-chain/solana/programs/tbtc/Cargo.toml b/cross-chain/solana/programs/tbtc/Cargo.toml index 127bfb608..18e88c859 100644 --- a/cross-chain/solana/programs/tbtc/Cargo.toml +++ b/cross-chain/solana/programs/tbtc/Cargo.toml @@ -9,11 +9,13 @@ crate-type = ["cdylib", "lib"] name = "tbtc" [features] +default = [] +mainnet = [] +solana-devnet = [] no-entrypoint = [] no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] -default = [] [dependencies] anchor-lang = { version = "=0.28.0", features = ["derive", "init-if-needed"] } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs index c36fb3e93..28ccdc59a 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs @@ -84,6 +84,8 @@ pub fn deposit_wormhole_tbtc(ctx: Context, amount: u64) -> amount, )?; + let custodian = &ctx.accounts.custodian; + // Now mint. tbtc::cpi::mint( CpiContext::new_with_signer( @@ -92,11 +94,11 @@ pub fn deposit_wormhole_tbtc(ctx: Context, amount: u64) -> mint: ctx.accounts.tbtc_mint.to_account_info(), config: ctx.accounts.tbtc_config.to_account_info(), minter_info: ctx.accounts.minter_info.to_account_info(), - minter: ctx.accounts.custodian.to_account_info(), + minter: custodian.to_account_info(), recipient_token: ctx.accounts.recipient_token.to_account_info(), token_program: ctx.accounts.token_program.to_account_info(), }, - &[&[Custodian::SEED_PREFIX, &[ctx.bumps["custodian"]]]], + &[&[Custodian::SEED_PREFIX, &[custodian.bump]]], ), amount, ) diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs index c26b191d2..f73831546 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs @@ -7,15 +7,15 @@ const TBTC_FOREIGN_TOKEN_CHAIN: u8 = 2; #[cfg(feature = "mainnet")] const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8d, 0xae, 0xba, 0xde, 0x92, 0x2d, - 0xf7, 0x35, 0xc3, 0x8c, 0x80, 0xc7, 0xeb, 0xd7, 0x08, 0xaf, 0x50, 0x81, 0x5f, 0xaa, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x08, 0x4f, 0xbA, 0x66, 0x6a, + 0x33, 0xd3, 0x75, 0x92, 0xfA, 0x26, 0x33, 0xfD, 0x49, 0xa7, 0x4D, 0xD9, 0x3a, 0x88, ]; /// TODO: Fix this to reflect testnet contract address. #[cfg(feature = "solana-devnet")] const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8d, 0xae, 0xba, 0xde, 0x92, 0x2d, - 0xf7, 0x35, 0xc3, 0x8c, 0x80, 0xc7, 0xeb, 0xd7, 0x08, 0xaf, 0x50, 0x81, 0x5f, 0xaa, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x08, 0x4f, 0xbA, 0x66, 0x6a, + 0x33, 0xd3, 0x75, 0x92, 0xfA, 0x26, 0x33, 0xfD, 0x49, 0xa7, 0x4D, 0xD9, 0x3a, 0x88, ]; #[derive(Accounts)] diff --git a/cross-chain/solana/tests/01__tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts index f69c0a820..0a70e3d93 100644 --- a/cross-chain/solana/tests/01__tbtc.ts +++ b/cross-chain/solana/tests/01__tbtc.ts @@ -5,6 +5,7 @@ import * as web3 from '@solana/web3.js'; import { Tbtc } from "../target/types/tbtc"; import { expect } from 'chai'; import { ASSOCIATED_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; +import { transferLamports } from "./helpers/utils"; function maybeAuthorityAnd( signer, @@ -446,17 +447,18 @@ describe("tbtc", () => { await checkState(program, authority, 1, 0, 0); // Transfer lamports to imposter. - await web3.sendAndConfirmTransaction( - program.provider.connection, - new web3.Transaction().add( - web3.SystemProgram.transfer({ - fromPubkey: authority.publicKey, - toPubkey: impostorKeys.publicKey, - lamports: 1000000000, - }) - ), - [authority.payer] - ); + await transferLamports(program.provider.connection, authority.payer, impostorKeys.publicKey, 1000000000); + // await web3.sendAndConfirmTransaction( + // program.provider.connection, + // new web3.Transaction().add( + // web3.SystemProgram.transfer({ + // fromPubkey: authority.publicKey, + // toPubkey: impostorKeys.publicKey, + // lamports: 1000000000, + // }) + // ), + // [authority.payer] + // ); try { await addMinter(program, impostorKeys, minter2Keys, authority); diff --git a/cross-chain/solana/tests/02__wormholeGateway.ts b/cross-chain/solana/tests/02__wormholeGateway.ts new file mode 100644 index 000000000..69eb14fe3 --- /dev/null +++ b/cross-chain/solana/tests/02__wormholeGateway.ts @@ -0,0 +1,116 @@ +import * as mock from "@certusone/wormhole-sdk/lib/cjs/mock"; +import * as tokenBridge from "@certusone/wormhole-sdk/lib/cjs/solana/tokenBridge"; +import * as coreBridge from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole"; +import { NodeWallet } from "@certusone/wormhole-sdk/lib/cjs/solana"; +import { parseTokenTransferVaa, postVaaSolana, redeemOnSolana, tryNativeToHexString } from "@certusone/wormhole-sdk"; +import * as anchor from "@coral-xyz/anchor"; +import { Program } from "@coral-xyz/anchor"; +import * as spl from "@solana/spl-token"; +import { expect } from 'chai'; +import { WormholeGateway } from "../target/types/wormhole_gateway"; +import { generatePayer, getOrCreateTokenAccount } from "./helpers/utils"; +import { web3 } from "@coral-xyz/anchor"; + +const SOLANA_CORE_BRIDGE_ADDRESS = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"; +const SOLANA_TOKEN_BRIDGE_ADDRESS = "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb"; +const ETHEREUM_TOKEN_BRIDGE_ADDRESS = "0x3ee18B2214AFF97000D974cf647E7C347E8fa585"; +const ETHEREUM_TBTC_ADDRESS = "0x18084fbA666a33d37592fA2633fD49a74DD93a88"; + +const GUARDIAN_SET_INDEX = 3; + +function getCustodianPDA( + program: Program, +): [anchor.web3.PublicKey, number] { + return web3.PublicKey.findProgramAddressSync( + [ + Buffer.from('custodian'), + ], + program.programId + ); +} + + +describe("wormhole-gateway", () => { + // Configure the client to use the local cluster. + anchor.setProvider(anchor.AnchorProvider.env()); + + const program = anchor.workspace.WormholeGateway as Program; + const connection = program.provider.connection; + + const authority = (program.provider as anchor.AnchorProvider).wallet as anchor.Wallet; + const newAuthority = anchor.web3.Keypair.generate(); + const minterKeys = anchor.web3.Keypair.generate(); + const minter2Keys = anchor.web3.Keypair.generate(); + const impostorKeys = anchor.web3.Keypair.generate(); + const guardianKeys = anchor.web3.Keypair.generate(); + const guardian2Keys = anchor.web3.Keypair.generate(); + + const recipientKeys = anchor.web3.Keypair.generate(); + + const ethereumTokenBridge = new mock.MockEthereumTokenBridge(ETHEREUM_TOKEN_BRIDGE_ADDRESS); + + it('check core bridge and token bridge', async () => { + // Check core bridge guardian set. + const guardianSetData = await coreBridge.getGuardianSet(connection, SOLANA_CORE_BRIDGE_ADDRESS, GUARDIAN_SET_INDEX); + expect(guardianSetData.keys).has.length(1); + + // Set up new wallet + const payer = await generatePayer(connection, authority.payer); + + // Check wrapped tBTC mint. + const wrappedTbtcMint = tokenBridge.deriveWrappedMintKey(SOLANA_TOKEN_BRIDGE_ADDRESS, 2, ETHEREUM_TBTC_ADDRESS); + const mintData = await spl.getMint(connection, wrappedTbtcMint); + expect(mintData.decimals).to.equal(8); + expect(mintData.supply).to.equal(BigInt(90)); + + const wrappedTbtcToken = await getOrCreateTokenAccount(connection, payer, wrappedTbtcMint, payer.publicKey); + + // Bridge tbtc to token account. + const published = ethereumTokenBridge.publishTransferTokens( + tryNativeToHexString(ETHEREUM_TBTC_ADDRESS, "ethereum"), + 2, + BigInt("100000000000"), + 1, + wrappedTbtcToken.address.toBuffer().toString("hex"), + BigInt(0), + 0, + 0 + ); + + const signedVaa = await mockSignAndPostVaa(connection, payer, published); + + const tx = await redeemOnSolana( + connection, + SOLANA_CORE_BRIDGE_ADDRESS, + SOLANA_TOKEN_BRIDGE_ADDRESS, + payer.publicKey, + signedVaa, + ); + await web3.sendAndConfirmTransaction(connection, tx, [payer]); + }); + + it('setup', async () => { + // await setup(program, authority); + // await checkState(program, authority, 0, 0, 0); + }); +}); + +async function mockSignAndPostVaa(connection: web3.Connection, payer: web3.Keypair, published: Buffer) { + const guardians = new mock.MockGuardians( + GUARDIAN_SET_INDEX, + ["cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0"] + ); + + // Add guardian signature. + const signedVaa = guardians.addSignatures(published, [0]); + + // Verify and post VAA. + await postVaaSolana(connection, + new NodeWallet(payer).signTransaction, + SOLANA_CORE_BRIDGE_ADDRESS, + payer.publicKey, + signedVaa + ); + + return signedVaa; +} diff --git a/cross-chain/solana/tests/accounts/core_bridge.json b/cross-chain/solana/tests/accounts/core_bridge.json new file mode 100644 index 000000000..5c14d521c --- /dev/null +++ b/cross-chain/solana/tests/accounts/core_bridge.json @@ -0,0 +1,13 @@ +{ + "pubkey": "2yVjuQwpsvdsrywzsJJVs9Ueh4zayyo5DYJbBNc3DDpn", + "account": { + "lamports": 1057920, + "data": [ + "AwAAAPhmKAUAAAAAgFEBAGQAAAAAAAAA", + "base64" + ], + "owner": "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth", + "executable": false, + "rentEpoch": 361 + } +} \ No newline at end of file diff --git a/cross-chain/solana/tests/accounts/core_emitter_sequence.json b/cross-chain/solana/tests/accounts/core_emitter_sequence.json new file mode 100644 index 000000000..966d215e5 --- /dev/null +++ b/cross-chain/solana/tests/accounts/core_emitter_sequence.json @@ -0,0 +1,13 @@ +{ + "pubkey": "GF2ghkjwsR9CHkGk1RvuZrApPZGBZynxMm817VNi51Nf", + "account": { + "lamports": 946560, + "data": [ + "4KMEAAAAAAA=", + "base64" + ], + "owner": "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth", + "executable": false, + "rentEpoch": 361 + } +} \ No newline at end of file diff --git a/cross-chain/solana/tests/accounts/core_fee_collector.json b/cross-chain/solana/tests/accounts/core_fee_collector.json new file mode 100644 index 000000000..6f355d442 --- /dev/null +++ b/cross-chain/solana/tests/accounts/core_fee_collector.json @@ -0,0 +1,13 @@ +{ + "pubkey": "9bFNrXNb2WTx8fMHXCheaZqkLZ3YCCaiqTftHxeintHy", + "account": { + "lamports": 86533780, + "data": [ + "", + "base64" + ], + "owner": "11111111111111111111111111111111", + "executable": false, + "rentEpoch": 361 + } +} \ No newline at end of file diff --git a/cross-chain/solana/tests/accounts/core_guardian_set.json b/cross-chain/solana/tests/accounts/core_guardian_set.json new file mode 100644 index 000000000..d503f9049 --- /dev/null +++ b/cross-chain/solana/tests/accounts/core_guardian_set.json @@ -0,0 +1,13 @@ +{ + "pubkey": "6d3w8mGjJauf6gCAg7WfLezbaPmUHYGuoNutnfYF1RYM", + "account": { + "lamports": 3647040, + "data": [ + "AwAAAAEAAAC++kKdV80Yt/ik2RotqatK8F0PvgAAAAAAAAAA", + "base64" + ], + "owner": "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth", + "executable": false, + "rentEpoch": 0 + } +} \ No newline at end of file diff --git a/cross-chain/solana/tests/accounts/ethereum_token_bridge.json b/cross-chain/solana/tests/accounts/ethereum_token_bridge.json new file mode 100644 index 000000000..e5c5ef3ad --- /dev/null +++ b/cross-chain/solana/tests/accounts/ethereum_token_bridge.json @@ -0,0 +1,13 @@ +{ + "pubkey": "DujfLgMKW71CT2W8pxknf42FT86VbcK5PjQ6LsutjWKC", + "account": { + "lamports": 1127520, + "data": [ + "AgAAAAAAAAAAAAAAAAA+4YsiFK/5cADZdM9kfnw0fo+lhQ==", + "base64" + ], + "owner": "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb", + "executable": false, + "rentEpoch": 361 + } +} \ No newline at end of file diff --git a/cross-chain/solana/tests/accounts/token_bridge_config.json b/cross-chain/solana/tests/accounts/token_bridge_config.json new file mode 100644 index 000000000..c4f8fb6c3 --- /dev/null +++ b/cross-chain/solana/tests/accounts/token_bridge_config.json @@ -0,0 +1,13 @@ +{ + "pubkey": "DapiQYH3BGonhN8cngWcXQ6SrqSm3cwysoznoHr6Sbsx", + "account": { + "lamports": 1113600, + "data": [ + "DgpYmkGlX71mxSpHXy2SptPcm0dHEUy5r4JamLVF084=", + "base64" + ], + "owner": "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb", + "executable": false, + "rentEpoch": 361 + } +} \ No newline at end of file diff --git a/cross-chain/solana/tests/accounts/wrapped_tbtc_asset.json b/cross-chain/solana/tests/accounts/wrapped_tbtc_asset.json new file mode 100644 index 000000000..423cf3610 --- /dev/null +++ b/cross-chain/solana/tests/accounts/wrapped_tbtc_asset.json @@ -0,0 +1,13 @@ +{ + "pubkey": "5LEUZpBxUQmoxoNGqmYmFEGAPDuhWbAY5CGt519UixLo", + "account": { + "lamports": 1134480, + "data": [ + "AgAAAAAAAAAAAAAAAAAYCE+6Zmoz03WS+iYz/UmnTdk6iBI=", + "base64" + ], + "owner": "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb", + "executable": false, + "rentEpoch": 0 + } +} \ No newline at end of file diff --git a/cross-chain/solana/tests/accounts/wrapped_tbtc_mint.json b/cross-chain/solana/tests/accounts/wrapped_tbtc_mint.json new file mode 100644 index 000000000..0dd211691 --- /dev/null +++ b/cross-chain/solana/tests/accounts/wrapped_tbtc_mint.json @@ -0,0 +1,13 @@ +{ + "pubkey": "25rXTx9zDZcHyTav5sRqM6YBvTGu9pPH9yv83uAEqbgG", + "account": { + "lamports": 1461600, + "data": [ + "AQAAAJdz8e+O65iVdMpxBFsTrA0MEUaiThB5GX5TF1UZTdCWWgAAAAAAAAAIAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", + "base64" + ], + "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", + "executable": false, + "rentEpoch": 0 + } +} \ No newline at end of file diff --git a/cross-chain/solana/tests/helpers/utils.ts b/cross-chain/solana/tests/helpers/utils.ts new file mode 100644 index 000000000..b87a0a948 --- /dev/null +++ b/cross-chain/solana/tests/helpers/utils.ts @@ -0,0 +1,53 @@ +import { web3 } from "@coral-xyz/anchor"; +import { Account, TokenAccountNotFoundError, createAssociatedTokenAccountIdempotentInstruction, getAccount, getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { Connection, Keypair, PublicKey, SystemProgram, Transaction, sendAndConfirmTransaction } from "@solana/web3.js"; + +export async function transferLamports(connection: web3.Connection, fromSigner: web3.Keypair, toPubkey: web3.PublicKey, lamports: number) { + return sendAndConfirmTransaction( + connection, + new Transaction().add( + SystemProgram.transfer({ + fromPubkey: fromSigner.publicKey, + toPubkey, + lamports, + }) + ), + [fromSigner] + ); +} + +export async function generatePayer(connection: web3.Connection, payer: Keypair, lamports?: number) { + const newPayer = Keypair.generate(); + await transferLamports(connection, payer, newPayer.publicKey, lamports === undefined ? 1000000000 : lamports); + return newPayer; +} + +export async function getOrCreateTokenAccount(connection: Connection, payer: Keypair, mint: PublicKey, owner: PublicKey) { + const token = getAssociatedTokenAddressSync(mint, owner); + const tokenData: Account = await getAccount(connection, token).catch((err) => { + if (err instanceof TokenAccountNotFoundError) { + return null; + } else { + throw err; + }; + }); + + if (tokenData === null) { + await web3.sendAndConfirmTransaction( + connection, + new web3.Transaction().add( + createAssociatedTokenAccountIdempotentInstruction( + payer.publicKey, + token, + owner, + mint, + ) + ), + [payer] + ); + + return getAccount(connection, token); + } else { + return tokenData; + } +} \ No newline at end of file From b053b8807975052248f7a3c9514c7ea526e01e1a Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Wed, 2 Aug 2023 09:49:27 +0200 Subject: [PATCH 045/205] Update Wormhole docs link fr base env The link has changed for the docs, now it is https://docs.wormhole.com/wormhole/blockchain-environments/evm#base --- .../deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-chain/base/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts index dc13a978f..8d72defea 100644 --- a/cross-chain/base/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts +++ b/cross-chain/base/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts @@ -6,7 +6,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { execute } = deployments const { deployer } = await getNamedAccounts() - // See https://docs.wormhole.com/wormhole/reference/environments/evm#base + // See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base // This ID is valid for both Base Goerli and Base Mainnet const wormholeChainID = 30 From c6f66611b6184b5a296ec1e70119e884dbb7fea0 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Wed, 2 Aug 2023 10:27:02 +0200 Subject: [PATCH 046/205] Exclude base networks from gitignore We need OpenZeppelin artifacts to be able to upgrade contracts. --- cross-chain/base/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cross-chain/base/.gitignore b/cross-chain/base/.gitignore index e0803a259..656127c19 100644 --- a/cross-chain/base/.gitignore +++ b/cross-chain/base/.gitignore @@ -13,3 +13,5 @@ # OZ /.openzeppelin/unknown-*.json +!/.openzeppelin/unknown-84531.json +!/.openzeppelin/unknown-8453.json From a9fc83cb0d4f455ad5694305124d22c6f85b564e Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Wed, 2 Aug 2023 10:28:00 +0200 Subject: [PATCH 047/205] Add contract artifacts for Base Goerli We add artifacts for contracts deployed to Base Goerli network. --- .../base/.openzeppelin/unknown-84531.json | 483 ++++++++++ .../base/deployments/baseGoerli/.chainId | 1 + .../base/deployments/baseGoerli/BaseTBTC.json | 863 ++++++++++++++++++ .../baseGoerli/BaseWormholeGateway.json | 495 ++++++++++ 4 files changed, 1842 insertions(+) create mode 100644 cross-chain/base/.openzeppelin/unknown-84531.json create mode 100644 cross-chain/base/deployments/baseGoerli/.chainId create mode 100644 cross-chain/base/deployments/baseGoerli/BaseTBTC.json create mode 100644 cross-chain/base/deployments/baseGoerli/BaseWormholeGateway.json diff --git a/cross-chain/base/.openzeppelin/unknown-84531.json b/cross-chain/base/.openzeppelin/unknown-84531.json new file mode 100644 index 000000000..ab814cbd8 --- /dev/null +++ b/cross-chain/base/.openzeppelin/unknown-84531.json @@ -0,0 +1,483 @@ +{ + "manifestVersion": "3.2", + "admin": { + "address": "0x9A82bE743f0120fA24893b1631B6b2817fD94b1D", + "txHash": "0xfa81d2265608a60b4c26636f562e9adacae4691af012d1871760c1eaab3e55ca" + }, + "proxies": [ + { + "address": "0xc3D46e0266d95215589DE639cC4E93b79f88fc6C", + "txHash": "0x7578780825066533baff8d42077b3eda3707d9b55bb8e9580c08ce4d9de1b5ca", + "kind": "transparent" + }, + { + "address": "0x49a6572e06ae805Bb4D021Acb198f197aD900EDC", + "txHash": "0xf78e314eafbbf2dfd82c3395d7f9f548feb81677efcd8021b7b529ad0fce5120", + "kind": "transparent" + }, + { + "address": "0x5D8e618f44A59dd528cce58d00801F4C8e5cfa8D", + "txHash": "0x7590bcf780801c54832d17b06267e15321e61db054d1e6e5238481e8d27812cd", + "kind": "transparent" + }, + { + "address": "0x91Fe7128f74dBd4F031ea3D90FC5Ea4DCfD81818", + "txHash": "0xaae098e6b8a061c23c85c5f1211cf0ae9b956601d88c7dd7a1e7c9260fbe2a36", + "kind": "transparent" + }, + { + "address": "0x1a53759DE2eADf73bd0b05c07a4F1F5B7912dA3d", + "txHash": "0x473202d4fa7f4702dd53d43c53b07bbe518623c16d68dfa3b7da0f7e5f6b27ef", + "kind": "transparent" + }, + { + "address": "0x783349cd20f26CE12e747b1a17bC38D252c9e119", + "txHash": "0x6522223ef442bbfd30541e99efa3e29fddf0984156d755df1ea48ce26c972f77", + "kind": "transparent" + }, + { + "address": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343", + "txHash": "0x0e376095c9884ff5adbf641b23fe3bbba25f7f63e212406e1283b5dd0c81d65b", + "kind": "transparent" + } + ], + "impls": { + "1eca3b29684e1fcc811e32be6ee7e72cd846a93f69838508595506ae72555f18": { + "address": "0xb8f31A249bcb45267d06b9E51252c4793B917Cd0", + "txHash": "0x0ccfe4fd9d585e215879d0de3f488b85469d2822eac47736607e166f0d81e4b1", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_balances", + "offset": 0, + "slot": "51", + "type": "t_mapping(t_address,t_uint256)", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:37" + }, + { + "label": "_allowances", + "offset": 0, + "slot": "52", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:39" + }, + { + "label": "_totalSupply", + "offset": 0, + "slot": "53", + "type": "t_uint256", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:41" + }, + { + "label": "_name", + "offset": 0, + "slot": "54", + "type": "t_string_storage", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:43" + }, + { + "label": "_symbol", + "offset": 0, + "slot": "55", + "type": "t_string_storage", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:44" + }, + { + "label": "__gap", + "offset": 0, + "slot": "56", + "type": "t_array(t_uint256)45_storage", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:400" + }, + { + "label": "__gap", + "offset": 0, + "slot": "101", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC20BurnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol:51" + }, + { + "label": "_HASHED_NAME", + "offset": 0, + "slot": "151", + "type": "t_bytes32", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:32" + }, + { + "label": "_HASHED_VERSION", + "offset": 0, + "slot": "152", + "type": "t_bytes32", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:33" + }, + { + "label": "__gap", + "offset": 0, + "slot": "153", + "type": "t_array(t_uint256)50_storage", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:120" + }, + { + "label": "_nonces", + "offset": 0, + "slot": "203", + "type": "t_mapping(t_address,t_struct(Counter)3297_storage)", + "contract": "ERC20PermitUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol:28" + }, + { + "label": "_PERMIT_TYPEHASH_DEPRECATED_SLOT", + "offset": 0, + "slot": "204", + "type": "t_bytes32", + "contract": "ERC20PermitUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol:40", + "renamedFrom": "_PERMIT_TYPEHASH" + }, + { + "label": "__gap", + "offset": 0, + "slot": "205", + "type": "t_array(t_uint256)49_storage", + "contract": "ERC20PermitUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol:108" + }, + { + "label": "_owner", + "offset": 0, + "slot": "254", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "255", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_paused", + "offset": 0, + "slot": "304", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "305", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:116" + }, + { + "label": "isMinter", + "offset": 0, + "slot": "354", + "type": "t_mapping(t_address,t_bool)", + "contract": "L2TBTC", + "src": "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol:76" + }, + { + "label": "minters", + "offset": 0, + "slot": "355", + "type": "t_array(t_address)dyn_storage", + "contract": "L2TBTC", + "src": "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol:77" + }, + { + "label": "isGuardian", + "offset": 0, + "slot": "356", + "type": "t_mapping(t_address,t_bool)", + "contract": "L2TBTC", + "src": "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol:85" + }, + { + "label": "guardians", + "offset": 0, + "slot": "357", + "type": "t_array(t_address)dyn_storage", + "contract": "L2TBTC", + "src": "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol:89" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "label": "address[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)45_storage": { + "label": "uint256[45]", + "numberOfBytes": "1440" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_struct(Counter)3297_storage)": { + "label": "mapping(address => struct CountersUpgradeable.Counter)", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_uint256)": { + "label": "mapping(address => uint256)", + "numberOfBytes": "32" + }, + "t_string_storage": { + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(Counter)3297_storage": { + "label": "struct CountersUpgradeable.Counter", + "members": [ + { + "label": "_value", + "type": "t_uint256", + "offset": 0, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + }, + "70974f3ab30d1010f875de7eebcbde08a1b6c71845f5272c23be8f95af866a64": { + "address": "0xa07f4E37C2E7089Ea3AFffbe51A6A281833a4D14", + "txHash": "0xe73e558bfee8eb79b7e73a56fb0c52eb1cb9805ea77a7c7b2755e90c60ec400f", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_status", + "offset": 0, + "slot": "101", + "type": "t_uint256", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:80" + }, + { + "label": "bridge", + "offset": 0, + "slot": "151", + "type": "t_contract(IWormholeTokenBridge)518", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:122" + }, + { + "label": "bridgeToken", + "offset": 0, + "slot": "152", + "type": "t_contract(IERC20Upgradeable)2252", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:123" + }, + { + "label": "tbtc", + "offset": 0, + "slot": "153", + "type": "t_contract(L2TBTC)443", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:124" + }, + { + "label": "gateways", + "offset": 0, + "slot": "154", + "type": "t_mapping(t_uint16,t_bytes32)", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:136" + }, + { + "label": "mintingLimit", + "offset": 0, + "slot": "155", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:147" + }, + { + "label": "mintedAmount", + "offset": 0, + "slot": "156", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:151" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IERC20Upgradeable)2252": { + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IWormholeTokenBridge)518": { + "label": "contract IWormholeTokenBridge", + "numberOfBytes": "20" + }, + "t_contract(L2TBTC)443": { + "label": "contract L2TBTC", + "numberOfBytes": "20" + }, + "t_mapping(t_uint16,t_bytes32)": { + "label": "mapping(uint16 => bytes32)", + "numberOfBytes": "32" + }, + "t_uint16": { + "label": "uint16", + "numberOfBytes": "2" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + } + } +} diff --git a/cross-chain/base/deployments/baseGoerli/.chainId b/cross-chain/base/deployments/baseGoerli/.chainId new file mode 100644 index 000000000..9b24bf023 --- /dev/null +++ b/cross-chain/base/deployments/baseGoerli/.chainId @@ -0,0 +1 @@ +84531 \ No newline at end of file diff --git a/cross-chain/base/deployments/baseGoerli/BaseTBTC.json b/cross-chain/base/deployments/baseGoerli/BaseTBTC.json new file mode 100644 index 000000000..573cdb4de --- /dev/null +++ b/cross-chain/base/deployments/baseGoerli/BaseTBTC.json @@ -0,0 +1,863 @@ +{ + "address": "0x783349cd20f26CE12e747b1a17bC38D252c9e119", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "GuardianAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "GuardianRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "MinterAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "MinterRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "addGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "addMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getGuardians", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMinters", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "guardians", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isGuardian", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isMinter", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "minters", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721Upgradeable", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "recoverERC721", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "removeGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "removeMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x6522223ef442bbfd30541e99efa3e29fddf0984156d755df1ea48ce26c972f77", + "receipt": { + "to": null, + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0x783349cd20f26CE12e747b1a17bC38D252c9e119", + "transactionIndex": 1, + "gasUsed": "754031", + "logsBloom": "0x00000000000000000000000000000008400000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000202000001000000000000000000000000000000000000020000000000000100000800000000800000000000001000000000400000100200000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000020041000000008000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xe22997c905b0a8c22b3dc921e9a54b310cf71f718c8de71360e9dfd0c9046f91", + "transactionHash": "0x6522223ef442bbfd30541e99efa3e29fddf0984156d755df1ea48ce26c972f77", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 7884728, + "transactionHash": "0x6522223ef442bbfd30541e99efa3e29fddf0984156d755df1ea48ce26c972f77", + "address": "0x783349cd20f26CE12e747b1a17bC38D252c9e119", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000b8f31a249bcb45267d06b9e51252c4793b917cd0" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xe22997c905b0a8c22b3dc921e9a54b310cf71f718c8de71360e9dfd0c9046f91" + }, + { + "transactionIndex": 1, + "blockNumber": 7884728, + "transactionHash": "0x6522223ef442bbfd30541e99efa3e29fddf0984156d755df1ea48ce26c972f77", + "address": "0x783349cd20f26CE12e747b1a17bC38D252c9e119", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0xe22997c905b0a8c22b3dc921e9a54b310cf71f718c8de71360e9dfd0c9046f91" + }, + { + "transactionIndex": 1, + "blockNumber": 7884728, + "transactionHash": "0x6522223ef442bbfd30541e99efa3e29fddf0984156d755df1ea48ce26c972f77", + "address": "0x783349cd20f26CE12e747b1a17bC38D252c9e119", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 2, + "blockHash": "0xe22997c905b0a8c22b3dc921e9a54b310cf71f718c8de71360e9dfd0c9046f91" + }, + { + "transactionIndex": 1, + "blockNumber": 7884728, + "transactionHash": "0x6522223ef442bbfd30541e99efa3e29fddf0984156d755df1ea48ce26c972f77", + "address": "0x783349cd20f26CE12e747b1a17bC38D252c9e119", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009a82be743f0120fa24893b1631b6b2817fd94b1d", + "logIndex": 3, + "blockHash": "0xe22997c905b0a8c22b3dc921e9a54b310cf71f718c8de71360e9dfd0c9046f91" + } + ], + "blockNumber": 7884728, + "cumulativeGasUsed": "800908", + "status": 1, + "byzantium": true + }, + "numDeployments": 1, + "implementation": "0xb8f31A249bcb45267d06b9E51252c4793B917Cd0", + "devdoc": "Contract deployed as upgradable proxy" +} \ No newline at end of file diff --git a/cross-chain/base/deployments/baseGoerli/BaseWormholeGateway.json b/cross-chain/base/deployments/baseGoerli/BaseWormholeGateway.json new file mode 100644 index 000000000..c57afbb14 --- /dev/null +++ b/cross-chain/base/deployments/baseGoerli/BaseWormholeGateway.json @@ -0,0 +1,495 @@ +{ + "address": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "chainId", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "gateway", + "type": "bytes32" + } + ], + "name": "GatewayAddressUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "mintingLimit", + "type": "uint256" + } + ], + "name": "MintingLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "WormholeTbtcDeposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "WormholeTbtcReceived", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "recipientChain", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "gateway", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "recipient", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "arbiterFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "nonce", + "type": "uint32" + } + ], + "name": "WormholeTbtcSent", + "type": "event" + }, + { + "inputs": [], + "name": "bridge", + "outputs": [ + { + "internalType": "contract IWormholeTokenBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bridgeToken", + "outputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "depositWormholeTbtc", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_address", + "type": "bytes32" + } + ], + "name": "fromWormholeAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "name": "gateways", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IWormholeTokenBridge", + "name": "_bridge", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "_bridgeToken", + "type": "address" + }, + { + "internalType": "contract L2TBTC", + "name": "_tbtc", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "mintedAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "mintingLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedVm", + "type": "bytes" + } + ], + "name": "receiveTbtc", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "recipientChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "recipient", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "arbiterFee", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "nonce", + "type": "uint32" + } + ], + "name": "sendTbtc", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "tbtc", + "outputs": [ + { + "internalType": "contract L2TBTC", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "toWormholeAddress", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "chainId", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "gateway", + "type": "bytes32" + } + ], + "name": "updateGatewayAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_mintingLimit", + "type": "uint256" + } + ], + "name": "updateMintingLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x0e376095c9884ff5adbf641b23fe3bbba25f7f63e212406e1283b5dd0c81d65b", + "receipt": { + "to": null, + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343", + "transactionIndex": 2, + "gasUsed": "771556", + "logsBloom": "0x00000000002000000000000004000000400000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000202000001000000000000000000400000000000000000020000000000000000000800000000800000000000000000000000400000000200000000000000000000000000000000000080000000000000800000000000000000000000000000000400002000000000000000000000000000000000000020000000000000000020040000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000100", + "blockHash": "0xc0be1a51282abfccd136222436807b45090e9130c962d1b12309199a03fca2ba", + "transactionHash": "0x0e376095c9884ff5adbf641b23fe3bbba25f7f63e212406e1283b5dd0c81d65b", + "logs": [ + { + "transactionIndex": 2, + "blockNumber": 7884759, + "transactionHash": "0x0e376095c9884ff5adbf641b23fe3bbba25f7f63e212406e1283b5dd0c81d65b", + "address": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000a07f4e37c2e7089ea3afffbe51a6a281833a4d14" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0xc0be1a51282abfccd136222436807b45090e9130c962d1b12309199a03fca2ba" + }, + { + "transactionIndex": 2, + "blockNumber": 7884759, + "transactionHash": "0x0e376095c9884ff5adbf641b23fe3bbba25f7f63e212406e1283b5dd0c81d65b", + "address": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0xc0be1a51282abfccd136222436807b45090e9130c962d1b12309199a03fca2ba" + }, + { + "transactionIndex": 2, + "blockNumber": 7884759, + "transactionHash": "0x0e376095c9884ff5adbf641b23fe3bbba25f7f63e212406e1283b5dd0c81d65b", + "address": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0xc0be1a51282abfccd136222436807b45090e9130c962d1b12309199a03fca2ba" + }, + { + "transactionIndex": 2, + "blockNumber": 7884759, + "transactionHash": "0x0e376095c9884ff5adbf641b23fe3bbba25f7f63e212406e1283b5dd0c81d65b", + "address": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000009a82be743f0120fa24893b1631b6b2817fd94b1d", + "logIndex": 4, + "blockHash": "0xc0be1a51282abfccd136222436807b45090e9130c962d1b12309199a03fca2ba" + } + ], + "blockNumber": 7884759, + "cumulativeGasUsed": "864700", + "status": 1, + "byzantium": true + }, + "numDeployments": 1, + "implementation": "0xa07f4E37C2E7089Ea3AFffbe51A6A281833a4D14", + "devdoc": "Contract deployed as upgradable proxy" +} \ No newline at end of file From cce9d9c6df0dea1ec98b4c408ae68decf0ccbd03 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 2 Aug 2023 12:22:05 +0200 Subject: [PATCH 048/205] Add a note about ethers.js problem --- typescript/src/ethereum.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/typescript/src/ethereum.ts b/typescript/src/ethereum.ts index f86c80798..6630d8b71 100644 --- a/typescript/src/ethereum.ts +++ b/typescript/src/ethereum.ts @@ -772,6 +772,12 @@ export class Bridge options?: GetEvents.Options, ...filterArgs: Array ): Promise { + // FIXME: Filtering by indexed walletPubKeyHash field may not work + // until https://github.com/ethers-io/ethers.js/pull/4244 is + // included in the currently used version of ethers.js. + // Ultimately, we should upgrade ethers.js to include that fix. + // Short-term, we can workaround the problem as presented in: + // https://github.com/threshold-network/token-dashboard/blob/main/src/threshold-ts/tbtc/index.ts#L1041C1-L1093C1 const events: EthersEvent[] = await this.getEvents( "RedemptionRequested", options, From 88ea7f301e77c07e1aaf7fa18de5d295030f4aa5 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 2 Aug 2023 13:54:57 +0200 Subject: [PATCH 049/205] Stale redemptions monitoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changeset adds one new system event to the monitoring system: ### Stale redemption A *warning system event* indicating that a redemption request became stale, i.e. was not handled within the expected time. This event is sent to Sentry hub and should get team’s attention. The default action is investigating the cause of the extended processing time as this alert may be an early sign of a malfunctioning wallet or may indicate a problem with the maintainer bot. --- monitoring/docs/monitoring-and-telemetry.adoc | 9 ++ monitoring/src/contracts.ts | 7 +- monitoring/src/redemption-monitor.ts | 115 +++++++++++++++++- 3 files changed, 126 insertions(+), 5 deletions(-) diff --git a/monitoring/docs/monitoring-and-telemetry.adoc b/monitoring/docs/monitoring-and-telemetry.adoc index a1a8c52ad..ead266961 100644 --- a/monitoring/docs/monitoring-and-telemetry.adoc +++ b/monitoring/docs/monitoring-and-telemetry.adoc @@ -118,6 +118,7 @@ events produced by the monitoring component are: * DKG result challenged, * large deposit revealed, * large redemption requested, +* stale redemption, * optimistic minting canceled, * optimistic minting requested too early, * optimistic minting requested for undetermined Bitcoin transaction, @@ -180,6 +181,14 @@ team’s attention. The default action is making sure that the redemption is not a result of a malicious action, and if not, that the redemption is handled correctly by the system. +=== Stale redemption + +A *warning system event* indicating that a redemption request became stale, i.e. +was not handled within the expected time. This event is sent to Sentry hub and +should get team’s attention. The default action is investigating the cause +of the extended processing time as this alert may be an early sign of +a malfunctioning wallet or may indicate a problem with the maintainer bot. + ==== Optimistic minting cancelled A *warning system event* indicating that an optimistic minting request was diff --git a/monitoring/src/contracts.ts b/monitoring/src/contracts.ts index 25ce2c0fc..7e82e34e3 100644 --- a/monitoring/src/contracts.ts +++ b/monitoring/src/contracts.ts @@ -39,6 +39,11 @@ const resolve = () => { return block.number } + const blockTimestamp = async (blockNumber: number): Promise => { + const block = await provider.getBlock(blockNumber) + return block.timestamp + } + // eslint-disable-next-line @typescript-eslint/no-var-requires,global-require,import/no-dynamic-require const bridgeArtifact = require(`${packageName}/artifacts/Bridge.json`) const bridge: Bridge = new EthereumBridge({ @@ -63,7 +68,7 @@ const resolve = () => { deployedAtBlockNumber: tbtcTokenArtifact.receipt.blockNumber, }) - return { bridge, tbtcVault, tbtcToken, latestBlock } + return { bridge, tbtcVault, tbtcToken, latestBlock, blockTimestamp } } export const contracts = resolve() diff --git a/monitoring/src/redemption-monitor.ts b/monitoring/src/redemption-monitor.ts index 45048cf4d..98feb60c9 100644 --- a/monitoring/src/redemption-monitor.ts +++ b/monitoring/src/redemption-monitor.ts @@ -1,13 +1,21 @@ import { BigNumber } from "ethers" +import { Hex } from "@keep-network/tbtc-v2.ts" import { context } from "./context" import { SystemEventType } from "./system-event" import { satsToRoundedBTC } from "./deposit-monitor" import { createEthTxUrl } from "./block-explorer" +import { contracts } from "./contracts" +import type { Monitor as SystemEventMonitor, SystemEvent } from "./system-event" import type { RedemptionRequestedEvent as RedemptionRequestedChainEvent } from "@keep-network/tbtc-v2.ts/dist/src/redemption" import type { Bridge } from "@keep-network/tbtc-v2.ts/dist/src/chain" -import type { Monitor as SystemEventMonitor, SystemEvent } from "./system-event" + +// The time after which a pending redemption request is considered stale. +// Typically, a redemption request processing time should not exceed 5 hours. +// A redemption request pending for 8 hours indicates that something is wrong. +// This value is expressed in blocks, assuming 12 seconds per block. +const redemptionRequestStaleBlocks = (8 * 60 * 60) / 12 const RedemptionRequested = ( chainEvent: RedemptionRequestedChainEvent @@ -47,6 +55,25 @@ const LargeRedemptionRequested = ( } } +const StaleRedemption = ( + chainEvent: RedemptionRequestedChainEvent +): SystemEvent => { + const ethRequestTxHashURL = createEthTxUrl(chainEvent.transactionHash) + + return { + title: "Stale redemption", + type: SystemEventType.Warning, + data: { + walletPublicKeyHash: chainEvent.walletPublicKeyHash, + redeemerOutputScript: chainEvent.redeemerOutputScript, + requestedAmountBTC: satsToRoundedBTC(chainEvent.requestedAmount), + ethRequestTxHash: chainEvent.transactionHash.toPrefixedString(), + ethRequestTxHashURL, + }, + block: chainEvent.blockNumber, + } +} + export class RedemptionMonitor implements SystemEventMonitor { private bridge: Bridge @@ -58,6 +85,22 @@ export class RedemptionMonitor implements SystemEventMonitor { // eslint-disable-next-line no-console console.log("running redemption monitor check") + const systemEvents: SystemEvent[] = [] + systemEvents.push( + ...(await this.checkRequestedRedemptions(fromBlock, toBlock)) + ) + systemEvents.push(...(await this.checkStaleRedemptions(fromBlock, toBlock))) + + // eslint-disable-next-line no-console + console.log("completed redemption monitor check") + + return systemEvents + } + + private async checkRequestedRedemptions( + fromBlock: number, + toBlock: number + ): Promise { const chainEvents = await this.bridge.getRedemptionRequestedEvents({ fromBlock, toBlock, @@ -80,9 +123,73 @@ export class RedemptionMonitor implements SystemEventMonitor { } } - // eslint-disable-next-line no-console - console.log("completed redemption monitor check") - return systemEvents } + + private async checkStaleRedemptions( + fromBlock: number, + toBlock: number + ): Promise { + const rewindBlock = (block: number, shift: number) => + block - shift > 0 ? block - shift : 0 + + // We need to rewind the block window by the minting request timeout. + // This way, we are looking for past deposits whose time for creating + // the minting request was already elapsed. + const chainEvents = await this.bridge.getRedemptionRequestedEvents({ + fromBlock: rewindBlock(fromBlock, redemptionRequestStaleBlocks), + toBlock: rewindBlock(toBlock, redemptionRequestStaleBlocks), + }) + + const chainEventsTimestamps = await Promise.all( + chainEvents.map((ce) => contracts.blockTimestamp(ce.blockNumber)) + ) + + // To fetch pending redemptions requests, we need to know the plain-text + // public keys of the wallets used by the given chain events. In order to + // achieve that, we build a cache where the key is the wallet public key + // hash and the value is the wallet plain text public key. + // + // TODO: This can be optimized by refactoring the Bridge.pendingRedemptions + // method to accept wallet public key hashes directly. + const walletCache = new Map() + // eslint-disable-next-line no-plusplus + for (let i = 0; i < chainEvents.length; i++) { + const { walletPublicKeyHash } = chainEvents[i] + + if (!walletCache.has(walletPublicKeyHash)) { + // eslint-disable-next-line no-await-in-loop + const wallet = await this.bridge.wallets(Hex.from(walletPublicKeyHash)) + walletCache.set(walletPublicKeyHash, wallet.walletPublicKey.toString()) + } + } + + const pendingRedemptionsRequests = await Promise.all( + chainEvents.map((ce) => + this.bridge.pendingRedemptions( + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + walletCache.get(ce.walletPublicKeyHash)!, + ce.redeemerOutputScript + ) + ) + ) + + return chainEvents + .filter((ce, index) => { + const pendingRedemptionRequest = pendingRedemptionsRequests[index] + const chainEventTimestamp = chainEventsTimestamps[index] + + // To consider a redemption as stale, the redemption request must be + // still pending after redemptionRequestStaleBlocks. As there can + // be multiple redemption requests for the given wallet and + // redeemer output script pair, we need to make sure the pending + // redemption request timestamp matches the timestamp of the given + // chain event emission block. + return ( + pendingRedemptionRequest.requestedAt !== 0 && + pendingRedemptionRequest.requestedAt === chainEventTimestamp + ) + }) + .map(StaleRedemption) + } } From c5070e7d1f1ff572519f596e1a2d021ac2179734 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 3 Aug 2023 08:45:09 +0200 Subject: [PATCH 050/205] Upgrade `@keep-network/tbtc-v2.ts` package --- monitoring/yarn.lock | 379 ++++++++++++++++++++++++++++--------------- 1 file changed, 244 insertions(+), 135 deletions(-) diff --git a/monitoring/yarn.lock b/monitoring/yarn.lock index 7ab7b8239..1563bb2dc 100644 --- a/monitoring/yarn.lock +++ b/monitoring/yarn.lock @@ -558,16 +558,16 @@ "@openzeppelin/contracts-upgradeable" "^4.6.0" "@threshold-network/solidity-contracts" "1.2.1" -"@keep-network/ecdsa@2.1.0-dev.6": - version "2.1.0-dev.6" - resolved "https://registry.yarnpkg.com/@keep-network/ecdsa/-/ecdsa-2.1.0-dev.6.tgz#ccc690f784b6e802a5b80b2dfb7127d96e548a25" - integrity sha512-1D74OPVzzxxVcG8za/niuxmwEdDc5R6KNuHsUvsFkcHNJE1UgQNw+QdrI+k3M2so6YrO4L5lP7vTvIvBDbEMNQ== +"@keep-network/ecdsa@2.1.0-dev.15": + version "2.1.0-dev.15" + resolved "https://registry.yarnpkg.com/@keep-network/ecdsa/-/ecdsa-2.1.0-dev.15.tgz#ee631a42e165f30c75aae8c54aace765b77e272a" + integrity sha512-iUE3SwDSNc/k1oui7Z+fDGhhGyOzpe4/f/oKvDUMHqXx0BQG3QCrOz9KqWuPFXTXMav4LxLbt12WyDITAl/hjw== dependencies: - "@keep-network/random-beacon" "2.1.0-dev.5" + "@keep-network/random-beacon" "2.1.0-dev.15" "@keep-network/sortition-pools" "^2.0.0-pre.16" "@openzeppelin/contracts" "^4.6.0" "@openzeppelin/contracts-upgradeable" "^4.6.0" - "@threshold-network/solidity-contracts" "1.3.0-dev.3" + "@threshold-network/solidity-contracts" "1.3.0-dev.6" "@keep-network/ecdsa@2.1.0-goerli.4": version "2.1.0-goerli.4" @@ -665,15 +665,25 @@ "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" "@threshold-network/solidity-contracts" "1.2.1" -"@keep-network/random-beacon@2.1.0-dev.5": - version "2.1.0-dev.5" - resolved "https://registry.yarnpkg.com/@keep-network/random-beacon/-/random-beacon-2.1.0-dev.5.tgz#5ea1a76f57c8171fe3b12ecf4cfcefee38f954ac" - integrity sha512-v3Mqzwx69WqG5bi8qEO4b72PpDMbwl69f5PYHZ0vO3g2pzU1PpVq2nq/vzgdqW2xgztvnHFwOq+lOyN8hx0K3A== +"@keep-network/random-beacon@2.1.0-dev.15": + version "2.1.0-dev.15" + resolved "https://registry.yarnpkg.com/@keep-network/random-beacon/-/random-beacon-2.1.0-dev.15.tgz#541620c469e3bc75a5d1f7649889540b0e032e9e" + integrity sha512-vxBICRtmqSmJtFU5hZMpwB0alhgKchyMbxk4DtLZ7T2zBjd5tjt3CqeKEk+ON09g7yL1mIxY07InP4okviUK4A== dependencies: "@keep-network/sortition-pools" "^2.0.0-pre.16" - "@openzeppelin/contracts" "^4.6.0" + "@openzeppelin/contracts" "4.7.3" "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" - "@threshold-network/solidity-contracts" "1.3.0-dev.3" + "@threshold-network/solidity-contracts" "1.3.0-dev.5" + +"@keep-network/random-beacon@2.1.0-dev.16": + version "2.1.0-dev.16" + resolved "https://registry.yarnpkg.com/@keep-network/random-beacon/-/random-beacon-2.1.0-dev.16.tgz#9f2b5c19aa79f6ff1a5498ba7b55eb170463161d" + integrity sha512-o+cG/VDkhUc91W+4bMplYCgOu0twSFICqarpv5k2ES8GcaafaeV8stXGhCxjvHYJjU/sfG8mhlQZhWdZixq+JQ== + dependencies: + "@keep-network/sortition-pools" "^2.0.0-pre.16" + "@openzeppelin/contracts" "4.7.3" + "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" + "@threshold-network/solidity-contracts" "1.3.0-dev.6" "@keep-network/random-beacon@2.1.0-goerli.6": version "2.1.0-goerli.6" @@ -741,12 +751,12 @@ "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" "@keep-network/tbtc-v2.ts@development": - version "1.1.0-dev.13" - resolved "https://registry.yarnpkg.com/@keep-network/tbtc-v2.ts/-/tbtc-v2.ts-1.1.0-dev.13.tgz#713c00c2ed01313d8bd24019e2097ce62e086c24" - integrity sha512-iT3q3POIRvNjiu82xmIRcR+dgZbNPPMZWAnXltg89yzruC/O7FFsGjUVUbW+h5nOhb+SUncUX+ag25XOQo+TyA== + version "1.4.0-dev.1" + resolved "https://registry.yarnpkg.com/@keep-network/tbtc-v2.ts/-/tbtc-v2.ts-1.4.0-dev.1.tgz#a2f89db54aa0e8924f205f3bfbd411a2b79c9553" + integrity sha512-+20QZ4/FFGUdqVrY+N6+K+t2aQ8WcKlFjo0J/wiTMfb00A5KjJ8SDb3QI8+RHsvtbKnulnyH3VXEOAHBcI0IkQ== dependencies: - "@keep-network/ecdsa" "2.1.0-dev.6" - "@keep-network/tbtc-v2" "1.0.3-dev.3" + "@keep-network/ecdsa" "2.1.0-dev.15" + "@keep-network/tbtc-v2" "1.6.0-dev.0" bcoin "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8" bcrypto "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0" bufio "^1.0.6" @@ -755,14 +765,14 @@ p-timeout "^4.1.0" wif "2.0.6" -"@keep-network/tbtc-v2@1.0.3-dev.3": - version "1.0.3-dev.3" - resolved "https://registry.yarnpkg.com/@keep-network/tbtc-v2/-/tbtc-v2-1.0.3-dev.3.tgz#12e35c34eb8c267fab4824a971691f90eea6ca84" - integrity sha512-iy2zsgUSZhq7Y+TNAJ8mxeytP+XdJhu8uBLIzMdkhkLZVQgcAXNZ5C80AnR+42lUeKbTa0f6byA0AN9pGAA35A== +"@keep-network/tbtc-v2@1.6.0-dev.0": + version "1.6.0-dev.0" + resolved "https://registry.yarnpkg.com/@keep-network/tbtc-v2/-/tbtc-v2-1.6.0-dev.0.tgz#ba95805cef3f04bde7379d3c3b14e882a9cfa080" + integrity sha512-5N2dMdFSdS+Ljvqnqoscft5xnbIK/U/z8Dc2hNXWULkPhIy0Mx/E7i7I4CpBTV4LazIo1Hq6W4EJtj+lmrekgg== dependencies: "@keep-network/bitcoin-spv-sol" "3.4.0-solc-0.8" - "@keep-network/ecdsa" "2.1.0-dev.6" - "@keep-network/random-beacon" "2.1.0-dev.5" + "@keep-network/ecdsa" "2.1.0-dev.15" + "@keep-network/random-beacon" "2.1.0-dev.16" "@keep-network/tbtc" "1.1.2-dev.1" "@openzeppelin/contracts" "^4.8.1" "@openzeppelin/contracts-upgradeable" "^4.8.1" @@ -875,24 +885,29 @@ integrity sha512-14CijdTyy4Y/3D3UUeFC2oW12nt1Yq1M8gFOtkuODEvSYPe3YSAKnKyhUeGf0UDNCZzwfGr15KdiFK6AoJjoSQ== "@openzeppelin/contracts-upgradeable@^4.6.0", "@openzeppelin/contracts-upgradeable@^4.8.1": - version "4.8.2" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.8.2.tgz#edef522bdbc46d478481391553bababdd2199e27" - integrity sha512-zIggnBwemUmmt9IS73qxi+tumALxCY4QEs3zLCII78k0Gfse2hAOdAkuAeLUzvWUpneMUfFE5sGHzEUSTvn4Ag== + version "4.9.3" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.9.3.tgz#ff17a80fb945f5102571f8efecb5ce5915cc4811" + integrity sha512-jjaHAVRMrE4UuZNfDwjlLGDxTHWIOwTJS2ldnc278a0gevfXfPr8hxKEVBGFBE96kl2G3VHDZhUimw/+G3TG2A== "@openzeppelin/contracts-upgradeable@~4.5.2": version "4.5.2" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.5.2.tgz#90d9e47bacfd8693bfad0ac8a394645575528d05" integrity sha512-xgWZYaPlrEOQo3cBj97Ufiuv79SPd8Brh4GcFYhPgb6WvAq4ppz8dWKL6h+jLAK01rUqMRp/TS9AdXgAeNvCLA== +"@openzeppelin/contracts@4.7.3": + version "4.7.3" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.7.3.tgz#939534757a81f8d69cc854c7692805684ff3111e" + integrity sha512-dGRS0agJzu8ybo44pCIf3xBaPQN/65AIXNgK8+4gzKd5kbvlqyxryUYVLJv7fK98Seyd2hDZzVEHSWAh0Bt1Yw== + "@openzeppelin/contracts@^2.4.0": version "2.5.1" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-2.5.1.tgz#c76e3fc57aa224da3718ec351812a4251289db31" integrity sha512-qIy6tLx8rtybEsIOAlrM4J/85s2q2nPkDqj/Rx46VakBZ0LwtFhXIVub96LXHczQX0vaqmAueDqNPXtbSXSaYQ== "@openzeppelin/contracts@^4.1.0", "@openzeppelin/contracts@^4.3.2", "@openzeppelin/contracts@^4.6.0", "@openzeppelin/contracts@^4.8.1": - version "4.8.2" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.2.tgz#d815ade0027b50beb9bcca67143c6bcc3e3923d6" - integrity sha512-kEUOgPQszC0fSYWpbh2kT94ltOJwj1qfT2DWo+zVttmGmf97JZ99LspePNaeeaLhCImaHVeBbjaQFZQn7+Zc5g== + version "4.9.3" + resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.3.tgz#00d7a8cf35a475b160b3f0293a6403c511099364" + integrity sha512-He3LieZ1pP2TNt5JbkPA4PNT9WC3gOTOlDcFGJW4Le4QKqwmiNJCRt44APfxMxvq7OugU/cqYuPcSBzOw38DAg== "@openzeppelin/contracts@~4.5.0": version "4.5.0" @@ -1112,10 +1127,20 @@ "@openzeppelin/contracts-upgradeable" "~4.5.2" "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" -"@threshold-network/solidity-contracts@1.3.0-dev.3": - version "1.3.0-dev.3" - resolved "https://registry.yarnpkg.com/@threshold-network/solidity-contracts/-/solidity-contracts-1.3.0-dev.3.tgz#aa896b80a083ca8a7cb5219e3c9d1c47e3d86b03" - integrity sha512-BNm5+JKrFvg9hZ02Sp/A+vKs1PQB37rYdcZqLrLhvwDFzHFvL+XA2IXqvN1CznQTeehwnX3DtCcONTVP42i56A== +"@threshold-network/solidity-contracts@1.3.0-dev.5": + version "1.3.0-dev.5" + resolved "https://registry.yarnpkg.com/@threshold-network/solidity-contracts/-/solidity-contracts-1.3.0-dev.5.tgz#f7a2727d627a10218f0667bc0d33e19ed8f87fdc" + integrity sha512-AInTKQkJ0PKa32q2m8GnZFPYEArsnvOwhIFdBFaHdq9r4EGyqHMf4YY1WjffkheBZ7AQ0DNA8Lst30kBoQd0SA== + dependencies: + "@keep-network/keep-core" ">1.8.1-dev <1.8.1-goerli" + "@openzeppelin/contracts" "~4.5.0" + "@openzeppelin/contracts-upgradeable" "~4.5.2" + "@thesis/solidity-contracts" "github:thesis/solidity-contracts#4985bcf" + +"@threshold-network/solidity-contracts@1.3.0-dev.6": + version "1.3.0-dev.6" + resolved "https://registry.yarnpkg.com/@threshold-network/solidity-contracts/-/solidity-contracts-1.3.0-dev.6.tgz#41e34a84f409f63635e59f9a6ce170df1472b8a1" + integrity sha512-U7nMp+86M5qkjW7YUvT3qWgRiEEUIxqE96vkEiARTOkWX5JdLP2CXehkHCkEzjdgOCczmCp3fFtcgKFnQhhZ8A== dependencies: "@keep-network/keep-core" ">1.8.1-dev <1.8.1-goerli" "@openzeppelin/contracts" "~4.5.0" @@ -1176,9 +1201,9 @@ integrity sha512-lIxCk6G7AwmUagQ4gIQGxUBnvAq664prFD9nSAz6dgd1XmBXBtZABV/op+QsJsIyaP1GZsf/iXhYKHX3azSRCw== "@types/debug@^4.1.5": - version "4.1.7" - resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.7.tgz#7cc0ea761509124709b8b2d1090d8f6c17aadb82" - integrity sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg== + version "4.1.8" + resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.8.tgz#cef723a5d0a90990313faec2d1e22aee5eecb317" + integrity sha512-/vPO1EPOs306Cvhwv7KfVfYvOJqA/S/AXjaHQiJboCZzcNDb+TIJFN9/2C9DZ//ijSKWioNyUxD792QmDJ+HKQ== dependencies: "@types/ms" "*" @@ -1198,9 +1223,9 @@ "@types/node" "*" "@types/google-libphonenumber@^7.4.17": - version "7.4.23" - resolved "https://registry.yarnpkg.com/@types/google-libphonenumber/-/google-libphonenumber-7.4.23.tgz#c44c9125d45f042943694d605fd8d8d796cafc3b" - integrity sha512-C3ydakLTQa8HxtYf9ge4q6uT9krDX8smSIxmmW3oACFi5g5vv6T068PRExF7UyWbWpuYiDG8Nm24q2X5XhcZWw== + version "7.4.24" + resolved "https://registry.yarnpkg.com/@types/google-libphonenumber/-/google-libphonenumber-7.4.24.tgz#37ae6dbea69bea99dfe47559aede45ab1dd4de98" + integrity sha512-0gTFkoEd7j3KmxOMyEnubyvAeH2UJzu4ba2BIgY88OonZIyyS9u3NB0q8UW4A+OdIQp6OK8jwtpzy6I/IQw8Lg== "@types/http-cache-semantics@*": version "4.0.1" @@ -1225,9 +1250,9 @@ "@types/node" "*" "@types/lodash@^4.14.170": - version "4.14.191" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.191.tgz#09511e7f7cba275acd8b419ddac8da9a6a79e2fa" - integrity sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ== + version "4.14.196" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.196.tgz#a7c3d6fc52d8d71328b764e28e080b4169ec7a95" + integrity sha512-22y3o88f4a94mKljsZcanlNWPzO0uBsBdzLAngf2tp533LzZcQzb6+eZPJ+vCTt+bqF2XnvT9gejTLsAcJAJyQ== "@types/ms@*": version "0.7.31" @@ -1235,9 +1260,9 @@ integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== "@types/node@*": - version "18.14.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.6.tgz#ae1973dd2b1eeb1825695bb11ebfb746d27e3e93" - integrity sha512-93+VvleD3mXwlLI/xASjw0FzKcwzl3OdTCzm1LaRfqgS21gfFtK3zDXM5Op9TeeMsJVOaJ2VRDpT9q4Y3d0AvA== + version "20.4.6" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.6.tgz#b66b66c9bb5d49b199f03399e341c9d6036e9e88" + integrity sha512-q0RkvNgMweWWIvSMDiXhflGUKMdIxBo2M2tYM/0kEGDueQByFzK4KZAgu5YHGFNxziTlppNpTIBcqHQAxlfHdA== "@types/node@10.12.18": version "10.12.18" @@ -1512,6 +1537,14 @@ aria-query@^5.1.3: dependencies: deep-equal "^2.0.5" +array-buffer-byte-length@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz#fabe8bc193fea865f317fe7807085ee0dee5aead" + integrity sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A== + dependencies: + call-bind "^1.0.2" + is-array-buffer "^3.0.1" + array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" @@ -1575,6 +1608,18 @@ array.prototype.tosorted@^1.1.1: es-shim-unscopables "^1.0.0" get-intrinsic "^1.1.3" +arraybuffer.prototype.slice@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.1.tgz#9b5ea3868a6eebc30273da577eb888381c0044bb" + integrity sha512-09x0ZWFEjj4WD8PDbykUwo3t9arLn8NIzmmYEJFpYekOAQjpkGSyrQhNoRTcwwcFRu+ycWF78QZ63oWTqSjBcw== + dependencies: + array-buffer-byte-length "^1.0.0" + call-bind "^1.0.2" + define-properties "^1.2.0" + get-intrinsic "^1.2.1" + is-array-buffer "^3.0.2" + is-shared-array-buffer "^1.0.2" + asn1.js@^5.2.0: version "5.4.1" resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" @@ -1679,8 +1724,8 @@ base64-js@^1.3.1: integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== "bcfg@git+https://github.com/bcoin-org/bcfg.git#semver:~0.1.7": - version "0.1.7" - resolved "git+https://github.com/bcoin-org/bcfg.git#05122154b35baa82cd01dc9478ebee7346386ba1" + version "0.1.8" + resolved "git+https://github.com/bcoin-org/bcfg.git#90e1aff3b040160cd73956a500765ffcc823f0c2" dependencies: bsert "~0.0.10" @@ -1764,8 +1809,8 @@ bech32@1.1.4: bsert "~0.0.10" "bfile@git+https://github.com/bcoin-org/bfile.git#semver:~0.2.1": - version "0.2.2" - resolved "git+https://github.com/bcoin-org/bfile.git#c3075133a02830dc384f8353d8275d4499b8bff9" + version "0.2.3" + resolved "git+https://github.com/bcoin-org/bfile.git#c13235d04974f0fa5a487fdbaf74611523e2f4e6" "bfilter@git+https://github.com/bcoin-org/bfilter.git#semver:~2.3.0": version "2.3.0" @@ -2077,10 +2122,15 @@ bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: create-hash "^1.1.0" safe-buffer "^5.1.2" -"bsert@git+https://github.com/chjj/bsert.git#semver:~0.0.10", bsert@~0.0.10: +"bsert@git+https://github.com/chjj/bsert.git#semver:~0.0.10": version "0.0.10" resolved "git+https://github.com/chjj/bsert.git#bd09d49eab8644bca08ae8259a3d8756e7d453fc" +bsert@~0.0.10: + version "0.0.12" + resolved "https://registry.yarnpkg.com/bsert/-/bsert-0.0.12.tgz#157c6a6beb1548af3b14d484fcd2a78eb440599d" + integrity sha512-lUB0EMu4KhIf+VQ6RZJ7J3dFdohYSeta+gNgDi00Hi/t3k/W6xZlwm9PSSG0q7hJ2zW9Rsn5yaMPymETxroTRw== + "bsock@git+https://github.com/bcoin-org/bsock.git#semver:~0.1.9", bsock@~0.1.8, bsock@~0.1.9: version "0.1.9" resolved "git+https://github.com/bcoin-org/bsock.git#7cf76b3021ae7929c023d1170f789811e91ae528" @@ -2186,8 +2236,8 @@ bufio@^1.0.6: bsert "~0.0.10" "bval@git+https://github.com/bcoin-org/bval.git#semver:~0.1.6": - version "0.1.7" - resolved "git+https://github.com/bcoin-org/bval.git#5dcc923f24da9fb7eb96269ef8ce01540da983e7" + version "0.1.8" + resolved "git+https://github.com/bcoin-org/bval.git#f9c44d510bbc5bcc13cbd4b67e9704a24cc5ec0e" dependencies: bsert "~0.0.10" @@ -2222,9 +2272,9 @@ cacheable-request@^6.0.0: responselike "^1.0.2" cacheable-request@^7.0.2: - version "7.0.2" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.2.tgz#ea0d0b889364a25854757301ca12b2da77f91d27" - integrity sha512-pouW8/FmiPQbuGpkXQ9BAPv/Mo5xDGANgSNXzTzJ8DrKGuXOssM4wIQRjfanNRh3Yu5cfYPvcorqbhg2KIJtew== + version "7.0.4" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.4.tgz#7a33ebf08613178b403635be7b899d3e69bbe817" + integrity sha512-v+p6ongsrp0yTGbJXjgxPow2+DL93DASP4kXCDKb8/bwRtt9OEF3whggkkDkGNzgcWy2XaF4a8nZglC7uElscg== dependencies: clone-response "^1.0.2" get-stream "^5.1.0" @@ -2512,11 +2562,11 @@ cross-fetch@3.0.4: whatwg-fetch "3.0.0" cross-fetch@^3.0.6: - version "3.1.5" - resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f" - integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw== + version "3.1.8" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" + integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== dependencies: - node-fetch "2.6.7" + node-fetch "^2.6.12" cross-spawn@^7.0.2: version "7.0.3" @@ -2731,7 +2781,7 @@ defer-to-connect@^2.0.0: resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-2.0.1.tgz#8016bdb4143e4632b77a3449c6236277de520587" integrity sha512-4tvttepXG1VaYGrRibk5EwJd1t4udunSOVMdLSAL6mId1ix438oPwPZMALY41FCijukO1L0twNcGsdzS7dHgDg== -define-properties@^1.1.2, define-properties@^1.1.3, define-properties@^1.1.4: +define-properties@^1.1.2, define-properties@^1.1.3, define-properties@^1.1.4, define-properties@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.0.tgz#52988570670c9eacedd8064f4a990f2405849bd5" integrity sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA== @@ -2755,9 +2805,9 @@ depd@2.0.0: integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== des.js@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" - integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== + version "1.1.0" + resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.1.0.tgz#1d37f5766f3bbff4ee9638e871a8768c173b81da" + integrity sha512-r17GxjhUCjSRy8aiJpr8/UadFIzMzJGexI3Nmz4ADi9LYSFx4gTBp80+NaX/YsXWWLhpZ7v/v/ubEc/bCNfKwg== dependencies: inherits "^2.0.1" minimalistic-assert "^1.0.0" @@ -2886,18 +2936,19 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: dependencies: once "^1.4.0" -es-abstract@^1.19.0, es-abstract@^1.20.4: - version "1.21.1" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.21.1.tgz#e6105a099967c08377830a0c9cb589d570dd86c6" - integrity sha512-QudMsPOz86xYz/1dG1OuGBKOELjCh99IIWHLzy5znUB6j8xG2yMA7bfTV86VSqKF+Y/H08vQPR+9jyXpuC6hfg== +es-abstract@^1.19.0, es-abstract@^1.20.4, es-abstract@^1.21.2: + version "1.22.1" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.22.1.tgz#8b4e5fc5cefd7f1660f0f8e1a52900dfbc9d9ccc" + integrity sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw== dependencies: + array-buffer-byte-length "^1.0.0" + arraybuffer.prototype.slice "^1.0.1" available-typed-arrays "^1.0.5" call-bind "^1.0.2" es-set-tostringtag "^2.0.1" es-to-primitive "^1.2.1" - function-bind "^1.1.1" function.prototype.name "^1.1.5" - get-intrinsic "^1.1.3" + get-intrinsic "^1.2.1" get-symbol-description "^1.0.0" globalthis "^1.0.3" gopd "^1.0.1" @@ -2905,8 +2956,8 @@ es-abstract@^1.19.0, es-abstract@^1.20.4: has-property-descriptors "^1.0.0" has-proto "^1.0.1" has-symbols "^1.0.3" - internal-slot "^1.0.4" - is-array-buffer "^3.0.1" + internal-slot "^1.0.5" + is-array-buffer "^3.0.2" is-callable "^1.2.7" is-negative-zero "^2.0.2" is-regex "^1.1.4" @@ -2914,16 +2965,21 @@ es-abstract@^1.19.0, es-abstract@^1.20.4: is-string "^1.0.7" is-typed-array "^1.1.10" is-weakref "^1.0.2" - object-inspect "^1.12.2" + object-inspect "^1.12.3" object-keys "^1.1.1" object.assign "^4.1.4" - regexp.prototype.flags "^1.4.3" + regexp.prototype.flags "^1.5.0" + safe-array-concat "^1.0.0" safe-regex-test "^1.0.0" + string.prototype.trim "^1.2.7" string.prototype.trimend "^1.0.6" string.prototype.trimstart "^1.0.6" + typed-array-buffer "^1.0.0" + typed-array-byte-length "^1.0.0" + typed-array-byte-offset "^1.0.0" typed-array-length "^1.0.4" unbox-primitive "^1.0.2" - which-typed-array "^1.1.9" + which-typed-array "^1.1.10" es-array-method-boxes-properly@^1.0.0: version "1.0.0" @@ -3772,15 +3828,15 @@ functional-red-black-tree@^1.0.1: resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" integrity sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g== -functions-have-names@^1.2.2: +functions-have-names@^1.2.2, functions-have-names@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== futoin-hkdf@^1.0.3: - version "1.5.1" - resolved "https://registry.yarnpkg.com/futoin-hkdf/-/futoin-hkdf-1.5.1.tgz#141f00427bc9950b38a42aa786b99c318b9b688d" - integrity sha512-g5d0Qp7ks55hYmYmfqn4Nz18XH49lcCR+vvIvHT92xXnsJaGZmY1EtWQWilJ6BQp57heCIXM/rRo+AFep8hGgg== + version "1.5.3" + resolved "https://registry.yarnpkg.com/futoin-hkdf/-/futoin-hkdf-1.5.3.tgz#6c8024f2e1429da086d4e18289ef2239ad33ee35" + integrity sha512-SewY5KdMpaoCeh7jachEWFsh1nNlaDjNHZXWqL5IGwtpEYHTgkr2+AMCgNwKWkcc0wpSYrZfR7he4WdmHFtDxQ== get-caller-file@^2.0.1: version "2.0.5" @@ -3792,13 +3848,14 @@ get-func-name@^2.0.0: resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig== -get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f" - integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q== +get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0, get-intrinsic@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.1.tgz#d295644fed4505fc9cde952c37ee12b477a83d82" + integrity sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw== dependencies: function-bind "^1.1.1" has "^1.0.3" + has-proto "^1.0.1" has-symbols "^1.0.3" get-stream@^2.2.0: @@ -3982,9 +4039,9 @@ got@^7.1.0: url-to-options "^1.0.1" graceful-fs@^4.1.10, graceful-fs@^4.1.2, graceful-fs@^4.1.6: - version "4.2.10" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== grapheme-splitter@^1.0.4: version "1.0.4" @@ -4207,7 +4264,7 @@ inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, i resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -internal-slot@^1.0.3, internal-slot@^1.0.4: +internal-slot@^1.0.3, internal-slot@^1.0.4, internal-slot@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.5.tgz#f2a2ee21f668f8627a4667f309dc0f4fb6674986" integrity sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ== @@ -4241,7 +4298,7 @@ is-arguments@^1.0.4, is-arguments@^1.1.1: call-bind "^1.0.2" has-tostringtag "^1.0.0" -is-array-buffer@^3.0.1: +is-array-buffer@^3.0.1, is-array-buffer@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz#f2653ced8412081638ecb0ebbd0c41c6e0aecbbe" integrity sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w== @@ -4405,15 +4462,11 @@ is-symbol@^1.0.2, is-symbol@^1.0.3: has-symbols "^1.0.2" is-typed-array@^1.1.10, is-typed-array@^1.1.3, is-typed-array@^1.1.9: - version "1.1.10" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.10.tgz#36a5b5cb4189b575d1a3e4b08536bfb485801e3f" - integrity sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A== + version "1.1.12" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.12.tgz#d0bab5686ef4a76f7a73097b95470ab199c57d4a" + integrity sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg== dependencies: - available-typed-arrays "^1.0.5" - call-bind "^1.0.2" - for-each "^0.3.3" - gopd "^1.0.1" - has-tostringtag "^1.0.0" + which-typed-array "^1.1.11" is-typedarray@^1.0.0, is-typedarray@~1.0.0: version "1.0.0" @@ -4598,9 +4651,9 @@ keyv@^3.0.0: json-buffer "3.0.0" keyv@^4.0.0: - version "4.5.2" - resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.2.tgz#0e310ce73bf7851ec702f2eaf46ec4e3805cce56" - integrity sha512-5MHbFaKn8cNSmVW7BYnijeAVlE4cYA/SVkifVgrh7yotnfhKmjuXpDKjrABLnT0SfHWV21P8ow07OGfRrNDg8g== + version "4.5.3" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.3.tgz#00873d2b046df737963157bd04f294ca818c9c25" + integrity sha512-QCiSav9WaX1PgETJ+SpNnx2PRRapJ/oRSXM4VO5OGYGSjrxbKPVFVhB3l2OCbLCk329N8qyAtsJjSjvVBWzEug== dependencies: json-buffer "3.0.1" @@ -4852,9 +4905,9 @@ mkdirp-promise@^5.0.1: mkdirp "*" mkdirp@*: - version "2.1.5" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.5.tgz#78d7eaf15e069ba7b6b47d76dd94cfadf7a4062f" - integrity sha512-jbjfql+shJtAPrFoKxHOXip4xS+kul9W3OzfzzrqueWK2QMGon2bFH2opl6W9EagBThjEz+iysyi/swOoVfB/w== + version "3.0.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50" + integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg== mkdirp@0.5.4: version "0.5.4" @@ -5025,10 +5078,10 @@ node-fetch@2.6.0: resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== -node-fetch@2.6.7: - version "2.6.7" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== +node-fetch@^2.6.12: + version "2.6.12" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" + integrity sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g== dependencies: whatwg-url "^5.0.0" @@ -5082,7 +5135,7 @@ object-assign@^4, object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1 resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== -object-inspect@^1.12.2, object-inspect@^1.9.0: +object-inspect@^1.12.3, object-inspect@^1.9.0: version "1.12.3" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== @@ -5139,14 +5192,15 @@ object.fromentries@^2.0.6: es-abstract "^1.20.4" object.getownpropertydescriptors@^2.0.3: - version "2.1.5" - resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.5.tgz#db5a9002489b64eef903df81d6623c07e5b4b4d3" - integrity sha512-yDNzckpM6ntyQiGTik1fKV1DcVDRS+w8bvpWNCBanvH5LfRX9O8WTHqQzG4RZwRAM4I0oU7TV11Lj5v0g20ibw== + version "2.1.6" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.6.tgz#5e5c384dd209fa4efffead39e3a0512770ccc312" + integrity sha512-lq+61g26E/BgHv0ZTFgRvi7NMEPuAxLkFU7rukXjc/AlwH4Am5xXVnIXy3un1bg/JPbXHrixRkK1itUzzPiIjQ== dependencies: array.prototype.reduce "^1.0.5" call-bind "^1.0.2" - define-properties "^1.1.4" - es-abstract "^1.20.4" + define-properties "^1.2.0" + es-abstract "^1.21.2" + safe-array-concat "^1.0.0" object.hasown@^1.1.2: version "1.1.2" @@ -5606,9 +5660,9 @@ readable-stream@^2.3.0, readable-stream@^2.3.5: util-deprecate "~1.0.1" readable-stream@^3.6.0: - version "3.6.1" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.1.tgz#f9f9b5f536920253b3d26e7660e7da4ccff9bb62" - integrity sha512-+rQmrWMYGA90yenhTYsLWAsLsqVC8osOw6PKE1HDYiO0gdPeKe/xDHNzIAIn4C91YQ6oenEhfYqqc1883qHbjQ== + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== dependencies: inherits "^2.0.3" string_decoder "^1.1.1" @@ -5619,14 +5673,14 @@ regenerator-runtime@^0.13.11: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== -regexp.prototype.flags@^1.4.3: - version "1.4.3" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz#87cab30f80f66660181a3bb7bf5981a872b367ac" - integrity sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA== +regexp.prototype.flags@^1.4.3, regexp.prototype.flags@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz#fe7ce25e7e4cca8db37b6634c8a2c7009199b9cb" + integrity sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA== dependencies: call-bind "^1.0.2" - define-properties "^1.1.3" - functions-have-names "^1.2.2" + define-properties "^1.2.0" + functions-have-names "^1.2.3" regexpp@^3.2.0: version "3.2.0" @@ -5765,6 +5819,16 @@ rxjs@6: dependencies: tslib "^1.9.0" +safe-array-concat@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/safe-array-concat/-/safe-array-concat-1.0.0.tgz#2064223cba3c08d2ee05148eedbc563cd6d84060" + integrity sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.2.0" + has-symbols "^1.0.3" + isarray "^2.0.5" + safe-buffer@5.2.1, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@^5.2.1, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" @@ -5833,16 +5897,23 @@ seek-bzip@^1.0.5: commander "^2.8.1" semver@^5.5.1, semver@^5.7.0: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== + +semver@^7.3.5: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" -semver@^7.3.5, semver@^7.3.7: +semver@^7.3.7: version "7.3.8" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== @@ -6052,6 +6123,15 @@ string.prototype.matchall@^4.0.8: regexp.prototype.flags "^1.4.3" side-channel "^1.0.4" +string.prototype.trim@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz#a68352740859f6893f14ce3ef1bb3037f7a90533" + integrity sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + string.prototype.trimend@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz#c4a27fa026d979d79c04f17397f250a462944533" @@ -6378,6 +6458,36 @@ type@^2.7.2: resolved "https://registry.yarnpkg.com/type/-/type-2.7.2.tgz#2376a15a3a28b1efa0f5350dcf72d24df6ef98d0" integrity sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw== +typed-array-buffer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz#18de3e7ed7974b0a729d3feecb94338d1472cd60" + integrity sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.2.1" + is-typed-array "^1.1.10" + +typed-array-byte-length@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz#d787a24a995711611fb2b87a4052799517b230d0" + integrity sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA== + dependencies: + call-bind "^1.0.2" + for-each "^0.3.3" + has-proto "^1.0.1" + is-typed-array "^1.1.10" + +typed-array-byte-offset@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz#cbbe89b51fdef9cd6aaf07ad4707340abbc4ea0b" + integrity sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + has-proto "^1.0.1" + is-typed-array "^1.1.10" + typed-array-length@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.4.tgz#89d83785e5c4098bec72e08b319651f0eac9c1bb" @@ -7339,21 +7449,20 @@ which-collection@^1.0.1: is-weakset "^2.0.1" which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - integrity sha512-B+enWhmw6cjfVC7kS8Pj9pCrKSc5txArRyaYGe088shv/FGWH+0Rjx/xPgtsWfsUtS27FkP697E4DDhgrgoc0Q== + version "2.0.1" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.1.tgz#776b1fe35d90aebe99e8ac15eb24093389a4a409" + integrity sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ== -which-typed-array@^1.1.2, which-typed-array@^1.1.9: - version "1.1.9" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.9.tgz#307cf898025848cf995e795e8423c7f337efbde6" - integrity sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA== +which-typed-array@^1.1.10, which-typed-array@^1.1.11, which-typed-array@^1.1.2, which-typed-array@^1.1.9: + version "1.1.11" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.11.tgz#99d691f23c72aab6768680805a271b69761ed61a" + integrity sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew== dependencies: available-typed-arrays "^1.0.5" call-bind "^1.0.2" for-each "^0.3.3" gopd "^1.0.1" has-tostringtag "^1.0.0" - is-typed-array "^1.1.10" which@1.3.1: version "1.3.1" From 85a99852f4e4fce911f8e6753b21a9d00c1da3a5 Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 3 Aug 2023 08:58:56 +0200 Subject: [PATCH 051/205] Add deployment artifacts for Base Mainnet contracts --- .../base/.openzeppelin/unknown-8453.json | 458 ++++++++++ cross-chain/base/deployments/base/.chainId | 1 + .../base/deployments/base/BaseTBTC.json | 863 ++++++++++++++++++ .../deployments/base/BaseWormholeGateway.json | 495 ++++++++++ 4 files changed, 1817 insertions(+) create mode 100644 cross-chain/base/.openzeppelin/unknown-8453.json create mode 100644 cross-chain/base/deployments/base/.chainId create mode 100644 cross-chain/base/deployments/base/BaseTBTC.json create mode 100644 cross-chain/base/deployments/base/BaseWormholeGateway.json diff --git a/cross-chain/base/.openzeppelin/unknown-8453.json b/cross-chain/base/.openzeppelin/unknown-8453.json new file mode 100644 index 000000000..41fc6dfe4 --- /dev/null +++ b/cross-chain/base/.openzeppelin/unknown-8453.json @@ -0,0 +1,458 @@ +{ + "manifestVersion": "3.2", + "admin": { + "address": "0x1293a54e160D1cd7075487898d65266081A15458", + "txHash": "0xb92ee3373032006668d9c9b1bac778b22683062044484a723e43dfa93ae978c6" + }, + "proxies": [ + { + "address": "0x236aa50979D5f3De3Bd1Eeb40E81137F22ab794b", + "txHash": "0x85f05786bb1d38013714332804139352f16aa2751d05b4517ed2f7e67d683a6a", + "kind": "transparent" + }, + { + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab", + "txHash": "0xa1f899fbe911303fd9202727a1c1613317b086a603ba780174eb8dde19919a79", + "kind": "transparent" + } + ], + "impls": { + "1eca3b29684e1fcc811e32be6ee7e72cd846a93f69838508595506ae72555f18": { + "address": "0x41C9b5639E3F2F6C61e9B78b2c6FF3746E79d91A", + "txHash": "0xf682ac58a70ef929940bfa273d740501dc2d9bd1f0e43f61ee96af91de322038", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_balances", + "offset": 0, + "slot": "51", + "type": "t_mapping(t_address,t_uint256)", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:37" + }, + { + "label": "_allowances", + "offset": 0, + "slot": "52", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:39" + }, + { + "label": "_totalSupply", + "offset": 0, + "slot": "53", + "type": "t_uint256", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:41" + }, + { + "label": "_name", + "offset": 0, + "slot": "54", + "type": "t_string_storage", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:43" + }, + { + "label": "_symbol", + "offset": 0, + "slot": "55", + "type": "t_string_storage", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:44" + }, + { + "label": "__gap", + "offset": 0, + "slot": "56", + "type": "t_array(t_uint256)45_storage", + "contract": "ERC20Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol:400" + }, + { + "label": "__gap", + "offset": 0, + "slot": "101", + "type": "t_array(t_uint256)50_storage", + "contract": "ERC20BurnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol:51" + }, + { + "label": "_HASHED_NAME", + "offset": 0, + "slot": "151", + "type": "t_bytes32", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:32" + }, + { + "label": "_HASHED_VERSION", + "offset": 0, + "slot": "152", + "type": "t_bytes32", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:33" + }, + { + "label": "__gap", + "offset": 0, + "slot": "153", + "type": "t_array(t_uint256)50_storage", + "contract": "EIP712Upgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol:120" + }, + { + "label": "_nonces", + "offset": 0, + "slot": "203", + "type": "t_mapping(t_address,t_struct(Counter)3297_storage)", + "contract": "ERC20PermitUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol:28" + }, + { + "label": "_PERMIT_TYPEHASH_DEPRECATED_SLOT", + "offset": 0, + "slot": "204", + "type": "t_bytes32", + "contract": "ERC20PermitUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol:40", + "renamedFrom": "_PERMIT_TYPEHASH" + }, + { + "label": "__gap", + "offset": 0, + "slot": "205", + "type": "t_array(t_uint256)49_storage", + "contract": "ERC20PermitUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol:108" + }, + { + "label": "_owner", + "offset": 0, + "slot": "254", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "255", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_paused", + "offset": 0, + "slot": "304", + "type": "t_bool", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:29" + }, + { + "label": "__gap", + "offset": 0, + "slot": "305", + "type": "t_array(t_uint256)49_storage", + "contract": "PausableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol:116" + }, + { + "label": "isMinter", + "offset": 0, + "slot": "354", + "type": "t_mapping(t_address,t_bool)", + "contract": "L2TBTC", + "src": "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol:76" + }, + { + "label": "minters", + "offset": 0, + "slot": "355", + "type": "t_array(t_address)dyn_storage", + "contract": "L2TBTC", + "src": "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol:77" + }, + { + "label": "isGuardian", + "offset": 0, + "slot": "356", + "type": "t_mapping(t_address,t_bool)", + "contract": "L2TBTC", + "src": "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol:85" + }, + { + "label": "guardians", + "offset": 0, + "slot": "357", + "type": "t_array(t_address)dyn_storage", + "contract": "L2TBTC", + "src": "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol:89" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "label": "address[]", + "numberOfBytes": "32" + }, + "t_array(t_uint256)45_storage": { + "label": "uint256[45]", + "numberOfBytes": "1440" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_bool)": { + "label": "mapping(address => bool)", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_struct(Counter)3297_storage)": { + "label": "mapping(address => struct CountersUpgradeable.Counter)", + "numberOfBytes": "32" + }, + "t_mapping(t_address,t_uint256)": { + "label": "mapping(address => uint256)", + "numberOfBytes": "32" + }, + "t_string_storage": { + "label": "string", + "numberOfBytes": "32" + }, + "t_struct(Counter)3297_storage": { + "label": "struct CountersUpgradeable.Counter", + "members": [ + { + "label": "_value", + "type": "t_uint256", + "offset": 0, + "slot": "0" + } + ], + "numberOfBytes": "32" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + }, + "70974f3ab30d1010f875de7eebcbde08a1b6c71845f5272c23be8f95af866a64": { + "address": "0x292C9fdf2e2475599cBe350cc473c221Bd67AE28", + "txHash": "0xfd56b0c2335f21ac0830b6496442b80c82e4a9f43ac3d7cc03cd67c01fe2276c", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_status", + "offset": 0, + "slot": "101", + "type": "t_uint256", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:80" + }, + { + "label": "bridge", + "offset": 0, + "slot": "151", + "type": "t_contract(IWormholeTokenBridge)518", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:122" + }, + { + "label": "bridgeToken", + "offset": 0, + "slot": "152", + "type": "t_contract(IERC20Upgradeable)2252", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:123" + }, + { + "label": "tbtc", + "offset": 0, + "slot": "153", + "type": "t_contract(L2TBTC)443", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:124" + }, + { + "label": "gateways", + "offset": 0, + "slot": "154", + "type": "t_mapping(t_uint16,t_bytes32)", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:136" + }, + { + "label": "mintingLimit", + "offset": 0, + "slot": "155", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:147" + }, + { + "label": "mintedAmount", + "offset": 0, + "slot": "156", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:151" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IERC20Upgradeable)2252": { + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IWormholeTokenBridge)518": { + "label": "contract IWormholeTokenBridge", + "numberOfBytes": "20" + }, + "t_contract(L2TBTC)443": { + "label": "contract L2TBTC", + "numberOfBytes": "20" + }, + "t_mapping(t_uint16,t_bytes32)": { + "label": "mapping(uint16 => bytes32)", + "numberOfBytes": "32" + }, + "t_uint16": { + "label": "uint16", + "numberOfBytes": "2" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } + } + } +} diff --git a/cross-chain/base/deployments/base/.chainId b/cross-chain/base/deployments/base/.chainId new file mode 100644 index 000000000..2a0c26389 --- /dev/null +++ b/cross-chain/base/deployments/base/.chainId @@ -0,0 +1 @@ +8453 \ No newline at end of file diff --git a/cross-chain/base/deployments/base/BaseTBTC.json b/cross-chain/base/deployments/base/BaseTBTC.json new file mode 100644 index 000000000..9ac553aa1 --- /dev/null +++ b/cross-chain/base/deployments/base/BaseTBTC.json @@ -0,0 +1,863 @@ +{ + "address": "0x236aa50979D5f3De3Bd1Eeb40E81137F22ab794b", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "GuardianAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "GuardianRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "MinterAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "MinterRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "addGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "addMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getGuardians", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMinters", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "guardians", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "_name", + "type": "string" + }, + { + "internalType": "string", + "name": "_symbol", + "type": "string" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isGuardian", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isMinter", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "minters", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721Upgradeable", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "recoverERC721", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "removeGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "removeMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x85f05786bb1d38013714332804139352f16aa2751d05b4517ed2f7e67d683a6a", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x236aa50979D5f3De3Bd1Eeb40E81137F22ab794b", + "transactionIndex": 1, + "gasUsed": "754031", + "logsBloom": "0x00000000000000000000400000000000400000000002000000800000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000002800001000000000000000080000000000000000000020000000000000000000800000000800000000000000000400000400000000000000000000000000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000040000000000440000000000000400000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x676b27fe07778a4d23b12ebcda86efb3396f4727c4f22fecfc534f22ad0382f2", + "transactionHash": "0x85f05786bb1d38013714332804139352f16aa2751d05b4517ed2f7e67d683a6a", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 2126367, + "transactionHash": "0x85f05786bb1d38013714332804139352f16aa2751d05b4517ed2f7e67d683a6a", + "address": "0x236aa50979D5f3De3Bd1Eeb40E81137F22ab794b", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000041c9b5639e3f2f6c61e9b78b2c6ff3746e79d91a" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0x676b27fe07778a4d23b12ebcda86efb3396f4727c4f22fecfc534f22ad0382f2" + }, + { + "transactionIndex": 1, + "blockNumber": 2126367, + "transactionHash": "0x85f05786bb1d38013714332804139352f16aa2751d05b4517ed2f7e67d683a6a", + "address": "0x236aa50979D5f3De3Bd1Eeb40E81137F22ab794b", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x676b27fe07778a4d23b12ebcda86efb3396f4727c4f22fecfc534f22ad0382f2" + }, + { + "transactionIndex": 1, + "blockNumber": 2126367, + "transactionHash": "0x85f05786bb1d38013714332804139352f16aa2751d05b4517ed2f7e67d683a6a", + "address": "0x236aa50979D5f3De3Bd1Eeb40E81137F22ab794b", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 2, + "blockHash": "0x676b27fe07778a4d23b12ebcda86efb3396f4727c4f22fecfc534f22ad0382f2" + }, + { + "transactionIndex": 1, + "blockNumber": 2126367, + "transactionHash": "0x85f05786bb1d38013714332804139352f16aa2751d05b4517ed2f7e67d683a6a", + "address": "0x236aa50979D5f3De3Bd1Eeb40E81137F22ab794b", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001293a54e160d1cd7075487898d65266081a15458", + "logIndex": 3, + "blockHash": "0x676b27fe07778a4d23b12ebcda86efb3396f4727c4f22fecfc534f22ad0382f2" + } + ], + "blockNumber": 2126367, + "cumulativeGasUsed": "818044", + "status": 1, + "byzantium": true + }, + "numDeployments": 1, + "implementation": "0x41C9b5639E3F2F6C61e9B78b2c6FF3746E79d91A", + "devdoc": "Contract deployed as upgradable proxy" +} \ No newline at end of file diff --git a/cross-chain/base/deployments/base/BaseWormholeGateway.json b/cross-chain/base/deployments/base/BaseWormholeGateway.json new file mode 100644 index 000000000..9b10333fa --- /dev/null +++ b/cross-chain/base/deployments/base/BaseWormholeGateway.json @@ -0,0 +1,495 @@ +{ + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "chainId", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "gateway", + "type": "bytes32" + } + ], + "name": "GatewayAddressUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "mintingLimit", + "type": "uint256" + } + ], + "name": "MintingLimitUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "WormholeTbtcDeposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "WormholeTbtcReceived", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "recipientChain", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "gateway", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "recipient", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "arbiterFee", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "nonce", + "type": "uint32" + } + ], + "name": "WormholeTbtcSent", + "type": "event" + }, + { + "inputs": [], + "name": "bridge", + "outputs": [ + { + "internalType": "contract IWormholeTokenBridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bridgeToken", + "outputs": [ + { + "internalType": "contract IERC20Upgradeable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "depositWormholeTbtc", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "_address", + "type": "bytes32" + } + ], + "name": "fromWormholeAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "name": "gateways", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IWormholeTokenBridge", + "name": "_bridge", + "type": "address" + }, + { + "internalType": "contract IERC20Upgradeable", + "name": "_bridgeToken", + "type": "address" + }, + { + "internalType": "contract L2TBTC", + "name": "_tbtc", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "mintedAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "mintingLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedVm", + "type": "bytes" + } + ], + "name": "receiveTbtc", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "recipientChain", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "recipient", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "arbiterFee", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "nonce", + "type": "uint32" + } + ], + "name": "sendTbtc", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "tbtc", + "outputs": [ + { + "internalType": "contract L2TBTC", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "toWormholeAddress", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "chainId", + "type": "uint16" + }, + { + "internalType": "bytes32", + "name": "gateway", + "type": "bytes32" + } + ], + "name": "updateGatewayAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_mintingLimit", + "type": "uint256" + } + ], + "name": "updateMintingLimit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xa1f899fbe911303fd9202727a1c1613317b086a603ba780174eb8dde19919a79", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x09959798B95d00a3183d20FaC298E4594E599eab", + "transactionIndex": 2, + "gasUsed": "771556", + "logsBloom": "0x00000000000000000000000000000000400000000800000000800000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000006000001000000000000000000000000000000000000030000000000000000000800000000800000000000000000000000400000000000000000000000000000000000000000000080000000000000800000000000000008000004000000000400000000000000000000000000000000000000000020000000000000000000440000000000000400000000000000000020000000000000000000002000000000000000000000000000000000000000000000", + "blockHash": "0x6ed42cc05db35ca75ff3a444611559b7154eef5832a56ddfcdfcef3babbf453f", + "transactionHash": "0xa1f899fbe911303fd9202727a1c1613317b086a603ba780174eb8dde19919a79", + "logs": [ + { + "transactionIndex": 2, + "blockNumber": 2126449, + "transactionHash": "0xa1f899fbe911303fd9202727a1c1613317b086a603ba780174eb8dde19919a79", + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000292c9fdf2e2475599cbe350cc473c221bd67ae28" + ], + "data": "0x", + "logIndex": 1, + "blockHash": "0x6ed42cc05db35ca75ff3a444611559b7154eef5832a56ddfcdfcef3babbf453f" + }, + { + "transactionIndex": 2, + "blockNumber": 2126449, + "transactionHash": "0xa1f899fbe911303fd9202727a1c1613317b086a603ba780174eb8dde19919a79", + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 2, + "blockHash": "0x6ed42cc05db35ca75ff3a444611559b7154eef5832a56ddfcdfcef3babbf453f" + }, + { + "transactionIndex": 2, + "blockNumber": 2126449, + "transactionHash": "0xa1f899fbe911303fd9202727a1c1613317b086a603ba780174eb8dde19919a79", + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 3, + "blockHash": "0x6ed42cc05db35ca75ff3a444611559b7154eef5832a56ddfcdfcef3babbf453f" + }, + { + "transactionIndex": 2, + "blockNumber": 2126449, + "transactionHash": "0xa1f899fbe911303fd9202727a1c1613317b086a603ba780174eb8dde19919a79", + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000001293a54e160d1cd7075487898d65266081a15458", + "logIndex": 4, + "blockHash": "0x6ed42cc05db35ca75ff3a444611559b7154eef5832a56ddfcdfcef3babbf453f" + } + ], + "blockNumber": 2126449, + "cumulativeGasUsed": "865081", + "status": 1, + "byzantium": true + }, + "numDeployments": 1, + "implementation": "0x292C9fdf2e2475599cBe350cc473c221Bd67AE28", + "devdoc": "Contract deployed as upgradable proxy" +} \ No newline at end of file From d8b514f3704c5c15436673a1efbc34bc2855a15a Mon Sep 17 00:00:00 2001 From: Jakub Nowakowski Date: Thu, 3 Aug 2023 09:01:24 +0200 Subject: [PATCH 052/205] Start base v1.1.0-dev v1.0.0 was alreday published for Base, so we start a new one. --- cross-chain/base/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-chain/base/package.json b/cross-chain/base/package.json index 149659c80..300f085ba 100644 --- a/cross-chain/base/package.json +++ b/cross-chain/base/package.json @@ -1,6 +1,6 @@ { "name": "@keep-network/tbtc-v2-base", - "version": "1.0.0-dev", + "version": "1.1.0-dev", "description": "tBTC v2 on Base", "license": "GPL-3.0-only", "files": [ From 426d09742ffa58521935e61917d65d67f9211927 Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Mon, 7 Aug 2023 09:21:57 -0500 Subject: [PATCH 053/205] solana: various fixes to tbtc and gateway programs Co-authored-by: gator-boi --- cross-chain/solana/.gitignore | 1 + cross-chain/solana/Anchor.toml | 8 +- cross-chain/solana/Cargo.lock | 169 +++++++++-- cross-chain/solana/Makefile | 9 +- cross-chain/solana/programs/tbtc/Cargo.toml | 9 +- cross-chain/solana/programs/tbtc/src/error.rs | 37 ++- cross-chain/solana/programs/tbtc/src/event.rs | 2 +- cross-chain/solana/programs/tbtc/src/lib.rs | 2 + .../tbtc/src/processor/admin/add_guardian.rs | 27 +- .../tbtc/src/processor/admin/add_minter.rs | 24 +- .../tbtc/src/processor/admin/initialize.rs | 78 ++++- .../src/processor/admin/remove_guardian.rs | 32 ++- .../tbtc/src/processor/admin/remove_minter.rs | 32 ++- .../src/processor/admin/take_authority.rs | 24 +- .../solana/programs/tbtc/src/state/config.rs | 4 +- .../programs/tbtc/src/state/guardian_info.rs | 2 +- .../programs/tbtc/src/state/guardians.rs | 30 ++ .../solana/programs/tbtc/src/state/minters.rs | 30 ++ .../solana/programs/tbtc/src/state/mod.rs | 6 + .../programs/wormhole-gateway/Cargo.toml | 4 +- .../wormhole-gateway/src/constants.rs | 18 ++ .../programs/wormhole-gateway/src/error.rs | 29 +- .../programs/wormhole-gateway/src/event.rs | 34 +++ .../programs/wormhole-gateway/src/lib.rs | 22 +- .../admin/cancel_authority_change.rs | 22 ++ .../src/processor/admin/change_authority.rs | 23 ++ .../src/processor/{ => admin}/initialize.rs | 43 +-- .../src/processor/admin/mod.rs | 17 ++ .../src/processor/admin/take_authority.rs | 38 +++ .../{ => admin}/update_gateway_address.rs | 7 +- .../{ => admin}/update_minting_limit.rs | 5 + .../src/processor/deposit_wormhole_tbtc.rs | 18 +- .../wormhole-gateway/src/processor/mod.rs | 16 +- .../src/processor/receive_tbtc.rs | 266 +++++++++++++++--- .../src/processor/send_tbtc/gateway.rs | 35 ++- .../src/processor/send_tbtc/mod.rs | 34 ++- .../src/processor/send_tbtc/wrapped.rs | 106 +++---- .../wormhole-gateway/src/state/custodian.rs | 11 +- 38 files changed, 1051 insertions(+), 223 deletions(-) create mode 100644 cross-chain/solana/programs/tbtc/src/state/guardians.rs create mode 100644 cross-chain/solana/programs/tbtc/src/state/minters.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/constants.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/event.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/admin/cancel_authority_change.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/admin/change_authority.rs rename cross-chain/solana/programs/wormhole-gateway/src/processor/{ => admin}/initialize.rs (62%) create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/admin/mod.rs create mode 100644 cross-chain/solana/programs/wormhole-gateway/src/processor/admin/take_authority.rs rename cross-chain/solana/programs/wormhole-gateway/src/processor/{ => admin}/update_gateway_address.rs (88%) rename cross-chain/solana/programs/wormhole-gateway/src/processor/{ => admin}/update_minting_limit.rs (86%) diff --git a/cross-chain/solana/.gitignore b/cross-chain/solana/.gitignore index 3db15d86f..0f1813a21 100644 --- a/cross-chain/solana/.gitignore +++ b/cross-chain/solana/.gitignore @@ -1,5 +1,6 @@ .anchor +.prettierrc.json .DS_Store target **/*.rs.bk diff --git a/cross-chain/solana/Anchor.toml b/cross-chain/solana/Anchor.toml index 6025a94f1..052529539 100644 --- a/cross-chain/solana/Anchor.toml +++ b/cross-chain/solana/Anchor.toml @@ -11,7 +11,7 @@ members = [ [programs.localnet] tbtc = "HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG" -wormhole-gateway = "8H9F5JGbEMyERycwaGuzLS5MQnV7dn2wm2h6egJ3Leiu" +wormhole_gateway = "8H9F5JGbEMyERycwaGuzLS5MQnV7dn2wm2h6egJ3Leiu" [registry] url = "https://api.apr.dev" @@ -61,10 +61,10 @@ filename = "tests/accounts/ethereum_token_bridge.json" address = "DapiQYH3BGonhN8cngWcXQ6SrqSm3cwysoznoHr6Sbsx" filename = "tests/accounts/token_bridge_config.json" -### Core Bridge -- Bridge -[[test.validator.clone]] +### Core Bridge -- Bridge Data +[[test.validator.account]] address = "2yVjuQwpsvdsrywzsJJVs9Ueh4zayyo5DYJbBNc3DDpn" -filename = "tests/accounts/core_bridge.json" +filename = "tests/accounts/core_bridge_data.json" ### Core Bridge -- Emitter Sequence (Token Bridge's) [[test.validator.account]] diff --git a/cross-chain/solana/Cargo.lock b/cross-chain/solana/Cargo.lock index b01fb264b..b9f9f8463 100644 --- a/cross-chain/solana/Cargo.lock +++ b/cross-chain/solana/Cargo.lock @@ -191,6 +191,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78f860599da1c2354e7234c768783049eb42e2f54509ecfc942d2e0076a2da7b" dependencies = [ "anchor-lang", + "mpl-token-metadata", "solana-program", "spl-associated-token-account", "spl-token", @@ -1015,6 +1016,77 @@ dependencies = [ "zeroize", ] +[[package]] +name = "mpl-token-auth-rules" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c376f2cc7dae80e2949cd6ca8a2420b3c61c1ecb7a275c6433d9a4d2d24f994d" +dependencies = [ + "borsh", + "bytemuck", + "mpl-token-metadata-context-derive 0.2.1", + "num-derive", + "num-traits", + "rmp-serde", + "serde", + "shank", + "solana-program", + "solana-zk-token-sdk", + "thiserror", +] + +[[package]] +name = "mpl-token-metadata" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e73b5df66f4e6f98606e3fb327cbc6a0dba8df11085246f2e766949acb96bb" +dependencies = [ + "arrayref", + "borsh", + "mpl-token-auth-rules", + "mpl-token-metadata-context-derive 0.3.0", + "mpl-utils", + "num-derive", + "num-traits", + "shank", + "solana-program", + "spl-associated-token-account", + "spl-token", + "thiserror", +] + +[[package]] +name = "mpl-token-metadata-context-derive" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12989bc45715b0ee91944855130131479f9c772e198a910c3eb0ea327d5bffc3" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "mpl-token-metadata-context-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a739019e11d93661a64ef5fe108ab17c79b35961e944442ff6efdd460ad01a" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "mpl-utils" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "822133b6cba8f9a43e5e0e189813be63dd795858f54155c729833be472ffdb51" +dependencies = [ + "arrayref", + "borsh", + "solana-program", + "spl-token", +] + [[package]] name = "num-derive" version = "0.3.3" @@ -1101,6 +1173,12 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + [[package]] name = "pbkdf2" version = "0.4.0" @@ -1308,6 +1386,28 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +[[package]] +name = "rmp" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44519172358fd6d58656c86ab8e7fbc9e1490c3e8f14d35ed78ca0dd07403c9f" +dependencies = [ + "byteorder", + "num-traits", + "paste", +] + +[[package]] +name = "rmp-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5b13be192e0220b8afb7222aa5813cb62cc269ebb5cac346ca6487681d2913e" +dependencies = [ + "byteorder", + "rmp", + "serde", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -1433,6 +1533,40 @@ dependencies = [ "keccak", ] +[[package]] +name = "shank" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63e565b5e95ad88ab38f312e89444c749360641c509ef2de0093b49f55974a5" +dependencies = [ + "shank_macro", +] + +[[package]] +name = "shank_macro" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63927d22a1e8b74bda98cc6e151fcdf178b7abb0dc6c4f81e0bbf5ffe2fc4ec8" +dependencies = [ + "proc-macro2", + "quote", + "shank_macro_impl", + "syn 1.0.109", +] + +[[package]] +name = "shank_macro_impl" +version = "0.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ce03403df682f80f4dc1efafa87a4d0cb89b03726d0565e6364bdca5b9a441" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "serde", + "syn 1.0.109", +] + [[package]] name = "signature" version = "1.6.4" @@ -1457,9 +1591,9 @@ checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "solana-frozen-abi" -version = "1.14.20" +version = "1.14.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a100b7fa8198c20354eb7256c0d9789107d8a62280221f3efe15f7c9dc4cec" +checksum = "225ac329a67b02e2ac4ae8010665ad4bb77b7db7fc8577b99e6746c7606072ee" dependencies = [ "ahash", "blake3", @@ -1491,9 +1625,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.14.20" +version = "1.14.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f527f44601b35dd67d11bc72f2f7512976a466f9304ef574b87dac83ced8a42" +checksum = "52444c75e502210ef16edbf0e8d57c3945603899216cb144dfb86449d260aa30" dependencies = [ "proc-macro2", "quote", @@ -1503,9 +1637,9 @@ dependencies = [ [[package]] name = "solana-logger" -version = "1.14.20" +version = "1.14.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8632c8bc480bb5615b70a18b807ede73024aebc7761503ff86a70b7f4906ae47" +checksum = "9a1d78de034cab8726fe7863873addf0aa6a4bb7ece54b5706616bac739e28b4" dependencies = [ "env_logger", "lazy_static", @@ -1514,9 +1648,9 @@ dependencies = [ [[package]] name = "solana-program" -version = "1.14.20" +version = "1.14.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ad5f48743ce505f6139a07e20aecdc689def12da7230fed661c2073ab97df8" +checksum = "f37355e56ce445ae981624d51b58a633be33bf476fd599722a4cfc8db98ef3cb" dependencies = [ "base64 0.13.1", "bincode", @@ -1563,9 +1697,9 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "1.14.20" +version = "1.14.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c515a5a5a5cdc115044c33959eb4d091680f5e7ca8be9eb5218fb0c21bf3568" +checksum = "31e0955817486854951828071fb6b248633928a86e2f9fd8f69230f365d59f2e" dependencies = [ "assert_matches", "base64 0.13.1", @@ -1614,9 +1748,9 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.14.20" +version = "1.14.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bbc3ab3070c090e1a18fd5a0a07d729d0db2bc8524414dc3e16504286d38049" +checksum = "8a83905d4911d35e7367544909fa1ca2611c974e5584e3e82efb2313da69df96" dependencies = [ "bs58 0.4.0", "proc-macro2", @@ -1627,9 +1761,9 @@ dependencies = [ [[package]] name = "solana-zk-token-sdk" -version = "1.14.20" +version = "1.14.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d51d131cdefcb621a8034321ce487c4f788e813f81ce81e4f65eed8d4b4f2aa" +checksum = "fb0789e84a4e93ad101a67d59a83270c3bad001206f923ea97b1791f54c33c80" dependencies = [ "aes-gcm-siv", "arrayref", @@ -1748,6 +1882,7 @@ version = "0.1.0" dependencies = [ "anchor-lang", "anchor-spl", + "mpl-token-metadata", "solana-program", ] @@ -2068,8 +2203,9 @@ dependencies = [ [[package]] name = "wormhole-anchor-sdk" -version = "0.1.0" -source = "git+https://github.com/wormhole-foundation/wormhole-scaffolding?rev=f8d5ba04bfd449ab3693b15c818fd3e85e30f758#f8d5ba04bfd449ab3693b15c818fd3e85e30f758" +version = "0.1.0-alpha.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1789eb9fd2113b6e2945cb67123b902141a9bfde1ec33762be58447eb2431f6" dependencies = [ "anchor-lang", "anchor-spl", @@ -2082,6 +2218,7 @@ version = "0.1.0" dependencies = [ "anchor-lang", "anchor-spl", + "solana-program", "tbtc", "wormhole-anchor-sdk", ] diff --git a/cross-chain/solana/Makefile b/cross-chain/solana/Makefile index 6fe96802c..60201a688 100644 --- a/cross-chain/solana/Makefile +++ b/cross-chain/solana/Makefile @@ -1,8 +1,7 @@ - out_solana-devnet=artifacts-testnet out_mainnet=artifacts-mainnet -.PHONY: all clean build test +.PHONY: all clean build test lint all: test @@ -24,3 +23,9 @@ endif test: node_modules anchor test --arch sbf + +lint: + cargo fmt --check + cargo check --features "mainnet" --no-default-features + cargo check --features "solana-devnet" --no-default-features + cargo clippy --no-deps --all-targets -- -D warnings \ No newline at end of file diff --git a/cross-chain/solana/programs/tbtc/Cargo.toml b/cross-chain/solana/programs/tbtc/Cargo.toml index 18e88c859..b80c4641c 100644 --- a/cross-chain/solana/programs/tbtc/Cargo.toml +++ b/cross-chain/solana/programs/tbtc/Cargo.toml @@ -18,6 +18,9 @@ no-log-ix-name = [] cpi = ["no-entrypoint"] [dependencies] -anchor-lang = { version = "=0.28.0", features = ["derive", "init-if-needed"] } -anchor-spl = "=0.28.0" -solana-program = "=1.14.20" +anchor-lang = { version = "0.28.0", features = ["derive", "init-if-needed"] } +anchor-spl = { version = "0.28.0", features = ["metadata"] } + +solana-program = "=1.14" + +mpl-token-metadata = "1.13.1" diff --git a/cross-chain/solana/programs/tbtc/src/error.rs b/cross-chain/solana/programs/tbtc/src/error.rs index 5e1b279d5..433eb20eb 100644 --- a/cross-chain/solana/programs/tbtc/src/error.rs +++ b/cross-chain/solana/programs/tbtc/src/error.rs @@ -2,9 +2,36 @@ use anchor_lang::prelude::error_code; #[error_code] pub enum TbtcError { - IsPaused, - IsNotPaused, - IsNotAuthority, - IsNotPendingAuthority, - NoPendingAuthorityChange, + #[msg("Not valid authority to perform this action")] + IsNotAuthority = 0x20, + + #[msg("Not valid pending authority to take authority")] + IsNotPendingAuthority = 0x22, + + #[msg("No pending authority")] + NoPendingAuthorityChange = 0x24, + + #[msg("This address is already a guardian")] + GuardianAlreadyExists = 0x30, + + #[msg("This address is not a guardian")] + GuardianNonexistent = 0x32, + + #[msg("Caller is not a guardian")] + SignerNotGuardian = 0x34, + + #[msg("This address is already a minter")] + MinterAlreadyExists = 0x40, + + #[msg("This address is not a minter")] + MinterNonexistent = 0x42, + + #[msg("Caller is not a minter")] + SignerNotMinter = 0x44, + + #[msg("Program is paused")] + IsPaused = 0x50, + + #[msg("Program is not paused")] + IsNotPaused = 0x52, } diff --git a/cross-chain/solana/programs/tbtc/src/event.rs b/cross-chain/solana/programs/tbtc/src/event.rs index 6a385a50a..341f6156e 100644 --- a/cross-chain/solana/programs/tbtc/src/event.rs +++ b/cross-chain/solana/programs/tbtc/src/event.rs @@ -18,4 +18,4 @@ pub struct GuardianAdded { #[event] pub struct GuardianRemoved { pub guardian: Pubkey, -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/lib.rs b/cross-chain/solana/programs/tbtc/src/lib.rs index f2604b0f9..8011c6cc2 100644 --- a/cross-chain/solana/programs/tbtc/src/lib.rs +++ b/cross-chain/solana/programs/tbtc/src/lib.rs @@ -5,6 +5,8 @@ pub use constants::*; pub mod error; +pub(crate) mod event; + mod processor; pub(crate) use processor::*; diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs index 422bac905..6cc51c2f6 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_guardian.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, GuardianInfo}, + state::{Config, GuardianInfo, Guardians}, }; use anchor_lang::prelude::*; @@ -17,6 +17,16 @@ pub struct AddGuardian<'info> { #[account(mut)] authority: Signer<'info>, + #[account( + mut, + seeds = [Guardians::SEED_PREFIX], + bump = guardians.bump, + realloc = Guardians::compute_size(guardians.keys.len() + 1), + realloc::payer = authority, + realloc::zero = true, + )] + guardians: Account<'info, Guardians>, + #[account( init, payer = authority, @@ -26,18 +36,29 @@ pub struct AddGuardian<'info> { )] guardian_info: Account<'info, GuardianInfo>, - /// CHECK: Required authority to pause contract. This pubkey lives in `GuardianInfo`. + /// CHECK: Required authority to pause contract. This pubkey lives in `GuardianInfo` and + /// `Guardians`. guardian: AccountInfo<'info>, system_program: Program<'info, System>, } pub fn add_guardian(ctx: Context) -> Result<()> { + let guardian = ctx.accounts.guardian.key(); + + // Set account data. ctx.accounts.guardian_info.set_inner(GuardianInfo { - guardian: ctx.accounts.guardian.key(), bump: ctx.bumps["guardian_info"], + guardian, }); + // Push pubkey to guardians account. + ctx.accounts.guardians.push(guardian); + + // Update config. ctx.accounts.config.num_guardians += 1; + + emit!(crate::event::GuardianAdded { guardian }); + Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs index ccb8620cb..a76cf2480 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/add_minter.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, MinterInfo}, + state::{Config, MinterInfo, Minters}, }; use anchor_lang::prelude::*; @@ -17,6 +17,16 @@ pub struct AddMinter<'info> { #[account(mut)] authority: Signer<'info>, + #[account( + mut, + seeds = [Minters::SEED_PREFIX], + bump = minters.bump, + realloc = Minters::compute_size(minters.keys.len() + 1), + realloc::payer = authority, + realloc::zero = true, + )] + minters: Account<'info, Minters>, + #[account( init, payer = authority, @@ -33,11 +43,21 @@ pub struct AddMinter<'info> { } pub fn add_minter(ctx: Context) -> Result<()> { + let minter = ctx.accounts.minter.key(); + + // Set account data. ctx.accounts.minter_info.set_inner(MinterInfo { - minter: ctx.accounts.minter.key(), bump: ctx.bumps["minter_info"], + minter, }); + // Push pubkey to minters account. + ctx.accounts.minters.push(minter); + + // Update config. ctx.accounts.config.num_minters += 1; + + emit!(crate::event::MinterAdded { minter }); + Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs index e32ebc5bb..d4cf6ecd7 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/initialize.rs @@ -1,6 +1,9 @@ -use crate::{constants::SEED_PREFIX_TBTC_MINT, state::Config}; +use crate::{ + constants::SEED_PREFIX_TBTC_MINT, + state::{Config, Guardians, Minters}, +}; use anchor_lang::prelude::*; -use anchor_spl::token; +use anchor_spl::{metadata, token}; #[derive(Accounts)] pub struct Initialize<'info> { @@ -11,7 +14,7 @@ pub struct Initialize<'info> { seeds = [SEED_PREFIX_TBTC_MINT], bump, payer = authority, - mint::decimals = 9, + mint::decimals = 8, mint::authority = config, )] mint: Account<'info, token::Mint>, @@ -25,14 +28,41 @@ pub struct Initialize<'info> { )] config: Account<'info, Config>, + #[account( + init, + payer = authority, + space = Guardians::compute_size(0), + seeds = [Guardians::SEED_PREFIX], + bump, + )] + guardians: Account<'info, Guardians>, + + #[account( + init, + payer = authority, + space = Minters::compute_size(0), + seeds = [Minters::SEED_PREFIX], + bump, + )] + minters: Account<'info, Minters>, + #[account(mut)] authority: Signer<'info>, + /// CHECK: This account is needed for the MPL Token Metadata program. + #[account(mut)] + tbtc_metadata: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the MPL Token Metadata program. + rent: UncheckedAccount<'info>, + + mpl_token_metadata_program: Program<'info, metadata::Metadata>, token_program: Program<'info, token::Token>, system_program: Program<'info, System>, } pub fn initialize(ctx: Context) -> Result<()> { + // Set Config account data. ctx.accounts.config.set_inner(Config { bump: ctx.bumps["config"], authority: ctx.accounts.authority.key(), @@ -43,5 +73,45 @@ pub fn initialize(ctx: Context) -> Result<()> { num_guardians: 0, paused: false, }); - Ok(()) + + // Set Guardians account data with empty vec. + ctx.accounts.guardians.set_inner(Guardians { + bump: ctx.bumps["guardians"], + keys: Vec::new(), + }); + + // Set Guardians account data with empty vec. + ctx.accounts.minters.set_inner(Minters { + bump: ctx.bumps["minters"], + keys: Vec::new(), + }); + + // Create metadata for tBTC. + metadata::create_metadata_accounts_v3( + CpiContext::new_with_signer( + ctx.accounts.mpl_token_metadata_program.to_account_info(), + metadata::CreateMetadataAccountsV3 { + metadata: ctx.accounts.tbtc_metadata.to_account_info(), + mint: ctx.accounts.mint.to_account_info(), + mint_authority: ctx.accounts.config.to_account_info(), + payer: ctx.accounts.authority.to_account_info(), + update_authority: ctx.accounts.config.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + rent: ctx.accounts.rent.to_account_info(), + }, + &[&[Config::SEED_PREFIX, &[ctx.bumps["config"]]]], + ), + mpl_token_metadata::state::DataV2 { + symbol: "tBTC".to_string(), + name: "tBTC v2".to_string(), + uri: "".to_string(), + seller_fee_basis_points: 0, + creators: None, + collection: None, + uses: None, + }, + true, + true, + None, + ) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs index 777edf865..06f45c3f6 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_guardian.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, GuardianInfo}, + state::{Config, GuardianInfo, Guardians}, }; use anchor_lang::prelude::*; @@ -12,8 +12,19 @@ pub struct RemoveGuardian<'info> { )] config: Account<'info, Config>, + #[account(mut)] authority: Signer<'info>, + #[account( + mut, + seeds = [Guardians::SEED_PREFIX], + bump = guardians.bump, + realloc = Guardians::compute_size(guardians.keys.len().saturating_sub(1)), + realloc::payer = authority, + realloc::zero = true, + )] + guardians: Account<'info, Guardians>, + #[account( mut, has_one = guardian, @@ -25,9 +36,28 @@ pub struct RemoveGuardian<'info> { /// CHECK: Required authority to pause contract. This pubkey lives in `GuardianInfo`. guardian: AccountInfo<'info>, + + system_program: Program<'info, System>, } pub fn remove_guardian(ctx: Context) -> Result<()> { + let guardians: &mut Vec<_> = &mut ctx.accounts.guardians; + let removed = ctx.accounts.guardian.key(); + + // It is safe to unwrap because the key we are removing is guaranteed to exist since there is + // a guardian info account for it. + let index = guardians + .iter() + .position(|&guardian| guardian == removed) + .unwrap(); + + // Remove pubkey to guardians account. + guardians.swap_remove(index); + + // Update config. ctx.accounts.config.num_guardians -= 1; + + emit!(crate::event::GuardianRemoved { guardian: removed }); + Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs index 83aa5a07d..a506bb1d5 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/remove_minter.rs @@ -1,6 +1,6 @@ use crate::{ error::TbtcError, - state::{Config, MinterInfo}, + state::{Config, MinterInfo, Minters}, }; use anchor_lang::prelude::*; @@ -14,8 +14,19 @@ pub struct RemoveMinter<'info> { )] config: Account<'info, Config>, + #[account(mut)] authority: Signer<'info>, + #[account( + mut, + seeds = [Minters::SEED_PREFIX], + bump = minters.bump, + realloc = Minters::compute_size(minters.keys.len().saturating_sub(1)), + realloc::payer = authority, + realloc::zero = true, + )] + minters: Account<'info, Minters>, + #[account( mut, has_one = minter, @@ -27,9 +38,28 @@ pub struct RemoveMinter<'info> { /// CHECK: Required authority to mint tokens. This pubkey lives in `MinterInfo`. minter: AccountInfo<'info>, + + system_program: Program<'info, System>, } pub fn remove_minter(ctx: Context) -> Result<()> { + let minters: &mut Vec<_> = &mut ctx.accounts.minters; + let removed = ctx.accounts.minter.key(); + + // It is safe to unwrap because the key we are removing is guaranteed to exist since there is + // a minter info account for it. + let index = minters + .iter() + .position(|&minter| minter == removed) + .unwrap(); + + // Remove pubkey to minters account. + minters.swap_remove(index); + + // Update config. ctx.accounts.config.num_minters -= 1; + + emit!(crate::event::MinterRemoved { minter: removed }); + Ok(()) } diff --git a/cross-chain/solana/programs/tbtc/src/processor/admin/take_authority.rs b/cross-chain/solana/programs/tbtc/src/processor/admin/take_authority.rs index 292d2d726..4d9826a73 100644 --- a/cross-chain/solana/programs/tbtc/src/processor/admin/take_authority.rs +++ b/cross-chain/solana/programs/tbtc/src/processor/admin/take_authority.rs @@ -7,18 +7,32 @@ pub struct TakeAuthority<'info> { mut, seeds = [Config::SEED_PREFIX], bump, - constraint = config.pending_authority.is_some() @ TbtcError::NoPendingAuthorityChange )] config: Account<'info, Config>, - #[account( - constraint = pending_authority.key() == config.pending_authority.unwrap() @ TbtcError::IsNotPendingAuthority - )] pending_authority: Signer<'info>, } +impl<'info> TakeAuthority<'info> { + fn constraints(ctx: &Context) -> Result<()> { + match ctx.accounts.config.pending_authority { + Some(pending_authority) => { + require_keys_eq!( + pending_authority, + ctx.accounts.pending_authority.key(), + TbtcError::IsNotPendingAuthority + ); + + Ok(()) + } + None => err!(TbtcError::NoPendingAuthorityChange), + } + } +} + +#[access_control(TakeAuthority::constraints(&ctx))] pub fn take_authority(ctx: Context) -> Result<()> { ctx.accounts.config.authority = ctx.accounts.pending_authority.key(); ctx.accounts.config.pending_authority = None; Ok(()) -} \ No newline at end of file +} diff --git a/cross-chain/solana/programs/tbtc/src/state/config.rs b/cross-chain/solana/programs/tbtc/src/state/config.rs index 497200848..da0366f2c 100644 --- a/cross-chain/solana/programs/tbtc/src/state/config.rs +++ b/cross-chain/solana/programs/tbtc/src/state/config.rs @@ -14,8 +14,8 @@ pub struct Config { pub mint_bump: u8, // Admin info. - pub num_minters: u8, - pub num_guardians: u8, + pub num_minters: u32, + pub num_guardians: u32, pub paused: bool, } diff --git a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs index 34f1492ba..a87c5cdbb 100644 --- a/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs +++ b/cross-chain/solana/programs/tbtc/src/state/guardian_info.rs @@ -3,8 +3,8 @@ use anchor_lang::prelude::*; #[account] #[derive(Debug, InitSpace)] pub struct GuardianInfo { - pub guardian: Pubkey, pub bump: u8, + pub guardian: Pubkey, } impl GuardianInfo { diff --git a/cross-chain/solana/programs/tbtc/src/state/guardians.rs b/cross-chain/solana/programs/tbtc/src/state/guardians.rs new file mode 100644 index 000000000..bfacd6935 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/state/guardians.rs @@ -0,0 +1,30 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Debug)] +pub struct Guardians { + pub bump: u8, + pub keys: Vec, +} + +impl Guardians { + pub const SEED_PREFIX: &'static [u8] = b"guardians"; + + pub(crate) fn compute_size(num_guardians: usize) -> usize { + 8 + 1 + 4 + num_guardians * 32 + } +} + +impl std::ops::Deref for Guardians { + type Target = Vec; + + fn deref(&self) -> &Self::Target { + &self.keys + } +} + +impl std::ops::DerefMut for Guardians { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.keys + } +} diff --git a/cross-chain/solana/programs/tbtc/src/state/minters.rs b/cross-chain/solana/programs/tbtc/src/state/minters.rs new file mode 100644 index 000000000..6974b10e4 --- /dev/null +++ b/cross-chain/solana/programs/tbtc/src/state/minters.rs @@ -0,0 +1,30 @@ +use anchor_lang::prelude::*; + +#[account] +#[derive(Debug)] +pub struct Minters { + pub bump: u8, + pub keys: Vec, +} + +impl Minters { + pub const SEED_PREFIX: &'static [u8] = b"minters"; + + pub(crate) fn compute_size(num_minters: usize) -> usize { + 8 + 1 + 4 + num_minters * 32 + } +} + +impl std::ops::Deref for Minters { + type Target = Vec; + + fn deref(&self) -> &Self::Target { + &self.keys + } +} + +impl std::ops::DerefMut for Minters { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.keys + } +} diff --git a/cross-chain/solana/programs/tbtc/src/state/mod.rs b/cross-chain/solana/programs/tbtc/src/state/mod.rs index dffd4099b..296352f95 100644 --- a/cross-chain/solana/programs/tbtc/src/state/mod.rs +++ b/cross-chain/solana/programs/tbtc/src/state/mod.rs @@ -4,5 +4,11 @@ pub use config::*; mod guardian_info; pub use guardian_info::*; +mod guardians; +pub use guardians::*; + mod minter_info; pub use minter_info::*; + +mod minters; +pub use minters::*; diff --git a/cross-chain/solana/programs/wormhole-gateway/Cargo.toml b/cross-chain/solana/programs/wormhole-gateway/Cargo.toml index 6df2961fc..b00b3ebb5 100644 --- a/cross-chain/solana/programs/wormhole-gateway/Cargo.toml +++ b/cross-chain/solana/programs/wormhole-gateway/Cargo.toml @@ -18,9 +18,11 @@ no-log-ix-name = [] cpi = ["no-entrypoint"] [dependencies] +wormhole-anchor-sdk = { version = "0.1.0-alpha.1", features = ["token-bridge"], default-features = false } + anchor-lang = { version = "0.28.0", features = ["init-if-needed"]} anchor-spl = "0.28.0" -wormhole-anchor-sdk = { git = "https://github.com/wormhole-foundation/wormhole-scaffolding", rev = "f8d5ba04bfd449ab3693b15c818fd3e85e30f758", features = ["token-bridge"], default-features = false } +solana-program = "=1.14" tbtc = { path = "../tbtc", features = ["cpi"] } \ No newline at end of file diff --git a/cross-chain/solana/programs/wormhole-gateway/src/constants.rs b/cross-chain/solana/programs/wormhole-gateway/src/constants.rs new file mode 100644 index 000000000..75ece6f5b --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/constants.rs @@ -0,0 +1,18 @@ +pub const TBTC_ETHEREUM_TOKEN_CHAIN: u16 = 2; + +#[cfg(feature = "mainnet")] +/// tBTC token address on the Ethereum Mainnet. +pub const TBTC_ETHEREUM_TOKEN_ADDRESS: [u8; 32] = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x08, 0x4f, 0xba, 0x66, 0x6a, + 0x33, 0xd3, 0x75, 0x92, 0xfa, 0x26, 0x33, 0xfd, 0x49, 0xa7, 0x4d, 0xd9, 0x3a, 0x88, +]; + +#[cfg(feature = "solana-devnet")] +/// tBTC token address on the Ethereum Testnet (Goerli). +pub const TBTC_ETHEREUM_TOKEN_ADDRESS: [u8; 32] = [ + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x67, 0x98, 0x74, 0xfb, 0xe6, 0xd4, + 0xe7, 0xcc, 0x54, 0xa5, 0x9e, 0x31, 0x5f, 0xf1, 0xeb, 0x26, 0x66, 0x86, 0xa9, 0x37, +]; + +/// A.K.A. b"msg". +pub const MSG_SEED_PREFIX: &[u8] = b"msg"; diff --git a/cross-chain/solana/programs/wormhole-gateway/src/error.rs b/cross-chain/solana/programs/wormhole-gateway/src/error.rs index 09a8b136c..c48f2760f 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/error.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/error.rs @@ -2,12 +2,18 @@ use anchor_lang::prelude::error_code; #[error_code] pub enum WormholeGatewayError { - #[msg("Cannot mint more than the minting limit.")] + #[msg("Cannot mint more than the minting limit")] MintingLimitExceeded = 0x10, - #[msg("Only custodian authority is permitted for this action.")] + #[msg("Only custodian authority is permitted for this action")] IsNotAuthority = 0x20, + #[msg("Not valid pending authority to take authority")] + IsNotPendingAuthority = 0x22, + + #[msg("No pending authority")] + NoPendingAuthorityChange = 0x24, + #[msg("0x0 recipient not allowed")] ZeroRecipient = 0x30, @@ -17,6 +23,21 @@ pub enum WormholeGatewayError { #[msg("Amount must not be 0")] ZeroAmount = 0x50, - #[msg("Amount too low to bridge")] - TruncatedZeroAmount = 0x60, + #[msg("Token Bridge transfer already redeemed")] + TransferAlreadyRedeemed = 0x70, + + #[msg("Token chain and address do not match Ethereum's tBTC")] + InvalidEthereumTbtc = 0x80, + + #[msg("No tBTC transferred")] + NoTbtcTransferred = 0x90, + + #[msg("0x0 receiver not allowed")] + RecipientZeroAddress = 0xa0, + + #[msg("Not enough minted by the gateway to satisfy sending tBTC")] + MintedAmountUnderflow = 0xb0, + + #[msg("Minted amount after deposit exceeds u64")] + MintedAmountOverflow = 0xb2, } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/event.rs b/cross-chain/solana/programs/wormhole-gateway/src/event.rs new file mode 100644 index 000000000..17a57b7f7 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/event.rs @@ -0,0 +1,34 @@ +use anchor_lang::prelude::*; + +#[event] +pub struct WormholeTbtcReceived { + pub receiver: Pubkey, + pub amount: u64, +} + +#[event] +pub struct WormholeTbtcSent { + pub amount: u64, + pub recipient_chain: u16, + pub gateway: [u8; 32], + pub recipient: [u8; 32], + pub arbiter_fee: u64, + pub nonce: u32, +} + +#[event] +pub struct WormholeTbtcDeposited { + pub depositor: Pubkey, + pub amount: u64, +} + +#[event] +pub struct GatewayAddressUpdated { + pub chain: u16, + pub gateway: [u8; 32], +} + +#[event] +pub struct MintingLimitUpdated { + pub minting_limit: u64, +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/lib.rs b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs index b58d6d681..65d5ca7c9 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/lib.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/lib.rs @@ -1,7 +1,11 @@ #![allow(clippy::result_large_err)] +pub mod constants; + pub mod error; +pub(crate) mod event; + mod processor; pub(crate) use processor::*; @@ -30,6 +34,18 @@ pub mod wormhole_gateway { processor::initialize(ctx, minting_limit) } + pub fn change_authority(ctx: Context) -> Result<()> { + processor::change_authority(ctx) + } + + pub fn cancel_authority_change(ctx: Context) -> Result<()> { + processor::cancel_authority_change(ctx) + } + + pub fn take_authority(ctx: Context) -> Result<()> { + processor::take_authority(ctx) + } + pub fn update_gateway_address( ctx: Context, args: UpdateGatewayAddressArgs, @@ -41,9 +57,9 @@ pub mod wormhole_gateway { processor::update_minting_limit(ctx, new_limit) } - // pub fn receive_tbtc(ctx: Context) -> Result<()> { - // processor::receive_tbtc(ctx) - // } + pub fn receive_tbtc(ctx: Context, message_hash: [u8; 32]) -> Result<()> { + processor::receive_tbtc(ctx, message_hash) + } pub fn send_tbtc_gateway( ctx: Context, diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/cancel_authority_change.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/cancel_authority_change.rs new file mode 100644 index 000000000..a428b64f6 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/cancel_authority_change.rs @@ -0,0 +1,22 @@ +use crate::{error::WormholeGatewayError, state::Custodian}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] + +pub struct CancelAuthorityChange<'info> { + #[account( + mut, + seeds = [Custodian::SEED_PREFIX], + bump, + has_one = authority @ WormholeGatewayError::IsNotAuthority, + constraint = custodian.pending_authority.is_some() @ WormholeGatewayError::NoPendingAuthorityChange + )] + custodian: Account<'info, Custodian>, + + authority: Signer<'info>, +} + +pub fn cancel_authority_change(ctx: Context) -> Result<()> { + ctx.accounts.custodian.pending_authority = None; + Ok(()) +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/change_authority.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/change_authority.rs new file mode 100644 index 000000000..9d77622f8 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/change_authority.rs @@ -0,0 +1,23 @@ +use crate::{error::WormholeGatewayError, state::Custodian}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct ChangeAuthority<'info> { + #[account( + mut, + seeds = [Custodian::SEED_PREFIX], + bump, + has_one = authority @ WormholeGatewayError::IsNotAuthority + )] + custodian: Account<'info, Custodian>, + + authority: Signer<'info>, + + /// CHECK: New authority. + new_authority: AccountInfo<'info>, +} + +pub fn change_authority(ctx: Context) -> Result<()> { + ctx.accounts.custodian.pending_authority = Some(ctx.accounts.new_authority.key()); + Ok(()) +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/initialize.rs similarity index 62% rename from cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs rename to cross-chain/solana/programs/wormhole-gateway/src/processor/admin/initialize.rs index f73831546..0b8c07d35 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/initialize.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/initialize.rs @@ -1,23 +1,11 @@ -use crate::state::Custodian; +use crate::{ + constants::{TBTC_ETHEREUM_TOKEN_ADDRESS, TBTC_ETHEREUM_TOKEN_CHAIN}, + state::Custodian, +}; use anchor_lang::prelude::*; use anchor_spl::token; use wormhole_anchor_sdk::token_bridge; -const TBTC_FOREIGN_TOKEN_CHAIN: u8 = 2; - -#[cfg(feature = "mainnet")] -const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x08, 0x4f, 0xbA, 0x66, 0x6a, - 0x33, 0xd3, 0x75, 0x92, 0xfA, 0x26, 0x33, 0xfD, 0x49, 0xa7, 0x4D, 0xD9, 0x3a, 0x88, -]; - -/// TODO: Fix this to reflect testnet contract address. -#[cfg(feature = "solana-devnet")] -const TBTC_FOREIGN_TOKEN_ADDRESS: [u8; 32] = [ - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x08, 0x4f, 0xbA, 0x66, 0x6a, - 0x33, 0xd3, 0x75, 0x92, 0xfA, 0x26, 0x33, 0xfD, 0x49, 0xa7, 0x4D, 0xD9, 0x3a, 0x88, -]; - #[derive(Accounts)] pub struct Initialize<'info> { #[account(mut)] @@ -45,10 +33,11 @@ pub struct Initialize<'info> { #[account( seeds = [ token_bridge::WrappedMint::SEED_PREFIX, - &TBTC_FOREIGN_TOKEN_CHAIN.to_be_bytes(), - TBTC_FOREIGN_TOKEN_ADDRESS.as_ref() + &TBTC_ETHEREUM_TOKEN_CHAIN.to_be_bytes(), + TBTC_ETHEREUM_TOKEN_ADDRESS.as_ref() ], - bump + bump, + seeds::program = token_bridge::program::ID )] wrapped_tbtc_mint: Account<'info, token::Mint>, @@ -56,7 +45,7 @@ pub struct Initialize<'info> { init, payer = authority, token::mint = wrapped_tbtc_mint, - token::authority = authority, + token::authority = custodian, seeds = [b"wrapped-token"], bump )] @@ -70,30 +59,22 @@ pub struct Initialize<'info> { )] token_bridge_sender: AccountInfo<'info>, - /// CHECK: This account is needed for the Token Bridge program. This PDA is specifically used to - /// sign for transferring via Token Bridge program with a message. - #[account( - seeds = [token_bridge::SEED_PREFIX_REDEEMER], - bump, - )] - token_bridge_redeemer: AccountInfo<'info>, - system_program: Program<'info, System>, token_program: Program<'info, token::Token>, } pub fn initialize(ctx: Context, minting_limit: u64) -> Result<()> { ctx.accounts.custodian.set_inner(Custodian { - bump: ctx.bumps["config"], + bump: ctx.bumps["custodian"], authority: ctx.accounts.authority.key(), + pending_authority: None, tbtc_mint: ctx.accounts.tbtc_mint.key(), wrapped_tbtc_mint: ctx.accounts.wrapped_tbtc_mint.key(), wrapped_tbtc_token: ctx.accounts.wrapped_tbtc_token.key(), token_bridge_sender: ctx.accounts.token_bridge_sender.key(), token_bridge_sender_bump: ctx.bumps["token_bridge_sender"], - token_bridge_redeemer: ctx.accounts.token_bridge_sender.key(), - token_bridge_redeemer_bump: ctx.bumps["token_bridge_redeemer"], minting_limit, + minted_amount: 0, }); Ok(()) diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/mod.rs new file mode 100644 index 000000000..a4c9400e1 --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/mod.rs @@ -0,0 +1,17 @@ +mod cancel_authority_change; +pub use cancel_authority_change::*; + +mod change_authority; +pub use change_authority::*; + +mod initialize; +pub use initialize::*; + +mod take_authority; +pub use take_authority::*; + +mod update_gateway_address; +pub use update_gateway_address::*; + +mod update_minting_limit; +pub use update_minting_limit::*; diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/take_authority.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/take_authority.rs new file mode 100644 index 000000000..e239b4dca --- /dev/null +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/take_authority.rs @@ -0,0 +1,38 @@ +use crate::{error::WormholeGatewayError, state::Custodian}; +use anchor_lang::prelude::*; + +#[derive(Accounts)] +pub struct TakeAuthority<'info> { + #[account( + mut, + seeds = [Custodian::SEED_PREFIX], + bump, + )] + custodian: Account<'info, Custodian>, + + pending_authority: Signer<'info>, +} + +impl<'info> TakeAuthority<'info> { + fn constraints(ctx: &Context) -> Result<()> { + match ctx.accounts.custodian.pending_authority { + Some(pending_authority) => { + require_keys_eq!( + pending_authority, + ctx.accounts.pending_authority.key(), + WormholeGatewayError::IsNotPendingAuthority + ); + + Ok(()) + } + None => err!(WormholeGatewayError::NoPendingAuthorityChange), + } + } +} + +#[access_control(TakeAuthority::constraints(&ctx))] +pub fn take_authority(ctx: Context) -> Result<()> { + ctx.accounts.custodian.authority = ctx.accounts.pending_authority.key(); + ctx.accounts.custodian.pending_authority = None; + Ok(()) +} diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/update_gateway_address.rs similarity index 88% rename from cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs rename to cross-chain/solana/programs/wormhole-gateway/src/processor/admin/update_gateway_address.rs index 6fcfbfed2..7b62dd521 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_gateway_address.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/update_gateway_address.rs @@ -39,12 +39,17 @@ pub fn update_gateway_address( ctx: Context, args: UpdateGatewayAddressArgs, ) -> Result<()> { - let UpdateGatewayAddressArgs { address, .. } = args; + let UpdateGatewayAddressArgs { chain, address } = args; ctx.accounts.gateway_info.set_inner(GatewayInfo { bump: ctx.bumps["gateway_info"], address, }); + emit!(crate::event::GatewayAddressUpdated { + chain, + gateway: address + }); + Ok(()) } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/update_minting_limit.rs similarity index 86% rename from cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs rename to cross-chain/solana/programs/wormhole-gateway/src/processor/admin/update_minting_limit.rs index b52b72df4..c86bc4194 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/update_minting_limit.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/admin/update_minting_limit.rs @@ -16,5 +16,10 @@ pub struct UpdateMintingLimit<'info> { pub fn update_minting_limit(ctx: Context, new_limit: u64) -> Result<()> { ctx.accounts.custodian.minting_limit = new_limit; + + emit!(crate::event::MintingLimitUpdated { + minting_limit: new_limit + }); + Ok(()) } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs index 28ccdc59a..a181c7889 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/deposit_wormhole_tbtc.rs @@ -7,6 +7,7 @@ use anchor_spl::token; pub struct DepositWormholeTbtc<'info> { /// NOTE: This account also acts as a minter for the TBTC program. #[account( + mut, seeds = [Custodian::SEED_PREFIX], bump = custodian.bump, has_one = wrapped_tbtc_token, @@ -51,7 +52,7 @@ pub struct DepositWormholeTbtc<'info> { tbtc_config: UncheckedAccount<'info>, /// CHECK: TBTC program requires this account. - minter_info: UncheckedAccount<'info>, + tbtc_minter_info: UncheckedAccount<'info>, token_program: Program<'info, token::Token>, tbtc_program: Program<'info, tbtc::Tbtc>, @@ -59,9 +60,15 @@ pub struct DepositWormholeTbtc<'info> { impl<'info> DepositWormholeTbtc<'info> { fn constraints(ctx: &Context, amount: u64) -> Result<()> { - require_gt!( + let updated_minted_amount = ctx + .accounts + .custodian + .minted_amount + .checked_add(amount) + .ok_or(WormholeGatewayError::MintedAmountOverflow)?; + require_gte!( ctx.accounts.custodian.minting_limit, - ctx.accounts.tbtc_mint.supply.saturating_add(amount), + updated_minted_amount, WormholeGatewayError::MintingLimitExceeded ); @@ -84,6 +91,9 @@ pub fn deposit_wormhole_tbtc(ctx: Context, amount: u64) -> amount, )?; + // Account for minted amount. + ctx.accounts.custodian.minted_amount += amount; + let custodian = &ctx.accounts.custodian; // Now mint. @@ -93,7 +103,7 @@ pub fn deposit_wormhole_tbtc(ctx: Context, amount: u64) -> tbtc::cpi::accounts::Mint { mint: ctx.accounts.tbtc_mint.to_account_info(), config: ctx.accounts.tbtc_config.to_account_info(), - minter_info: ctx.accounts.minter_info.to_account_info(), + minter_info: ctx.accounts.tbtc_minter_info.to_account_info(), minter: custodian.to_account_info(), recipient_token: ctx.accounts.recipient_token.to_account_info(), token_program: ctx.accounts.token_program.to_account_info(), diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs index 8948c9b82..2744a62ea 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/mod.rs @@ -1,17 +1,11 @@ +mod admin; +pub use admin::*; + mod deposit_wormhole_tbtc; pub use deposit_wormhole_tbtc::*; -mod initialize; -pub use initialize::*; - -// mod receive_tbtc; -// pub use receive_tbtc::*; +mod receive_tbtc; +pub use receive_tbtc::*; mod send_tbtc; pub use send_tbtc::*; - -mod update_gateway_address; -pub use update_gateway_address::*; - -mod update_minting_limit; -pub use update_minting_limit::*; diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs index b3cc68d83..e5df5ab85 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/receive_tbtc.rs @@ -1,77 +1,251 @@ -use crate::state::Custodian; +use crate::{ + constants::{TBTC_ETHEREUM_TOKEN_ADDRESS, TBTC_ETHEREUM_TOKEN_CHAIN}, + error::WormholeGatewayError, + state::Custodian, +}; use anchor_lang::prelude::*; -use anchor_spl::token; +use anchor_spl::{associated_token, token}; +use wormhole_anchor_sdk::{ + token_bridge::{self, program::TokenBridge}, + wormhole::{self as core_bridge, program::Wormhole as CoreBridge}, +}; #[derive(Accounts)] +#[instruction(message_hash: [u8; 32])] pub struct ReceiveTbtc<'info> { #[account(mut)] payer: Signer<'info>, - /// NOTE: This account also acts as a minter for the TBTC program. #[account( + mut, seeds = [Custodian::SEED_PREFIX], bump = custodian.bump, has_one = wrapped_tbtc_token, has_one = wrapped_tbtc_mint, - has_one = tbtc_mint, + has_one = tbtc_mint )] custodian: Account<'info, Custodian>, - // TODO: posted_vaa + #[account( + seeds = [core_bridge::SEED_PREFIX_POSTED_VAA, &message_hash], + bump, + seeds::program = core_bridge_program + )] + posted_vaa: Box>>, + + /// CHECK: This claim account is created by the Token Bridge program when it redeems its inbound + /// transfer. By checking whether this account exists is a short-circuit way of bailing out + /// early if this transfer has already been redeemed (as opposed to letting the Token Bridge + /// instruction fail). #[account(mut)] - tbtc_mint: Account<'info, token::Mint>, + token_bridge_claim: AccountInfo<'info>, - /// CHECK: This account is needed fot the TBTC program. - tbtc_config: UncheckedAccount<'info>, + /// Custody account. + #[account(mut)] + wrapped_tbtc_token: Box>, - /// CHECK: This account is needed fot the TBTC program. - minter_info: UncheckedAccount<'info>, + /// This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the + /// custodian account. + #[account(mut)] + wrapped_tbtc_mint: Box>, + + #[account(mut)] + tbtc_mint: Box>, - // Use the associated token account for the recipient. + /// Token account for minted tBTC. + /// + /// NOTE: Because the recipient is encoded in the transfer message payload, we can check the + /// authority from the deserialized VAA. But we should still check whether the authority is the + /// zero address in access control. #[account( - associated_token::mint = tbtc_mint, - associated_token::authority = recipient, + mut, + token::mint = tbtc_mint, + token::authority = recipient, )] - pub recipient_account: Account<'info, token::TokenAccount>, + recipient_token: Box>, - /// CHECK: the recipient doesn't need to sign the mint, - /// and it doesn't conform to any specific rules. - /// Validating the recipient is the minter's responsibility. + /// CHECK: This account needs to be in the context in case an associated token account needs to + /// be created for him. + #[account(address = Pubkey::from(*posted_vaa.data().message()))] recipient: AccountInfo<'info>, + + /// CHECK: This account exists just in case the minting limit is breached after this transfer. + /// The gateway will create an associated token account for the recipient if it doesn't exist. + /// + /// NOTE: When the minting limit increases, the recipient can use this token account to mint + /// tBTC using the deposit_wormhole_tbtc instruction. + #[account( + mut, + address = associated_token::get_associated_token_address( + &recipient.key(), + &wrapped_tbtc_mint.key() + ), + )] + recipient_wrapped_token: AccountInfo<'info>, + + /// CHECK: This account is needed for the TBTC program. + tbtc_config: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the TBTC program. + tbtc_minter_info: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_config: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_registered_emitter: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_wrapped_asset: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + token_bridge_mint_authority: UncheckedAccount<'info>, + + /// CHECK: This account is needed for the Token Bridge program. + rent: UncheckedAccount<'info>, + + tbtc_program: Program<'info, tbtc::Tbtc>, + token_bridge_program: Program<'info, TokenBridge>, + core_bridge_program: Program<'info, CoreBridge>, + associated_token_program: Program<'info, associated_token::AssociatedToken>, + token_program: Program<'info, token::Token>, + system_program: Program<'info, System>, } -pub fn receive_tbtc(ctx: Context) -> Result<()> { - // get balance delta +impl<'info> ReceiveTbtc<'info> { + fn constraints(ctx: &Context) -> Result<()> { + // Check if transfer has already been claimed. + require!( + ctx.accounts.token_bridge_claim.data_is_empty(), + WormholeGatewayError::TransferAlreadyRedeemed + ); - let amount = _; + // Token info must match Ethereum's canonical tBTC token info. + let transfer = ctx.accounts.posted_vaa.data(); + require!( + transfer.token_chain() == TBTC_ETHEREUM_TOKEN_CHAIN + && *transfer.token_address() == TBTC_ETHEREUM_TOKEN_ADDRESS, + WormholeGatewayError::InvalidEthereumTbtc + ); - let minted_amount = ctx.accounts.wormhole_gateway.minted_amount; - let minting_limit = ctx.accounts.wormhole_gateway.minting_limit; + // There must be an encoded amount. + require_gt!( + transfer.amount(), + 0, + WormholeGatewayError::NoTbtcTransferred + ); - if (minted_amount + amount > minting_limit) { - // transfer bridge token - } else { - ctx.accounts.wormhole_gateway.minted_amount += amount; - - let seed_prefix = Config::SEED_PREFIX; - let key_seed = ctx.accounts.wormhole_gateway.key(); - let gateway_bump = ctx.accounts.wormhole_gateway.self_bump; - - let signer: &[&[&[u8]]] = &[&[seed_prefix, key_seed.as_ref(), &[gateway_bump]]]; - - let mint_cpi_ctx = CpiContext::new_with_signer( - ctx.accounts.tbtc.to_account_info(), - tbtc::Mint { - tbtc_mint: ctx.accounts.tbtc_mint.to_account_info(), - tbtc: ctx.accounts.tbtc.to_account_info(), - minter_info: ctx.accounts.minter_info.to_account_info(), - minter: ctx.accounts.wormhole_gateway.to_account_info(), - recipient_account: ctx.accounts.recipient_account.to_account_info(), - recipient: ctx.accounts.recipient.to_account_info(), - payer: ctx.accounts.payer.to_account_info(), - }, - signer, + // Recipient must not be zero address. + require_keys_neq!( + ctx.accounts.recipient.key(), + Pubkey::default(), + WormholeGatewayError::RecipientZeroAddress ); - tbtc::mint(mint_cpi_ctx, amount) + + Ok(()) + } +} + +#[access_control(ReceiveTbtc::constraints(&ctx))] +pub fn receive_tbtc(ctx: Context, _message_hash: [u8; 32]) -> Result<()> { + let wrapped_tbtc_token = &ctx.accounts.wrapped_tbtc_token; + let wrapped_tbtc_mint = &ctx.accounts.wrapped_tbtc_mint; + + // Redeem the token transfer. + token_bridge::complete_transfer_wrapped_with_payload(CpiContext::new_with_signer( + ctx.accounts.token_bridge_program.to_account_info(), + token_bridge::CompleteTransferWrappedWithPayload { + payer: ctx.accounts.payer.to_account_info(), + config: ctx.accounts.token_bridge_config.to_account_info(), + vaa: ctx.accounts.posted_vaa.to_account_info(), + claim: ctx.accounts.token_bridge_claim.to_account_info(), + foreign_endpoint: ctx + .accounts + .token_bridge_registered_emitter + .to_account_info(), + to: wrapped_tbtc_token.to_account_info(), + redeemer: ctx.accounts.custodian.to_account_info(), + wrapped_mint: wrapped_tbtc_mint.to_account_info(), + wrapped_metadata: ctx.accounts.token_bridge_wrapped_asset.to_account_info(), + mint_authority: ctx.accounts.token_bridge_mint_authority.to_account_info(), + rent: ctx.accounts.rent.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + token_program: ctx.accounts.token_program.to_account_info(), + wormhole_program: ctx.accounts.core_bridge_program.to_account_info(), + }, + &[&[ + token_bridge::SEED_PREFIX_REDEEMER, + &[ctx.accounts.custodian.bump], + ]], + ))?; + + // Because we are working with wrapped token amounts, we can take the amount as-is and determine + // whether to mint or transfer based on the minting limit. + let amount = ctx.accounts.posted_vaa.data().amount(); + let recipient = &ctx.accounts.recipient; + + emit!(crate::event::WormholeTbtcReceived { + receiver: recipient.key(), + amount + }); + + let updated_minted_amount = ctx.accounts.custodian.minted_amount.saturating_add(amount); + let custodian_seeds = &[Custodian::SEED_PREFIX, &[ctx.accounts.custodian.bump]]; + + // We send Wormhole tBTC OR mint canonical tBTC. We do not want to send dust. Sending Wormhole + // tBTC is an exceptional situation and we want to keep it simple. + if updated_minted_amount > ctx.accounts.custodian.minting_limit { + msg!("Insufficient minted amount. Sending Wormhole tBTC instead"); + + let ata = &ctx.accounts.recipient_wrapped_token; + + // Create associated token account for recipient if it doesn't exist already. + if ata.data_is_empty() { + associated_token::create(CpiContext::new( + ctx.accounts.associated_token_program.to_account_info(), + associated_token::Create { + payer: ctx.accounts.payer.to_account_info(), + associated_token: ata.to_account_info(), + authority: recipient.to_account_info(), + mint: wrapped_tbtc_mint.to_account_info(), + token_program: ctx.accounts.token_program.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + }, + ))?; + } + + // Finally transfer. + token::transfer( + CpiContext::new_with_signer( + ctx.accounts.token_program.to_account_info(), + token::Transfer { + from: wrapped_tbtc_token.to_account_info(), + to: ata.to_account_info(), + authority: ctx.accounts.custodian.to_account_info(), + }, + &[custodian_seeds], + ), + amount, + ) + } else { + // The function is non-reentrant given bridge.completeTransferWithPayload + // call that does not allow to use the same VAA again. + ctx.accounts.custodian.minted_amount = updated_minted_amount; + + tbtc::cpi::mint( + CpiContext::new_with_signer( + ctx.accounts.tbtc_program.to_account_info(), + tbtc::cpi::accounts::Mint { + mint: ctx.accounts.tbtc_mint.to_account_info(), + config: ctx.accounts.tbtc_config.to_account_info(), + minter_info: ctx.accounts.tbtc_minter_info.to_account_info(), + minter: ctx.accounts.custodian.to_account_info(), + recipient_token: ctx.accounts.recipient_token.to_account_info(), + token_program: ctx.accounts.token_program.to_account_info(), + }, + &[custodian_seeds], + ), + amount, + ) } } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs index babd8a490..0802a9e7c 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/gateway.rs @@ -1,4 +1,7 @@ -use crate::state::{Custodian, GatewayInfo}; +use crate::{ + constants::MSG_SEED_PREFIX, + state::{Custodian, GatewayInfo}, +}; use anchor_lang::prelude::*; use anchor_spl::token; use wormhole_anchor_sdk::{ @@ -10,6 +13,7 @@ use wormhole_anchor_sdk::{ #[instruction(args: SendTbtcGatewayArgs)] pub struct SendTbtcGateway<'info> { #[account( + mut, seeds = [Custodian::SEED_PREFIX], bump = custodian.bump, has_one = wrapped_tbtc_token, @@ -26,9 +30,11 @@ pub struct SendTbtcGateway<'info> { gateway_info: Account<'info, GatewayInfo>, /// Custody account. + #[account(mut)] wrapped_tbtc_token: Box>, /// CHECK: This account is needed for the Token Bridge program. + #[account(mut)] wrapped_tbtc_mint: UncheckedAccount<'info>, #[account(mut)] @@ -55,12 +61,15 @@ pub struct SendTbtcGateway<'info> { /// CHECK: This account is needed for the Token Bridge program. #[account(mut)] - core_bridge: UncheckedAccount<'info>, + core_bridge_data: UncheckedAccount<'info>, /// CHECK: This account is needed for the Token Bridge program. #[account( mut, - seeds = [b"msg", &core_emitter_sequence.value().to_le_bytes()], + seeds = [ + MSG_SEED_PREFIX, + &core_emitter_sequence.value().to_le_bytes() + ], bump, )] core_message: AccountInfo<'info>, @@ -120,16 +129,17 @@ pub fn send_tbtc_gateway(ctx: Context, args: SendTbtcGatewayArg } = args; let sender = &ctx.accounts.sender; - let custodian = &ctx.accounts.custodian; let wrapped_tbtc_token = &ctx.accounts.wrapped_tbtc_token; let token_bridge_transfer_authority = &ctx.accounts.token_bridge_transfer_authority; let token_program = &ctx.accounts.token_program; + let gateway = ctx.accounts.gateway_info.address; + // Prepare for wrapped tBTC transfer (this method also truncates the amount to prevent having to // handle dust since tBTC has >8 decimals). - let amount = super::burn_and_prepare_transfer( + super::burn_and_prepare_transfer( super::PrepareTransfer { - custodian, + custodian: &mut ctx.accounts.custodian, tbtc_mint: &ctx.accounts.tbtc_mint, sender_token: &ctx.accounts.sender_token, sender, @@ -138,8 +148,15 @@ pub fn send_tbtc_gateway(ctx: Context, args: SendTbtcGatewayArg token_program, }, amount, + recipient_chain, + Some(gateway), + recipient, + None, // arbiter_fee + nonce, )?; + let custodian = &ctx.accounts.custodian; + // Finally transfer wrapped tBTC with the recipient encoded as this transfer's message. token_bridge::transfer_wrapped_with_payload( CpiContext::new_with_signer( @@ -152,7 +169,7 @@ pub fn send_tbtc_gateway(ctx: Context, args: SendTbtcGatewayArg wrapped_mint: ctx.accounts.wrapped_tbtc_mint.to_account_info(), wrapped_metadata: ctx.accounts.token_bridge_wrapped_asset.to_account_info(), authority_signer: token_bridge_transfer_authority.to_account_info(), - wormhole_bridge: ctx.accounts.core_bridge.to_account_info(), + wormhole_bridge: ctx.accounts.core_bridge_data.to_account_info(), wormhole_message: ctx.accounts.core_message.to_account_info(), wormhole_emitter: ctx.accounts.token_bridge_core_emitter.to_account_info(), wormhole_sequence: ctx.accounts.core_emitter_sequence.to_account_info(), @@ -171,7 +188,7 @@ pub fn send_tbtc_gateway(ctx: Context, args: SendTbtcGatewayArg &[ctx.accounts.custodian.token_bridge_sender_bump], ], &[ - b"msg", + MSG_SEED_PREFIX, &ctx.accounts.core_emitter_sequence.value().to_le_bytes(), &[ctx.bumps["core_message"]], ], @@ -179,7 +196,7 @@ pub fn send_tbtc_gateway(ctx: Context, args: SendTbtcGatewayArg ), nonce, amount, - ctx.accounts.gateway_info.address, + gateway, recipient_chain, recipient.to_vec(), &crate::ID, diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs index a1b89550f..aa79c836a 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/mod.rs @@ -28,7 +28,7 @@ pub fn validate_send( } pub struct PrepareTransfer<'ctx, 'info> { - custodian: &'ctx Account<'info, Custodian>, + custodian: &'ctx mut Account<'info, Custodian>, tbtc_mint: &'ctx Account<'info, token::Mint>, sender_token: &'ctx Account<'info, token::TokenAccount>, sender: &'ctx Signer<'info>, @@ -37,7 +37,15 @@ pub struct PrepareTransfer<'ctx, 'info> { token_program: &'ctx Program<'info, token::Token>, } -pub fn burn_and_prepare_transfer(prepare_transfer: PrepareTransfer, amount: u64) -> Result { +pub fn burn_and_prepare_transfer( + prepare_transfer: PrepareTransfer, + amount: u64, + recipient_chain: u16, + gateway: Option<[u8; 32]>, + recipient: [u8; 32], + arbiter_fee: Option, + nonce: u32, +) -> Result<()> { let PrepareTransfer { custodian, tbtc_mint, @@ -48,8 +56,11 @@ pub fn burn_and_prepare_transfer(prepare_transfer: PrepareTransfer, amount: u64) token_program, } = prepare_transfer; - let truncated = 10 * (amount / 10); - require_gt!(truncated, 0, WormholeGatewayError::TruncatedZeroAmount); + // Account for burning tBTC. + custodian.minted_amount = custodian + .minted_amount + .checked_sub(amount) + .ok_or(WormholeGatewayError::MintedAmountUnderflow)?; // Burn TBTC mint. token::burn( @@ -64,6 +75,15 @@ pub fn burn_and_prepare_transfer(prepare_transfer: PrepareTransfer, amount: u64) amount, )?; + emit!(crate::event::WormholeTbtcSent { + amount, + recipient_chain, + gateway: gateway.unwrap_or_default(), + recipient, + arbiter_fee: arbiter_fee.unwrap_or_default(), + nonce + }); + // Delegate authority to Token Bridge's transfer authority. token::approve( CpiContext::new_with_signer( @@ -75,8 +95,6 @@ pub fn burn_and_prepare_transfer(prepare_transfer: PrepareTransfer, amount: u64) }, &[&[Custodian::SEED_PREFIX, &[custodian.bump]]], ), - truncated, - )?; - - Ok(truncated) + amount, + ) } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs index 37ba459c5..99f26a1b0 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/processor/send_tbtc/wrapped.rs @@ -1,5 +1,5 @@ -use crate::state::Custodian; -use anchor_lang::{prelude::*, solana_program}; +use crate::{constants::MSG_SEED_PREFIX, state::Custodian}; +use anchor_lang::prelude::*; use anchor_spl::token; use wormhole_anchor_sdk::{ token_bridge::{self, program::TokenBridge}, @@ -10,6 +10,7 @@ use wormhole_anchor_sdk::{ #[instruction(args: SendTbtcWrappedArgs)] pub struct SendTbtcWrapped<'info> { #[account( + mut, seeds = [Custodian::SEED_PREFIX], bump = custodian.bump, has_one = wrapped_tbtc_token, @@ -19,9 +20,11 @@ pub struct SendTbtcWrapped<'info> { custodian: Account<'info, Custodian>, /// Custody account. + #[account(mut)] wrapped_tbtc_token: Box>, /// CHECK: This account is needed for the Token Bridge program. + #[account(mut)] wrapped_tbtc_mint: UncheckedAccount<'info>, #[account(mut)] @@ -48,13 +51,16 @@ pub struct SendTbtcWrapped<'info> { /// CHECK: This account is needed for the Token Bridge program. #[account(mut)] - core_bridge: UncheckedAccount<'info>, + core_bridge_data: UncheckedAccount<'info>, /// CHECK: This account is needed for the Token Bridge program. #[account( mut, - seeds = [b"msg", &core_emitter_sequence.value().to_le_bytes()], - bump, + seeds = [ + MSG_SEED_PREFIX, + &core_emitter_sequence.value().to_le_bytes() + ], + bump )] core_message: AccountInfo<'info>, @@ -111,15 +117,14 @@ pub fn send_tbtc_wrapped(ctx: Context, args: SendTbtcWrappedArg } = args; let sender = &ctx.accounts.sender; - let custodian = &ctx.accounts.custodian; let wrapped_tbtc_token = &ctx.accounts.wrapped_tbtc_token; let token_bridge_transfer_authority = &ctx.accounts.token_bridge_transfer_authority; let token_program = &ctx.accounts.token_program; // Prepare for wrapped tBTC transfer. - let amount = super::burn_and_prepare_transfer( + super::burn_and_prepare_transfer( super::PrepareTransfer { - custodian, + custodian: &mut ctx.accounts.custodian, tbtc_mint: &ctx.accounts.tbtc_mint, sender_token: &ctx.accounts.sender_token, sender, @@ -128,52 +133,51 @@ pub fn send_tbtc_wrapped(ctx: Context, args: SendTbtcWrappedArg token_program, }, amount, + recipient_chain, + None, // gateway + recipient, + Some(arbiter_fee), + nonce, )?; - // Because the wormhole-anchor-sdk does not support relayable transfers (i.e. payload ID == 1), - // we need to construct the instruction from scratch and invoke it. - let ix = solana_program::instruction::Instruction { - program_id: ctx.accounts.token_bridge_program.key(), - accounts: vec![ - AccountMeta::new(sender.key(), true), - AccountMeta::new_readonly(ctx.accounts.token_bridge_config.key(), false), - AccountMeta::new(wrapped_tbtc_token.key(), false), - AccountMeta::new_readonly(custodian.key(), false), - AccountMeta::new(ctx.accounts.wrapped_tbtc_mint.key(), false), - AccountMeta::new_readonly(ctx.accounts.token_bridge_wrapped_asset.key(), false), - AccountMeta::new_readonly(token_bridge_transfer_authority.key(), false), - AccountMeta::new(ctx.accounts.core_bridge.key(), false), - AccountMeta::new(ctx.accounts.core_message.key(), true), - AccountMeta::new_readonly(ctx.accounts.token_bridge_core_emitter.key(), false), - AccountMeta::new(ctx.accounts.core_emitter_sequence.key(), false), - AccountMeta::new(ctx.accounts.core_fee_collector.key(), false), - AccountMeta::new_readonly(ctx.accounts.clock.key(), false), - AccountMeta::new_readonly(ctx.accounts.rent.key(), false), - AccountMeta::new_readonly(ctx.accounts.system_program.key(), false), - AccountMeta::new_readonly(ctx.accounts.core_bridge_program.key(), false), - AccountMeta::new_readonly(token_program.key(), false), - ], - data: token_bridge::Instruction::TransferWrapped { - batch_id: nonce, - amount, - fee: arbiter_fee, - recipient_address: recipient, - recipient_chain, - } - .try_to_vec()?, - }; - - solana_program::program::invoke_signed( - &ix, - &ctx.accounts.to_account_infos(), - &[ - &[Custodian::SEED_PREFIX, &[custodian.bump]], + let custodian = &ctx.accounts.custodian; + + // Finally transfer wrapped tBTC to the recipient. + token_bridge::transfer_wrapped( + CpiContext::new_with_signer( + ctx.accounts.token_bridge_program.to_account_info(), + token_bridge::TransferWrapped { + payer: sender.to_account_info(), + config: ctx.accounts.token_bridge_config.to_account_info(), + from: wrapped_tbtc_token.to_account_info(), + from_owner: custodian.to_account_info(), + wrapped_mint: ctx.accounts.wrapped_tbtc_mint.to_account_info(), + wrapped_metadata: ctx.accounts.token_bridge_wrapped_asset.to_account_info(), + authority_signer: token_bridge_transfer_authority.to_account_info(), + wormhole_bridge: ctx.accounts.core_bridge_data.to_account_info(), + wormhole_message: ctx.accounts.core_message.to_account_info(), + wormhole_emitter: ctx.accounts.token_bridge_core_emitter.to_account_info(), + wormhole_sequence: ctx.accounts.core_emitter_sequence.to_account_info(), + wormhole_fee_collector: ctx.accounts.core_fee_collector.to_account_info(), + clock: ctx.accounts.clock.to_account_info(), + rent: ctx.accounts.rent.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + token_program: token_program.to_account_info(), + wormhole_program: ctx.accounts.core_bridge_program.to_account_info(), + }, &[ - b"msg", - &ctx.accounts.core_emitter_sequence.value().to_le_bytes(), - &[ctx.bumps["core_message"]], + &[Custodian::SEED_PREFIX, &[custodian.bump]], + &[ + MSG_SEED_PREFIX, + &ctx.accounts.core_emitter_sequence.value().to_le_bytes(), + &[ctx.bumps["core_message"]], + ], ], - ], + ), + nonce, + amount, + arbiter_fee, + recipient, + recipient_chain, ) - .map_err(Into::into) } diff --git a/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs b/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs index 72882128d..15a545f43 100644 --- a/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs +++ b/cross-chain/solana/programs/wormhole-gateway/src/state/custodian.rs @@ -1,22 +1,25 @@ use anchor_lang::prelude::*; +use wormhole_anchor_sdk::token_bridge; #[account] #[derive(Debug, InitSpace)] pub struct Custodian { pub bump: u8, pub authority: Pubkey, + pub pending_authority: Option, pub tbtc_mint: Pubkey, pub wrapped_tbtc_mint: Pubkey, pub wrapped_tbtc_token: Pubkey, pub token_bridge_sender: Pubkey, pub token_bridge_sender_bump: u8, - pub token_bridge_redeemer: Pubkey, - pub token_bridge_redeemer_bump: u8, - pub minting_limit: u64, + pub minted_amount: u64, } impl Custodian { - pub const SEED_PREFIX: &'static [u8] = b"custodian"; + /// Due to the Token Bridge requiring the redeemer PDA be the owner of the token account for + /// completing transfers with payload, we are conveniently having the Custodian's PDA address + /// derived as this redeemer. + pub const SEED_PREFIX: &'static [u8] = token_bridge::SEED_PREFIX_REDEEMER; } From 79885a19f219a2f5f4512fb4f76960f52fbb644b Mon Sep 17 00:00:00 2001 From: A5 Pickle Date: Mon, 7 Aug 2023 09:22:13 -0500 Subject: [PATCH 054/205] solana: fix tests to reflect program changes Co-authored-by: gator-boi --- cross-chain/solana/package-lock.json | 100 ++ cross-chain/solana/package.json | 1 + cross-chain/solana/tests/01__tbtc.ts | 1493 +++++++++-------- .../solana/tests/02__wormholeGateway.ts | 1294 +++++++++++++- ...core_bridge.json => core_bridge_data.json} | 0 .../tests/accounts/core_fee_collector.json | 2 +- cross-chain/solana/tests/helpers/consts.ts | 50 + cross-chain/solana/tests/helpers/index.ts | 2 + cross-chain/solana/tests/helpers/tbtc.ts | 510 ++++++ cross-chain/solana/tests/helpers/utils.ts | 327 +++- .../solana/tests/helpers/wormholeGateway.ts | 809 +++++++++ 11 files changed, 3758 insertions(+), 830 deletions(-) rename cross-chain/solana/tests/accounts/{core_bridge.json => core_bridge_data.json} (100%) create mode 100644 cross-chain/solana/tests/helpers/consts.ts create mode 100644 cross-chain/solana/tests/helpers/index.ts create mode 100644 cross-chain/solana/tests/helpers/tbtc.ts create mode 100644 cross-chain/solana/tests/helpers/wormholeGateway.ts diff --git a/cross-chain/solana/package-lock.json b/cross-chain/solana/package-lock.json index ddcd6cb2d..caf320a81 100644 --- a/cross-chain/solana/package-lock.json +++ b/cross-chain/solana/package-lock.json @@ -9,6 +9,7 @@ }, "devDependencies": { "@certusone/wormhole-sdk": "^0.9.22", + "@metaplex-foundation/mpl-token-metadata": "^2.13.0", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.77.3", "@types/bn.js": "^5.1.0", @@ -1602,6 +1603,99 @@ "rlp": "^2.2.3" } }, + "node_modules/@metaplex-foundation/beet": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@metaplex-foundation/beet/-/beet-0.7.1.tgz", + "integrity": "sha512-hNCEnS2WyCiYyko82rwuISsBY3KYpe828ubsd2ckeqZr7tl0WVLivGkoyA/qdiaaHEBGdGl71OpfWa2rqL3DiA==", + "dev": true, + "dependencies": { + "ansicolors": "^0.3.2", + "bn.js": "^5.2.0", + "debug": "^4.3.3" + } + }, + "node_modules/@metaplex-foundation/beet-solana": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@metaplex-foundation/beet-solana/-/beet-solana-0.4.0.tgz", + "integrity": "sha512-B1L94N3ZGMo53b0uOSoznbuM5GBNJ8LwSeznxBxJ+OThvfHQ4B5oMUqb+0zdLRfkKGS7Q6tpHK9P+QK0j3w2cQ==", + "dev": true, + "dependencies": { + "@metaplex-foundation/beet": ">=0.1.0", + "@solana/web3.js": "^1.56.2", + "bs58": "^5.0.0", + "debug": "^4.3.4" + } + }, + "node_modules/@metaplex-foundation/beet-solana/node_modules/base-x": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.0.tgz", + "integrity": "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==", + "dev": true + }, + "node_modules/@metaplex-foundation/beet-solana/node_modules/bs58": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz", + "integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==", + "dev": true, + "dependencies": { + "base-x": "^4.0.0" + } + }, + "node_modules/@metaplex-foundation/beet-solana/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@metaplex-foundation/cusper": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@metaplex-foundation/cusper/-/cusper-0.0.2.tgz", + "integrity": "sha512-S9RulC2fFCFOQraz61bij+5YCHhSO9llJegK8c8Y6731fSi6snUSQJdCUqYS8AIgR0TKbQvdvgSyIIdbDFZbBA==", + "dev": true + }, + "node_modules/@metaplex-foundation/mpl-token-metadata": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/@metaplex-foundation/mpl-token-metadata/-/mpl-token-metadata-2.13.0.tgz", + "integrity": "sha512-Fl/8I0L9rv4bKTV/RAl5YIbJe9SnQPInKvLz+xR1fEc4/VQkuCn3RPgypfUMEKWmCznzaw4sApDxy6CFS4qmJw==", + "dev": true, + "dependencies": { + "@metaplex-foundation/beet": "^0.7.1", + "@metaplex-foundation/beet-solana": "^0.4.0", + "@metaplex-foundation/cusper": "^0.0.2", + "@solana/spl-token": "^0.3.6", + "@solana/web3.js": "^1.66.2", + "bn.js": "^5.2.0", + "debug": "^4.3.4" + } + }, + "node_modules/@metaplex-foundation/mpl-token-metadata/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/@mysten/bcs": { "version": "0.7.1", "dev": true, @@ -2222,6 +2316,12 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/ansicolors": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/ansicolors/-/ansicolors-0.3.2.tgz", + "integrity": "sha512-QXu7BPrP29VllRxH8GwB7x5iX5qWKAAMLqKQGWTeLWVlNHNOpVMJ91dsxQAIWXpjuW5wqvxu3Jd/nRjrJ+0pqg==", + "dev": true + }, "node_modules/anymatch": { "version": "3.1.3", "dev": true, diff --git a/cross-chain/solana/package.json b/cross-chain/solana/package.json index a18adfd59..ea15b6a98 100644 --- a/cross-chain/solana/package.json +++ b/cross-chain/solana/package.json @@ -8,6 +8,7 @@ }, "devDependencies": { "@certusone/wormhole-sdk": "^0.9.22", + "@metaplex-foundation/mpl-token-metadata": "^2.13.0", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.77.3", "@types/bn.js": "^5.1.0", diff --git a/cross-chain/solana/tests/01__tbtc.ts b/cross-chain/solana/tests/01__tbtc.ts index 0a70e3d93..7d3591ec0 100644 --- a/cross-chain/solana/tests/01__tbtc.ts +++ b/cross-chain/solana/tests/01__tbtc.ts @@ -1,363 +1,17 @@ import * as anchor from "@coral-xyz/anchor"; -import { Program, AnchorError } from "@coral-xyz/anchor"; +import { Program } from "@coral-xyz/anchor"; import * as spl from "@solana/spl-token"; -import * as web3 from '@solana/web3.js'; +import { assert, expect } from "chai"; import { Tbtc } from "../target/types/tbtc"; -import { expect } from 'chai'; -import { ASSOCIATED_PROGRAM_ID } from "@coral-xyz/anchor/dist/cjs/utils/token"; -import { transferLamports } from "./helpers/utils"; - -function maybeAuthorityAnd( - signer, - signers -) { - return signers.concat(signer instanceof (anchor.Wallet as any) ? [] : [signer]); -} - -async function setup( - program: Program, - authority -) { - const [config,] = getConfigPDA(program); - const [tbtcMintPDA, _] = getTokenPDA(program); - - await program.methods - .initialize() - .accounts({ - mint: tbtcMintPDA, - config, - authority: authority.publicKey - }) - .rpc(); -} - -async function checkState( - program: Program, - expectedAuthority, - expectedMinters, - expectedGuardians, - expectedTokensSupply -) { - const [config,] = getConfigPDA(program); - let configState = await program.account.config.fetch(config); - - expect(configState.authority).to.eql(expectedAuthority.publicKey); - expect(configState.numMinters).to.equal(expectedMinters); - expect(configState.numGuardians).to.equal(expectedGuardians); - - let tbtcMint = configState.mint; - - let mintState = await spl.getMint(program.provider.connection, tbtcMint); - - expect(mintState.supply).to.equal(BigInt(expectedTokensSupply)); -} - -async function changeAuthority( - program: Program, - authority, - newAuthority, -) { - const [config,] = getConfigPDA(program); - await program.methods - .changeAuthority() - .accounts({ - config, - authority: authority.publicKey, - newAuthority: newAuthority.publicKey, - }) - .signers(maybeAuthorityAnd(authority, [])) - .rpc(); -} - -async function takeAuthority( - program: Program, - newAuthority, -) { - const [config,] = getConfigPDA(program); - await program.methods - .takeAuthority() - .accounts({ - config, - pendingAuthority: newAuthority.publicKey, - }) - .signers(maybeAuthorityAnd(newAuthority, [])) - .rpc(); -} - -async function cancelAuthorityChange( - program: Program, - authority, -) { - const [config,] = getConfigPDA(program); - await program.methods - .cancelAuthorityChange() - .accounts({ - config, - authority: authority.publicKey, - }) - .signers(maybeAuthorityAnd(authority, [])) - .rpc(); -} - -async function checkPendingAuthority( - program: Program, - pendingAuthority, -) { - const [config,] = getConfigPDA(program); - let configState = await program.account.config.fetch(config); - expect(configState.pendingAuthority).to.eql(pendingAuthority.publicKey); -} - -async function checkNoPendingAuthority( - program: Program, -) { - const [config,] = getConfigPDA(program); - let configState = await program.account.config.fetch(config); - expect(configState.pendingAuthority).to.equal(null); -} - -async function checkPaused( - program: Program, - paused: boolean -) { - const [config,] = getConfigPDA(program); - let configState = await program.account.config.fetch(config); - expect(configState.paused).to.equal(paused); -} - - -function getConfigPDA( - program: Program, -): [anchor.web3.PublicKey, number] { - return web3.PublicKey.findProgramAddressSync( - [ - Buffer.from('config'), - ], - program.programId - ); -} - -function getTokenPDA( - program: Program, -): [anchor.web3.PublicKey, number] { - return web3.PublicKey.findProgramAddressSync( - [ - Buffer.from('tbtc-mint'), - ], - program.programId - ); -} - -function getMinterPDA( - program: Program, - minter -): [anchor.web3.PublicKey, number] { - return web3.PublicKey.findProgramAddressSync( - [ - Buffer.from('minter-info'), - minter.publicKey.toBuffer(), - ], - program.programId - ); -} - -async function addMinter( - program: Program, - authority, - minter, - payer -): Promise { - const [config,] = getConfigPDA(program); - const [minterInfoPDA, _] = getMinterPDA(program, minter); - await program.methods - .addMinter() - .accounts({ - config, - authority: authority.publicKey, - minter: minter.publicKey, - minterInfo: minterInfoPDA, - }) - .signers(maybeAuthorityAnd(authority, [])) - .rpc(); - return minterInfoPDA; -} - -async function checkMinter( - program: Program, - minter -) { - const [minterInfoPDA, bump] = getMinterPDA(program, minter); - let minterInfo = await program.account.minterInfo.fetch(minterInfoPDA); - - expect(minterInfo.minter).to.eql(minter.publicKey); - expect(minterInfo.bump).to.equal(bump); -} - -async function removeMinter( - program: Program, - authority, - minter, - minterInfo -) { - const [config,] = getConfigPDA(program); - await program.methods - .removeMinter() - .accounts({ - config, - authority: authority.publicKey, - minterInfo: minterInfo, - minter: minter.publicKey - }) - .signers(maybeAuthorityAnd(authority, [])) - .rpc(); -} - -function getGuardianPDA( - program: Program, - guardian -): [anchor.web3.PublicKey, number] { - return web3.PublicKey.findProgramAddressSync( - [ - Buffer.from('guardian-info'), - guardian.publicKey.toBuffer(), - ], - program.programId - ); -} - -async function addGuardian( - program: Program, - authority, - guardian, - payer -): Promise { - const [config,] = getConfigPDA(program); - const [guardianInfoPDA, _] = getGuardianPDA(program, guardian); - await program.methods - .addGuardian() - .accounts({ - config, - authority: authority.publicKey, - guardianInfo: guardianInfoPDA, - guardian: guardian.publicKey, - }) - .signers(maybeAuthorityAnd(authority, [])) - .rpc(); - return guardianInfoPDA; -} - -async function checkGuardian( - program: Program, - guardian -) { - const [guardianInfoPDA, bump] = getGuardianPDA(program, guardian); - let guardianInfo = await program.account.guardianInfo.fetch(guardianInfoPDA); - - expect(guardianInfo.guardian).to.eql(guardian.publicKey); - expect(guardianInfo.bump).to.equal(bump); -} - -async function removeGuardian( - program: Program, - authority, - guardian, - guardianInfo -) { - const [config,] = getConfigPDA(program); - await program.methods - .removeGuardian() - .accounts({ - config, - authority: authority.publicKey, - guardianInfo: guardianInfo, - guardian: guardian.publicKey - }) - .signers(maybeAuthorityAnd(authority, [])) - .rpc(); -} - -async function pause( - program: Program, - guardian -) { - const [config,] = getConfigPDA(program); - const [guardianInfoPDA, _] = getGuardianPDA(program, guardian); - await program.methods - .pause() - .accounts({ - config, - guardianInfo: guardianInfoPDA, - guardian: guardian.publicKey - }) - .signers([guardian]) - .rpc(); -} - -async function unpause( - program: Program, - authority -) { - const [config,] = getConfigPDA(program); - await program.methods - .unpause() - .accounts({ - config, - authority: authority.publicKey - }) - .signers(maybeAuthorityAnd(authority, [])) - .rpc(); -} - -async function mint( - program: Program, - minter, - minterInfoPDA, - recipient, - amount, - payer, -) { - const connection = program.provider.connection; - - const [config,] = getConfigPDA(program); - const [tbtcMintPDA, _] = getTokenPDA(program); - const recipientToken = spl.getAssociatedTokenAddressSync(tbtcMintPDA, recipient.publicKey); - - const tokenData = await spl.getAccount(connection, recipientToken).catch((err) => { - if (err instanceof spl.TokenAccountNotFoundError) { - return null; - } else { - throw err; - }; - }); - - if (tokenData === null) { - const tx = await web3.sendAndConfirmTransaction( - connection, - new web3.Transaction().add( - spl.createAssociatedTokenAccountIdempotentInstruction( - payer.publicKey, - recipientToken, - recipient.publicKey, - tbtcMintPDA, - ) - ), - [payer.payer] - ); - } - - - await program.methods - .mint(new anchor.BN(amount)) - .accounts({ - mint: tbtcMintPDA, - config, - minterInfo: minterInfoPDA, - minter: minter.publicKey, - recipientToken, - }) - .signers(maybeAuthorityAnd(payer, [minter])) - .rpc(); -} +import * as tbtc from "./helpers/tbtc"; +import { + expectIxFail, + expectIxSuccess, + getOrCreateAta, + getTokenBalance, + sleep, + transferLamports, +} from "./helpers/utils"; describe("tbtc", () => { // Configure the client to use the local cluster. @@ -365,348 +19,805 @@ describe("tbtc", () => { const program = anchor.workspace.Tbtc as Program; - const authority = (program.provider as anchor.AnchorProvider).wallet as anchor.Wallet; + const authority = ( + (program.provider as anchor.AnchorProvider).wallet as anchor.Wallet + ).payer; const newAuthority = anchor.web3.Keypair.generate(); - const minterKeys = anchor.web3.Keypair.generate(); - const minter2Keys = anchor.web3.Keypair.generate(); - const impostorKeys = anchor.web3.Keypair.generate(); - const guardianKeys = anchor.web3.Keypair.generate(); - const guardian2Keys = anchor.web3.Keypair.generate(); - - const recipientKeys = anchor.web3.Keypair.generate(); - - it('setup', async () => { - await setup(program, authority); - await checkState(program, authority, 0, 0, 0); - }); - - it('change authority', async () => { - await checkState(program, authority, 0, 0, 0); - await checkNoPendingAuthority(program); - try { - await cancelAuthorityChange(program, authority); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('NoPendingAuthorityChange'); - expect(err.program.equals(program.programId)).is.true; - } - try { - await takeAuthority(program, newAuthority); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('NoPendingAuthorityChange'); - expect(err.program.equals(program.programId)).is.true; - } - - await changeAuthority(program, authority, newAuthority); - await checkPendingAuthority(program, newAuthority); - await takeAuthority(program, newAuthority); - await checkNoPendingAuthority(program); - await checkState(program, newAuthority, 0, 0, 0); - await changeAuthority(program, newAuthority, authority.payer); - try { - await takeAuthority(program, impostorKeys); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotPendingAuthority'); - expect(err.program.equals(program.programId)).is.true; - } - try { - await takeAuthority(program, newAuthority); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotPendingAuthority'); - expect(err.program.equals(program.programId)).is.true; - } - try { - await cancelAuthorityChange(program, authority); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotAuthority'); - expect(err.program.equals(program.programId)).is.true; - } - await takeAuthority(program, authority); - - await checkState(program, authority, 0, 0, 0); - }) - - it('add minter', async () => { - await checkState(program, authority, 0, 0, 0); - await addMinter(program, authority, minterKeys, authority); - await checkMinter(program, minterKeys); - await checkState(program, authority, 1, 0, 0); - - // Transfer lamports to imposter. - await transferLamports(program.provider.connection, authority.payer, impostorKeys.publicKey, 1000000000); - // await web3.sendAndConfirmTransaction( - // program.provider.connection, - // new web3.Transaction().add( - // web3.SystemProgram.transfer({ - // fromPubkey: authority.publicKey, - // toPubkey: impostorKeys.publicKey, - // lamports: 1000000000, - // }) - // ), - // [authority.payer] - // ); - - try { - await addMinter(program, impostorKeys, minter2Keys, authority); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotAuthority'); - expect(err.program.equals(program.programId)).is.true; - } - }); - - it('mint', async () => { - await checkState(program, authority, 1, 0, 0); - const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys); - - // await setupMint(program, authority, recipientKeys); - await mint(program, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); - - await checkState(program, authority, 1, 0, 1000); - - // // Burn for next test. - // const ix = spl.createBurnCheckedInstruction( - // account, // PublicKey of Owner's Associated Token Account - // new PublicKey(MINT_ADDRESS), // Public Key of the Token Mint Address - // WALLET.publicKey, // Public Key of Owner's Wallet - // BURN_QUANTITY * (10**MINT_DECIMALS), // Number of tokens to burn - // MINT_DECIMALS // Number of Decimals of the Token Mint - // ) - - }); - - it('won\'t mint', async () => { - await checkState(program, authority, 1, 0, 1000); - const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys); - - // await setupMint(program, authority, recipientKeys); - - try { - await mint(program, impostorKeys, minterInfoPDA, recipientKeys, 1000, authority); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('ConstraintSeeds'); - expect(err.program.equals(program.programId)).is.true; - } - }); - - it('use two minters', async () => { - await checkState(program, authority, 1, 0, 1000); - const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys); - const minter2InfoPDA = await addMinter(program, authority, minter2Keys, authority); - await checkMinter(program, minter2Keys); - await checkState(program, authority, 2, 0, 1000); - // await setupMint(program, authority, recipientKeys); - - // cannot mint with wrong keys - try { - await mint(program, minter2Keys, minterInfoPDA, recipientKeys, 1000, authority); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('ConstraintSeeds'); - expect(err.program.equals(program.programId)).is.true; - } - - // cannot remove minter with wrong keys - try { - await removeMinter(program, authority, minter2Keys, minterInfoPDA); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('ConstraintSeeds'); - expect(err.program.equals(program.programId)).is.true; - } - - await mint(program, minterKeys, minterInfoPDA, recipientKeys, 500, authority); - await checkState(program, authority, 2, 0, 1500); - }); - - it('remove minter', async () => { - await checkState(program, authority, 2, 0, 1500); - const [minter2InfoPDA, _] = getMinterPDA(program, minter2Keys); - await checkMinter(program, minter2Keys); - await removeMinter(program, authority, minter2Keys, minter2InfoPDA); - await checkState(program, authority, 1, 0, 1500); + const minter = anchor.web3.Keypair.generate(); + const anotherMinter = anchor.web3.Keypair.generate(); + const imposter = anchor.web3.Keypair.generate(); + const guardian = anchor.web3.Keypair.generate(); + const anotherGuardian = anchor.web3.Keypair.generate(); + + const recipient = anchor.web3.Keypair.generate(); + const txPayer = anchor.web3.Keypair.generate(); + + it("set up payers", async () => { + await transferLamports(authority, newAuthority.publicKey, 10000000000); + await transferLamports(authority, imposter.publicKey, 10000000000); + await transferLamports(authority, recipient.publicKey, 10000000000); + await transferLamports(authority, txPayer.publicKey, 10000000000); }); - it('won\'t remove minter', async () => { - await checkState(program, authority, 1, 0, 1500); - const [minterInfoPDA, _] = getMinterPDA(program, minterKeys); - await checkMinter(program, minterKeys); - - try { - await removeMinter(program, impostorKeys, minterKeys, minterInfoPDA); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotAuthority'); - expect(err.program.equals(program.programId)).is.true; - } - - await removeMinter(program, authority, minterKeys, minterInfoPDA); - await checkState(program, authority, 0, 0, 1500); - - try { - await removeMinter(program, authority, minterKeys, minterInfoPDA); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('AccountNotInitialized'); - expect(err.program.equals(program.programId)).is.true; - } - }); - - it('add guardian', async () => { - await checkState(program, authority, 0, 0, 1500); - await addGuardian(program, authority, guardianKeys, authority); - await checkGuardian(program, guardianKeys); - await checkState(program, authority, 0, 1, 1500); - - try { - await addGuardian(program, impostorKeys, guardian2Keys, authority); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotAuthority'); - expect(err.program.equals(program.programId)).is.true; - } - }); - - it('remove guardian', async () => { - await checkState(program, authority, 0, 1, 1500); - const [guardianInfoPDA, _] = getGuardianPDA(program, guardianKeys); - await checkGuardian(program, guardianKeys); - - try { - await removeGuardian(program, impostorKeys, guardianKeys, guardianInfoPDA); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotAuthority'); - expect(err.program.equals(program.programId)).is.true; - } - - await removeGuardian(program, authority, guardianKeys, guardianInfoPDA); - await checkState(program, authority, 0, 0, 1500); - - try { - await removeGuardian(program, authority, guardianKeys, guardianInfoPDA); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('AccountNotInitialized'); - expect(err.program.equals(program.programId)).is.true; - } + it("initialize", async () => { + const ix = await tbtc.initializeIx({ authority: authority.publicKey }); + await expectIxSuccess([ix], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 0, + numGuardians: 0, + supply: BigInt(0), + paused: false, + pendingAuthority: null, + }); }); - it('pause', async () => { - await checkState(program, authority, 0, 0, 1500); - await addGuardian(program, authority, guardianKeys, authority); - await checkPaused(program, false); - await pause(program, guardianKeys); - await checkPaused(program, true); + describe("authority changes", () => { + it("cannot cancel authority if no pending", async () => { + const failedCancelIx = await tbtc.cancelAuthorityChangeIx({ + authority: authority.publicKey, + }); + await expectIxFail( + [failedCancelIx], + [authority], + "NoPendingAuthorityChange" + ); + }); + + it("cannot take authority if no pending", async () => { + const failedTakeIx = await tbtc.takeAuthorityIx({ + pendingAuthority: newAuthority.publicKey, + }); + await expectIxFail( + [failedTakeIx], + [newAuthority], + "NoPendingAuthorityChange" + ); + }); + + it("change authority to new authority", async () => { + const changeIx = await tbtc.changeAuthorityIx({ + authority: authority.publicKey, + newAuthority: newAuthority.publicKey, + }); + await expectIxSuccess([changeIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 0, + numGuardians: 0, + supply: BigInt(0), + paused: false, + pendingAuthority: newAuthority.publicKey, + }); + }); + + it("take as new authority", async () => { + // Bug in validator? Need to wait a bit for new blockhash. + await sleep(10000); + + const takeIx = await tbtc.takeAuthorityIx({ + pendingAuthority: newAuthority.publicKey, + }); + await expectIxSuccess([takeIx], [newAuthority]); + await tbtc.checkConfig({ + authority: newAuthority.publicKey, + numMinters: 0, + numGuardians: 0, + supply: BigInt(0), + paused: false, + pendingAuthority: null, + }); + }); + + it("change pending authority back to original authority", async () => { + const changeBackIx = await tbtc.changeAuthorityIx({ + authority: newAuthority.publicKey, + newAuthority: authority.publicKey, + }); + await expectIxSuccess([changeBackIx], [newAuthority]); + await tbtc.checkConfig({ + authority: newAuthority.publicKey, + numMinters: 0, + numGuardians: 0, + supply: BigInt(0), + paused: false, + pendingAuthority: authority.publicKey, + }); + }); + + it("cannot take as signers that are not pending authority", async () => { + const failedImposterTakeIx = await tbtc.takeAuthorityIx({ + pendingAuthority: imposter.publicKey, + }); + await expectIxFail( + [failedImposterTakeIx], + [imposter], + "IsNotPendingAuthority" + ); + + const failedNewAuthorityTakeIx = await tbtc.takeAuthorityIx({ + pendingAuthority: newAuthority.publicKey, + }); + await expectIxFail( + [failedNewAuthorityTakeIx], + [newAuthority], + "IsNotPendingAuthority" + ); + }); + + it("cannot cancel as someone else", async () => { + const anotherFailedCancelIx = await tbtc.cancelAuthorityChangeIx({ + authority: authority.publicKey, + }); + await expectIxFail( + [anotherFailedCancelIx], + [authority], + "IsNotAuthority" + ); + }); + + it("finally take as authority", async () => { + const anotherTakeIx = await tbtc.takeAuthorityIx({ + pendingAuthority: authority.publicKey, + }); + await expectIxSuccess([anotherTakeIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 0, + numGuardians: 0, + supply: BigInt(0), + paused: false, + pendingAuthority: null, + }); + }); }); - it('unpause', async () => { - await checkState(program, authority, 0, 1, 1500); - await checkPaused(program, true); - await unpause(program, authority); - await checkPaused(program, false); - - try { - await unpause(program, authority); - - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsNotPaused'); - expect(err.program.equals(program.programId)).is.true; - } + describe("minting", () => { + it("cannot add minter without authority", async () => { + const cannotAddMinterIx = await tbtc.addMinterIx({ + authority: imposter.publicKey, + minter: minter.publicKey, + }); + await expectIxFail([cannotAddMinterIx], [imposter], "IsNotAuthority"); + }); + + it("add minter", async () => { + const mustBeNull = await tbtc + .checkMinterInfo(minter.publicKey) + .catch((_) => null); + assert(mustBeNull === null, "minter info found"); + + const addMinterIx = await tbtc.addMinterIx({ + authority: authority.publicKey, + minter: minter.publicKey, + }); + await expectIxSuccess([addMinterIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 0, + supply: BigInt(0), + paused: false, + pendingAuthority: null, + }); + await tbtc.checkMinterInfo(minter.publicKey); + }); + + it("mint", async () => { + const amount = BigInt(1000); + + const recipientToken = await getOrCreateAta( + authority, + tbtc.getMintPDA(), + recipient.publicKey + ); + const recipientBefore = await getTokenBalance(recipientToken); + expect(recipientBefore).to.equal(BigInt(0)); + + const mintIx = await tbtc.mintIx( + { + minter: minter.publicKey, + recipientToken, + }, + new anchor.BN(amount.toString()) + ); + await expectIxSuccess([mintIx], [txPayer, minter]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 0, + supply: BigInt(1000), + paused: false, + pendingAuthority: null, + }); + + const recipientAfter = await getTokenBalance(recipientToken); + expect(recipientAfter).to.equal(amount); + }); + + it("cannot mint without minter", async () => { + const recipientToken = spl.getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient.publicKey + ); + + const cannotMintIx = await tbtc.mintIx( + { + minter: imposter.publicKey, + recipientToken, + }, + new anchor.BN(420) + ); + await expectIxFail( + [cannotMintIx], + [txPayer, imposter], + "AccountNotInitialized" + ); + + // Now try with actual minter's info account. + const minterInfo = tbtc.getMinterInfoPDA(minter.publicKey); + + const cannotMintAgainIx = await tbtc.mintIx( + { + minterInfo, + minter: imposter.publicKey, + recipientToken, + }, + new anchor.BN(420) + ); + await expectIxFail( + [cannotMintAgainIx], + [txPayer, imposter], + "ConstraintSeeds" + ); + }); + + it("add another minter", async () => { + const mustBeNull = await tbtc + .checkMinterInfo(anotherMinter.publicKey) + .catch((_) => null); + assert(mustBeNull === null, "minter info found"); + + const addMinterIx = await tbtc.addMinterIx({ + authority: authority.publicKey, + minter: anotherMinter.publicKey, + }); + await expectIxSuccess([addMinterIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 2, + numGuardians: 0, + supply: BigInt(1000), + paused: false, + pendingAuthority: null, + }); + await tbtc.checkMinterInfo(anotherMinter.publicKey); + }); + + it("cannot remove minter with wrong key", async () => { + const minterInfo = tbtc.getMinterInfoPDA(minter.publicKey); + const cannotRemoveIx = await tbtc.removeMinterIx({ + authority: authority.publicKey, + minterInfo, + minter: anotherMinter.publicKey, + }); + await expectIxFail([cannotRemoveIx], [authority], "ConstraintSeeds"); + }); + + it("mint with another minter", async () => { + const amount = BigInt(500); + + const recipientToken = await spl.getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient.publicKey + ); + const recipientBefore = await getTokenBalance(recipientToken); + expect(recipientBefore).to.equal(BigInt(1000)); + + const mintIx = await tbtc.mintIx( + { + minter: anotherMinter.publicKey, + recipientToken, + }, + new anchor.BN(amount.toString()) + ); + await expectIxSuccess([mintIx], [txPayer, anotherMinter]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 2, + numGuardians: 0, + supply: BigInt(1500), + paused: false, + pendingAuthority: null, + }); + + const recipientAfter = await getTokenBalance(recipientToken); + expect(recipientAfter).to.equal(recipientBefore + amount); + }); + + it("cannot remove minter without authority", async () => { + const cannotRemoveIx = await tbtc.removeMinterIx({ + authority: imposter.publicKey, + minter: anotherMinter.publicKey, + }); + await expectIxFail([cannotRemoveIx], [imposter], "IsNotAuthority"); + }); + + it("remove minter", async () => { + const removeIx = await tbtc.removeMinterIx({ + authority: authority.publicKey, + minter: anotherMinter.publicKey, + }); + await expectIxSuccess([removeIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 0, + supply: BigInt(1500), + paused: false, + pendingAuthority: null, + }); + const mustBeNull = await tbtc + .checkMinterInfo(anotherMinter.publicKey) + .catch((_) => null); + assert(mustBeNull === null, "minter info found"); + }); + + it("cannot remove same minter again", async () => { + const cannotRemoveIx = await tbtc.removeMinterIx({ + authority: authority.publicKey, + minter: anotherMinter.publicKey, + }); + await expectIxFail( + [cannotRemoveIx], + [authority], + "AccountNotInitialized" + ); + }); + + it("remove last minter", async () => { + const removeIx = await tbtc.removeMinterIx({ + authority: authority.publicKey, + minter: minter.publicKey, + }); + await expectIxSuccess([removeIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 0, + numGuardians: 0, + supply: BigInt(1500), + paused: false, + pendingAuthority: null, + }); + const mustBeNull = await tbtc + .checkMinterInfo(minter.publicKey) + .catch((_) => null); + assert(mustBeNull === null, "minter info found"); + }); }); - it('won\'t mint when paused', async () => { - await checkState(program, authority, 0, 1, 1500); - const minterInfoPDA = await addMinter(program, authority, minterKeys, authority); - await pause(program, guardianKeys); - // await setupMint(program, authority, recipientKeys); - - try { - await mint(program, minterKeys, minterInfoPDA, recipientKeys, 1000, authority); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsPaused'); - expect(err.program.equals(program.programId)).is.true; - } - - await unpause(program, authority); - await checkPaused(program, false); - }) - - it('use two guardians', async () => { - await checkState(program, authority, 1, 1, 1500); - const [guardianInfoPDA, _] = getGuardianPDA(program, guardianKeys); - await checkGuardian(program, guardianKeys); - await addGuardian(program, authority, guardian2Keys, authority); - await checkGuardian(program, guardian2Keys); - - await pause(program, guardianKeys); - - try { - await pause(program, guardian2Keys); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('IsPaused'); - expect(err.program.equals(program.programId)).is.true; - } - - await unpause(program, authority); - await pause(program, guardian2Keys); - await checkPaused(program, true); - await unpause(program, authority); - - // cannot remove guardian with wrong keys - try { - await removeGuardian(program, authority, guardian2Keys, guardianInfoPDA); - chai.assert(false, "should've failed but didn't"); - } catch (_err) { - expect(_err).to.be.instanceOf(AnchorError); - const err: AnchorError = _err; - expect(err.error.errorCode.code).to.equal('ConstraintSeeds'); - expect(err.program.equals(program.programId)).is.true; - } + describe("guardians", () => { + it("cannot add guardian without authority", async () => { + const cannotAddIx = await tbtc.addGuardianIx({ + authority: imposter.publicKey, + guardian: guardian.publicKey, + }); + await expectIxFail([cannotAddIx], [imposter], "IsNotAuthority"); + }); + + it("add guardian", async () => { + const mustBeNull = await tbtc + .checkGuardianInfo(guardian.publicKey) + .catch((_) => null); + assert(mustBeNull === null, "guardian info found"); + + const addIx = await tbtc.addGuardianIx({ + authority: authority.publicKey, + guardian: guardian.publicKey, + }); + await expectIxSuccess([addIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 0, + numGuardians: 1, + supply: BigInt(1500), + paused: false, + pendingAuthority: null, + }); + await tbtc.checkGuardianInfo(guardian.publicKey); + }); + + it("cannot pause without guardian", async () => { + const cannotPauseIx = await tbtc.pauseIx({ + guardian: imposter.publicKey, + }); + await expectIxFail( + [cannotPauseIx], + [txPayer, imposter], + "AccountNotInitialized" + ); + + // Now try with actual guardian's info account. + const guardianInfo = tbtc.getGuardianInfoPDA(guardian.publicKey); + + const cannotPauseAgainIx = await tbtc.pauseIx({ + guardianInfo, + guardian: imposter.publicKey, + }); + await expectIxFail( + [cannotPauseAgainIx], + [txPayer, imposter], + "ConstraintSeeds" + ); + }); + + it("add minter and mint", async () => { + const addMinterIx = await tbtc.addMinterIx({ + authority: authority.publicKey, + minter: minter.publicKey, + }); + await expectIxSuccess([addMinterIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 1, + supply: BigInt(1500), + paused: false, + pendingAuthority: null, + }); + + const amount = BigInt(100); + + const recipientToken = spl.getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient.publicKey + ); + const recipientBefore = await getTokenBalance(recipientToken); + expect(recipientBefore).to.equal(BigInt(1500)); + + const mintIx = await tbtc.mintIx( + { + minter: minter.publicKey, + recipientToken, + }, + new anchor.BN(amount.toString()) + ); + await expectIxSuccess([mintIx], [txPayer, minter]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 1, + supply: BigInt(1600), + paused: false, + pendingAuthority: null, + }); + + const recipientAfter = await getTokenBalance(recipientToken); + expect(recipientAfter).to.equal(recipientBefore + amount); + }); + + it("pause", async () => { + const pauseIx = await tbtc.pauseIx({ + guardian: guardian.publicKey, + }); + await expectIxSuccess([pauseIx], [txPayer, guardian]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 1, + supply: BigInt(1600), + paused: true, + pendingAuthority: null, + }); + }); + + it("cannot mint while paused", async () => { + const recipientToken = spl.getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient.publicKey + ); + + const mintIx = await tbtc.mintIx( + { + minter: minter.publicKey, + recipientToken, + }, + new anchor.BN(100) + ); + await expectIxFail([mintIx], [txPayer, minter], "IsPaused"); + }); + + it("add another guardian", async () => { + const mustBeNull = await tbtc + .checkGuardianInfo(anotherGuardian.publicKey) + .catch((_) => null); + assert(mustBeNull === null, "guardian info found"); + + const addIx = await tbtc.addGuardianIx({ + authority: authority.publicKey, + guardian: anotherGuardian.publicKey, + }); + await expectIxSuccess([addIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 2, + supply: BigInt(1600), + paused: true, + pendingAuthority: null, + }); + await tbtc.checkGuardianInfo(anotherGuardian.publicKey); + }); + + it("cannot pause again", async () => { + const cannotPauseIx = await tbtc.pauseIx({ + guardian: anotherGuardian.publicKey, + }); + await expectIxFail( + [cannotPauseIx], + [txPayer, anotherGuardian], + "IsPaused" + ); + }); + + it("unpause", async () => { + const unpauseIx = await tbtc.unpauseIx({ + authority: authority.publicKey, + }); + await expectIxSuccess([unpauseIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 2, + supply: BigInt(1600), + paused: false, + pendingAuthority: null, + }); + }); + + it("cannot unpause again", async () => { + const cannotUnpauseIx = await tbtc.unpauseIx({ + authority: authority.publicKey, + }); + await expectIxFail( + [cannotUnpauseIx], + [txPayer, authority], + "IsNotPaused" + ); + }); + + it("mint while unpaused", async () => { + const amount = BigInt(200); + + const recipientToken = spl.getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient.publicKey + ); + const recipientBefore = await getTokenBalance(recipientToken); + expect(recipientBefore).to.equal(BigInt(1600)); + + const mintIx = await tbtc.mintIx( + { + minter: minter.publicKey, + recipientToken, + }, + new anchor.BN(amount.toString()) + ); + await expectIxSuccess([mintIx], [txPayer, minter]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 2, + supply: BigInt(1800), + paused: false, + pendingAuthority: null, + }); + + const recipientAfter = await getTokenBalance(recipientToken); + expect(recipientAfter).to.equal(recipientBefore + amount); + }); + + it("pause as another guardian", async () => { + const pauseIx = await tbtc.pauseIx({ + guardian: anotherGuardian.publicKey, + }); + await expectIxSuccess([pauseIx], [txPayer, anotherGuardian]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 2, + supply: BigInt(1800), + paused: true, + pendingAuthority: null, + }); + }); + + it("cannot mint again while paused", async () => { + const recipientToken = spl.getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient.publicKey + ); + + const mintIx = await tbtc.mintIx( + { + minter: minter.publicKey, + recipientToken, + }, + new anchor.BN(100) + ); + await expectIxFail([mintIx], [txPayer, minter], "IsPaused"); + }); + + it("cannot remove guardian without authority", async () => { + const cannotRemoveIx = await tbtc.removeGuardianIx({ + authority: imposter.publicKey, + guardian: anotherGuardian.publicKey, + }); + await expectIxFail([cannotRemoveIx], [imposter], "IsNotAuthority"); + }); + + it("cannot remove guardian with mismatched info", async () => { + const guardianInfo = tbtc.getGuardianInfoPDA(anotherGuardian.publicKey); + const cannotRemoveIx = await tbtc.removeGuardianIx({ + authority: authority.publicKey, + guardianInfo, + guardian: guardian.publicKey, + }); + await expectIxFail([cannotRemoveIx], [authority], "ConstraintSeeds"); + }); + + it("remove guardian", async () => { + const removeIx = await tbtc.removeGuardianIx({ + authority: authority.publicKey, + guardian: anotherGuardian.publicKey, + }); + await expectIxSuccess([removeIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 1, + supply: BigInt(1800), + paused: true, + pendingAuthority: null, + }); + const mustBeNull = await tbtc + .checkGuardianInfo(anotherGuardian.publicKey) + .catch((_) => null); + assert(mustBeNull === null, "guardian info found"); + }); + + it("unpause", async () => { + const unpauseIx = await tbtc.unpauseIx({ + authority: authority.publicKey, + }); + await expectIxSuccess([unpauseIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 1, + supply: BigInt(1800), + paused: false, + pendingAuthority: null, + }); + }); + + it("cannot pause with removed guardian", async () => { + const pauseIx = await tbtc.pauseIx({ + guardian: anotherGuardian.publicKey, + }); + await expectIxFail( + [pauseIx], + [txPayer, anotherGuardian], + "AccountNotInitialized" + ); + }); + + it("pause and remove last guardian", async () => { + const pauseIx = await tbtc.pauseIx({ + guardian: guardian.publicKey, + }); + await expectIxSuccess([pauseIx], [txPayer, guardian]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 1, + supply: BigInt(1800), + paused: true, + pendingAuthority: null, + }); + + const removeIx = await tbtc.removeGuardianIx({ + authority: authority.publicKey, + guardian: guardian.publicKey, + }); + await expectIxSuccess([removeIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 0, + supply: BigInt(1800), + paused: true, + pendingAuthority: null, + }); + const mustBeNull = await tbtc + .checkGuardianInfo(guardian.publicKey) + .catch((_) => null); + assert(mustBeNull === null, "guardian info found"); + }); + + it("cannot mint yet again", async () => { + const recipientToken = spl.getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient.publicKey + ); + + const mintIx = await tbtc.mintIx( + { + minter: minter.publicKey, + recipientToken, + }, + new anchor.BN(100) + ); + await expectIxFail([mintIx], [txPayer, minter], "IsPaused"); + }); + + it("unpause without any guardians then mint", async () => { + const unpauseIx = await tbtc.unpauseIx({ + authority: authority.publicKey, + }); + await expectIxSuccess([unpauseIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 0, + supply: BigInt(1800), + paused: false, + pendingAuthority: null, + }); + + const recipientToken = spl.getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient.publicKey + ); + + const amount = BigInt(200); + + const recipientBefore = await getTokenBalance(recipientToken); + const mintIx = await tbtc.mintIx( + { + minter: minter.publicKey, + recipientToken, + }, + new anchor.BN(amount.toString()) + ); + await expectIxSuccess([mintIx], [txPayer, minter]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 0, + supply: BigInt(2000), + paused: false, + pendingAuthority: null, + }); + + const recipientAfter = await getTokenBalance(recipientToken); + expect(recipientAfter).to.equal(recipientBefore + amount); + }); + + it("remove minter", async () => { + const removeIx = await tbtc.removeMinterIx({ + authority: authority.publicKey, + minter: minter.publicKey, + }); + await expectIxSuccess([removeIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 0, + numGuardians: 0, + supply: BigInt(2000), + paused: false, + pendingAuthority: null, + }); + }); }); }); diff --git a/cross-chain/solana/tests/02__wormholeGateway.ts b/cross-chain/solana/tests/02__wormholeGateway.ts index 69eb14fe3..e5641ddea 100644 --- a/cross-chain/solana/tests/02__wormholeGateway.ts +++ b/cross-chain/solana/tests/02__wormholeGateway.ts @@ -1,116 +1,1232 @@ -import * as mock from "@certusone/wormhole-sdk/lib/cjs/mock"; -import * as tokenBridge from "@certusone/wormhole-sdk/lib/cjs/solana/tokenBridge"; -import * as coreBridge from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole"; -import { NodeWallet } from "@certusone/wormhole-sdk/lib/cjs/solana"; -import { parseTokenTransferVaa, postVaaSolana, redeemOnSolana, tryNativeToHexString } from "@certusone/wormhole-sdk"; +import { MockEthereumTokenBridge } from "@certusone/wormhole-sdk/lib/cjs/mock"; import * as anchor from "@coral-xyz/anchor"; import { Program } from "@coral-xyz/anchor"; -import * as spl from "@solana/spl-token"; -import { expect } from 'chai'; +import { getAccount, getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { PublicKey } from "@solana/web3.js"; +import { expect } from "chai"; import { WormholeGateway } from "../target/types/wormhole_gateway"; -import { generatePayer, getOrCreateTokenAccount } from "./helpers/utils"; -import { web3 } from "@coral-xyz/anchor"; +import { + ETHEREUM_TOKEN_BRIDGE_ADDRESS, + WORMHOLE_GATEWAY_PROGRAM_ID, + WRAPPED_TBTC_MINT, + ethereumGatewaySendTbtc, + expectIxFail, + expectIxSuccess, + generatePayer, + getOrCreateAta, + preloadWrappedTbtc, + transferLamports, +} from "./helpers"; +import * as tbtc from "./helpers/tbtc"; +import * as wormholeGateway from "./helpers/wormholeGateway"; -const SOLANA_CORE_BRIDGE_ADDRESS = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"; -const SOLANA_TOKEN_BRIDGE_ADDRESS = "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb"; -const ETHEREUM_TOKEN_BRIDGE_ADDRESS = "0x3ee18B2214AFF97000D974cf647E7C347E8fa585"; -const ETHEREUM_TBTC_ADDRESS = "0x18084fbA666a33d37592fA2633fD49a74DD93a88"; - -const GUARDIAN_SET_INDEX = 3; - -function getCustodianPDA( +async function setup( program: Program, -): [anchor.web3.PublicKey, number] { - return web3.PublicKey.findProgramAddressSync( - [ - Buffer.from('custodian'), - ], - program.programId - ); -} + authority, + mintingLimit: bigint +) { + const custodian = wormholeGateway.getCustodianPDA(); + const tbtcMint = tbtc.getMintPDA(); + const gatewayWrappedTbtcToken = wormholeGateway.getWrappedTbtcTokenPDA(); + const tokenBridgeSender = wormholeGateway.getTokenBridgeSenderPDA(); + await program.methods + .initialize(new anchor.BN(mintingLimit.toString())) + .accounts({ + authority: authority.publicKey, + custodian, + tbtcMint, + wrappedTbtcMint: WRAPPED_TBTC_MINT, + wrappedTbtcToken: gatewayWrappedTbtcToken, + tokenBridgeSender, + }) + .rpc(); +} describe("wormhole-gateway", () => { // Configure the client to use the local cluster. anchor.setProvider(anchor.AnchorProvider.env()); + // Initialize anchor program. const program = anchor.workspace.WormholeGateway as Program; const connection = program.provider.connection; - const authority = (program.provider as anchor.AnchorProvider).wallet as anchor.Wallet; + const custodian = wormholeGateway.getCustodianPDA(); + const tbtcMint = tbtc.getMintPDA(); + const tbtcConfig = tbtc.getConfigPDA(); + const gatewayWrappedTbtcToken = wormholeGateway.getWrappedTbtcTokenPDA(); + const tokenBridgeSender = wormholeGateway.getTokenBridgeSenderPDA(); + const tokenBridgeRedeemer = wormholeGateway.getTokenBridgeRedeemerPDA(); + + const authority = ( + (program.provider as anchor.AnchorProvider).wallet as anchor.Wallet + ).payer; const newAuthority = anchor.web3.Keypair.generate(); const minterKeys = anchor.web3.Keypair.generate(); const minter2Keys = anchor.web3.Keypair.generate(); - const impostorKeys = anchor.web3.Keypair.generate(); + const imposter = anchor.web3.Keypair.generate(); const guardianKeys = anchor.web3.Keypair.generate(); const guardian2Keys = anchor.web3.Keypair.generate(); - const recipientKeys = anchor.web3.Keypair.generate(); - - const ethereumTokenBridge = new mock.MockEthereumTokenBridge(ETHEREUM_TOKEN_BRIDGE_ADDRESS); - - it('check core bridge and token bridge', async () => { - // Check core bridge guardian set. - const guardianSetData = await coreBridge.getGuardianSet(connection, SOLANA_CORE_BRIDGE_ADDRESS, GUARDIAN_SET_INDEX); - expect(guardianSetData.keys).has.length(1); - - // Set up new wallet - const payer = await generatePayer(connection, authority.payer); - - // Check wrapped tBTC mint. - const wrappedTbtcMint = tokenBridge.deriveWrappedMintKey(SOLANA_TOKEN_BRIDGE_ADDRESS, 2, ETHEREUM_TBTC_ADDRESS); - const mintData = await spl.getMint(connection, wrappedTbtcMint); - expect(mintData.decimals).to.equal(8); - expect(mintData.supply).to.equal(BigInt(90)); - - const wrappedTbtcToken = await getOrCreateTokenAccount(connection, payer, wrappedTbtcMint, payer.publicKey); - - // Bridge tbtc to token account. - const published = ethereumTokenBridge.publishTransferTokens( - tryNativeToHexString(ETHEREUM_TBTC_ADDRESS, "ethereum"), - 2, - BigInt("100000000000"), - 1, - wrappedTbtcToken.address.toBuffer().toString("hex"), - BigInt(0), - 0, - 0 - ); - - const signedVaa = await mockSignAndPostVaa(connection, payer, published); - - const tx = await redeemOnSolana( - connection, - SOLANA_CORE_BRIDGE_ADDRESS, - SOLANA_TOKEN_BRIDGE_ADDRESS, - payer.publicKey, - signedVaa, - ); - await web3.sendAndConfirmTransaction(connection, tx, [payer]); + const recipient = anchor.web3.Keypair.generate(); + const txPayer = anchor.web3.Keypair.generate(); + + const commonTokenOwner = anchor.web3.Keypair.generate(); + + // Mock foreign emitter. + const ethereumTokenBridge = new MockEthereumTokenBridge( + ETHEREUM_TOKEN_BRIDGE_ADDRESS + ); + + it("set up payers", async () => { + await transferLamports(authority, newAuthority.publicKey, 10000000000); + await transferLamports(authority, imposter.publicKey, 10000000000); + await transferLamports(authority, recipient.publicKey, 10000000000); + await transferLamports(authority, txPayer.publicKey, 10000000000); + await transferLamports(authority, commonTokenOwner.publicKey, 10000000000); }); - it('setup', async () => { - // await setup(program, authority); - // await checkState(program, authority, 0, 0, 0); + describe("setup", () => { + it("initialize", async () => { + // Max amount of TBTC that can be minted. + const mintingLimit = BigInt(10000); + + // Initialize the program. + await setup(program, authority, mintingLimit); + await wormholeGateway.checkCustodian({ + authority: authority.publicKey, + mintingLimit, + pendingAuthority: null, + }); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 0, + numGuardians: 0, + supply: BigInt(2000), + paused: false, + pendingAuthority: null, + }); + + // Also set up common token account. + await getOrCreateAta( + authority, + tbtc.getMintPDA(), + commonTokenOwner.publicKey + ); + + // Give the impostor some lamports. + await transferLamports(authority, imposter.publicKey, 100000000000); + }); }); -}); -async function mockSignAndPostVaa(connection: web3.Connection, payer: web3.Keypair, published: Buffer) { - const guardians = new mock.MockGuardians( - GUARDIAN_SET_INDEX, - ["cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0"] - ); + describe("authority changes", () => { + it("cannot cancel authority if no pending", async () => { + const failedCancelIx = await wormholeGateway.cancelAuthorityChangeIx({ + authority: authority.publicKey, + }); + await expectIxFail( + [failedCancelIx], + [authority], + "NoPendingAuthorityChange" + ); + }); - // Add guardian signature. - const signedVaa = guardians.addSignatures(published, [0]); + it("cannot take authority if no pending", async () => { + const failedTakeIx = await wormholeGateway.takeAuthorityIx({ + pendingAuthority: newAuthority.publicKey, + }); + await expectIxFail( + [failedTakeIx], + [newAuthority], + "NoPendingAuthorityChange" + ); + }); - // Verify and post VAA. - await postVaaSolana(connection, - new NodeWallet(payer).signTransaction, - SOLANA_CORE_BRIDGE_ADDRESS, - payer.publicKey, - signedVaa - ); + it("change authority to new authority", async () => { + const changeIx = await wormholeGateway.changeAuthorityIx({ + authority: authority.publicKey, + newAuthority: newAuthority.publicKey, + }); + await expectIxSuccess([changeIx], [authority]); + await wormholeGateway.checkCustodian({ + authority: authority.publicKey, + mintingLimit: BigInt(10000), + pendingAuthority: newAuthority.publicKey, + }); + }); - return signedVaa; -} + it("take as new authority", async () => { + // Bug in validator? Need to wait a bit for new blockhash. + //await sleep(10000); + + const takeIx = await wormholeGateway.takeAuthorityIx({ + pendingAuthority: newAuthority.publicKey, + }); + await expectIxSuccess([takeIx], [newAuthority]); + await wormholeGateway.checkCustodian({ + authority: newAuthority.publicKey, + mintingLimit: BigInt(10000), + pendingAuthority: null, + }); + }); + + it("change pending authority back to original authority", async () => { + const changeBackIx = await wormholeGateway.changeAuthorityIx({ + authority: newAuthority.publicKey, + newAuthority: authority.publicKey, + }); + await expectIxSuccess([changeBackIx], [newAuthority]); + await wormholeGateway.checkCustodian({ + authority: newAuthority.publicKey, + mintingLimit: BigInt(10000), + pendingAuthority: authority.publicKey, + }); + }); + + it("cannot take as signers that are not pending authority", async () => { + const failedImposterTakeIx = await wormholeGateway.takeAuthorityIx({ + pendingAuthority: imposter.publicKey, + }); + await expectIxFail( + [failedImposterTakeIx], + [imposter], + "IsNotPendingAuthority" + ); + + const failedNewAuthorityTakeIx = await wormholeGateway.takeAuthorityIx({ + pendingAuthority: newAuthority.publicKey, + }); + await expectIxFail( + [failedNewAuthorityTakeIx], + [newAuthority], + "IsNotPendingAuthority" + ); + }); + + it("cannot cancel as someone else", async () => { + const anotherFailedCancelIx = + await wormholeGateway.cancelAuthorityChangeIx({ + authority: authority.publicKey, + }); + await expectIxFail( + [anotherFailedCancelIx], + [authority], + "IsNotAuthority" + ); + }); + + it("finally take as authority", async () => { + const anotherTakeIx = await wormholeGateway.takeAuthorityIx({ + pendingAuthority: authority.publicKey, + }); + await expectIxSuccess([anotherTakeIx], [authority]); + await wormholeGateway.checkCustodian({ + authority: authority.publicKey, + mintingLimit: BigInt(10000), + pendingAuthority: null, + }); + }); + }); + + describe("minting limit", () => { + it("update minting limit", async () => { + // Update minting limit as authority. + const newLimit = BigInt(20000); + const ix = await wormholeGateway.updateMintingLimitIx( + { + authority: authority.publicKey, + }, + newLimit + ); + await expectIxSuccess([ix], [authority]); + await wormholeGateway.checkCustodian({ + authority: authority.publicKey, + mintingLimit: newLimit, + pendingAuthority: null, + }); + }); + + it("cannot update minting limit (not authority)", async () => { + // Only the authority can update the minting limit. + const newLimit = BigInt(69000); + const failingIx = await wormholeGateway.updateMintingLimitIx( + { + authority: imposter.publicKey, + }, + newLimit + ); + await expectIxFail([failingIx], [imposter], "IsNotAuthority"); + }); + }); + + describe("gateway address", () => { + const chain = 2; + + it("gateway does not exist", async () => { + // demonstrate gateway address does not exist + const gatewayInfo = await connection.getAccountInfo( + wormholeGateway.getGatewayInfoPDA(chain) + ); + expect(gatewayInfo).is.null; + }); + + it("set initial gateway address", async () => { + // Make new gateway. + const firstAddress = Array.from(Buffer.alloc(32, "deadbeef", "hex")); + const firstIx = await wormholeGateway.updateGatewayAddress( + { + authority: authority.publicKey, + }, + { chain, address: firstAddress } + ); + await expectIxSuccess([firstIx], [authority]); + await wormholeGateway.checkGateway(chain, firstAddress); + }); + + it("update gateway address", async () => { + // Update gateway. + const goodAddress = Array.from(ethereumTokenBridge.address); + const secondIx = await wormholeGateway.updateGatewayAddress( + { + authority: authority.publicKey, + }, + { chain, address: goodAddress } + ); + await expectIxSuccess([secondIx], [authority]); + await wormholeGateway.checkGateway(chain, goodAddress); + }); + + it("cannot update gateway address (not authority)", async () => { + // Only the authority can update the gateway address. + const goodAddress = Array.from(ethereumTokenBridge.address); + const failingIx = await wormholeGateway.updateGatewayAddress( + { + authority: imposter.publicKey, + }, + { chain, address: goodAddress } + ); + await expectIxFail([failingIx], [imposter], "IsNotAuthority"); + }); + }); + + describe("deposit wrapped tbtc", () => { + it("cannot deposit wrapped tbtc (custodian not a minter)", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Check wrapped tBTC mint. + const recipientWrappedToken = await preloadWrappedTbtc( + payer, + ethereumTokenBridge, + BigInt("100000000000"), + payer.publicKey + ); + + const recipientToken = await getOrCreateAta( + payer, + tbtcMint, + payer.publicKey + ); + + const depositAmount = BigInt(500); + + // Attempt to deposit before the custodian is a minter. + const ix = await wormholeGateway.depositWormholeTbtcIx( + { + recipientWrappedToken, + recipientToken, + recipient: payer.publicKey, + }, + depositAmount + ); + await expectIxFail([ix], [payer], "AccountNotInitialized"); + }); + + it("deposit wrapped tokens", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Check wrapped tBTC mint. + const recipientWrappedToken = await preloadWrappedTbtc( + payer, + ethereumTokenBridge, + BigInt("100000000000"), + payer.publicKey + ); + + const recipientToken = await getOrCreateAta( + payer, + tbtcMint, + payer.publicKey + ); + + const mintedAmountBefore = await wormholeGateway.getMintedAmount(); + + const depositAmount = BigInt(500); + + const ix = await wormholeGateway.depositWormholeTbtcIx( + { + recipientWrappedToken, + recipientToken, + recipient: payer.publicKey, + }, + depositAmount + ); + + // Add custodian as minter. + const addMinterIx = await tbtc.addMinterIx({ + authority: authority.publicKey, + minter: custodian, + }); + await expectIxSuccess([addMinterIx], [authority]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 0, + supply: BigInt(2000), + paused: false, + pendingAuthority: null, + }); + + // Check token account balances before deposit. + const [wrappedBefore, tbtcBefore, gatewayBefore] = await Promise.all([ + getAccount(connection, recipientWrappedToken), + getAccount(connection, recipientToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + await expectIxSuccess([ix], [payer]); + await tbtc.checkConfig({ + authority: authority.publicKey, + numMinters: 1, + numGuardians: 0, + supply: BigInt(2500), + paused: false, + pendingAuthority: null, + }); + + const [wrappedAfter, tbtcAfter, gatewayAfter] = await Promise.all([ + getAccount(connection, recipientWrappedToken), + getAccount(connection, recipientToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + // Check minted amount after. + const mintedAmountAfter = await wormholeGateway.getMintedAmount(); + expect(mintedAmountAfter).to.equal(mintedAmountBefore + depositAmount); + + // Check balance change. + expect(wrappedAfter.amount).to.equal( + wrappedBefore.amount - depositAmount + ); + expect(tbtcAfter.amount).to.equal(tbtcBefore.amount + depositAmount); + expect(gatewayAfter.amount).to.equal( + gatewayBefore.amount + depositAmount + ); + }); + + it("cannot deposit wrapped tbtc (minting limit exceeded)", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Check wrapped tBTC mint. + const recipientWrappedToken = await preloadWrappedTbtc( + payer, + ethereumTokenBridge, + BigInt("100000000000"), + payer.publicKey + ); + + const recipientToken = await getOrCreateAta( + payer, + tbtcMint, + payer.publicKey + ); + + // Cannot deposit past minting limit. + const failingIx = await wormholeGateway.depositWormholeTbtcIx( + { + recipientWrappedToken, + recipientToken, + recipient: payer.publicKey, + }, + BigInt(50000) + ); + await expectIxFail([failingIx], [payer], "MintingLimitExceeded"); + }); + + it("deposit wrapped tbtc after increasing mint limit", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Check wrapped tBTC mint. + const recipientWrappedToken = await preloadWrappedTbtc( + payer, + ethereumTokenBridge, + BigInt("100000000000"), + payer.publicKey + ); + + const recipientToken = await getOrCreateAta( + payer, + tbtcMint, + payer.publicKey + ); + + // Check minted amount before deposit. + const mintedAmountBefore = await wormholeGateway.getMintedAmount(); + + const depositAmount = BigInt(50000); + + // Cannot deposit past minting limit. + const failingIx = await wormholeGateway.depositWormholeTbtcIx( + { + recipientWrappedToken, + recipientToken, + recipient: payer.publicKey, + }, + depositAmount + ); + + // Will succeed if minting limit is increased. + const newLimit = BigInt(70000); + const updateLimitIx = await wormholeGateway.updateMintingLimitIx( + { + authority: authority.publicKey, + }, + newLimit + ); + await expectIxSuccess([updateLimitIx], [authority]); + await wormholeGateway.checkCustodian({ + authority: authority.publicKey, + mintingLimit: newLimit, + pendingAuthority: null, + }); + await expectIxSuccess([failingIx], [payer]); + + // Check minted amount after. + const mintedAmountAfter = await wormholeGateway.getMintedAmount(); + expect(mintedAmountAfter).to.equal(mintedAmountBefore + depositAmount); + }); + }); + + describe("receive tbtc", () => { + let replayVaa; + + it("receive tbtc", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Use common token account. + const recipient = commonTokenOwner.publicKey; + const recipientToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient + ); + + // Get foreign gateway. + const fromGateway = await wormholeGateway + .getGatewayInfo(2) + .then((info) => info.address); + + // Get minted amount before. + const mintedAmountBefore = await wormholeGateway.getMintedAmount(); + + const sentAmount = BigInt(5000); + const signedVaa = await ethereumGatewaySendTbtc( + payer, + ethereumTokenBridge, + sentAmount, + fromGateway, + WORMHOLE_GATEWAY_PROGRAM_ID, + recipient + ); + + const [tbtcBefore, gatewayBefore] = await Promise.all([ + getAccount(connection, recipientToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + const ix = await wormholeGateway.receiveTbtcIx( + { + payer: payer.publicKey, + recipientToken, + recipient, + }, + signedVaa + ); + await expectIxSuccess([ix], [payer]); + + const [tbtcAfter, gatewayAfter] = await Promise.all([ + getAccount(connection, recipientToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + // Check balance change. + expect(tbtcAfter.amount).to.equal(tbtcBefore.amount + sentAmount); + expect(gatewayAfter.amount).to.equal(gatewayBefore.amount + sentAmount); + + // Check minted amount. + const mintedAmountAfter = await wormholeGateway.getMintedAmount(); + expect(mintedAmountAfter).to.equal(mintedAmountBefore + sentAmount); + + // Save vaa. + replayVaa = signedVaa; + }); + + it("cannot receive tbtc (vaa already redeemed)", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Use common token account. + const recipient = commonTokenOwner.publicKey; + const recipientToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient + ); + + const ix = await wormholeGateway.receiveTbtcIx( + { + payer: payer.publicKey, + recipientToken, + recipient, + }, + replayVaa + ); + + // Cannot receive tbtc again. + await expectIxFail([ix], [payer], "TransferAlreadyRedeemed"); + }); + + it("receive wrapped tbtc (ata doesn't exist)", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Use common token account. + const recipient = commonTokenOwner.publicKey; + const recipientToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient + ); + const recipientWrappedToken = getAssociatedTokenAddressSync( + WRAPPED_TBTC_MINT, + recipient + ); + + // Get minted amount before. + const mintedAmountBefore = await wormholeGateway.getMintedAmount(); + + // Verify that the wrapped token account doesn't exist yet. + try { + await getAccount(connection, recipientWrappedToken); + } catch (e: any) { + expect(e.toString()).to.equal("TokenAccountNotFoundError"); + } + + // Get foreign gateway. + const fromGateway = await wormholeGateway + .getGatewayInfo(2) + .then((info) => info.address); + + // Create transfer VAA. + const sentAmount = BigInt(5000); + const signedVaa = await ethereumGatewaySendTbtc( + payer, + ethereumTokenBridge, + sentAmount, + fromGateway, + WORMHOLE_GATEWAY_PROGRAM_ID, + recipient + ); + + // Set the mint limit to a value smaller than sentAmount. + const newLimit = sentAmount - BigInt(69); + const updateLimitIx = await wormholeGateway.updateMintingLimitIx( + { + authority: authority.publicKey, + }, + newLimit + ); + await expectIxSuccess([updateLimitIx], [authority]); + await wormholeGateway.checkCustodian({ + authority: authority.publicKey, + mintingLimit: newLimit, + pendingAuthority: null, + }); + + // Balance check before receiving wrapped tbtc. We can't + // check the balance of the recipient's wrapped tbtc yet, + // since the contract will create the ATA. + const [tbtcBefore, gatewayBefore] = await Promise.all([ + getAccount(connection, recipientToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + const ix = await wormholeGateway.receiveTbtcIx( + { + payer: payer.publicKey, + recipientToken, + recipient, + }, + signedVaa + ); + await expectIxSuccess([ix], [payer]); + + // Check token accounts after receiving wrapped tbtc. We should + // be able to fetch the recipient's wrapped tbtc now. + const [tbtcAfter, wrappedTbtcAfter, gatewayAfter] = await Promise.all([ + getAccount(connection, recipientToken), + getAccount(connection, recipientWrappedToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + // Check minted amount. + const mintedAmountAfter = await wormholeGateway.getMintedAmount(); + expect(mintedAmountAfter).to.equal(mintedAmountBefore); + + // Check balance change. + expect(tbtcAfter.amount).to.equal(tbtcBefore.amount); + expect(gatewayAfter.amount).to.equal(gatewayBefore.amount); + expect(wrappedTbtcAfter.amount).to.equal(sentAmount); + }); + + it("receive wrapped tbtc (ata exists)", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Use common token account. + const recipient = commonTokenOwner.publicKey; + const recipientToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient + ); + const recipientWrappedToken = await getOrCreateAta( + payer, + WRAPPED_TBTC_MINT, + recipient + ); + + // Get foreign gateway. + const fromGateway = await wormholeGateway + .getGatewayInfo(2) + .then((info) => info.address); + + // Get minted amount before. + const mintedAmountBefore = await wormholeGateway.getMintedAmount(); + + // Create transfer VAA. + const sentAmount = BigInt(5000); + const signedVaa = await ethereumGatewaySendTbtc( + payer, + ethereumTokenBridge, + sentAmount, + fromGateway, + WORMHOLE_GATEWAY_PROGRAM_ID, + recipient + ); + + // Set the mint limit to a value smaller than sentAmount. + const newLimit = sentAmount - BigInt(69); + const updateLimitIx = await wormholeGateway.updateMintingLimitIx( + { + authority: authority.publicKey, + }, + newLimit + ); + await expectIxSuccess([updateLimitIx], [authority]); + await wormholeGateway.checkCustodian({ + authority: authority.publicKey, + mintingLimit: newLimit, + pendingAuthority: null, + }); + + // Balance check before receiving wrapped tbtc. If this + // line successfully executes, then the recipient's + // wrapped tbtc account already exists. + const [tbtcBefore, wrappedTbtcBefore, gatewayBefore] = await Promise.all([ + getAccount(connection, recipientToken), + getAccount(connection, recipientWrappedToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + const ix = await wormholeGateway.receiveTbtcIx( + { + payer: payer.publicKey, + recipientToken, + recipient, + }, + signedVaa + ); + await expectIxSuccess([ix], [payer]); + + // Check token accounts after receiving wrapped tbtc. + const [tbtcAfter, wrappedTbtcAfter, gatewayAfter] = await Promise.all([ + getAccount(connection, recipientToken), + getAccount(connection, recipientWrappedToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + // Check minted amount. + const mintedAmountAfter = await wormholeGateway.getMintedAmount(); + expect(mintedAmountAfter).to.equal(mintedAmountBefore); + + // Check balance change. + expect(tbtcAfter.amount).to.equal(tbtcBefore.amount); + expect(gatewayAfter.amount).to.equal(gatewayBefore.amount); + expect(wrappedTbtcAfter.amount).to.equal( + wrappedTbtcBefore.amount + sentAmount + ); + }); + + it("cannot receive non-tbtc transfers", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Use common token account. + const recipient = commonTokenOwner.publicKey; + const recipientToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient + ); + + // Get foreign gateway. + const fromGateway = await wormholeGateway + .getGatewayInfo(2) + .then((info) => info.address); + + const sentAmount = BigInt(5000); + const signedVaa = await ethereumGatewaySendTbtc( + payer, + ethereumTokenBridge, + sentAmount, + fromGateway, + WORMHOLE_GATEWAY_PROGRAM_ID, + recipient, + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH address + 69 // hehe + ); + + const failingIx = await wormholeGateway.receiveTbtcIx( + { + payer: payer.publicKey, + recipientToken, + recipient, + }, + signedVaa + ); + await expectIxFail([failingIx], [payer], "InvalidEthereumTbtc"); + }); + + it("cannot receive zero-amount tbtc transfers", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Use common token account. + const recipient = commonTokenOwner.publicKey; + const recipientToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + recipient + ); + + // Get foreign gateway. + const fromGateway = await wormholeGateway + .getGatewayInfo(2) + .then((info) => info.address); + + const sentAmount = BigInt(0); + const signedVaa = await ethereumGatewaySendTbtc( + payer, + ethereumTokenBridge, + sentAmount, + fromGateway, + WORMHOLE_GATEWAY_PROGRAM_ID, + recipient + ); + + const failingIx = await wormholeGateway.receiveTbtcIx( + { + payer: payer.publicKey, + recipientToken, + recipient, + }, + signedVaa + ); + await expectIxFail([failingIx], [payer], "NoTbtcTransferred"); + }); + + it("cannot receive tbtc transfer with zero address as recipient", async () => { + // Set up new wallet + const payer = await generatePayer(authority); + + // Use common token account. Set the recipient to the zero address. + const recipient = PublicKey.default; + const defaultTokenAccount = await getOrCreateAta( + payer, + tbtc.getMintPDA(), + recipient + ); + + // Get foreign gateway. + const fromGateway = await wormholeGateway + .getGatewayInfo(2) + .then((info) => info.address); + + const sentAmount = BigInt(100); + const signedVaa = await ethereumGatewaySendTbtc( + payer, + ethereumTokenBridge, + sentAmount, + fromGateway, + WORMHOLE_GATEWAY_PROGRAM_ID, + recipient + ); + + const failingIx = await wormholeGateway.receiveTbtcIx( + { + payer: payer.publicKey, + recipientToken: defaultTokenAccount, + recipient, + }, + signedVaa + ); + await expectIxFail([failingIx], [payer], "RecipientZeroAddress"); + }); + }); + + describe("send tbtc", () => { + it("send tbtc to gateway", async () => { + // Use common token account. + const sender = commonTokenOwner.publicKey; + const senderToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + sender + ); + + // Check token accounts. + const [senderTbtcBefore, gatewayBefore] = await Promise.all([ + getAccount(connection, senderToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + // Check minted amount before. + const mintedAmountBefore = await wormholeGateway.getMintedAmount(); + + // Get destination gateway. + const recipientChain = 2; + const recipient = Array.from(Buffer.alloc(32, "deadbeef", "hex")); + const nonce = 420; + + // This should work. + const sendAmount = BigInt(2000); + const ix = await wormholeGateway.sendTbtcGatewayIx( + { + senderToken, + sender, + }, + { + amount: new anchor.BN(sendAmount.toString()), + recipientChain, + recipient, + nonce, + } + ); + await expectIxSuccess([ix], [commonTokenOwner]); + + // Check token accounts after sending tbtc. + const [senderTbtcAfter, gatewayAfter] = await Promise.all([ + getAccount(connection, senderToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + // Check minted amount. + const mintedAmountAfter = await wormholeGateway.getMintedAmount(); + expect(mintedAmountAfter).to.equal(mintedAmountBefore - sendAmount); + + // Check balance change. + expect(senderTbtcAfter.amount).to.equal( + senderTbtcBefore.amount - sendAmount + ); + expect(gatewayAfter.amount).to.equal(gatewayBefore.amount - sendAmount); + }); + + it("cannot send tbtc to gateway (insufficient wrapped balance)", async () => { + // Use common token account. + const sender = commonTokenOwner.publicKey; + const senderToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + sender + ); + + // Get destination gateway. + const recipientChain = 2; + const recipient = Array.from(Buffer.alloc(32, "deadbeef", "hex")); + const nonce = 420; + + // Check token accounts. + const gatewayWrappedBalance = await getAccount( + connection, + gatewayWrappedTbtcToken + ); + + // Try an amount that won't work. + const sendAmount = gatewayWrappedBalance.amount + BigInt(69); + const ix = await wormholeGateway.sendTbtcGatewayIx( + { + senderToken, + sender, + }, + { + amount: new anchor.BN(sendAmount.toString()), + recipientChain, + recipient, + nonce, + } + ); + await expectIxFail([ix], [commonTokenOwner], "NotEnoughWrappedTbtc"); + }); + + it("cannot send tbtc to gateway (zero amount)", async () => { + // Use common token account. + const sender = commonTokenOwner.publicKey; + const senderToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + sender + ); + + // Get destination gateway. + const recipientChain = 2; + const recipient = Array.from(Buffer.alloc(32, "deadbeef", "hex")); + const nonce = 420; + + // Try an amount that won't work. + const sendAmount = BigInt(0); + const ix = await wormholeGateway.sendTbtcGatewayIx( + { + senderToken, + sender, + }, + { + amount: new anchor.BN(sendAmount.toString()), + recipientChain, + recipient, + nonce, + } + ); + await expectIxFail([ix], [commonTokenOwner], "ZeroAmount"); + }); + + it("cannot send tbtc to gateway (recipient is zero address)", async () => { + // Use common token account. + const sender = commonTokenOwner.publicKey; + const senderToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + sender + ); + + // Get destination gateway. + const recipientChain = 2; + const recipient = Array.from(Buffer.alloc(32)); // empty buffer + const nonce = 420; + + const sendAmount = BigInt(69); + const ix = await wormholeGateway.sendTbtcGatewayIx( + { + senderToken, + sender, + }, + { + amount: new anchor.BN(sendAmount.toString()), + recipientChain, + recipient, + nonce, + } + ); + await expectIxFail([ix], [commonTokenOwner], "ZeroRecipient"); + }); + + it("cannot send tbtc to gateway (invalid target gateway)", async () => { + // Use common token account. + const sender = commonTokenOwner.publicKey; + const senderToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + sender + ); + + // Get destination gateway. + const recipientChain = 69; // bad gateway + const recipient = Array.from(Buffer.alloc(32)); // empty buffer + const nonce = 420; + + const sendAmount = BigInt(69); + const ix = await wormholeGateway.sendTbtcGatewayIx( + { + senderToken, + sender, + }, + { + amount: new anchor.BN(sendAmount.toString()), + recipientChain, + recipient, + nonce, + } + ); + await expectIxFail([ix], [commonTokenOwner], "AccountNotInitialized"); + }); + }); + + describe("send wrapped tbtc", () => { + it("send wrapped tbtc", async () => { + // Use common token account. + const sender = commonTokenOwner.publicKey; + const senderToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + sender + ); + + // Check token accounts. + const [senderTbtcBefore, gatewayBefore] = await Promise.all([ + getAccount(connection, senderToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + // Check minted amount before. + const mintedAmountBefore = await wormholeGateway.getMintedAmount(); + + // Get destination gateway. + const recipientChain = 69; + const recipient = Array.from(Buffer.alloc(32, "deadbeef", "hex")); + const nonce = 420; + + // This should work. + const sendAmount = BigInt(2000); + const ix = await wormholeGateway.sendTbtcWrappedIx( + { + senderToken, + sender, + }, + { + amount: new anchor.BN(sendAmount.toString()), + recipientChain, + recipient, + arbiterFee: new anchor.BN(0), + nonce, + } + ); + await expectIxSuccess([ix], [commonTokenOwner]); + + // Check token accounts after sending tbtc. + const [senderTbtcAfter, gatewayAfter] = await Promise.all([ + getAccount(connection, senderToken), + getAccount(connection, gatewayWrappedTbtcToken), + ]); + + // Check minted amount. + const mintedAmountAfter = await wormholeGateway.getMintedAmount(); + expect(mintedAmountAfter).to.equal(mintedAmountBefore - sendAmount); + + // Check balance change. + expect(senderTbtcAfter.amount).to.equal( + senderTbtcBefore.amount - sendAmount + ); + expect(gatewayAfter.amount).to.equal(gatewayBefore.amount - sendAmount); + }); + + it("cannot send wrapped tbtc (insufficient wrapped balance)", async () => { + // Use common token account. + const sender = commonTokenOwner.publicKey; + const senderToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + sender + ); + + // Get destination gateway. + const recipientChain = 2; + const recipient = Array.from(Buffer.alloc(32, "deadbeef", "hex")); + const nonce = 420; + + // Check token accounts. + const gatewayWrappedBalance = await getAccount( + connection, + gatewayWrappedTbtcToken + ); + + // Try an amount that won't work. + const sendAmount = gatewayWrappedBalance.amount + BigInt(69); + const ix = await wormholeGateway.sendTbtcWrappedIx( + { + senderToken, + sender, + }, + { + amount: new anchor.BN(sendAmount.toString()), + recipientChain, + recipient, + arbiterFee: new anchor.BN(0), + nonce, + } + ); + await expectIxFail([ix], [commonTokenOwner], "NotEnoughWrappedTbtc"); + }); + + it("cannot send wrapped tbtc(zero amount)", async () => { + // Use common token account. + const sender = commonTokenOwner.publicKey; + const senderToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + sender + ); + + // Get destination gateway. + const recipientChain = 2; + const recipient = Array.from(Buffer.alloc(32, "deadbeef", "hex")); + const nonce = 420; + + // Try an amount that won't work. + const sendAmount = BigInt(0); + const ix = await wormholeGateway.sendTbtcWrappedIx( + { + senderToken, + sender, + }, + { + amount: new anchor.BN(sendAmount.toString()), + recipientChain, + recipient, + arbiterFee: new anchor.BN(0), + nonce, + } + ); + await expectIxFail([ix], [commonTokenOwner], "ZeroAmount"); + }); + + it("cannot send wrapped tbtc (recipient is zero address)", async () => { + // Use common token account. + const sender = commonTokenOwner.publicKey; + const senderToken = getAssociatedTokenAddressSync( + tbtc.getMintPDA(), + sender + ); + + // Get destination gateway. + const recipientChain = 2; + const recipient = Array.from(Buffer.alloc(32)); // empty buffer + const nonce = 420; + + const sendAmount = BigInt(69); + const ix = await wormholeGateway.sendTbtcWrappedIx( + { + senderToken, + sender, + }, + { + amount: new anchor.BN(sendAmount.toString()), + recipientChain, + recipient, + arbiterFee: new anchor.BN(0), + nonce, + } + ); + await expectIxFail([ix], [commonTokenOwner], "ZeroRecipient"); + }); + }); +}); diff --git a/cross-chain/solana/tests/accounts/core_bridge.json b/cross-chain/solana/tests/accounts/core_bridge_data.json similarity index 100% rename from cross-chain/solana/tests/accounts/core_bridge.json rename to cross-chain/solana/tests/accounts/core_bridge_data.json diff --git a/cross-chain/solana/tests/accounts/core_fee_collector.json b/cross-chain/solana/tests/accounts/core_fee_collector.json index 6f355d442..beae11950 100644 --- a/cross-chain/solana/tests/accounts/core_fee_collector.json +++ b/cross-chain/solana/tests/accounts/core_fee_collector.json @@ -1,7 +1,7 @@ { "pubkey": "9bFNrXNb2WTx8fMHXCheaZqkLZ3YCCaiqTftHxeintHy", "account": { - "lamports": 86533780, + "lamports": 86533880, "data": [ "", "base64" diff --git a/cross-chain/solana/tests/helpers/consts.ts b/cross-chain/solana/tests/helpers/consts.ts new file mode 100644 index 000000000..748be2689 --- /dev/null +++ b/cross-chain/solana/tests/helpers/consts.ts @@ -0,0 +1,50 @@ +import { PublicKey } from "@solana/web3.js"; + +export const TBTC_PROGRAM_ID = new PublicKey( + "HksEtDgsXJV1BqcuhzbLRTmXp5gHgHJktieJCtQd3pG" +); +export const WORMHOLE_GATEWAY_PROGRAM_ID = new PublicKey( + "8H9F5JGbEMyERycwaGuzLS5MQnV7dn2wm2h6egJ3Leiu" +); + +export const CORE_BRIDGE_PROGRAM_ID = new PublicKey( + "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth" +); +export const TOKEN_BRIDGE_PROGRAM_ID = new PublicKey( + "wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb" +); + +export const ETHEREUM_TOKEN_BRIDGE_ADDRESS = + "0x3ee18B2214AFF97000D974cf647E7C347E8fa585"; +export const ETHEREUM_TBTC_ADDRESS = + "0x18084fbA666a33d37592fA2633fD49a74DD93a88"; + +export const GUARDIAN_SET_INDEX = 3; +export const GUARDIAN_DEVNET_PRIVATE_KEYS = [ + "cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0", +]; + +// relevant core bridge PDAs +export const CORE_BRIDGE_DATA = new PublicKey( + "2yVjuQwpsvdsrywzsJJVs9Ueh4zayyo5DYJbBNc3DDpn" +); +export const CORE_EMITTER_SEQUENCE = new PublicKey( + "GF2ghkjwsR9CHkGk1RvuZrApPZGBZynxMm817VNi51Nf" +); +export const CORE_FEE_COLLECTOR = new PublicKey( + "9bFNrXNb2WTx8fMHXCheaZqkLZ3YCCaiqTftHxeintHy" +); + +// relevant token bridge PDAs +export const WRAPPED_TBTC_MINT = new PublicKey( + "25rXTx9zDZcHyTav5sRqM6YBvTGu9pPH9yv83uAEqbgG" +); +export const WRAPPED_TBTC_ASSET = new PublicKey( + "5LEUZpBxUQmoxoNGqmYmFEGAPDuhWbAY5CGt519UixLo" +); +export const ETHEREUM_ENDPOINT = new PublicKey( + "DujfLgMKW71CT2W8pxknf42FT86VbcK5PjQ6LsutjWKC" +); +export const TOKEN_BRIDGE_CONFIG = new PublicKey( + "DapiQYH3BGonhN8cngWcXQ6SrqSm3cwysoznoHr6Sbsx" +); diff --git a/cross-chain/solana/tests/helpers/index.ts b/cross-chain/solana/tests/helpers/index.ts new file mode 100644 index 000000000..cb1b44601 --- /dev/null +++ b/cross-chain/solana/tests/helpers/index.ts @@ -0,0 +1,2 @@ +export * from "./consts"; +export * from "./utils"; \ No newline at end of file diff --git a/cross-chain/solana/tests/helpers/tbtc.ts b/cross-chain/solana/tests/helpers/tbtc.ts new file mode 100644 index 000000000..7302c3ed3 --- /dev/null +++ b/cross-chain/solana/tests/helpers/tbtc.ts @@ -0,0 +1,510 @@ +import { BN, Program, Wallet, workspace } from "@coral-xyz/anchor"; +import { getMint } from "@solana/spl-token"; +import { PublicKey, TransactionInstruction } from "@solana/web3.js"; +import { config, expect } from "chai"; +import { Tbtc } from "../../target/types/tbtc"; +import { TBTC_PROGRAM_ID } from "./consts"; +import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; + +export function getConfigPDA(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("config")], + TBTC_PROGRAM_ID + )[0]; +} + +export function getMintPDA(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("tbtc-mint")], + TBTC_PROGRAM_ID + )[0]; +} + +export function getTbtcMetadataPDA(): PublicKey { + return PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + METADATA_PROGRAM_ID.toBuffer(), + getMintPDA().toBuffer(), + ], + METADATA_PROGRAM_ID + )[0]; +} + +export function getMinterInfoPDA(minter: PublicKey): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("minter-info"), minter.toBuffer()], + TBTC_PROGRAM_ID + )[0]; +} + +export function getGuardianInfoPDA(guardian: PublicKey): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("guardian-info"), guardian.toBuffer()], + TBTC_PROGRAM_ID + )[0]; +} + +export function getGuardiansPDA(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("guardians")], + TBTC_PROGRAM_ID + )[0]; +} + +export function getMintersPDA(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("minters")], + TBTC_PROGRAM_ID + )[0]; +} + +export async function getConfigData() { + const program = workspace.Tbtc as Program; + const config = getConfigPDA(); + return program.account.config.fetch(config); +} + +export async function checkConfig(expected: { + authority: PublicKey; + numMinters: number; + numGuardians: number; + supply: bigint; + paused: boolean; + pendingAuthority: PublicKey | null; +}) { + let { + authority, + numMinters, + numGuardians, + supply, + paused, + pendingAuthority, + } = expected; + const program = workspace.Tbtc as Program; + const configState = await getConfigData(); + + expect(configState.authority).to.eql(authority); + expect(configState.numMinters).to.equal(numMinters); + expect(configState.numGuardians).to.equal(numGuardians); + expect(configState.paused).to.equal(paused); + expect(configState.pendingAuthority).to.eql(pendingAuthority); + + const mintState = await getMint( + program.provider.connection, + configState.mint + ); + expect(mintState.supply).to.equal(supply); + + const guardians = getGuardiansPDA(); + const guardiansState = await program.account.guardians.fetch(guardians); + expect(guardiansState.keys).has.length(numGuardians); + + const minters = getMintersPDA(); + const mintersState = await program.account.minters.fetch(minters); + expect(mintersState.keys).has.length(numMinters); +} + +export async function getMinterInfo(minter: PublicKey) { + const program = workspace.Tbtc as Program; + const minterInfoPDA = getMinterInfoPDA(minter); + return program.account.minterInfo.fetch(minterInfoPDA); +} + +export async function checkMinterInfo(minter: PublicKey) { + const minterInfo = await getMinterInfo(minter); + expect(minterInfo.minter).to.eql(minter); +} + +export async function getGuardianInfo(guardian: PublicKey) { + const program = workspace.Tbtc as Program; + const guardianInfoPDA = getGuardianInfoPDA(guardian); + return program.account.guardianInfo.fetch(guardianInfoPDA); +} + +export async function checkGuardianInfo(guardian: PublicKey) { + let guardianInfo = await getGuardianInfo(guardian); + expect(guardianInfo.guardian).to.eql(guardian); +} + +type AddGuardianContext = { + config?: PublicKey; + authority: PublicKey; + guardians?: PublicKey; + guardianInfo?: PublicKey; + guardian: PublicKey; +}; + +export async function addGuardianIx( + accounts: AddGuardianContext +): Promise { + const program = workspace.Tbtc as Program; + + let { config, authority, guardians, guardianInfo, guardian } = accounts; + if (config === undefined) { + config = getConfigPDA(); + } + + if (guardians === undefined) { + guardians = getGuardiansPDA(); + } + + if (guardianInfo === undefined) { + guardianInfo = getGuardianInfoPDA(guardian); + } + + return program.methods + .addGuardian() + .accounts({ + config, + authority, + guardians, + guardianInfo, + guardian, + }) + .instruction(); +} + +type AddMinterContext = { + config?: PublicKey; + authority: PublicKey; + minters?: PublicKey; + minterInfo?: PublicKey; + minter: PublicKey; +}; + +export async function addMinterIx( + accounts: AddMinterContext +): Promise { + const program = workspace.Tbtc as Program; + + let { config, authority, minters, minterInfo, minter } = accounts; + if (config === undefined) { + config = getConfigPDA(); + } + + if (minters === undefined) { + minters = getMintersPDA(); + } + + if (minterInfo === undefined) { + minterInfo = getMinterInfoPDA(minter); + } + + return program.methods + .addMinter() + .accounts({ + config, + authority, + minters, + minterInfo, + minter, + }) + .instruction(); +} + +type CancelAuthorityChange = { + config?: PublicKey; + authority: PublicKey; +}; + +export async function cancelAuthorityChangeIx( + accounts: CancelAuthorityChange +): Promise { + const program = workspace.Tbtc as Program; + + let { config, authority } = accounts; + if (config === undefined) { + config = getConfigPDA(); + } + + return program.methods + .cancelAuthorityChange() + .accounts({ + config, + authority, + }) + .instruction(); +} + +type ChangeAuthorityContext = { + config?: PublicKey; + authority: PublicKey; + newAuthority: PublicKey; +}; + +export async function changeAuthorityIx( + accounts: ChangeAuthorityContext +): Promise { + const program = workspace.Tbtc as Program; + + let { config, authority, newAuthority } = accounts; + if (config === undefined) { + config = getConfigPDA(); + } + + return program.methods + .changeAuthority() + .accounts({ + config, + authority, + newAuthority, + }) + .instruction(); +} + +type InitializeContext = { + mint?: PublicKey; + config?: PublicKey; + guardians?: PublicKey; + minters?: PublicKey; + authority: PublicKey; + tbtcMetadata?: PublicKey; + mplTokenMetadataProgram?: PublicKey; +}; + +export async function initializeIx( + accounts: InitializeContext +): Promise { + const program = workspace.Tbtc as Program; + + let { + mint, + config, + guardians, + minters, + authority, + tbtcMetadata, + mplTokenMetadataProgram, + } = accounts; + + if (mint === undefined) { + mint = getMintPDA(); + } + + if (config === undefined) { + config = getConfigPDA(); + } + + if (guardians === undefined) { + guardians = getGuardiansPDA(); + } + + if (minters === undefined) { + minters = getMintersPDA(); + } + + if (tbtcMetadata === undefined) { + tbtcMetadata = getTbtcMetadataPDA(); + } + + if (mplTokenMetadataProgram === undefined) { + mplTokenMetadataProgram = METADATA_PROGRAM_ID; + } + + return program.methods + .initialize() + .accounts({ + mint, + config, + guardians, + minters, + authority, + tbtcMetadata, + mplTokenMetadataProgram, + }) + .instruction(); +} + +type PauseContext = { + config?: PublicKey; + guardianInfo?: PublicKey; + guardian: PublicKey; +}; + +export async function pauseIx( + accounts: PauseContext +): Promise { + const program = workspace.Tbtc as Program; + + let { config, guardianInfo, guardian } = accounts; + if (config === undefined) { + config = getConfigPDA(); + } + + if (guardianInfo === undefined) { + guardianInfo = getGuardianInfoPDA(guardian); + } + + return program.methods + .pause() + .accounts({ + config, + guardianInfo, + guardian, + }) + .instruction(); +} + +type RemoveGuardianContext = { + config?: PublicKey; + authority: PublicKey; + guardians?: PublicKey; + guardianInfo?: PublicKey; + guardian: PublicKey; +}; + +export async function removeGuardianIx( + accounts: RemoveGuardianContext +): Promise { + const program = workspace.Tbtc as Program; + + let { config, authority, guardians, guardianInfo, guardian } = accounts; + if (config === undefined) { + config = getConfigPDA(); + } + + if (guardians === undefined) { + guardians = getGuardiansPDA(); + } + + if (guardianInfo === undefined) { + guardianInfo = getGuardianInfoPDA(guardian); + } + + return program.methods + .removeGuardian() + .accounts({ + config, + authority, + guardians, + guardianInfo, + guardian, + }) + .instruction(); +} + +type RemoveMinterContext = { + config?: PublicKey; + authority: PublicKey; + minters?: PublicKey; + minterInfo?: PublicKey; + minter: PublicKey; +}; + +export async function removeMinterIx( + accounts: RemoveMinterContext +): Promise { + const program = workspace.Tbtc as Program; + + let { config, authority, minters, minterInfo, minter } = accounts; + if (config === undefined) { + config = getConfigPDA(); + } + + if (minters === undefined) { + minters = getMintersPDA(); + } + + if (minterInfo === undefined) { + minterInfo = getMinterInfoPDA(minter); + } + + return program.methods + .removeMinter() + .accounts({ + config, + authority, + minters, + minterInfo, + minter, + }) + .instruction(); +} + +type TakeAuthorityContext = { + config?: PublicKey; + pendingAuthority: PublicKey; +}; + +export async function takeAuthorityIx( + accounts: TakeAuthorityContext +): Promise { + const program = workspace.Tbtc as Program; + + let { config, pendingAuthority } = accounts; + if (config === undefined) { + config = getConfigPDA(); + } + + return program.methods + .takeAuthority() + .accounts({ + config, + pendingAuthority, + }) + .instruction(); +} + +type UnpauseContext = { + config?: PublicKey; + authority: PublicKey; +}; + +export async function unpauseIx( + accounts: UnpauseContext +): Promise { + const program = workspace.Tbtc as Program; + + let { config, authority } = accounts; + if (config === undefined) { + config = getConfigPDA(); + } + + return program.methods + .unpause() + .accounts({ + config, + authority, + }) + .instruction(); +} + +type MintContext = { + mint?: PublicKey; + config?: PublicKey; + minterInfo?: PublicKey; + minter: PublicKey; + recipientToken: PublicKey; +}; + +export async function mintIx( + accounts: MintContext, + amount: BN +): Promise { + const program = workspace.Tbtc as Program; + + let { mint, config, minterInfo, minter, recipientToken } = accounts; + if (mint === undefined) { + mint = getMintPDA(); + } + + if (config === undefined) { + config = getConfigPDA(); + } + + if (minterInfo === undefined) { + minterInfo = getMinterInfoPDA(minter); + } + + return program.methods + .mint(amount) + .accounts({ + mint, + config, + minterInfo, + minter, + recipientToken, + }) + .instruction(); +} diff --git a/cross-chain/solana/tests/helpers/utils.ts b/cross-chain/solana/tests/helpers/utils.ts index b87a0a948..40980e668 100644 --- a/cross-chain/solana/tests/helpers/utils.ts +++ b/cross-chain/solana/tests/helpers/utils.ts @@ -1,53 +1,282 @@ -import { web3 } from "@coral-xyz/anchor"; -import { Account, TokenAccountNotFoundError, createAssociatedTokenAccountIdempotentInstruction, getAccount, getAssociatedTokenAddressSync } from "@solana/spl-token"; -import { Connection, Keypair, PublicKey, SystemProgram, Transaction, sendAndConfirmTransaction } from "@solana/web3.js"; - -export async function transferLamports(connection: web3.Connection, fromSigner: web3.Keypair, toPubkey: web3.PublicKey, lamports: number) { - return sendAndConfirmTransaction( - connection, - new Transaction().add( - SystemProgram.transfer({ - fromPubkey: fromSigner.publicKey, - toPubkey, - lamports, - }) - ), - [fromSigner] +import { + postVaaSolana, + redeemOnSolana, + tryNativeToHexString, +} from "@certusone/wormhole-sdk"; +import { + MockEthereumTokenBridge, + MockGuardians, +} from "@certusone/wormhole-sdk/lib/cjs/mock"; +import { NodeWallet } from "@certusone/wormhole-sdk/lib/cjs/solana"; +import * as coreBridge from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole"; +import { Program, web3, workspace } from "@coral-xyz/anchor"; +import { + Account, + TokenAccountNotFoundError, + createAssociatedTokenAccountIdempotentInstruction, + getAccount, + getAssociatedTokenAddressSync, +} from "@solana/spl-token"; +import { + Keypair, + PublicKey, + SystemProgram, + Transaction, + TransactionInstruction, + sendAndConfirmTransaction, +} from "@solana/web3.js"; +import { assert, expect } from "chai"; +import { WormholeGateway } from "../../target/types/wormhole_gateway"; // This is only here to hack a connection. +import { + CORE_BRIDGE_PROGRAM_ID, + ETHEREUM_TBTC_ADDRESS, + GUARDIAN_DEVNET_PRIVATE_KEYS, + GUARDIAN_SET_INDEX, + TOKEN_BRIDGE_PROGRAM_ID, + WRAPPED_TBTC_MINT, +} from "./consts"; + +export const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); + +export async function transferLamports( + fromSigner: web3.Keypair, + toPubkey: web3.PublicKey, + lamports: number +) { + const program = workspace.WormholeGateway as Program; + return sendAndConfirmTransaction( + program.provider.connection, + new Transaction().add( + SystemProgram.transfer({ + fromPubkey: fromSigner.publicKey, + toPubkey, + lamports, + }) + ), + [fromSigner] + ); +} + +export async function generatePayer(funder: Keypair, lamports?: number) { + const newPayer = Keypair.generate(); + await transferLamports( + funder, + newPayer.publicKey, + lamports === undefined ? 1000000000 : lamports + ); + return newPayer; +} + +export async function getOrCreateAta( + payer: Keypair, + mint: PublicKey, + owner: PublicKey +) { + const program = workspace.WormholeGateway as Program; + const connection = program.provider.connection; + + const token = getAssociatedTokenAddressSync(mint, owner); + const tokenData: Account = await getAccount(connection, token).catch( + (err) => { + if (err instanceof TokenAccountNotFoundError) { + return null; + } else { + throw err; + } + } + ); + + if (tokenData === null) { + await web3.sendAndConfirmTransaction( + connection, + new web3.Transaction().add( + createAssociatedTokenAccountIdempotentInstruction( + payer.publicKey, + token, + owner, + mint + ) + ), + [payer] ); + } + + return token; +} + +export async function getTokenBalance(token: PublicKey): Promise { + const program = workspace.WormholeGateway as Program; + return getAccount(program.provider.connection, token).then( + (account) => account.amount + ); +} + +export async function preloadWrappedTbtc( + payer: Keypair, + ethereumTokenBridge: MockEthereumTokenBridge, + amount: bigint, + tokenOwner: PublicKey +) { + const program = workspace.WormholeGateway as Program; + const connection = program.provider.connection; + + const wrappedTbtcToken = await getOrCreateAta( + payer, + WRAPPED_TBTC_MINT, + tokenOwner + ); + + // Bridge tbtc to token account. + const published = ethereumTokenBridge.publishTransferTokens( + tryNativeToHexString(ETHEREUM_TBTC_ADDRESS, "ethereum"), + 2, + amount, + 1, + wrappedTbtcToken.toBuffer().toString("hex"), + BigInt(0), + 0, + 0 + ); + + const signedVaa = await mockSignAndPostVaa(payer, published); + + const tx = await redeemOnSolana( + connection, + CORE_BRIDGE_PROGRAM_ID, + TOKEN_BRIDGE_PROGRAM_ID, + payer.publicKey, + signedVaa + ); + await web3.sendAndConfirmTransaction(connection, tx, [payer]); + + return wrappedTbtcToken; +} + +export async function mockSignAndPostVaa( + payer: web3.Keypair, + published: Buffer +) { + const program = workspace.WormholeGateway as Program; + + const guardians = new MockGuardians(GUARDIAN_SET_INDEX, [ + "cfb12303a19cde580bb4dd771639b0d26bc68353645571a8cff516ab2ee113a0", + ]); + + // Add guardian signature. + const signedVaa = guardians.addSignatures(published, [0]); + + // Verify and post VAA. + await postVaaSolana( + program.provider.connection, + new NodeWallet(payer).signTransaction, + CORE_BRIDGE_PROGRAM_ID, + payer.publicKey, + signedVaa + ); + + return signedVaa; +} + +export async function ethereumGatewaySendTbtc( + payer: web3.Keypair, + ethereumTokenBridge: MockEthereumTokenBridge, + amount: bigint, + fromGateway: number[], + toGateway: PublicKey, + recipient: PublicKey, + tokenAddress?: string, + tokenChain?: number +) { + const program = workspace.WormholeGateway as Program; + + const published = ethereumTokenBridge.publishTransferTokensWithPayload( + tryNativeToHexString(tokenAddress ?? ETHEREUM_TBTC_ADDRESS, "ethereum"), + tokenChain ?? 2, + amount, + 1, + toGateway.toBuffer().toString("hex"), + Buffer.from(fromGateway), + recipient.toBuffer(), + 0, + 0 + ); + + const guardians = new MockGuardians( + GUARDIAN_SET_INDEX, + GUARDIAN_DEVNET_PRIVATE_KEYS + ); + + // Add guardian signature. + const signedVaa = guardians.addSignatures(published, [0]); + + // Verify and post VAA. + await postVaaSolana( + program.provider.connection, + new NodeWallet(payer).signTransaction, + CORE_BRIDGE_PROGRAM_ID, + payer.publicKey, + signedVaa + ); + + return signedVaa; } -export async function generatePayer(connection: web3.Connection, payer: Keypair, lamports?: number) { - const newPayer = Keypair.generate(); - await transferLamports(connection, payer, newPayer.publicKey, lamports === undefined ? 1000000000 : lamports); - return newPayer; -} - -export async function getOrCreateTokenAccount(connection: Connection, payer: Keypair, mint: PublicKey, owner: PublicKey) { - const token = getAssociatedTokenAddressSync(mint, owner); - const tokenData: Account = await getAccount(connection, token).catch((err) => { - if (err instanceof TokenAccountNotFoundError) { - return null; - } else { - throw err; - }; - }); - - if (tokenData === null) { - await web3.sendAndConfirmTransaction( - connection, - new web3.Transaction().add( - createAssociatedTokenAccountIdempotentInstruction( - payer.publicKey, - token, - owner, - mint, - ) - ), - [payer] - ); - - return getAccount(connection, token); - } else { - return tokenData; +export async function expectIxSuccess( + ixes: TransactionInstruction[], + signers: Keypair[] +) { + const program = workspace.WormholeGateway as Program; + await sendAndConfirmTransaction( + program.provider.connection, + new Transaction().add(...ixes), + signers + ).catch((err) => { + if (err.logs !== undefined) { + console.log(err.logs); } -} \ No newline at end of file + throw err; + }); +} + +export async function expectIxFail( + ixes: TransactionInstruction[], + signers: Keypair[], + errorMessage: string +) { + const program = workspace.WormholeGateway as Program; + try { + const txSig = await sendAndConfirmTransaction( + program.provider.connection, + new Transaction().add(...ixes), + signers + ); + assert(false, `transaction should have failed: ${txSig}`); + } catch (err) { + if (err.logs === undefined) { + throw err; + } + const logs: string[] = err.logs; + expect(logs.join("\n")).includes(errorMessage); + } +} + +export function getTokenBridgeCoreEmitter() { + const [tokenBridgeCoreEmitter] = PublicKey.findProgramAddressSync( + [Buffer.from("emitter")], + TOKEN_BRIDGE_PROGRAM_ID + ); + + return tokenBridgeCoreEmitter; +} + +export async function getTokenBridgeSequence() { + const program = workspace.WormholeGateway as Program; + const emitter = getTokenBridgeCoreEmitter(); + return coreBridge + .getSequenceTracker( + program.provider.connection, + emitter, + CORE_BRIDGE_PROGRAM_ID + ) + .then((tracker) => tracker.sequence); +} diff --git a/cross-chain/solana/tests/helpers/wormholeGateway.ts b/cross-chain/solana/tests/helpers/wormholeGateway.ts new file mode 100644 index 000000000..efb3f06d6 --- /dev/null +++ b/cross-chain/solana/tests/helpers/wormholeGateway.ts @@ -0,0 +1,809 @@ +import { parseVaa } from "@certusone/wormhole-sdk"; +import * as tokenBridge from "@certusone/wormhole-sdk/lib/cjs/solana/tokenBridge"; +import * as coreBridge from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole"; +import { BN, Program, workspace } from "@coral-xyz/anchor"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; +import { + PublicKey, + SYSVAR_CLOCK_PUBKEY, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from "@solana/web3.js"; +import { expect } from "chai"; +import { WormholeGateway } from "../../target/types/wormhole_gateway"; +import { + CORE_BRIDGE_DATA, + CORE_BRIDGE_PROGRAM_ID, + ETHEREUM_ENDPOINT, + TBTC_PROGRAM_ID, + TOKEN_BRIDGE_PROGRAM_ID, + WORMHOLE_GATEWAY_PROGRAM_ID, + WRAPPED_TBTC_ASSET, + WRAPPED_TBTC_MINT, +} from "./consts"; +import * as tbtc from "./tbtc"; +import { getTokenBridgeCoreEmitter, getTokenBridgeSequence } from "./utils"; + +export function getCustodianPDA(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("redeemer")], + WORMHOLE_GATEWAY_PROGRAM_ID + )[0]; +} + +export function getCoreMessagePDA(sequence: bigint): PublicKey { + const encodedSequence = Buffer.alloc(8); + encodedSequence.writeBigUInt64LE(sequence); + return PublicKey.findProgramAddressSync( + [Buffer.from("msg"), encodedSequence], + WORMHOLE_GATEWAY_PROGRAM_ID + )[0]; +} + +export function getGatewayInfoPDA(targetChain: number): PublicKey { + const encodedChain = Buffer.alloc(2); + encodedChain.writeUInt16LE(targetChain); + return PublicKey.findProgramAddressSync( + [Buffer.from("gateway-info"), encodedChain], + WORMHOLE_GATEWAY_PROGRAM_ID + )[0]; +} + +export function getWrappedTbtcTokenPDA(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("wrapped-token")], + WORMHOLE_GATEWAY_PROGRAM_ID + )[0]; +} + +export function getTokenBridgeSenderPDA(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("sender")], + WORMHOLE_GATEWAY_PROGRAM_ID + )[0]; +} + +export function getTokenBridgeRedeemerPDA(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("redeemer")], + WORMHOLE_GATEWAY_PROGRAM_ID + )[0]; +} + +export async function getCustodianData() { + const program = workspace.WormholeGateway as Program; + const custodian = getCustodianPDA(); + return program.account.custodian.fetch(custodian); +} + +export async function checkCustodian(expected: { + authority: PublicKey; + mintingLimit: bigint; + pendingAuthority: PublicKey | null; +}) { + let { authority, mintingLimit, pendingAuthority } = expected; + const custodianState = await getCustodianData(); + + expect(custodianState.mintingLimit.eq(new BN(mintingLimit.toString()))).to.be + .true; + expect(custodianState.authority).to.eql(authority); + expect(custodianState.pendingAuthority).to.eql(pendingAuthority); +} + +export async function getMintedAmount(): Promise { + const custodianState = await getCustodianData(); + return BigInt(custodianState.mintedAmount.toString()); +} + +export async function getGatewayInfo(chain: number) { + const program = workspace.WormholeGateway as Program; + const gatewayInfo = getGatewayInfoPDA(chain); + return program.account.gatewayInfo.fetch(gatewayInfo); +} + +export async function checkGateway(chain: number, expectedAddress: number[]) { + const gatewayInfoState = await getGatewayInfo(chain); + expect(gatewayInfoState.address).to.eql(expectedAddress); +} + +type CancelAuthorityChange = { + custodian?: PublicKey; + authority: PublicKey; +}; + +export async function cancelAuthorityChangeIx( + accounts: CancelAuthorityChange +): Promise { + const program = workspace.WormholeGateway as Program; + + let { custodian, authority } = accounts; + if (custodian === undefined) { + custodian = getCustodianPDA(); + } + + return program.methods + .cancelAuthorityChange() + .accounts({ + custodian, + authority, + }) + .instruction(); +} + +type ChangeAuthorityContext = { + custodian?: PublicKey; + authority: PublicKey; + newAuthority: PublicKey; +}; + +export async function changeAuthorityIx( + accounts: ChangeAuthorityContext +): Promise { + const program = workspace.WormholeGateway as Program; + + let { custodian, authority, newAuthority } = accounts; + if (custodian === undefined) { + custodian = getCustodianPDA(); + } + + return program.methods + .changeAuthority() + .accounts({ + custodian, + authority, + newAuthority, + }) + .instruction(); +} + +type TakeAuthorityContext = { + custodian?: PublicKey; + pendingAuthority: PublicKey; +}; + +export async function takeAuthorityIx( + accounts: TakeAuthorityContext +): Promise { + const program = workspace.WormholeGateway as Program; + + let { custodian, pendingAuthority } = accounts; + if (custodian === undefined) { + custodian = getCustodianPDA(); + } + + return program.methods + .takeAuthority() + .accounts({ + custodian, + pendingAuthority, + }) + .instruction(); +} + +type UpdateMintingLimitContext = { + custodian?: PublicKey; + authority: PublicKey; +}; + +export async function updateMintingLimitIx( + accounts: UpdateMintingLimitContext, + amount: bigint +): Promise { + const program = workspace.WormholeGateway as Program; + + let { custodian, authority } = accounts; + if (custodian === undefined) { + custodian = getCustodianPDA(); + } + + return program.methods + .updateMintingLimit(new BN(amount.toString())) + .accounts({ + custodian, + authority, + }) + .instruction(); +} + +type UpdateGatewayAddressContext = { + custodian?: PublicKey; + gatewayInfo?: PublicKey; + authority: PublicKey; +}; + +type UpdateGatewayAddressArgs = { + chain: number; + address: number[]; +}; + +export async function updateGatewayAddress( + accounts: UpdateGatewayAddressContext, + args: UpdateGatewayAddressArgs +) { + const program = workspace.WormholeGateway as Program; + let { custodian, gatewayInfo, authority } = accounts; + + if (custodian === undefined) { + custodian = getCustodianPDA(); + } + + if (gatewayInfo === undefined) { + gatewayInfo = getGatewayInfoPDA(args.chain); + } + + return program.methods + .updateGatewayAddress(args) + .accounts({ + custodian, + gatewayInfo, + authority, + }) + .instruction(); +} + +type DepositWormholeTbtcContext = { + custodian?: PublicKey; + wrappedTbtcToken?: PublicKey; + wrappedTbtcMint?: PublicKey; + tbtcMint?: PublicKey; + recipientWrappedToken: PublicKey; + recipientToken: PublicKey; + recipient: PublicKey; + tbtcConfig?: PublicKey; + tbtcMinterInfo?: PublicKey; + tbtcProgram?: PublicKey; +}; + +export async function depositWormholeTbtcIx( + accounts: DepositWormholeTbtcContext, + amount: bigint +): Promise { + const program = workspace.WormholeGateway as Program; + let { + custodian, + wrappedTbtcToken, + wrappedTbtcMint, + tbtcMint, + recipientWrappedToken, + recipientToken, + recipient, + tbtcConfig, + tbtcMinterInfo, + tbtcProgram, + } = accounts; + + if (custodian === undefined) { + custodian = getCustodianPDA(); + } + + if (wrappedTbtcToken === undefined) { + wrappedTbtcToken = getWrappedTbtcTokenPDA(); + } + + if (wrappedTbtcMint === undefined) { + wrappedTbtcMint = WRAPPED_TBTC_MINT; + } + + if (tbtcMint === undefined) { + tbtcMint = tbtc.getMintPDA(); + } + + if (tbtcConfig === undefined) { + tbtcConfig = tbtc.getConfigPDA(); + } + + if (tbtcMinterInfo === undefined) { + tbtcMinterInfo = tbtc.getMinterInfoPDA(custodian); + } + + if (tbtcProgram === undefined) { + tbtcProgram = TBTC_PROGRAM_ID; + } + + return program.methods + .depositWormholeTbtc(new BN(amount.toString())) + .accounts({ + custodian, + wrappedTbtcToken, + wrappedTbtcMint, + tbtcMint, + recipientWrappedToken, + recipientToken, + recipient, + tbtcConfig, + tbtcMinterInfo, + tbtcProgram, + }) + .instruction(); +} + +type ReceiveTbtcContext = { + payer: PublicKey; + custodian?: PublicKey; + postedVaa?: PublicKey; + tokenBridgeClaim?: PublicKey; + wrappedTbtcToken?: PublicKey; + wrappedTbtcMint?: PublicKey; + tbtcMint?: PublicKey; + recipientToken: PublicKey; + recipient: PublicKey; + recipientWrappedToken?: PublicKey; + tbtcConfig?: PublicKey; + tbtcMinterInfo?: PublicKey; + tokenBridgeConfig?: PublicKey; + tokenBridgeRegisteredEmitter?: PublicKey; + //tokenBridgeRedeemer?: PublicKey; + tokenBridgeWrappedAsset?: PublicKey; + tokenBridgeMintAuthority?: PublicKey; + rent?: PublicKey; + tbtcProgram?: PublicKey; + tokenBridgeProgram?: PublicKey; + coreBridgeProgram?: PublicKey; +}; + +export async function receiveTbtcIx( + accounts: ReceiveTbtcContext, + signedVaa: Buffer +): Promise { + const parsed = parseVaa(signedVaa); + + const program = workspace.WormholeGateway as Program; + let { + payer, + custodian, + postedVaa, + tokenBridgeClaim, + wrappedTbtcToken, + wrappedTbtcMint, + tbtcMint, + recipientToken, + recipient, + recipientWrappedToken, + tbtcConfig, + tbtcMinterInfo, + tokenBridgeConfig, + tokenBridgeRegisteredEmitter, + //tokenBridgeRedeemer, + tokenBridgeWrappedAsset, + tokenBridgeMintAuthority, + rent, + tbtcProgram, + tokenBridgeProgram, + coreBridgeProgram, + } = accounts; + + if (custodian === undefined) { + custodian = getCustodianPDA(); + } + + if (postedVaa === undefined) { + postedVaa = coreBridge.derivePostedVaaKey( + CORE_BRIDGE_PROGRAM_ID, + parsed.hash + ); + } + + if (tokenBridgeClaim === undefined) { + tokenBridgeClaim = coreBridge.deriveClaimKey( + TOKEN_BRIDGE_PROGRAM_ID, + parsed.emitterAddress, + parsed.emitterChain, + parsed.sequence + ); + } + + if (wrappedTbtcToken === undefined) { + wrappedTbtcToken = getWrappedTbtcTokenPDA(); + } + + if (wrappedTbtcMint === undefined) { + wrappedTbtcMint = WRAPPED_TBTC_MINT; + } + + if (tbtcMint === undefined) { + tbtcMint = tbtc.getMintPDA(); + } + + if (recipientWrappedToken == undefined) { + recipientWrappedToken = getAssociatedTokenAddressSync( + wrappedTbtcMint, + recipient + ); + } + + if (tbtcConfig === undefined) { + tbtcConfig = tbtc.getConfigPDA(); + } + + if (tbtcMinterInfo === undefined) { + tbtcMinterInfo = tbtc.getMinterInfoPDA(custodian); + } + + if (tokenBridgeConfig === undefined) { + tokenBridgeConfig = tokenBridge.deriveTokenBridgeConfigKey( + TOKEN_BRIDGE_PROGRAM_ID + ); + } + + if (tokenBridgeRegisteredEmitter === undefined) { + tokenBridgeRegisteredEmitter = ETHEREUM_ENDPOINT; + } + + // if (tokenBridgeRedeemer === undefined) { + // tokenBridgeRedeemer = tokenBridge.deriveRedeemerAccountKey( + // WORMHOLE_GATEWAY_PROGRAM_ID + // ); + // } + + if (tokenBridgeWrappedAsset === undefined) { + tokenBridgeWrappedAsset = WRAPPED_TBTC_ASSET; + } + + if (tokenBridgeMintAuthority === undefined) { + tokenBridgeMintAuthority = tokenBridge.deriveMintAuthorityKey( + TOKEN_BRIDGE_PROGRAM_ID + ); + } + + if (rent === undefined) { + rent = SYSVAR_RENT_PUBKEY; + } + + if (tbtcProgram === undefined) { + tbtcProgram = TBTC_PROGRAM_ID; + } + + if (tokenBridgeProgram === undefined) { + tokenBridgeProgram = TOKEN_BRIDGE_PROGRAM_ID; + } + + if (coreBridgeProgram === undefined) { + coreBridgeProgram = CORE_BRIDGE_PROGRAM_ID; + } + + return program.methods + .receiveTbtc(Array.from(parsed.hash)) + .accounts({ + payer, + custodian, + postedVaa, + tokenBridgeClaim, + wrappedTbtcToken, + tbtcMint, + recipientToken, + recipient, + recipientWrappedToken, + tbtcConfig, + tbtcMinterInfo, + wrappedTbtcMint, + tokenBridgeConfig, + tokenBridgeRegisteredEmitter, + //tokenBridgeRedeemer, + tokenBridgeWrappedAsset, + tokenBridgeMintAuthority, + rent, + tbtcProgram, + tokenBridgeProgram, + coreBridgeProgram, + }) + .instruction(); +} + +type SendTbtcGatewayContext = { + custodian?: PublicKey; + gatewayInfo?: PublicKey; + wrappedTbtcToken?: PublicKey; + wrappedTbtcMint?: PublicKey; + tbtcMint?: PublicKey; + senderToken: PublicKey; + sender: PublicKey; + tokenBridgeConfig?: PublicKey; + tokenBridgeWrappedAsset?: PublicKey; + tokenBridgeTransferAuthority?: PublicKey; + coreBridgeData?: PublicKey; + coreMessage?: PublicKey; + tokenBridgeCoreEmitter?: PublicKey; + coreEmitterSequence?: PublicKey; + coreFeeCollector?: PublicKey; + clock?: PublicKey; + tokenBridgeSender?: PublicKey; + rent?: PublicKey; + tokenBridgeProgram?: PublicKey; + coreBridgeProgram?: PublicKey; +}; + +type SendTbtcGatewayArgs = { + amount: BN; + recipientChain: number; + recipient: number[]; + nonce: number; +}; + +export async function sendTbtcGatewayIx( + accounts: SendTbtcGatewayContext, + args: SendTbtcGatewayArgs +): Promise { + const program = workspace.WormholeGateway as Program; + let { + custodian, + gatewayInfo, + wrappedTbtcToken, + wrappedTbtcMint, + tbtcMint, + senderToken, + sender, + tokenBridgeConfig, + tokenBridgeWrappedAsset, + tokenBridgeTransferAuthority, + coreBridgeData, + coreMessage, + tokenBridgeCoreEmitter, + coreEmitterSequence, + coreFeeCollector, + clock, + tokenBridgeSender, + rent, + tokenBridgeProgram, + coreBridgeProgram, + } = accounts; + + if (custodian === undefined) { + custodian = getCustodianPDA(); + } + + if (gatewayInfo === undefined) { + gatewayInfo = getGatewayInfoPDA(args.recipientChain); + } + + if (wrappedTbtcToken === undefined) { + wrappedTbtcToken = getWrappedTbtcTokenPDA(); + } + + if (wrappedTbtcMint === undefined) { + wrappedTbtcMint = WRAPPED_TBTC_MINT; + } + + if (tbtcMint === undefined) { + tbtcMint = tbtc.getMintPDA(); + } + + if (tokenBridgeConfig === undefined) { + tokenBridgeConfig = tokenBridge.deriveTokenBridgeConfigKey( + TOKEN_BRIDGE_PROGRAM_ID + ); + } + + if (tokenBridgeWrappedAsset === undefined) { + tokenBridgeWrappedAsset = WRAPPED_TBTC_ASSET; + } + + if (tokenBridgeTransferAuthority === undefined) { + tokenBridgeTransferAuthority = tokenBridge.deriveAuthoritySignerKey( + TOKEN_BRIDGE_PROGRAM_ID + ); + } + + if (coreBridgeData === undefined) { + coreBridgeData = CORE_BRIDGE_DATA; + } + + if (coreMessage === undefined) { + const sequence = await getTokenBridgeSequence(); + coreMessage = getCoreMessagePDA(sequence); + } + + if (tokenBridgeCoreEmitter === undefined) { + tokenBridgeCoreEmitter = getTokenBridgeCoreEmitter(); + } + + if (coreEmitterSequence === undefined) { + coreEmitterSequence = coreBridge.deriveEmitterSequenceKey( + tokenBridgeCoreEmitter, + CORE_BRIDGE_PROGRAM_ID + ); + } + + if (coreFeeCollector === undefined) { + coreFeeCollector = coreBridge.deriveFeeCollectorKey(CORE_BRIDGE_PROGRAM_ID); + } + + if (clock === undefined) { + clock = SYSVAR_CLOCK_PUBKEY; + } + + if (tokenBridgeSender === undefined) { + tokenBridgeSender = tokenBridge.deriveSenderAccountKey( + WORMHOLE_GATEWAY_PROGRAM_ID + ); + } + + if (rent === undefined) { + rent = SYSVAR_RENT_PUBKEY; + } + + if (tokenBridgeProgram === undefined) { + tokenBridgeProgram = TOKEN_BRIDGE_PROGRAM_ID; + } + + if (coreBridgeProgram === undefined) { + coreBridgeProgram = CORE_BRIDGE_PROGRAM_ID; + } + + return program.methods + .sendTbtcGateway(args) + .accounts({ + custodian, + gatewayInfo, + wrappedTbtcToken, + wrappedTbtcMint, + tbtcMint, + senderToken, + sender, + tokenBridgeConfig, + tokenBridgeWrappedAsset, + tokenBridgeTransferAuthority, + coreBridgeData, + coreMessage, + tokenBridgeCoreEmitter, + coreEmitterSequence, + coreFeeCollector, + clock, + tokenBridgeSender, + rent, + tokenBridgeProgram, + coreBridgeProgram, + }) + .instruction(); +} + +type SendTbtcWrappedContext = { + custodian?: PublicKey; + wrappedTbtcToken?: PublicKey; + wrappedTbtcMint?: PublicKey; + tbtcMint?: PublicKey; + senderToken: PublicKey; + sender: PublicKey; + tokenBridgeConfig?: PublicKey; + tokenBridgeWrappedAsset?: PublicKey; + tokenBridgeTransferAuthority?: PublicKey; + coreBridgeData?: PublicKey; + coreMessage?: PublicKey; + tokenBridgeCoreEmitter?: PublicKey; + coreEmitterSequence?: PublicKey; + coreFeeCollector?: PublicKey; + clock?: PublicKey; + rent?: PublicKey; + tokenBridgeProgram?: PublicKey; + coreBridgeProgram?: PublicKey; +}; + +type SendTbtcWrappedArgs = { + amount: BN; + recipientChain: number; + recipient: number[]; + arbiterFee: BN; + nonce: number; +}; + +export async function sendTbtcWrappedIx( + accounts: SendTbtcWrappedContext, + args: SendTbtcWrappedArgs +): Promise { + const program = workspace.WormholeGateway as Program; + let { + custodian, + wrappedTbtcToken, + wrappedTbtcMint, + tbtcMint, + senderToken, + sender, + tokenBridgeConfig, + tokenBridgeWrappedAsset, + tokenBridgeTransferAuthority, + coreBridgeData, + coreMessage, + tokenBridgeCoreEmitter, + coreEmitterSequence, + coreFeeCollector, + clock, + rent, + tokenBridgeProgram, + coreBridgeProgram, + } = accounts; + + if (custodian === undefined) { + custodian = getCustodianPDA(); + } + + if (wrappedTbtcToken === undefined) { + wrappedTbtcToken = getWrappedTbtcTokenPDA(); + } + + if (wrappedTbtcMint === undefined) { + wrappedTbtcMint = WRAPPED_TBTC_MINT; + } + + if (tbtcMint === undefined) { + tbtcMint = tbtc.getMintPDA(); + } + + if (tokenBridgeConfig === undefined) { + tokenBridgeConfig = tokenBridge.deriveTokenBridgeConfigKey( + TOKEN_BRIDGE_PROGRAM_ID + ); + } + + if (tokenBridgeWrappedAsset === undefined) { + tokenBridgeWrappedAsset = WRAPPED_TBTC_ASSET; + } + + if (tokenBridgeTransferAuthority === undefined) { + tokenBridgeTransferAuthority = tokenBridge.deriveAuthoritySignerKey( + TOKEN_BRIDGE_PROGRAM_ID + ); + } + + if (coreBridgeData === undefined) { + coreBridgeData = CORE_BRIDGE_DATA; + } + + if (coreMessage === undefined) { + const sequence = await getTokenBridgeSequence(); + coreMessage = getCoreMessagePDA(sequence); + } + + if (tokenBridgeCoreEmitter === undefined) { + tokenBridgeCoreEmitter = getTokenBridgeCoreEmitter(); + } + + if (coreEmitterSequence === undefined) { + coreEmitterSequence = coreBridge.deriveEmitterSequenceKey( + tokenBridgeCoreEmitter, + CORE_BRIDGE_PROGRAM_ID + ); + } + + if (coreFeeCollector === undefined) { + coreFeeCollector = coreBridge.deriveFeeCollectorKey(CORE_BRIDGE_PROGRAM_ID); + } + + if (clock === undefined) { + clock = SYSVAR_CLOCK_PUBKEY; + } + + if (rent === undefined) { + rent = SYSVAR_RENT_PUBKEY; + } + + if (tokenBridgeProgram === undefined) { + tokenBridgeProgram = TOKEN_BRIDGE_PROGRAM_ID; + } + + if (coreBridgeProgram === undefined) { + coreBridgeProgram = CORE_BRIDGE_PROGRAM_ID; + } + + return program.methods + .sendTbtcWrapped(args) + .accounts({ + custodian, + wrappedTbtcToken, + wrappedTbtcMint, + tbtcMint, + senderToken, + sender, + tokenBridgeConfig, + tokenBridgeWrappedAsset, + tokenBridgeTransferAuthority, + coreBridgeData, + coreMessage, + tokenBridgeCoreEmitter, + coreEmitterSequence, + coreFeeCollector, + clock, + rent, + tokenBridgeProgram, + coreBridgeProgram, + }) + .instruction(); +} From c0aed4dab2ea37511197227f39b0171c599242ab Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 7 Aug 2023 20:47:51 +0200 Subject: [PATCH 055/205] Updating existing supported chains after Base deployment - Updated external addresses for Mainnet and Testnet - Updated mappings for existing supported chains --- .../00_resolve_base_wormhole_gateway.ts | 28 +++++++++++++ ...e_with_base_in_wormhole_gateway_mapping.ts | 39 ++++++++++++++++++ .../arbitrumGoerli/BaseWormholeGateway.json | 3 ++ .../arbitrumOne/BaseWormholeGateway.json | 3 ++ .../00_resolve_base_wormhole_gateway.ts | 28 +++++++++++++ ...e_with_base_in_wormhole_gateway_mapping.ts | 39 ++++++++++++++++++ .../optimism/BaseWormholeGateway.json | 3 ++ .../optimismGoerli/BaseWormholeGateway.json | 3 ++ .../00_resolve_base_wormhole_gateway.ts | 28 +++++++++++++ ...e_with_base_in_wormhole_gateway_mapping.ts | 41 +++++++++++++++++++ .../external/mumbai/BaseWormholeGateway.json | 3 ++ .../external/polygon/BaseWormholeGateway.json | 3 ++ 12 files changed, 221 insertions(+) create mode 100644 cross-chain/arbitrum/deploy_l2/00_resolve_base_wormhole_gateway.ts create mode 100644 cross-chain/arbitrum/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/arbitrum/external/arbitrumGoerli/BaseWormholeGateway.json create mode 100644 cross-chain/arbitrum/external/arbitrumOne/BaseWormholeGateway.json create mode 100644 cross-chain/optimism/deploy_l2/00_resolve_base_wormhole_gateway.ts create mode 100644 cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/optimism/external/optimism/BaseWormholeGateway.json create mode 100644 cross-chain/optimism/external/optimismGoerli/BaseWormholeGateway.json create mode 100644 cross-chain/polygon/deploy_sidechain/00_resolve_base_wormhole_gateway.ts create mode 100644 cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/polygon/external/mumbai/BaseWormholeGateway.json create mode 100644 cross-chain/polygon/external/polygon/BaseWormholeGateway.json diff --git a/cross-chain/arbitrum/deploy_l2/00_resolve_base_wormhole_gateway.ts b/cross-chain/arbitrum/deploy_l2/00_resolve_base_wormhole_gateway.ts new file mode 100644 index 000000000..598d1c494 --- /dev/null +++ b/cross-chain/arbitrum/deploy_l2/00_resolve_base_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const BaseWormholeGateway = await deployments.getOrNull( + "BaseWormholeGateway" + ) + + if ( + BaseWormholeGateway && + helpers.address.isValid(BaseWormholeGateway.address) + ) { + log( + `using existing BaseWormholeGateway at ${BaseWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake BaseWormholeGateway for hardhat network") + } else { + throw new Error("deployed BaseWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["BaseWormholeGateway"] diff --git a/cross-chain/arbitrum/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts b/cross-chain/arbitrum/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..fbdfa25d2 --- /dev/null +++ b/cross-chain/arbitrum/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts @@ -0,0 +1,39 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, ethers } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake BaseWormholeGateway for local development purposes only. + const fakeBaseWormholeGateway = + "0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9" + + // See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base + // This ID is valid for both Base Testnet and Mainnet + const baseWormholeChainID = 30 + + const baseWormholeGateway = await deployments.getOrNull( + "BaseWormholeGateway" + ) + + let baseWormholeGatewayAddress = baseWormholeGateway?.address + if (!baseWormholeGatewayAddress && hre.network.name === "hardhat") { + baseWormholeGatewayAddress = fakeBaseWormholeGateway + log(`fake BaseWormholeGateway address ${baseWormholeGatewayAddress}`) + } + + await execute( + "ArbitrumWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + baseWormholeChainID, + ethers.utils.hexZeroPad(baseWormholeGatewayAddress, 32) + ) +} + +export default func + +func.tags = ["SetBaseGatewayAddress"] +func.dependencies = ["BaseWormholeGateway"] diff --git a/cross-chain/arbitrum/external/arbitrumGoerli/BaseWormholeGateway.json b/cross-chain/arbitrum/external/arbitrumGoerli/BaseWormholeGateway.json new file mode 100644 index 000000000..74c39592d --- /dev/null +++ b/cross-chain/arbitrum/external/arbitrumGoerli/BaseWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343" +} diff --git a/cross-chain/arbitrum/external/arbitrumOne/BaseWormholeGateway.json b/cross-chain/arbitrum/external/arbitrumOne/BaseWormholeGateway.json new file mode 100644 index 000000000..6571efe8d --- /dev/null +++ b/cross-chain/arbitrum/external/arbitrumOne/BaseWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab" +} diff --git a/cross-chain/optimism/deploy_l2/00_resolve_base_wormhole_gateway.ts b/cross-chain/optimism/deploy_l2/00_resolve_base_wormhole_gateway.ts new file mode 100644 index 000000000..598d1c494 --- /dev/null +++ b/cross-chain/optimism/deploy_l2/00_resolve_base_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const BaseWormholeGateway = await deployments.getOrNull( + "BaseWormholeGateway" + ) + + if ( + BaseWormholeGateway && + helpers.address.isValid(BaseWormholeGateway.address) + ) { + log( + `using existing BaseWormholeGateway at ${BaseWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake BaseWormholeGateway for hardhat network") + } else { + throw new Error("deployed BaseWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["BaseWormholeGateway"] diff --git a/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts b/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..854060ea4 --- /dev/null +++ b/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts @@ -0,0 +1,39 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, ethers } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake BaseWormholeGateway for local development purposes only. + const fakeBaseWormholeGateway = + "0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9" + + // See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base + // This ID is valid for both Base Testnet and Mainnet + const baseWormholeChainID = 30 + + const baseWormholeGateway = await deployments.getOrNull( + "BaseWormholeGateway" + ) + + let baseWormholeGatewayAddress = baseWormholeGateway?.address + if (!baseWormholeGatewayAddress && hre.network.name === "hardhat") { + baseWormholeGatewayAddress = fakeBaseWormholeGateway + log(`fake BaseWormholeGateway address ${baseWormholeGatewayAddress}`) + } + + await execute( + "OptimismWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + baseWormholeChainID, + ethers.utils.hexZeroPad(baseWormholeGatewayAddress, 32) + ) +} + +export default func + +func.tags = ["SetBaseGatewayAddress"] +func.dependencies = ["BaseWormholeGateway"] diff --git a/cross-chain/optimism/external/optimism/BaseWormholeGateway.json b/cross-chain/optimism/external/optimism/BaseWormholeGateway.json new file mode 100644 index 000000000..6571efe8d --- /dev/null +++ b/cross-chain/optimism/external/optimism/BaseWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab" +} diff --git a/cross-chain/optimism/external/optimismGoerli/BaseWormholeGateway.json b/cross-chain/optimism/external/optimismGoerli/BaseWormholeGateway.json new file mode 100644 index 000000000..74c39592d --- /dev/null +++ b/cross-chain/optimism/external/optimismGoerli/BaseWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343" +} diff --git a/cross-chain/polygon/deploy_sidechain/00_resolve_base_wormhole_gateway.ts b/cross-chain/polygon/deploy_sidechain/00_resolve_base_wormhole_gateway.ts new file mode 100644 index 000000000..598d1c494 --- /dev/null +++ b/cross-chain/polygon/deploy_sidechain/00_resolve_base_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const BaseWormholeGateway = await deployments.getOrNull( + "BaseWormholeGateway" + ) + + if ( + BaseWormholeGateway && + helpers.address.isValid(BaseWormholeGateway.address) + ) { + log( + `using existing BaseWormholeGateway at ${BaseWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake BaseWormholeGateway for hardhat network") + } else { + throw new Error("deployed BaseWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["BaseWormholeGateway"] diff --git a/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts b/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..d5f4d771d --- /dev/null +++ b/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts @@ -0,0 +1,41 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts, ethers } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake BaseWormholeGateway for local development purposes only. + const fakeBaseWormholeGateway = + "0x2af5DC16568EFF2d480a43A77E6C409e497FcFb9" + + // See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base + // This ID is valid for both Base Goerli and Mainnet + const baseWormholeChainID = 30 + + const baseWormholeGateway = await deployments.getOrNull( + "BaseWormholeGateway" + ) + + let baseWormholeGatewayAddress = baseWormholeGateway?.address + if (!baseWormholeGatewayAddress && hre.network.name === "hardhat") { + baseWormholeGatewayAddress = fakeBaseWormholeGateway + log( + `fake BaseWormholeGateway address ${baseWormholeGatewayAddress}` + ) + } + + await execute( + "PolygonWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + baseWormholeChainID, + ethers.utils.hexZeroPad(baseWormholeGatewayAddress, 32) + ) +} + +export default func + +func.tags = ["SetBaseGatewayAddress"] +func.dependencies = ["BaseWormholeGateway"] diff --git a/cross-chain/polygon/external/mumbai/BaseWormholeGateway.json b/cross-chain/polygon/external/mumbai/BaseWormholeGateway.json new file mode 100644 index 000000000..74c39592d --- /dev/null +++ b/cross-chain/polygon/external/mumbai/BaseWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0xe3e0511EEbD87F08FbaE4486419cb5dFB06e1343" +} diff --git a/cross-chain/polygon/external/polygon/BaseWormholeGateway.json b/cross-chain/polygon/external/polygon/BaseWormholeGateway.json new file mode 100644 index 000000000..6571efe8d --- /dev/null +++ b/cross-chain/polygon/external/polygon/BaseWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x09959798B95d00a3183d20FaC298E4594E599eab" +} From 0822d07e5245340f34f959ddd0561c41c4b2d0e1 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 7 Aug 2023 20:54:57 +0200 Subject: [PATCH 056/205] Linting only --- .../deploy_l2/00_resolve_base_wormhole_gateway.ts | 8 ++------ ...15_update_with_base_in_wormhole_gateway_mapping.ts | 7 ++----- .../deploy_l2/00_resolve_base_wormhole_gateway.ts | 8 ++------ ...15_update_with_base_in_wormhole_gateway_mapping.ts | 7 ++----- .../00_resolve_base_wormhole_gateway.ts | 8 ++------ ...15_update_with_base_in_wormhole_gateway_mapping.ts | 11 +++-------- 6 files changed, 13 insertions(+), 36 deletions(-) diff --git a/cross-chain/arbitrum/deploy_l2/00_resolve_base_wormhole_gateway.ts b/cross-chain/arbitrum/deploy_l2/00_resolve_base_wormhole_gateway.ts index 598d1c494..b615c4850 100644 --- a/cross-chain/arbitrum/deploy_l2/00_resolve_base_wormhole_gateway.ts +++ b/cross-chain/arbitrum/deploy_l2/00_resolve_base_wormhole_gateway.ts @@ -5,17 +5,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { helpers, deployments } = hre const { log } = deployments - const BaseWormholeGateway = await deployments.getOrNull( - "BaseWormholeGateway" - ) + const BaseWormholeGateway = await deployments.getOrNull("BaseWormholeGateway") if ( BaseWormholeGateway && helpers.address.isValid(BaseWormholeGateway.address) ) { - log( - `using existing BaseWormholeGateway at ${BaseWormholeGateway.address}` - ) + log(`using existing BaseWormholeGateway at ${BaseWormholeGateway.address}`) } else if (hre.network.name === "hardhat") { log("using fake BaseWormholeGateway for hardhat network") } else { diff --git a/cross-chain/arbitrum/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts b/cross-chain/arbitrum/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts index fbdfa25d2..bed5ff5ad 100644 --- a/cross-chain/arbitrum/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts +++ b/cross-chain/arbitrum/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts @@ -7,16 +7,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { deployer } = await getNamedAccounts() // Fake BaseWormholeGateway for local development purposes only. - const fakeBaseWormholeGateway = - "0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9" + const fakeBaseWormholeGateway = "0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9" // See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base // This ID is valid for both Base Testnet and Mainnet const baseWormholeChainID = 30 - const baseWormholeGateway = await deployments.getOrNull( - "BaseWormholeGateway" - ) + const baseWormholeGateway = await deployments.getOrNull("BaseWormholeGateway") let baseWormholeGatewayAddress = baseWormholeGateway?.address if (!baseWormholeGatewayAddress && hre.network.name === "hardhat") { diff --git a/cross-chain/optimism/deploy_l2/00_resolve_base_wormhole_gateway.ts b/cross-chain/optimism/deploy_l2/00_resolve_base_wormhole_gateway.ts index 598d1c494..b615c4850 100644 --- a/cross-chain/optimism/deploy_l2/00_resolve_base_wormhole_gateway.ts +++ b/cross-chain/optimism/deploy_l2/00_resolve_base_wormhole_gateway.ts @@ -5,17 +5,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { helpers, deployments } = hre const { log } = deployments - const BaseWormholeGateway = await deployments.getOrNull( - "BaseWormholeGateway" - ) + const BaseWormholeGateway = await deployments.getOrNull("BaseWormholeGateway") if ( BaseWormholeGateway && helpers.address.isValid(BaseWormholeGateway.address) ) { - log( - `using existing BaseWormholeGateway at ${BaseWormholeGateway.address}` - ) + log(`using existing BaseWormholeGateway at ${BaseWormholeGateway.address}`) } else if (hre.network.name === "hardhat") { log("using fake BaseWormholeGateway for hardhat network") } else { diff --git a/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts b/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts index 854060ea4..8c69bec2a 100644 --- a/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts +++ b/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts @@ -7,16 +7,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { deployer } = await getNamedAccounts() // Fake BaseWormholeGateway for local development purposes only. - const fakeBaseWormholeGateway = - "0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9" + const fakeBaseWormholeGateway = "0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9" // See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base // This ID is valid for both Base Testnet and Mainnet const baseWormholeChainID = 30 - const baseWormholeGateway = await deployments.getOrNull( - "BaseWormholeGateway" - ) + const baseWormholeGateway = await deployments.getOrNull("BaseWormholeGateway") let baseWormholeGatewayAddress = baseWormholeGateway?.address if (!baseWormholeGatewayAddress && hre.network.name === "hardhat") { diff --git a/cross-chain/polygon/deploy_sidechain/00_resolve_base_wormhole_gateway.ts b/cross-chain/polygon/deploy_sidechain/00_resolve_base_wormhole_gateway.ts index 598d1c494..b615c4850 100644 --- a/cross-chain/polygon/deploy_sidechain/00_resolve_base_wormhole_gateway.ts +++ b/cross-chain/polygon/deploy_sidechain/00_resolve_base_wormhole_gateway.ts @@ -5,17 +5,13 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { helpers, deployments } = hre const { log } = deployments - const BaseWormholeGateway = await deployments.getOrNull( - "BaseWormholeGateway" - ) + const BaseWormholeGateway = await deployments.getOrNull("BaseWormholeGateway") if ( BaseWormholeGateway && helpers.address.isValid(BaseWormholeGateway.address) ) { - log( - `using existing BaseWormholeGateway at ${BaseWormholeGateway.address}` - ) + log(`using existing BaseWormholeGateway at ${BaseWormholeGateway.address}`) } else if (hre.network.name === "hardhat") { log("using fake BaseWormholeGateway for hardhat network") } else { diff --git a/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts b/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts index d5f4d771d..c0db4cbff 100644 --- a/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts +++ b/cross-chain/polygon/deploy_sidechain/15_update_with_base_in_wormhole_gateway_mapping.ts @@ -7,23 +7,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { deployer } = await getNamedAccounts() // Fake BaseWormholeGateway for local development purposes only. - const fakeBaseWormholeGateway = - "0x2af5DC16568EFF2d480a43A77E6C409e497FcFb9" + const fakeBaseWormholeGateway = "0x2af5DC16568EFF2d480a43A77E6C409e497FcFb9" // See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base // This ID is valid for both Base Goerli and Mainnet const baseWormholeChainID = 30 - const baseWormholeGateway = await deployments.getOrNull( - "BaseWormholeGateway" - ) + const baseWormholeGateway = await deployments.getOrNull("BaseWormholeGateway") let baseWormholeGatewayAddress = baseWormholeGateway?.address if (!baseWormholeGatewayAddress && hre.network.name === "hardhat") { baseWormholeGatewayAddress = fakeBaseWormholeGateway - log( - `fake BaseWormholeGateway address ${baseWormholeGatewayAddress}` - ) + log(`fake BaseWormholeGateway address ${baseWormholeGatewayAddress}`) } await execute( From 849d0ea40057770e54646c81aca76eb9aa90c507 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 8 Aug 2023 15:56:11 +0200 Subject: [PATCH 057/205] Drafting deployment scripts for Solana These changes include bash scripts and typescripts that are used to build and deploy programs on Solana. We also need to initalize these programs. More init work to come.. --- cross-chain/solana/.gitignore | 3 +- cross-chain/solana/.prettierrc.js | 3 + cross-chain/solana/Anchor.toml | 1 + cross-chain/solana/migrations/deploy.ts | 84 +- cross-chain/solana/package-lock.json | 3395 +++++++++++++++-- cross-chain/solana/package.json | 16 +- cross-chain/solana/scripts/deploy.sh | 31 + .../solana/scripts/transfer_authority.sh | 12 + cross-chain/solana/solana.env.template | 3 + .../solana/typescript/transfer_authority.ts | 46 + 10 files changed, 3253 insertions(+), 341 deletions(-) create mode 100644 cross-chain/solana/.prettierrc.js create mode 100755 cross-chain/solana/scripts/deploy.sh create mode 100755 cross-chain/solana/scripts/transfer_authority.sh create mode 100644 cross-chain/solana/solana.env.template create mode 100644 cross-chain/solana/typescript/transfer_authority.ts diff --git a/cross-chain/solana/.gitignore b/cross-chain/solana/.gitignore index 0f1813a21..29be122a2 100644 --- a/cross-chain/solana/.gitignore +++ b/cross-chain/solana/.gitignore @@ -7,4 +7,5 @@ target node_modules test-ledger artifacts-mainnet -artifacts-testnet \ No newline at end of file +artifacts-testnet +solana.env \ No newline at end of file diff --git a/cross-chain/solana/.prettierrc.js b/cross-chain/solana/.prettierrc.js new file mode 100644 index 000000000..c22abd03a --- /dev/null +++ b/cross-chain/solana/.prettierrc.js @@ -0,0 +1,3 @@ +module.exports = { + ...require("@thesis-co/prettier-config"), +} diff --git a/cross-chain/solana/Anchor.toml b/cross-chain/solana/Anchor.toml index 052529539..46ce2c333 100644 --- a/cross-chain/solana/Anchor.toml +++ b/cross-chain/solana/Anchor.toml @@ -22,6 +22,7 @@ wallet = "~/.config/solana/id.json" [scripts] test = "npx ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" +authority = "ts-node --files ./typescript/transfer_authority.ts" [test] startup_wait = 10000 diff --git a/cross-chain/solana/migrations/deploy.ts b/cross-chain/solana/migrations/deploy.ts index 82fb175fa..8c5ae8ac9 100644 --- a/cross-chain/solana/migrations/deploy.ts +++ b/cross-chain/solana/migrations/deploy.ts @@ -1,12 +1,78 @@ -// Migrations are an early feature. Currently, they're nothing more than this -// single deploy script that's invoked from the CLI, injecting a provider -// configured from the workspace's Anchor.toml. - -const anchor = require("@coral-xyz/anchor"); +import * as anchor from "@coral-xyz/anchor" +import fs from "fs" +import { PublicKey, Keypair } from "@solana/web3.js" +import dotenv from "dotenv" +import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; module.exports = async function (provider) { - // Configure client to use the provider. - anchor.setProvider(provider); + dotenv.config({ path: "../solana.env" }) + + anchor.setProvider(provider) + + const tbtcProgram = anchor.workspace.Tbtc + // This wallet deployed the program and is also an authority + const authority = loadKey(process.env.AUTHORITY) + const newAuthority = process.env.THRESHOLD_COUNCIL_MULTISIG + + const mint = PublicKey.findProgramAddressSync( + [Buffer.from("tbtc-mint")], + tbtcProgram.programId + )[0]; + + const config = PublicKey.findProgramAddressSync( + [Buffer.from("config")], + tbtcProgram.programId + )[0]; + + const guardians = PublicKey.findProgramAddressSync( + [Buffer.from("guardians")], + tbtcProgram.programId + )[0]; + + const minters = PublicKey.findProgramAddressSync( + [Buffer.from("minters")], + tbtcProgram.programId + )[0]; + + const tbtcMetadata = PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + METADATA_PROGRAM_ID.toBuffer(), + mint.toBuffer(), + ], + METADATA_PROGRAM_ID + )[0]; + + const mplTokenMetadataProgram = METADATA_PROGRAM_ID; + + // Initalize tbtc program + await tbtcProgram.methods + .initialize() + .accounts({ + mint, + config, + guardians, + minters, + authority, + tbtcMetadata, + mplTokenMetadataProgram + }) + .instruction() + + // add minter + + // add guardian? + + // update mappings (self, base, arbitrum, optimism, polygon) +} + +function loadKey(filename: string): Keypair { + try { + const contents = fs.readFileSync(filename).toString() + const bs = Uint8Array.from(JSON.parse(contents)) - // Add your deploy script here. -}; + return Keypair.fromSecretKey(bs) + } catch { + console.log("Unable to read keypair...", filename) + } +} \ No newline at end of file diff --git a/cross-chain/solana/package-lock.json b/cross-chain/solana/package-lock.json index caf320a81..4415d5564 100644 --- a/cross-chain/solana/package-lock.json +++ b/cross-chain/solana/package-lock.json @@ -1,9 +1,13 @@ { - "name": "solana", + "name": "@keep-network/tbtc-v2-solana", + "version": "1.0.0-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { + "name": "@keep-network/tbtc-v2-solana", + "version": "1.0.0-dev", + "license": "GPL-3.0-only", "dependencies": { "@coral-xyz/anchor": "^0.28.0" }, @@ -12,16 +16,30 @@ "@metaplex-foundation/mpl-token-metadata": "^2.13.0", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.77.3", + "@thesis-co/eslint-config": "github:thesis/eslint-config", "@types/bn.js": "^5.1.0", "@types/chai": "^4.3.0", "@types/mocha": "^9.0.0", + "@types/node": "^18.11.18", "chai": "^4.3.4", + "dotenv": "^16.3.1", "mocha": "^9.0.3", "prettier": "^2.6.2", "ts-mocha": "^10.0.0", + "ts-node": "^10.1.0", "typescript": "^4.3.5" } }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@apollo/client": { "version": "3.7.17", "dev": true, @@ -163,11 +181,6 @@ "@types/node": "^18.0.3" } }, - "node_modules/@certusone/wormhole-sdk-wasm/node_modules/@types/node": { - "version": "18.17.1", - "dev": true, - "license": "MIT" - }, "node_modules/@certusone/wormhole-sdk/node_modules/@injectivelabs/networks": { "version": "1.10.12", "dev": true, @@ -470,6 +483,76 @@ "license": "Apache-2.0", "optional": true }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.6.2.tgz", + "integrity": "sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.1.tgz", + "integrity": "sha512-9t7ZA7NGGK8ckelF0PQCfcxIUzs1Md5rrO6U/c+FIQNanea5UZC0wqKXH4vHBccmu4ZJgZ2idtPeW7+Q2npOEA==", + "dev": true, + "peer": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/js": { + "version": "8.46.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.46.0.tgz", + "integrity": "sha512-a8TLtmPi8xzPkCbp/OGFUo5yhRkHM2Ko9kOWP4znJr0WAhWyThaw3PnwX4vOTWOAMsV2uRt32PPDcEz63esSaA==", + "dev": true, + "peer": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/@ethereumjs/common": { "version": "2.6.5", "dev": true, @@ -1222,6 +1305,42 @@ "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", + "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", + "dev": true, + "peer": true, + "dependencies": { + "@humanwhocodes/object-schema": "^1.2.1", + "debug": "^4.1.1", + "minimatch": "^3.0.5" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "peer": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", + "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "dev": true, + "peer": true + }, "node_modules/@improbable-eng/grpc-web": { "version": "0.14.1", "dev": true, @@ -1557,6 +1676,31 @@ "node_modules/@injectivelabs/utils/dist": { "extraneous": true }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", + "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@metamask/eth-sig-util": { "version": "4.0.1", "dev": true, @@ -1777,6 +1921,41 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@project-serum/anchor": { "version": "0.25.0", "dev": true, @@ -2055,6 +2234,66 @@ "protobufjs": "~6.11.2" } }, + "node_modules/@thesis-co/eslint-config": { + "version": "0.6.0-pre", + "resolved": "git+ssh://git@github.com/thesis/eslint-config.git#6f0be99fd2efc446a74b5967db27aa2e4d4beaeb", + "dev": true, + "license": "MIT", + "dependencies": { + "@thesis-co/prettier-config": "github:thesis/prettier-config", + "@typescript-eslint/eslint-plugin": ">4.32.0", + "@typescript-eslint/parser": ">4.32.0", + "eslint-config-airbnb": "^19.0.0", + "eslint-config-airbnb-typescript": "^17.0.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-import": "^2.26.0", + "eslint-plugin-jsx-a11y": "^6.6.1", + "eslint-plugin-no-only-tests": "^3.1.0", + "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-react": "^7.31.11", + "eslint-plugin-react-hooks": "^4.3.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "eslint": ">=6.8.0" + } + }, + "node_modules/@thesis-co/prettier-config": { + "name": "@thesis/prettier-config", + "version": "0.0.1", + "resolved": "git+ssh://git@github.com/thesis/prettier-config.git#a057ca0bab89fee9ee81ac580c446618c722d75d", + "dev": true, + "license": "MIT", + "peerDependencies": { + "prettier": "^2.3.0" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@types/bn.js": { "version": "5.1.1", "dev": true, @@ -2075,11 +2314,16 @@ "@types/node": "*" } }, + "node_modules/@types/json-schema": { + "version": "7.0.12", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", + "integrity": "sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==", + "dev": true + }, "node_modules/@types/json5": { "version": "0.0.29", "dev": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/@types/lodash": { "version": "4.14.196", @@ -2107,8 +2351,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.4.5", - "license": "MIT" + "version": "18.17.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.3.tgz", + "integrity": "sha512-2x8HWtFk0S99zqVQABU9wTpr8wPoaDHZUcAkoTKH+nL7kPv3WUI9cRi/Kk5Mz4xdqXSqTkKP7IWNoQQYCnDsTA==" }, "node_modules/@types/pbkdf2": { "version": "3.1.0", @@ -2126,6 +2371,12 @@ "@types/node": "*" } }, + "node_modules/@types/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true + }, "node_modules/@types/ws": { "version": "7.4.7", "license": "MIT", @@ -2133,119 +2384,92 @@ "@types/node": "*" } }, - "node_modules/@ungap/promise-all-settled": { - "version": "1.1.2", - "dev": true, - "license": "ISC" - }, - "node_modules/@wry/context": { - "version": "0.7.3", + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.3.0.tgz", + "integrity": "sha512-IZYjYZ0ifGSLZbwMqIip/nOamFiWJ9AH+T/GYNZBWkVcyNQOFGtSMoWV7RvY4poYCMZ/4lHzNl796WOSNxmk8A==", "dev": true, - "license": "MIT", - "optional": true, "dependencies": { - "tslib": "^2.3.0" + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.3.0", + "@typescript-eslint/type-utils": "6.3.0", + "@typescript-eslint/utils": "6.3.0", + "@typescript-eslint/visitor-keys": "6.3.0", + "debug": "^4.3.4", + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "natural-compare-lite": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": ">=8" - } - }, - "node_modules/@wry/equality": { - "version": "0.5.6", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "tslib": "^2.3.0" + "node": "^16.0.0 || >=18.0.0" }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@wry/trie": { - "version": "0.4.3", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "tslib": "^2.3.0" + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" }, - "engines": { - "node": ">=8" - } - }, - "node_modules/@xpla/xpla.js": { - "version": "0.2.3", - "dev": true, - "license": "MIT", - "dependencies": { - "@ethersproject/bytes": "^5.6.1", - "@ethersproject/keccak256": "^5.6.1", - "@ethersproject/signing-key": "^5.6.2", - "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", - "@terra-money/terra.proto": "^2.1.0", - "axios": "^0.26.1", - "bech32": "^2.0.0", - "bip32": "^2.0.6", - "bip39": "^3.0.3", - "bufferutil": "^4.0.3", - "crypto-addr-codec": "^0.1.7", - "decimal.js": "^10.2.1", - "elliptic": "^6.5.4", - "ethereumjs-util": "^7.1.5", - "jscrypto": "^1.0.1", - "readable-stream": "^3.6.0", - "secp256k1": "^4.0.2", - "tmp": "^0.2.1", - "utf-8-validate": "^5.0.5", - "ws": "^7.5.8" + "peerDependencies": { + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" }, - "engines": { - "node": ">=14" + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, - "node_modules/@xpla/xpla.js/node_modules/axios": { - "version": "0.26.1", + "node_modules/@typescript-eslint/eslint-plugin/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, - "license": "MIT", "dependencies": { - "follow-redirects": "^1.14.8" - } - }, - "node_modules/acorn": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", - "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", - "dev": true, - "optional": true, - "bin": { - "acorn": "bin/acorn" + "ms": "2.1.2" }, "engines": { - "node": ">=0.4.0" + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "node_modules/aes-js": { - "version": "3.0.0", + "node_modules/@typescript-eslint/parser": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.3.0.tgz", + "integrity": "sha512-ibP+y2Gr6p0qsUkhs7InMdXrwldjxZw66wpcQq9/PzAroM45wdwyu81T+7RibNCh8oc0AgrsyCwJByncY0Ongg==", "dev": true, - "license": "MIT", - "optional": true - }, - "node_modules/agentkeepalive": { - "version": "4.3.0", - "license": "MIT", "dependencies": { - "debug": "^4.1.0", - "depd": "^2.0.0", - "humanize-ms": "^1.2.1" + "@typescript-eslint/scope-manager": "6.3.0", + "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/typescript-estree": "6.3.0", + "@typescript-eslint/visitor-keys": "6.3.0", + "debug": "^4.3.4" }, "engines": { - "node": ">= 8.0.0" + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, - "node_modules/agentkeepalive/node_modules/debug": { + "node_modules/@typescript-eslint/parser/node_modules/debug": { "version": "4.3.4", - "license": "MIT", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, "dependencies": { "ms": "2.1.2" }, @@ -2258,12 +2482,332 @@ } } }, - "node_modules/algo-msgpack-with-bigint": { - "version": "2.1.1", + "node_modules/@typescript-eslint/scope-manager": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.3.0.tgz", + "integrity": "sha512-WlNFgBEuGu74ahrXzgefiz/QlVb+qg8KDTpknKwR7hMH+lQygWyx0CQFoUmMn1zDkQjTBBIn75IxtWss77iBIQ==", "dev": true, - "license": "ISC", + "dependencies": { + "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/visitor-keys": "6.3.0" + }, "engines": { - "node": ">= 10" + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.3.0.tgz", + "integrity": "sha512-7Oj+1ox1T2Yc8PKpBvOKWhoI/4rWFd1j7FA/rPE0lbBPXTKjdbtC+7Ev0SeBjEKkIhKWVeZSP+mR7y1Db1CdfQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "6.3.0", + "@typescript-eslint/utils": "6.3.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/type-utils/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.3.0.tgz", + "integrity": "sha512-K6TZOvfVyc7MO9j60MkRNWyFSf86IbOatTKGrpTQnzarDZPYPVy0oe3myTMq7VjhfsUAbNUW8I5s+2lZvtx1gg==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.3.0.tgz", + "integrity": "sha512-Xh4NVDaC4eYKY4O3QGPuQNp5NxBAlEvNQYOqJquR2MePNxO11E5K3t5x4M4Mx53IZvtpW+mBxIT0s274fLUocg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/visitor-keys": "6.3.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.3.0.tgz", + "integrity": "sha512-hLLg3BZE07XHnpzglNBG8P/IXq/ZVXraEbgY7FM0Cnc1ehM8RMdn9mat3LubJ3KBeYXXPxV1nugWbQPjGeJk6Q==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.3.0", + "@typescript-eslint/types": "6.3.0", + "@typescript-eslint/typescript-estree": "6.3.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.3.0.tgz", + "integrity": "sha512-kEhRRj7HnvaSjux1J9+7dBen15CdWmDnwrpyiHsFX6Qx2iW5LOBUgNefOFeh2PjWPlNwN8TOn6+4eBU3J/gupw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.3.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@ungap/promise-all-settled": { + "version": "1.1.2", + "dev": true, + "license": "ISC" + }, + "node_modules/@wry/context": { + "version": "0.7.3", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wry/equality": { + "version": "0.5.6", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@wry/trie": { + "version": "0.4.3", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@xpla/xpla.js": { + "version": "0.2.3", + "dev": true, + "license": "MIT", + "dependencies": { + "@ethersproject/bytes": "^5.6.1", + "@ethersproject/keccak256": "^5.6.1", + "@ethersproject/signing-key": "^5.6.2", + "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", + "@terra-money/terra.proto": "^2.1.0", + "axios": "^0.26.1", + "bech32": "^2.0.0", + "bip32": "^2.0.6", + "bip39": "^3.0.3", + "bufferutil": "^4.0.3", + "crypto-addr-codec": "^0.1.7", + "decimal.js": "^10.2.1", + "elliptic": "^6.5.4", + "ethereumjs-util": "^7.1.5", + "jscrypto": "^1.0.1", + "readable-stream": "^3.6.0", + "secp256k1": "^4.0.2", + "tmp": "^0.2.1", + "utf-8-validate": "^5.0.5", + "ws": "^7.5.8" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@xpla/xpla.js/node_modules/axios": { + "version": "0.26.1", + "dev": true, + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.14.8" + } + }, + "node_modules/acorn": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peer": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/aes-js": { + "version": "3.0.0", + "dev": true, + "license": "MIT", + "optional": true + }, + "node_modules/agentkeepalive": { + "version": "4.3.0", + "license": "MIT", + "dependencies": { + "debug": "^4.1.0", + "depd": "^2.0.0", + "humanize-ms": "^1.2.1" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/agentkeepalive/node_modules/debug": { + "version": "4.3.4", + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "peer": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/algo-msgpack-with-bigint": { + "version": "2.1.1", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 10" } }, "node_modules/algosdk": { @@ -2369,32 +2913,204 @@ "form-data": "^4.0.0" } }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "2.0.1", "dev": true, "license": "Python-2.0" }, - "node_modules/arrify": { - "version": "1.0.1", + "node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" + "dependencies": { + "dequal": "^2.0.3" } }, - "node_modules/assertion-error": { - "version": "1.1.0", + "node_modules/array-buffer-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz", + "integrity": "sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A==", "dev": true, - "license": "MIT", - "engines": { - "node": "*" - } - }, + "dependencies": { + "call-bind": "^1.0.2", + "is-array-buffer": "^3.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array-includes": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.6.tgz", + "integrity": "sha512-sgTbLvL6cNnw24FnbaDyjmvddQ2ML8arZsgaJhoABMoplz/4QRhtrYS+alr1BUM1Bwp6dhx8vVCBSLG+StwOFw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4", + "get-intrinsic": "^1.1.3", + "is-string": "^1.0.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/array.prototype.findlastindex": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.2.tgz", + "integrity": "sha512-tb5thFFlUcp7NdNF6/MpDk/1r/4awWG1FIz3YqDf+/zJSTezBb+/5WViH41obXULHVpDzoiCLpJ/ZO9YbJMsdw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4", + "es-shim-unscopables": "^1.0.0", + "get-intrinsic": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flat": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz", + "integrity": "sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.flatmap": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.1.tgz", + "integrity": "sha512-8UGn9O1FDVvMNB0UlLv4voxRMze7+FpHyF5mSMRjWHUMlpoDViniy05870VlxhfgTnLbpuwTzvD76MTtWxB/mQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4", + "es-shim-unscopables": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array.prototype.tosorted": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.1.tgz", + "integrity": "sha512-pZYPXPRl2PqWcsUs6LOMn+1f1532nEoPTYowBtqLwAW+W8vSVhkIGnmOX1t/UQjD6YGI0vcD2B1U7ZFGQH9jnQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4", + "es-shim-unscopables": "^1.0.0", + "get-intrinsic": "^1.1.3" + } + }, + "node_modules/arraybuffer.prototype.slice": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.1.tgz", + "integrity": "sha512-09x0ZWFEjj4WD8PDbykUwo3t9arLn8NIzmmYEJFpYekOAQjpkGSyrQhNoRTcwwcFRu+ycWF78QZ63oWTqSjBcw==", + "dev": true, + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "get-intrinsic": "^1.2.1", + "is-array-buffer": "^3.0.2", + "is-shared-array-buffer": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/assertion-error": { + "version": "1.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/ast-types-flow": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz", + "integrity": "sha512-eBvWn1lvIApYMhzQMsu9ciLfkBY499mFZlNqG+/9WR7PVlroQw0vG30cOQQbaKz3sCEc44TAOu2ykzqXSNnwag==", + "dev": true + }, "node_modules/asynckit": { "version": "0.4.0", "dev": true, "license": "MIT" }, + "node_modules/available-typed-arrays": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", + "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/axe-core": { + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.7.2.tgz", + "integrity": "sha512-zIURGIS1E1Q4pcrMjp+nnEh+16G56eG/MUllJH8yEvw7asDo7Ac9uhC9KIH5jzpITueEZolfYglnCGIuSBz39g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/axios": { "version": "0.21.4", "dev": true, @@ -2404,6 +3120,15 @@ "follow-redirects": "^1.14.0" } }, + "node_modules/axobject-query": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", + "integrity": "sha512-jsyHu61e6N4Vbz/v18DHwWYKK0bSWLqn47eeDSKPB7m8tqMHF9YJ+mhIk2lVteyZrY8tnSj/jHOv4YiTCuCJgg==", + "dev": true, + "dependencies": { + "dequal": "^2.0.3" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "dev": true, @@ -2636,8 +3361,9 @@ }, "node_modules/buffer-from": { "version": "1.1.2", - "dev": true, - "license": "MIT" + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true }, "node_modules/buffer-layout": { "version": "1.2.2", @@ -2663,6 +3389,29 @@ "node": ">=6.14.2" } }, + "node_modules/call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "peer": true, + "engines": { + "node": ">=6" + } + }, "node_modules/camelcase": { "version": "6.3.0", "license": "MIT", @@ -2855,6 +3604,12 @@ "dev": true, "license": "MIT" }, + "node_modules/confusing-browser-globals": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz", + "integrity": "sha512-JsPKdmh8ZkmnHxDk55FZ1TqVLvEQTvoByJZRN9jzI0UjxK/QgAmsphz7PGtqgPieQZ/CQcHWXCR7ATDNhGe+YA==", + "dev": true + }, "node_modules/copyfiles": { "version": "2.4.1", "dev": true, @@ -2939,6 +3694,12 @@ "sha.js": "^2.4.8" } }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/cross-fetch": { "version": "3.1.8", "license": "MIT", @@ -2946,6 +3707,21 @@ "node-fetch": "^2.6.12" } }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "peer": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/crypto-addr-codec": { "version": "0.1.7", "dev": true, @@ -2964,241 +3740,966 @@ "version": "1.3.0", "license": "MIT", "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/damerau-levenshtein": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", + "integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==", + "dev": true + }, + "node_modules/debug": { + "version": "4.3.3", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/decimal.js": { + "version": "10.4.3", + "dev": true, + "license": "MIT" + }, + "node_modules/deep-eql": { + "version": "4.1.3", + "dev": true, + "license": "MIT", + "dependencies": { + "type-detect": "^4.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "peer": true + }, + "node_modules/define-properties": { + "version": "1.2.0", + "dev": true, + "license": "MIT", + "dependencies": { + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delay": { + "version": "5.0.0", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/diff": { + "version": "5.0.0", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "peer": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/dot-case": { + "version": "3.0.4", + "license": "MIT", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/dotenv": { + "version": "16.3.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, + "node_modules/drbg.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", + "integrity": "sha512-F4wZ06PvqxYLFEZKkFxTDcns9oFNk34hvmJSEwdzsxVQ8YI5YaxtACgQatkYgv2VI2CFkUd2Y+xosPQnHv809g==", + "dev": true, + "optional": true, + "dependencies": { + "browserify-aes": "^1.0.6", + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/eccrypto": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/eccrypto/-/eccrypto-1.1.6.tgz", + "integrity": "sha512-d78ivVEzu7Tn0ZphUUaL43+jVPKTMPFGtmgtz1D0LrFn7cY3K8CdrvibuLz2AAkHBLKZtR8DMbB2ukRYFk987A==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "dependencies": { + "acorn": "7.1.1", + "elliptic": "6.5.4", + "es6-promise": "4.2.8", + "nan": "2.14.0" + }, + "optionalDependencies": { + "secp256k1": "3.7.1" + } + }, + "node_modules/eccrypto/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true, + "optional": true + }, + "node_modules/eccrypto/node_modules/nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true, + "optional": true + }, + "node_modules/eccrypto/node_modules/secp256k1": { + "version": "3.7.1", + "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.7.1.tgz", + "integrity": "sha512-1cf8sbnRreXrQFdH6qsg2H71Xw91fCCS9Yp021GnUNJzWJS/py96fS4lHbnTnouLp08Xj6jBoBB6V78Tdbdu5g==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "dependencies": { + "bindings": "^1.5.0", + "bip66": "^1.1.5", + "bn.js": "^4.11.8", + "create-hash": "^1.2.0", + "drbg.js": "^1.0.1", + "elliptic": "^6.4.1", + "nan": "^2.14.0", + "safe-buffer": "^5.1.2" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/elliptic": { + "version": "6.5.4", + "dev": true, + "license": "MIT", + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "dev": true, + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "dev": true, + "license": "MIT" + }, + "node_modules/error-polyfill": { + "version": "0.1.3", + "dev": true, + "license": "MIT", + "dependencies": { + "capability": "^0.2.5", + "o3": "^1.0.3", + "u3": "^0.1.1" + } + }, + "node_modules/es-abstract": { + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.22.1.tgz", + "integrity": "sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw==", + "dev": true, + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "arraybuffer.prototype.slice": "^1.0.1", + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "es-set-tostringtag": "^2.0.1", + "es-to-primitive": "^1.2.1", + "function.prototype.name": "^1.1.5", + "get-intrinsic": "^1.2.1", + "get-symbol-description": "^1.0.0", + "globalthis": "^1.0.3", + "gopd": "^1.0.1", + "has": "^1.0.3", + "has-property-descriptors": "^1.0.0", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "internal-slot": "^1.0.5", + "is-array-buffer": "^3.0.2", + "is-callable": "^1.2.7", + "is-negative-zero": "^2.0.2", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "is-string": "^1.0.7", + "is-typed-array": "^1.1.10", + "is-weakref": "^1.0.2", + "object-inspect": "^1.12.3", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.5.0", + "safe-array-concat": "^1.0.0", + "safe-regex-test": "^1.0.0", + "string.prototype.trim": "^1.2.7", + "string.prototype.trimend": "^1.0.6", + "string.prototype.trimstart": "^1.0.6", + "typed-array-buffer": "^1.0.0", + "typed-array-byte-length": "^1.0.0", + "typed-array-byte-offset": "^1.0.0", + "typed-array-length": "^1.0.4", + "unbox-primitive": "^1.0.2", + "which-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz", + "integrity": "sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.3", + "has": "^1.0.3", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-shim-unscopables": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz", + "integrity": "sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + } + }, + "node_modules/es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es6-promise": { + "version": "4.2.8", + "license": "MIT" + }, + "node_modules/es6-promisify": { + "version": "5.0.0", + "license": "MIT", + "dependencies": { + "es6-promise": "^4.0.3" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "8.46.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.46.0.tgz", + "integrity": "sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg==", + "dev": true, + "peer": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.1", + "@eslint/js": "^8.46.0", + "@humanwhocodes/config-array": "^0.11.10", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.2", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-config-airbnb": { + "version": "19.0.4", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-19.0.4.tgz", + "integrity": "sha512-T75QYQVQX57jiNgpF9r1KegMICE94VYwoFQyMGhrvc+lB8YF2E/M/PYDaQe1AJcWaEgqLE+ErXV1Og/+6Vyzew==", + "dev": true, + "dependencies": { + "eslint-config-airbnb-base": "^15.0.0", + "object.assign": "^4.1.2", + "object.entries": "^1.1.5" + }, + "engines": { + "node": "^10.12.0 || ^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^7.32.0 || ^8.2.0", + "eslint-plugin-import": "^2.25.3", + "eslint-plugin-jsx-a11y": "^6.5.1", + "eslint-plugin-react": "^7.28.0", + "eslint-plugin-react-hooks": "^4.3.0" + } + }, + "node_modules/eslint-config-airbnb-base": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-15.0.0.tgz", + "integrity": "sha512-xaX3z4ZZIcFLvh2oUNvcX5oEofXda7giYmuplVxoOg5A7EXJMrUyqRgR+mhDhPK8LZ4PttFOBvCYDbX3sUoUig==", + "dev": true, + "dependencies": { + "confusing-browser-globals": "^1.0.10", + "object.assign": "^4.1.2", + "object.entries": "^1.1.5", + "semver": "^6.3.0" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "peerDependencies": { + "eslint": "^7.32.0 || ^8.2.0", + "eslint-plugin-import": "^2.25.2" + } + }, + "node_modules/eslint-config-airbnb-base/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-config-airbnb-typescript": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-typescript/-/eslint-config-airbnb-typescript-17.1.0.tgz", + "integrity": "sha512-GPxI5URre6dDpJ0CtcthSZVBAfI+Uw7un5OYNVxP2EYi3H81Jw701yFP7AU+/vCE7xBtFmjge7kfhhk4+RAiig==", + "dev": true, + "dependencies": { + "eslint-config-airbnb-base": "^15.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^5.13.0 || ^6.0.0", + "@typescript-eslint/parser": "^5.0.0 || ^6.0.0", + "eslint": "^7.32.0 || ^8.2.0", + "eslint-plugin-import": "^2.25.3" + } + }, + "node_modules/eslint-config-prettier": { + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.10.0.tgz", + "integrity": "sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-import-resolver-node": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", + "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", + "dev": true, + "dependencies": { + "debug": "^3.2.7", + "is-core-module": "^2.13.0", + "resolve": "^1.22.4" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-import-resolver-node/node_modules/resolve": { + "version": "1.22.4", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz", + "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==", + "dev": true, + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/eslint-module-utils": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz", + "integrity": "sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==", + "dev": true, + "dependencies": { + "debug": "^3.2.7" + }, + "engines": { + "node": ">=4" + }, + "peerDependenciesMeta": { + "eslint": { + "optional": true + } + } + }, + "node_modules/eslint-module-utils/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import": { + "version": "2.28.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.28.0.tgz", + "integrity": "sha512-B8s/n+ZluN7sxj9eUf7/pRFERX0r5bnFA2dCaLHy2ZeaQEAz0k+ZZkFWRFHJAqxfxQDx6KLv9LeIki7cFdwW+Q==", + "dev": true, + "dependencies": { + "array-includes": "^3.1.6", + "array.prototype.findlastindex": "^1.2.2", + "array.prototype.flat": "^1.3.1", + "array.prototype.flatmap": "^1.3.1", + "debug": "^3.2.7", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.7", + "eslint-module-utils": "^2.8.0", + "has": "^1.0.3", + "is-core-module": "^2.12.1", + "is-glob": "^4.0.3", + "minimatch": "^3.1.2", + "object.fromentries": "^2.0.6", + "object.groupby": "^1.0.0", + "object.values": "^1.1.6", + "resolve": "^1.22.3", + "semver": "^6.3.1", + "tsconfig-paths": "^3.14.2" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" + } + }, + "node_modules/eslint-plugin-import/node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/eslint-plugin-import/node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eslint-plugin-import/node_modules/resolve": { + "version": "1.22.4", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz", + "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==", + "dev": true, + "dependencies": { + "is-core-module": "^2.13.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/eslint-plugin-import/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-plugin-jsx-a11y": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.7.1.tgz", + "integrity": "sha512-63Bog4iIethyo8smBklORknVjB0T2dwB8Mr/hIC+fBS0uyHdYYpzM/Ed+YC8VxTjlXHEWFOdmgwcDn1U2L9VCA==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.20.7", + "aria-query": "^5.1.3", + "array-includes": "^3.1.6", + "array.prototype.flatmap": "^1.3.1", + "ast-types-flow": "^0.0.7", + "axe-core": "^4.6.2", + "axobject-query": "^3.1.1", + "damerau-levenshtein": "^1.0.8", + "emoji-regex": "^9.2.2", + "has": "^1.0.3", + "jsx-ast-utils": "^3.3.3", + "language-tags": "=1.0.5", + "minimatch": "^3.1.2", + "object.entries": "^1.1.6", + "object.fromentries": "^2.0.6", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=4.0" + }, + "peerDependencies": { + "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8" + } + }, + "node_modules/eslint-plugin-jsx-a11y/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "node_modules/eslint-plugin-jsx-a11y/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/eslint-plugin-no-only-tests": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-only-tests/-/eslint-plugin-no-only-tests-3.1.0.tgz", + "integrity": "sha512-Lf4YW/bL6Un1R6A76pRZyE1dl1vr31G/ev8UzIc/geCgFWyrKil8hVjYqWVKGB/UIGmb6Slzs9T0wNezdSVegw==", + "dev": true, + "engines": { + "node": ">=5.0.0" } }, - "node_modules/debug": { - "version": "4.3.3", + "node_modules/eslint-plugin-prettier": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz", + "integrity": "sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==", "dev": true, - "license": "MIT", "dependencies": { - "ms": "2.1.2" + "prettier-linter-helpers": "^1.0.0" }, "engines": { - "node": ">=6.0" + "node": ">=12.0.0" + }, + "peerDependencies": { + "eslint": ">=7.28.0", + "prettier": ">=2.0.0" }, "peerDependenciesMeta": { - "supports-color": { + "eslint-config-prettier": { "optional": true } } }, - "node_modules/decamelize": { - "version": "4.0.0", + "node_modules/eslint-plugin-react": { + "version": "7.33.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.33.1.tgz", + "integrity": "sha512-L093k0WAMvr6VhNwReB8VgOq5s2LesZmrpPdKz/kZElQDzqS7G7+DnKoqT+w4JwuiGeAhAvHO0fvy0Eyk4ejDA==", "dev": true, - "license": "MIT", + "dependencies": { + "array-includes": "^3.1.6", + "array.prototype.flatmap": "^1.3.1", + "array.prototype.tosorted": "^1.1.1", + "doctrine": "^2.1.0", + "estraverse": "^5.3.0", + "jsx-ast-utils": "^2.4.1 || ^3.0.0", + "minimatch": "^3.1.2", + "object.entries": "^1.1.6", + "object.fromentries": "^2.0.6", + "object.hasown": "^1.1.2", + "object.values": "^1.1.6", + "prop-types": "^15.8.1", + "resolve": "^2.0.0-next.4", + "semver": "^6.3.1", + "string.prototype.matchall": "^4.0.8" + }, "engines": { - "node": ">=10" + "node": ">=4" }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "peerDependencies": { + "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8" } }, - "node_modules/decimal.js": { - "version": "10.4.3", + "node_modules/eslint-plugin-react-hooks": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.0.tgz", + "integrity": "sha512-oFc7Itz9Qxh2x4gNHStv3BqJq54ExXmfC+a1NjAta66IAN87Wu0R/QArgIS9qKzX3dXKPI9H5crl9QchNMY9+g==", "dev": true, - "license": "MIT" + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" + } }, - "node_modules/deep-eql": { - "version": "4.1.3", + "node_modules/eslint-plugin-react/node_modules/doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, - "license": "MIT", "dependencies": { - "type-detect": "^4.0.0" + "esutils": "^2.0.2" }, "engines": { - "node": ">=6" + "node": ">=0.10.0" } }, - "node_modules/define-properties": { - "version": "1.2.0", + "node_modules/eslint-plugin-react/node_modules/resolve": { + "version": "2.0.0-next.4", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.4.tgz", + "integrity": "sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ==", "dev": true, - "license": "MIT", - "optional": true, "dependencies": { - "has-property-descriptors": "^1.0.0", - "object-keys": "^1.1.1" + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" }, - "engines": { - "node": ">= 0.4" + "bin": { + "resolve": "bin/resolve" }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/delay": { - "version": "5.0.0", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", + "node_modules/eslint-plugin-react/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.4.0" + "bin": { + "semver": "bin/semver.js" } }, - "node_modules/depd": { - "version": "2.0.0", - "license": "MIT", + "node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "peer": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, "engines": { - "node": ">= 0.8" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/diff": { - "version": "5.0.0", + "node_modules/eslint-visitor-keys": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.2.tgz", + "integrity": "sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw==", "dev": true, - "license": "BSD-3-Clause", "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/dot-case": { - "version": "3.0.4", - "license": "MIT", - "dependencies": { - "no-case": "^3.0.4", - "tslib": "^2.0.3" + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/drbg.js": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", - "integrity": "sha512-F4wZ06PvqxYLFEZKkFxTDcns9oFNk34hvmJSEwdzsxVQ8YI5YaxtACgQatkYgv2VI2CFkUd2Y+xosPQnHv809g==", + "node_modules/eslint/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, - "optional": true, + "peer": true, "dependencies": { - "browserify-aes": "^1.0.6", - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" }, "engines": { - "node": ">=0.10" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/eccrypto": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/eccrypto/-/eccrypto-1.1.6.tgz", - "integrity": "sha512-d78ivVEzu7Tn0ZphUUaL43+jVPKTMPFGtmgtz1D0LrFn7cY3K8CdrvibuLz2AAkHBLKZtR8DMbB2ukRYFk987A==", + "node_modules/eslint/node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, - "hasInstallScript": true, - "optional": true, + "peer": true, "dependencies": { - "acorn": "7.1.1", - "elliptic": "6.5.4", - "es6-promise": "4.2.8", - "nan": "2.14.0" + "is-glob": "^4.0.3" }, - "optionalDependencies": { - "secp256k1": "3.7.1" + "engines": { + "node": ">=10.13.0" } }, - "node_modules/eccrypto/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true, - "optional": true - }, - "node_modules/eccrypto/node_modules/nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", - "dev": true, - "optional": true - }, - "node_modules/eccrypto/node_modules/secp256k1": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.7.1.tgz", - "integrity": "sha512-1cf8sbnRreXrQFdH6qsg2H71Xw91fCCS9Yp021GnUNJzWJS/py96fS4lHbnTnouLp08Xj6jBoBB6V78Tdbdu5g==", + "node_modules/eslint/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, - "hasInstallScript": true, - "optional": true, + "peer": true, "dependencies": { - "bindings": "^1.5.0", - "bip66": "^1.1.5", - "bn.js": "^4.11.8", - "create-hash": "^1.2.0", - "drbg.js": "^1.0.1", - "elliptic": "^6.4.1", - "nan": "^2.14.0", - "safe-buffer": "^5.1.2" + "has-flag": "^4.0.0" }, "engines": { - "node": ">=4.0.0" + "node": ">=8" } }, - "node_modules/elliptic": { - "version": "6.5.4", + "node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, - "license": "MIT", + "peer": true, "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "dev": true, - "license": "MIT" - }, - "node_modules/emoji-regex": { - "version": "8.0.0", + "node_modules/espree/node_modules/acorn": { + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", "dev": true, - "license": "MIT" + "peer": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } }, - "node_modules/error-polyfill": { - "version": "0.1.3", + "node_modules/esquery": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.5.0.tgz", + "integrity": "sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==", "dev": true, - "license": "MIT", + "peer": true, "dependencies": { - "capability": "^0.2.5", - "o3": "^1.0.3", - "u3": "^0.1.1" + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" } }, - "node_modules/es6-promise": { - "version": "4.2.8", - "license": "MIT" - }, - "node_modules/es6-promisify": { - "version": "5.0.0", - "license": "MIT", + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "peer": true, "dependencies": { - "es6-promise": "^4.0.3" + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" } }, - "node_modules/escalade": { - "version": "3.1.1", + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, - "license": "MIT", "engines": { - "node": ">=6" + "node": ">=4.0" } }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true, - "license": "MIT", "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": ">=0.10.0" } }, "node_modules/eth-crypto": { @@ -3407,13 +4908,78 @@ "node_modules/eyes": { "version": "0.1.8", "engines": { - "node": "> 0.1.90" + "node": "> 0.1.90" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "peer": true + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, + "node_modules/fast-glob": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", + "integrity": "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "peer": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "peer": true + }, + "node_modules/fast-stable-stringify": { + "version": "1.0.0", + "license": "MIT" + }, + "node_modules/fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "peer": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/fast-stable-stringify": { - "version": "1.0.0", - "license": "MIT" - }, "node_modules/file-uri-to-path": { "version": "1.0.0", "license": "MIT" @@ -3452,6 +5018,27 @@ "flat": "cli.js" } }, + "node_modules/flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dev": true, + "peer": true, + "dependencies": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flatted": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.7.tgz", + "integrity": "sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==", + "dev": true, + "peer": true + }, "node_modules/follow-redirects": { "version": "1.15.2", "dev": true, @@ -3471,6 +5058,15 @@ } } }, + "node_modules/for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.3" + } + }, "node_modules/form-data": { "version": "4.0.0", "dev": true, @@ -3492,8 +5088,34 @@ "node_modules/function-bind": { "version": "1.1.1", "dev": true, - "license": "MIT", - "optional": true + "license": "MIT" + }, + "node_modules/function.prototype.name": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", + "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.0", + "functions-have-names": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/get-caller-file": { "version": "2.0.5", @@ -3515,7 +5137,6 @@ "version": "1.2.1", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -3526,6 +5147,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-symbol-description": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", + "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/glob": { "version": "7.2.3", "dev": true, @@ -3556,11 +5193,39 @@ "node": ">= 6" } }, + "node_modules/globals": { + "version": "13.20.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", + "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "dev": true, + "peer": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/globals/node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "peer": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globalthis": { "version": "1.0.3", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "define-properties": "^1.1.3" }, @@ -3571,11 +5236,49 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/google-protobuf": { "version": "3.21.2", "dev": true, "license": "(BSD-3-Clause AND Apache-2.0)" }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/graphql": { "version": "16.7.1", "dev": true, @@ -3612,7 +5315,6 @@ "version": "1.0.3", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "function-bind": "^1.1.1" }, @@ -3620,6 +5322,15 @@ "node": ">= 0.4.0" } }, + "node_modules/has-bigints": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-flag": { "version": "4.0.0", "dev": true, @@ -3632,7 +5343,6 @@ "version": "1.0.0", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "get-intrinsic": "^1.1.1" }, @@ -3644,7 +5354,6 @@ "version": "1.0.1", "dev": true, "license": "MIT", - "optional": true, "engines": { "node": ">= 0.4" }, @@ -3656,7 +5365,21 @@ "version": "1.0.3", "dev": true, "license": "MIT", - "optional": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, "engines": { "node": ">= 0.4" }, @@ -3776,6 +5499,42 @@ ], "license": "BSD-3-Clause" }, + "node_modules/ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "peer": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "peer": true, + "engines": { + "node": ">=0.8.19" + } + }, "node_modules/inflight": { "version": "1.0.6", "dev": true, @@ -3790,6 +5549,20 @@ "dev": true, "license": "ISC" }, + "node_modules/internal-slot": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.5.tgz", + "integrity": "sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.0", + "has": "^1.0.3", + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/interpret": { "version": "1.4.0", "dev": true, @@ -3799,6 +5572,32 @@ "node": ">= 0.10" } }, + "node_modules/is-array-buffer": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.2.tgz", + "integrity": "sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.0", + "is-typed-array": "^1.1.10" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "dev": true, + "dependencies": { + "has-bigints": "^1.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-binary-path": { "version": "2.1.0", "dev": true, @@ -3810,11 +5609,39 @@ "node": ">=8" } }, + "node_modules/is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-core-module": { - "version": "2.12.1", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", + "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==", "dev": true, - "license": "MIT", - "optional": true, "dependencies": { "has": "^1.0.3" }, @@ -3822,6 +5649,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-date-object": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", + "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "dev": true, @@ -3849,30 +5691,140 @@ "node": ">=0.10.0" } }, - "node_modules/is-hex-prefixed": { - "version": "1.0.0", + "node_modules/is-hex-prefixed": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=6.5.0", + "npm": ">=3" + } + }, + "node_modules/is-negative-zero": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", + "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-number-object": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", + "dev": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-regex": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-string": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", + "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", "dev": true, - "license": "MIT", - "optional": true, + "dependencies": { + "has-tostringtag": "^1.0.0" + }, "engines": { - "node": ">=6.5.0", - "npm": ">=3" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-number": { - "version": "7.0.0", + "node_modules/is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", "dev": true, - "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.2" + }, "engines": { - "node": ">=0.12.0" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-plain-obj": { - "version": "2.1.0", + "node_modules/is-typed-array": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.12.tgz", + "integrity": "sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg==", "dev": true, - "license": "MIT", + "dependencies": { + "which-typed-array": "^1.1.11" + }, "engines": { - "node": ">=8" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/is-unicode-supported": { @@ -3886,6 +5838,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-weakref": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", + "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/isarray": { "version": "0.0.1", "dev": true, @@ -3954,8 +5918,7 @@ "node_modules/js-tokens": { "version": "4.0.0", "dev": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/js-yaml": { "version": "4.1.0", @@ -3984,6 +5947,20 @@ "bignumber.js": "^9.0.0" } }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "peer": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "peer": true + }, "node_modules/json-stringify-safe": { "version": "5.0.1", "license": "ISC" @@ -3992,7 +5969,6 @@ "version": "1.0.2", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "minimist": "^1.2.0" }, @@ -4030,6 +6006,21 @@ "node": "*" } }, + "node_modules/jsx-ast-utils": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", + "integrity": "sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==", + "dev": true, + "dependencies": { + "array-includes": "^3.1.6", + "array.prototype.flat": "^1.3.1", + "object.assign": "^4.1.4", + "object.values": "^1.1.6" + }, + "engines": { + "node": ">=4.0" + } + }, "node_modules/keccak": { "version": "3.0.3", "dev": true, @@ -4055,6 +6046,35 @@ "keccak": "^3.0.2" } }, + "node_modules/language-subtag-registry": { + "version": "0.3.22", + "resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz", + "integrity": "sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==", + "dev": true + }, + "node_modules/language-tags": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/language-tags/-/language-tags-1.0.5.tgz", + "integrity": "sha512-qJhlO9cGXi6hBGKoxEG/sKZDAHD5Hnu9Hs4WbOY3pCWXDhw0N8x1NenNzm2EnNLkLkk7J2SdxAkDSbb6ftT+UQ==", + "dev": true, + "dependencies": { + "language-subtag-registry": "~0.3.2" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "peer": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/libsodium": { "version": "0.7.11", "dev": true, @@ -4105,6 +6125,13 @@ "license": "MIT", "optional": true }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "peer": true + }, "node_modules/lodash.values": { "version": "4.3.0", "dev": true, @@ -4161,7 +6188,6 @@ "version": "1.4.0", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" }, @@ -4184,6 +6210,18 @@ "tslib": "^2.0.3" } }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/make-error": { "version": "1.3.6", "dev": true, @@ -4211,6 +6249,28 @@ "safe-buffer": "^5.1.2" } }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, "node_modules/mime-db": { "version": "1.52.0", "dev": true, @@ -4261,8 +6321,9 @@ }, "node_modules/mkdirp": { "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, - "license": "MIT", "dependencies": { "minimist": "^1.2.6" }, @@ -4386,6 +6447,18 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "node_modules/near-api-js": { "version": "1.1.0", "dev": true, @@ -4493,20 +6566,118 @@ "version": "4.1.1", "dev": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } }, + "node_modules/object-inspect": { + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/object-keys": { "version": "1.1.1", "dev": true, "license": "MIT", - "optional": true, "engines": { "node": ">= 0.4" } }, + "node_modules/object.assign": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.entries": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.6.tgz", + "integrity": "sha512-leTPzo4Zvg3pmbQ3rDK69Rl8GQvIqMWubrkxONG9/ojtFE2rD9fjMKfSI5BxW3osRH1m6VdzmqK8oAY9aT4x5w==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.fromentries": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.6.tgz", + "integrity": "sha512-VciD13dswC4j1Xt5394WR4MzmAQmlgN72phd/riNp9vtD7tp4QQWJ0R4wvclXcafgcYK8veHRed2W6XeGBvcfg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.groupby": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.0.tgz", + "integrity": "sha512-70MWG6NfRH9GnbZOikuhPPYzpUpof9iW2J9E4dW7FXTqPNb6rllE6u39SKwwiNh8lCwX3DDb5OgcKGiEBrTTyw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "es-abstract": "^1.21.2", + "get-intrinsic": "^1.2.1" + } + }, + "node_modules/object.hasown": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/object.hasown/-/object.hasown-1.1.2.tgz", + "integrity": "sha512-B5UIT3J1W+WuWIU55h0mjlwaqxiE5vYENJXIXZ4VFe05pNYrkKuK0U/6aFcb0pKywYJh7IhfoqUfKVmrJJHZHw==", + "dev": true, + "dependencies": { + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object.values": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.6.tgz", + "integrity": "sha512-FVVTkD1vENCsAcwNs9k6jea2uHC/X0+JcjG8YA60FN5CMaJmG95wT9jek/xX9nornqGRrBkKtzuAu2wuHpKqvw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/once": { "version": "1.4.0", "dev": true, @@ -4537,6 +6708,24 @@ "node": ">=8" } }, + "node_modules/optionator": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", + "dev": true, + "peer": true, + "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/p-limit": { "version": "3.1.0", "dev": true, @@ -4569,6 +6758,19 @@ "version": "2.1.0", "license": "(MIT AND Zlib)" }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "peer": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/path-exists": { "version": "4.0.0", "dev": true, @@ -4585,11 +6787,29 @@ "node": ">=0.10.0" } }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "peer": true, + "engines": { + "node": ">=8" + } + }, "node_modules/path-parse": { "version": "1.0.7", "dev": true, - "license": "MIT", - "optional": true + "license": "MIT" + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "engines": { + "node": ">=8" + } }, "node_modules/pathval": { "version": "1.1.1", @@ -4625,6 +6845,16 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "peer": true, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/prettier": { "version": "2.8.8", "dev": true, @@ -4639,6 +6869,18 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "dev": true, @@ -4649,7 +6891,6 @@ "version": "15.8.1", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -4681,6 +6922,36 @@ "pbts": "bin/pbts" } }, + "node_modules/punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "dev": true, + "peer": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/randombytes": { "version": "2.1.0", "dev": true, @@ -4692,8 +6963,7 @@ "node_modules/react-is": { "version": "16.13.1", "dev": true, - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/readable-stream": { "version": "3.6.2", @@ -4740,6 +7010,23 @@ "version": "0.13.11", "license": "MIT" }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz", + "integrity": "sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.2.0", + "functions-have-names": "^1.2.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/require-directory": { "version": "2.1.1", "dev": true, @@ -4765,6 +7052,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "peer": true, + "engines": { + "node": ">=4" + } + }, "node_modules/response-iterator": { "version": "0.2.6", "dev": true, @@ -4774,6 +7071,16 @@ "node": ">=0.8" } }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rimraf": { "version": "3.0.2", "dev": true, @@ -4852,6 +7159,29 @@ } } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/rxjs": { "version": "7.8.1", "dev": true, @@ -4860,6 +7190,30 @@ "tslib": "^2.1.0" } }, + "node_modules/safe-array-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.0.0.tgz", + "integrity": "sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.0", + "has-symbols": "^1.0.3", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-array-concat/node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, "node_modules/safe-buffer": { "version": "5.2.1", "funding": [ @@ -4878,6 +7232,20 @@ ], "license": "MIT" }, + "node_modules/safe-regex-test": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz", + "integrity": "sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "is-regex": "^1.1.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/scrypt-js": { "version": "3.0.1", "dev": true, @@ -4897,6 +7265,21 @@ "node": ">=10.0.0" } }, + "node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/serialize-javascript": { "version": "6.0.0", "dev": true, @@ -4935,6 +7318,29 @@ "buffer": "6.0.3" } }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "peer": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "peer": true, + "engines": { + "node": ">=8" + } + }, "node_modules/shelljs": { "version": "0.8.5", "dev": true, @@ -4968,6 +7374,29 @@ "node": ">=6" } }, + "node_modules/side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/snake-case": { "version": "3.0.4", "license": "MIT", @@ -4992,16 +7421,18 @@ }, "node_modules/source-map": { "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, - "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } }, "node_modules/source-map-support": { "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", "dev": true, - "license": "MIT", "dependencies": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" @@ -5042,6 +7473,70 @@ "node": ">=8" } }, + "node_modules/string.prototype.matchall": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.8.tgz", + "integrity": "sha512-6zOCOcJ+RJAQshcTvXPHoxoQGONa3e/Lqx90wUA+wEzX78sg5Bo+1tQo4N0pohS0erG9qtCqJDjNCQBjeWVxyg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4", + "get-intrinsic": "^1.1.3", + "has-symbols": "^1.0.3", + "internal-slot": "^1.0.3", + "regexp.prototype.flags": "^1.4.3", + "side-channel": "^1.0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trim": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz", + "integrity": "sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz", + "integrity": "sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz", + "integrity": "sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.20.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "dev": true, @@ -5057,7 +7552,6 @@ "version": "3.0.0", "dev": true, "license": "MIT", - "optional": true, "engines": { "node": ">=4" } @@ -5108,7 +7602,6 @@ "version": "1.0.0", "dev": true, "license": "MIT", - "optional": true, "engines": { "node": ">= 0.4" }, @@ -5128,6 +7621,13 @@ "node_modules/text-encoding-utf-8": { "version": "1.0.2" }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true, + "peer": true + }, "node_modules/through": { "version": "2.3.8", "license": "MIT" @@ -5237,6 +7737,18 @@ "version": "0.0.3", "license": "MIT" }, + "node_modules/ts-api-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.1.tgz", + "integrity": "sha512-lC/RGlPmwdrIBFTX59wwNzqh7aR2otPNPR/5brHZm/XKFYKsfqxihXUe9pU3JI+3vGkl+vyCoNNnPhJn3aLK1A==", + "dev": true, + "engines": { + "node": ">=16.13.0" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/ts-invariant": { "version": "0.10.3", "dev": true, @@ -5269,10 +7781,20 @@ "mocha": "^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X" } }, - "node_modules/ts-node": { + "node_modules/ts-mocha/node_modules/diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/ts-mocha/node_modules/ts-node": { "version": "7.0.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz", + "integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==", "dev": true, - "license": "MIT", "dependencies": { "arrify": "^1.0.0", "buffer-from": "^1.1.0", @@ -5290,10 +7812,75 @@ "node": ">=4.2.0" } }, + "node_modules/ts-mocha/node_modules/yn": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", + "integrity": "sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/acorn": { + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", + "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/ts-node/node_modules/diff": { - "version": "3.5.0", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true, - "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" } @@ -5302,7 +7889,6 @@ "version": "3.14.2", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "@types/json5": "^0.0.29", "json5": "^1.0.2", @@ -5325,6 +7911,19 @@ "license": "Unlicense", "optional": true }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "peer": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/type-detect": { "version": "4.0.8", "dev": true, @@ -5345,6 +7944,71 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typed-array-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz", + "integrity": "sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.2.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-length": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz", + "integrity": "sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-byte-offset": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz", + "integrity": "sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "has-proto": "^1.0.1", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.4.tgz", + "integrity": "sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "is-typed-array": "^1.1.9" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/typeforce": { "version": "1.18.0", "dev": true, @@ -5367,6 +8031,21 @@ "dev": true, "license": "MIT" }, + "node_modules/unbox-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", + "which-boxed-primitive": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/untildify": { "version": "4.0.0", "dev": true, @@ -5376,6 +8055,16 @@ "node": ">=8" } }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "peer": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, "node_modules/utf-8-validate": { "version": "5.0.10", "devOptional": true, @@ -5400,6 +8089,12 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/vlq": { "version": "2.0.4", "dev": true, @@ -5431,6 +8126,41 @@ "node": ">= 8" } }, + "node_modules/which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "dependencies": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.11.tgz", + "integrity": "sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/wif": { "version": "2.0.6", "dev": true, @@ -5520,6 +8250,12 @@ "node": ">=10" } }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, "node_modules/yargs": { "version": "16.2.0", "dev": true, @@ -5568,11 +8304,12 @@ } }, "node_modules/yn": { - "version": "2.0.0", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", "dev": true, - "license": "MIT", "engines": { - "node": ">=4" + "node": ">=6" } }, "node_modules/yocto-queue": { diff --git a/cross-chain/solana/package.json b/cross-chain/solana/package.json index ea15b6a98..7e59b5895 100644 --- a/cross-chain/solana/package.json +++ b/cross-chain/solana/package.json @@ -1,7 +1,15 @@ { + "name": "@keep-network/tbtc-v2-solana", + "version": "1.0.0-dev", + "description": "tBTC v2 on Solana", + "license": "GPL-3.0-only", "scripts": { + "build": "anchor build", + "format": "npm run lint", + "format:fix": "npm run lint:fix", "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", + "test": "anchor test" }, "dependencies": { "@coral-xyz/anchor": "^0.28.0" @@ -18,6 +26,10 @@ "mocha": "^9.0.3", "prettier": "^2.6.2", "ts-mocha": "^10.0.0", - "typescript": "^4.3.5" + "typescript": "^4.3.5", + "@types/node": "^18.11.18", + "@thesis-co/eslint-config": "github:thesis/eslint-config", + "dotenv": "^16.3.1", + "ts-node": "^10.1.0" } } diff --git a/cross-chain/solana/scripts/deploy.sh b/cross-chain/solana/scripts/deploy.sh new file mode 100755 index 000000000..a0619f171 --- /dev/null +++ b/cross-chain/solana/scripts/deploy.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -eo pipefail + +# Setting env variables in the current bash shell +source solana.env + +[ -z "$CLUSTER" ] && { + echo "'--cluster' option not provided" >&2 + help + exit 1 +} + +[ -z "$AUTHORITY" ] && { + echo "'AUTHORITY' env var is not set" >&2 + exit 1 +} + +echo "Building workspace for cluster: $CLUSTER ..." +anchor build --provider.cluster $CLUSTER + +echo "Syncing the program's id ..." +anchor keys sync + +echo "Building workspace again to include new program ID in the binary ..." +anchor build --provider.cluster $CLUSTER + +echo "Deploying program(s) for cluster: $CLUSTER ..." +anchor deploy --provider.cluster $CLUSTER --provider.wallet $AUTHORITY + +echo "Migrating..." +anchor migrate --provider.cluster $CLUSTER --provider.wallet $AUTHORITY \ No newline at end of file diff --git a/cross-chain/solana/scripts/transfer_authority.sh b/cross-chain/solana/scripts/transfer_authority.sh new file mode 100755 index 000000000..88edc0d55 --- /dev/null +++ b/cross-chain/solana/scripts/transfer_authority.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -eo pipefail + +# Setting env variables in the current bash shell +source solana.env + +# TODO: transfer upgrade authority to Threshold Council Multisig +# solana program set-upgrade-authority -k --new-upgrade-authority + +# Transfer authority to the Threshold Council Multisig +# TODO: verify if the authority was actually transferred. +anchor run authority --provider.cluster $CLUSTER \ No newline at end of file diff --git a/cross-chain/solana/solana.env.template b/cross-chain/solana/solana.env.template new file mode 100644 index 000000000..17955b8fe --- /dev/null +++ b/cross-chain/solana/solana.env.template @@ -0,0 +1,3 @@ +AUTHORITY= +THRESHOLD_COUNCIL_MULTISIG= +CLUSTER= \ No newline at end of file diff --git a/cross-chain/solana/typescript/transfer_authority.ts b/cross-chain/solana/typescript/transfer_authority.ts new file mode 100644 index 000000000..8146d0e83 --- /dev/null +++ b/cross-chain/solana/typescript/transfer_authority.ts @@ -0,0 +1,46 @@ +import * as anchor from "@coral-xyz/anchor" +import fs from "fs" +import { PublicKey, Keypair } from "@solana/web3.js" +import dotenv from "dotenv" + +async function run(): Promise { + dotenv.config({ path: "solana.env" }) + + const authority = loadKey(process.env.AUTHORITY) + const newAuthority = process.env.THRESHOLD_COUNCIL_MULTISIG + + const tbtcProgram = anchor.workspace.Tbtc + + const config = PublicKey.findProgramAddressSync( + [Buffer.from("config")], + tbtcProgram.programId + )[0]; + + await tbtcProgram.methods + .changeAuthority() + .accounts({ + config, + authority, + newAuthority, + }) + .instruction(); +} + +;(async () => { + try { + await run() + } catch (e) { + console.log("Exception called:", e) + } +})() + +function loadKey(filename: string): Keypair { + try { + const contents = fs.readFileSync(filename).toString() + const bs = Uint8Array.from(JSON.parse(contents)) + + return Keypair.fromSecretKey(bs) + } catch { + console.log("Unable to read keypair...", filename) + } +} \ No newline at end of file From 3882cc4e49a9240d7420f4d825bc4005a18dd4df Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 8 Aug 2023 22:44:58 +0200 Subject: [PATCH 058/205] Adjusting deployment scripts to utilize Makefile - Moved init TS scripts to /deploy dir - Building programs with make build - Deploying programs with solana cli instead of anchor --- cross-chain/solana/.env.template | 6 ++ cross-chain/solana/.gitignore | 2 +- cross-chain/solana/Anchor.toml | 1 - cross-chain/solana/Makefile | 8 +- cross-chain/solana/deploy/deploy.ts | 89 +++++++++++++++++++ .../transfer_authority.ts | 0 cross-chain/solana/migrations/deploy.ts | 85 ++---------------- cross-chain/solana/scripts/deploy.sh | 31 +++---- cross-chain/solana/solana.env.template | 3 - 9 files changed, 128 insertions(+), 97 deletions(-) create mode 100644 cross-chain/solana/.env.template create mode 100644 cross-chain/solana/deploy/deploy.ts rename cross-chain/solana/{typescript => deploy}/transfer_authority.ts (100%) delete mode 100644 cross-chain/solana/solana.env.template diff --git a/cross-chain/solana/.env.template b/cross-chain/solana/.env.template new file mode 100644 index 000000000..564120216 --- /dev/null +++ b/cross-chain/solana/.env.template @@ -0,0 +1,6 @@ +export AUTHORITY= +export THRESHOLD_COUNCIL_MULTISIG= +export NETWORK= +export CLUSTER= +export ANCHOR_PROVIDER_URL= +export ANCHOR_WALLET= \ No newline at end of file diff --git a/cross-chain/solana/.gitignore b/cross-chain/solana/.gitignore index 29be122a2..05e8d8768 100644 --- a/cross-chain/solana/.gitignore +++ b/cross-chain/solana/.gitignore @@ -8,4 +8,4 @@ node_modules test-ledger artifacts-mainnet artifacts-testnet -solana.env \ No newline at end of file +.env \ No newline at end of file diff --git a/cross-chain/solana/Anchor.toml b/cross-chain/solana/Anchor.toml index 46ce2c333..052529539 100644 --- a/cross-chain/solana/Anchor.toml +++ b/cross-chain/solana/Anchor.toml @@ -22,7 +22,6 @@ wallet = "~/.config/solana/id.json" [scripts] test = "npx ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" -authority = "ts-node --files ./typescript/transfer_authority.ts" [test] startup_wait = 10000 diff --git a/cross-chain/solana/Makefile b/cross-chain/solana/Makefile index 60201a688..8440d187c 100644 --- a/cross-chain/solana/Makefile +++ b/cross-chain/solana/Makefile @@ -28,4 +28,10 @@ lint: cargo fmt --check cargo check --features "mainnet" --no-default-features cargo check --features "solana-devnet" --no-default-features - cargo clippy --no-deps --all-targets -- -D warnings \ No newline at end of file + cargo clippy --no-deps --all-targets -- -D warnings + +init_programs: + ts-node --files ./deploy/deploy.ts + +transfer_authority: + ts-node --files deploy/transfer_authority.ts \ No newline at end of file diff --git a/cross-chain/solana/deploy/deploy.ts b/cross-chain/solana/deploy/deploy.ts new file mode 100644 index 000000000..6335d4d9f --- /dev/null +++ b/cross-chain/solana/deploy/deploy.ts @@ -0,0 +1,89 @@ +import * as anchor from "@coral-xyz/anchor" +import fs from "fs" +import { PublicKey, Keypair } from "@solana/web3.js" +import dotenv from "dotenv" +import { Program } from "@coral-xyz/anchor"; +import { Tbtc } from "../target/types/tbtc"; +import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; + +async function run(): Promise { + dotenv.config({ path: "../solana.env" }) + + anchor.setProvider(anchor.AnchorProvider.env()); + + const tbtcProgram = anchor.workspace.Tbtc as Program; + + // This wallet deployed the program and is also an authority + const authority = (loadKey(process.env.AUTHORITY)).publicKey + + const mint = PublicKey.findProgramAddressSync( + [Buffer.from("tbtc-mint")], + tbtcProgram.programId + )[0]; + + const config = PublicKey.findProgramAddressSync( + [Buffer.from("config")], + tbtcProgram.programId + )[0]; + + const guardians = PublicKey.findProgramAddressSync( + [Buffer.from("guardians")], + tbtcProgram.programId + )[0]; + + const minters = PublicKey.findProgramAddressSync( + [Buffer.from("minters")], + tbtcProgram.programId + )[0]; + + const tbtcMetadata = PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + METADATA_PROGRAM_ID.toBuffer(), + mint.toBuffer(), + ], + METADATA_PROGRAM_ID + )[0]; + + const mplTokenMetadataProgram = METADATA_PROGRAM_ID; + + // Initalize tbtc program + await tbtcProgram.methods + .initialize() + .accounts({ + mint, + config, + guardians, + minters, + authority, + tbtcMetadata, + mplTokenMetadataProgram + }) + .instruction() + + + // add minter + + // add guardian? + + // update mappings (self, base, arbitrum, optimism, polygon) +} + +;(async () => { + try { + await run() + } catch (e) { + console.log("Exception called:", e) + } +})() + +function loadKey(filename: string): Keypair { + try { + const contents = fs.readFileSync(filename).toString() + const bs = Uint8Array.from(JSON.parse(contents)) + + return Keypair.fromSecretKey(bs) + } catch { + console.log("Unable to read keypair...", filename) + } +} \ No newline at end of file diff --git a/cross-chain/solana/typescript/transfer_authority.ts b/cross-chain/solana/deploy/transfer_authority.ts similarity index 100% rename from cross-chain/solana/typescript/transfer_authority.ts rename to cross-chain/solana/deploy/transfer_authority.ts diff --git a/cross-chain/solana/migrations/deploy.ts b/cross-chain/solana/migrations/deploy.ts index 8c5ae8ac9..448a1b3f2 100644 --- a/cross-chain/solana/migrations/deploy.ts +++ b/cross-chain/solana/migrations/deploy.ts @@ -1,78 +1,11 @@ -import * as anchor from "@coral-xyz/anchor" -import fs from "fs" -import { PublicKey, Keypair } from "@solana/web3.js" -import dotenv from "dotenv" -import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; +// Migrations are an early feature. Currently, they're nothing more than this +// single deploy script that's invoked from the CLI, injecting a provider +// configured from the workspace's Anchor.toml. -module.exports = async function (provider) { - dotenv.config({ path: "../solana.env" }) - - anchor.setProvider(provider) - - const tbtcProgram = anchor.workspace.Tbtc - // This wallet deployed the program and is also an authority - const authority = loadKey(process.env.AUTHORITY) - const newAuthority = process.env.THRESHOLD_COUNCIL_MULTISIG - - const mint = PublicKey.findProgramAddressSync( - [Buffer.from("tbtc-mint")], - tbtcProgram.programId - )[0]; - - const config = PublicKey.findProgramAddressSync( - [Buffer.from("config")], - tbtcProgram.programId - )[0]; - - const guardians = PublicKey.findProgramAddressSync( - [Buffer.from("guardians")], - tbtcProgram.programId - )[0]; - - const minters = PublicKey.findProgramAddressSync( - [Buffer.from("minters")], - tbtcProgram.programId - )[0]; - - const tbtcMetadata = PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - ], - METADATA_PROGRAM_ID - )[0]; +const anchor = require("@coral-xyz/anchor"); - const mplTokenMetadataProgram = METADATA_PROGRAM_ID; - - // Initalize tbtc program - await tbtcProgram.methods - .initialize() - .accounts({ - mint, - config, - guardians, - minters, - authority, - tbtcMetadata, - mplTokenMetadataProgram - }) - .instruction() - - // add minter - - // add guardian? - - // update mappings (self, base, arbitrum, optimism, polygon) -} - -function loadKey(filename: string): Keypair { - try { - const contents = fs.readFileSync(filename).toString() - const bs = Uint8Array.from(JSON.parse(contents)) - - return Keypair.fromSecretKey(bs) - } catch { - console.log("Unable to read keypair...", filename) - } -} \ No newline at end of file +module.exports = async function (provider) { + // Configure client to use the provider. + anchor.setProvider(provider); + // Add your deploy script here. +}; \ No newline at end of file diff --git a/cross-chain/solana/scripts/deploy.sh b/cross-chain/solana/scripts/deploy.sh index a0619f171..19d2dcd55 100755 --- a/cross-chain/solana/scripts/deploy.sh +++ b/cross-chain/solana/scripts/deploy.sh @@ -2,11 +2,13 @@ set -eo pipefail # Setting env variables in the current bash shell -source solana.env +source .env -[ -z "$CLUSTER" ] && { - echo "'--cluster' option not provided" >&2 - help +# Deploy to devnet by default +ARTIFACTS_PATH=artifacts-testnet + +[ -z "$NETWORK" ] && { + echo "'NETWORK' env var is not set" >&2 exit 1 } @@ -15,17 +17,16 @@ source solana.env exit 1 } -echo "Building workspace for cluster: $CLUSTER ..." -anchor build --provider.cluster $CLUSTER - -echo "Syncing the program's id ..." -anchor keys sync +if [[ $CLUSTER = mainnet-beta ]] +then + ARTIFACTS_PATH=artifacts-mainnet +fi -echo "Building workspace again to include new program ID in the binary ..." -anchor build --provider.cluster $CLUSTER +echo "Building workspace for cluster: $NETWORK ..." +make build -echo "Deploying program(s) for cluster: $CLUSTER ..." -anchor deploy --provider.cluster $CLUSTER --provider.wallet $AUTHORITY +echo "Deploying TBTC program for cluster: $CLUSTER ..." +solana program deploy --url $CLUSTER --keypair $AUTHORITY ./$ARTIFACTS_PATH/tbtc.so -echo "Migrating..." -anchor migrate --provider.cluster $CLUSTER --provider.wallet $AUTHORITY \ No newline at end of file +echo "Deploying WORMHOLE_GATEWAY program for cluster: $CLUSTER ..." +solana program deploy --url $CLUSTER --keypair $AUTHORITY ./$ARTIFACTS_PATH/wormhole_gateway.so diff --git a/cross-chain/solana/solana.env.template b/cross-chain/solana/solana.env.template deleted file mode 100644 index 17955b8fe..000000000 --- a/cross-chain/solana/solana.env.template +++ /dev/null @@ -1,3 +0,0 @@ -AUTHORITY= -THRESHOLD_COUNCIL_MULTISIG= -CLUSTER= \ No newline at end of file From 89618465479c09b003bd58473bf87c971f61669d Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 9 Aug 2023 02:30:13 +0200 Subject: [PATCH 059/205] Progressing with programs init --- cross-chain/solana/Makefile | 4 +- cross-chain/solana/deploy/deploy.ts | 89 --------------- cross-chain/solana/deploy/init.ts | 166 ++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 91 deletions(-) delete mode 100644 cross-chain/solana/deploy/deploy.ts create mode 100644 cross-chain/solana/deploy/init.ts diff --git a/cross-chain/solana/Makefile b/cross-chain/solana/Makefile index 8440d187c..daf14b139 100644 --- a/cross-chain/solana/Makefile +++ b/cross-chain/solana/Makefile @@ -31,7 +31,7 @@ lint: cargo clippy --no-deps --all-targets -- -D warnings init_programs: - ts-node --files ./deploy/deploy.ts + ts-node --files ./deploy/init.ts transfer_authority: - ts-node --files deploy/transfer_authority.ts \ No newline at end of file + ts-node --files ./deploy/transfer_authority.ts \ No newline at end of file diff --git a/cross-chain/solana/deploy/deploy.ts b/cross-chain/solana/deploy/deploy.ts deleted file mode 100644 index 6335d4d9f..000000000 --- a/cross-chain/solana/deploy/deploy.ts +++ /dev/null @@ -1,89 +0,0 @@ -import * as anchor from "@coral-xyz/anchor" -import fs from "fs" -import { PublicKey, Keypair } from "@solana/web3.js" -import dotenv from "dotenv" -import { Program } from "@coral-xyz/anchor"; -import { Tbtc } from "../target/types/tbtc"; -import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; - -async function run(): Promise { - dotenv.config({ path: "../solana.env" }) - - anchor.setProvider(anchor.AnchorProvider.env()); - - const tbtcProgram = anchor.workspace.Tbtc as Program; - - // This wallet deployed the program and is also an authority - const authority = (loadKey(process.env.AUTHORITY)).publicKey - - const mint = PublicKey.findProgramAddressSync( - [Buffer.from("tbtc-mint")], - tbtcProgram.programId - )[0]; - - const config = PublicKey.findProgramAddressSync( - [Buffer.from("config")], - tbtcProgram.programId - )[0]; - - const guardians = PublicKey.findProgramAddressSync( - [Buffer.from("guardians")], - tbtcProgram.programId - )[0]; - - const minters = PublicKey.findProgramAddressSync( - [Buffer.from("minters")], - tbtcProgram.programId - )[0]; - - const tbtcMetadata = PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - ], - METADATA_PROGRAM_ID - )[0]; - - const mplTokenMetadataProgram = METADATA_PROGRAM_ID; - - // Initalize tbtc program - await tbtcProgram.methods - .initialize() - .accounts({ - mint, - config, - guardians, - minters, - authority, - tbtcMetadata, - mplTokenMetadataProgram - }) - .instruction() - - - // add minter - - // add guardian? - - // update mappings (self, base, arbitrum, optimism, polygon) -} - -;(async () => { - try { - await run() - } catch (e) { - console.log("Exception called:", e) - } -})() - -function loadKey(filename: string): Keypair { - try { - const contents = fs.readFileSync(filename).toString() - const bs = Uint8Array.from(JSON.parse(contents)) - - return Keypair.fromSecretKey(bs) - } catch { - console.log("Unable to read keypair...", filename) - } -} \ No newline at end of file diff --git a/cross-chain/solana/deploy/init.ts b/cross-chain/solana/deploy/init.ts new file mode 100644 index 000000000..70e1c8a1d --- /dev/null +++ b/cross-chain/solana/deploy/init.ts @@ -0,0 +1,166 @@ +import * as anchor from "@coral-xyz/anchor" +import fs from "fs" +import { PublicKey, Keypair } from "@solana/web3.js" +import dotenv from "dotenv" +import { Program } from "@coral-xyz/anchor"; +import { Tbtc } from "../target/types/tbtc"; +import { WormholeGateway } from "../target/types/wormhole_gateway"; +import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; + +async function run(): Promise { + dotenv.config({ path: "../solana.env" }) + + anchor.setProvider(anchor.AnchorProvider.env()); + + const tbtcProgram = anchor.workspace.Tbtc as Program; + const wormholeGatewayProgram = anchor.workspace.WormholeGateway as Program; + + console.log("tbtcProgram.programId", tbtcProgram.programId) + console.log("wormholeGatewayProgram.programId", wormholeGatewayProgram.programId) + + // This wallet deployed the program and is also an authority + const authority = (loadKey(process.env.AUTHORITY)).publicKey + + const mint = PublicKey.findProgramAddressSync( + [Buffer.from("tbtc-mint")], + tbtcProgram.programId + )[0]; + + const config = PublicKey.findProgramAddressSync( + [Buffer.from("config")], + tbtcProgram.programId + )[0]; + + const guardians = PublicKey.findProgramAddressSync( + [Buffer.from("guardians")], + tbtcProgram.programId + )[0]; + + const minters = PublicKey.findProgramAddressSync( + [Buffer.from("minters")], + tbtcProgram.programId + )[0]; + + const tbtcMetadata = PublicKey.findProgramAddressSync( + [ + Buffer.from("metadata"), + METADATA_PROGRAM_ID.toBuffer(), + mint.toBuffer(), + ], + METADATA_PROGRAM_ID + )[0]; + + const mplTokenMetadataProgram = METADATA_PROGRAM_ID; + + // Initalize tbtc program + await tbtcProgram.methods + .initialize() + .accounts({ + mint, + config, + guardians, + minters, + authority, + tbtcMetadata, + mplTokenMetadataProgram + }) + .instruction() + + const minter = PublicKey.findProgramAddressSync( + [Buffer.from("redeemer")], + wormholeGatewayProgram.programId + )[0] + + const mintingLimit = 10000 // Arbitrary big number of TBTC + // TODO: verify with WH team if the address is correct + const WRAPPED_TBTC_MINT = new PublicKey( + "25rXTx9zDZcHyTav5sRqM6YBvTGu9pPH9yv83uAEqbgG" + ); + + const gatewayWrappedTbtcToken = PublicKey.findProgramAddressSync( + [Buffer.from("wrapped-token")], + wormholeGatewayProgram.programId + )[0] + + const tokenBridgeSender = PublicKey.findProgramAddressSync( + [Buffer.from("sender")], + wormholeGatewayProgram.programId + )[0] + + await wormholeGatewayProgram.methods + .initialize(new anchor.BN(mintingLimit)) + .accounts({ + authority, + custodian: minter, + tbtcMint: mint, + wrappedTbtcMint: WRAPPED_TBTC_MINT, + wrappedTbtcToken: gatewayWrappedTbtcToken, + tokenBridgeSender, + }) + .rpc(); + + const minterInfo = PublicKey.findProgramAddressSync( + [Buffer.from("minter-info"), minter.toBuffer()], + tbtcProgram.programId + )[0] + + // // Adding a minter (wormholeGateway) + // await tbtcProgram.methods + // .addMinter() + // .accounts({ + // config, + // authority, + // minters, + // minterInfo, + // minter, + // }) + // .instruction(); + + // // update mappings (self?, arbitrum, optimism, polygon, base) + + // // arbitrum chain ID: 23 + // // ETH Goerli address: 0x00000000000000000000000031a15e213b59e230b45e8c5c99dafac3d1236ee2 + // // ETH Mainnet address: 0x0000000000000000000000001293a54e160d1cd7075487898d65266081a15458 + // const arbitrumChain = 23 + // const arbiArgs = { + // chain: arbitrumChain, + // address: Array.from(Buffer.alloc(32, "00000000000000000000000031a15e213b59e230b45e8c5c99dafac3d1236ee2", "hex")) + // } + + // const encodedChain = Buffer.alloc(2); + // encodedChain.writeUInt16LE(arbitrumChain); + // const gatewayInfo = PublicKey.findProgramAddressSync( + // [Buffer.from("gateway-info"), encodedChain], + // wormholeGatewayProgram.programId + // )[0] + + // wormholeGatewayProgram.methods + // .updateGatewayAddress(arbiArgs) + // .accounts({ + // custodian: minter, + // gatewayInfo, + // authority, + // }) + // .instruction(); + + console.log("success") +} + +;(async () => { + try { + await run() + } catch (e) { + console.log("Exception called:", e) + } +})() + +function loadKey(filename: string): Keypair { + try { + const contents = fs.readFileSync(filename).toString() + const bs = Uint8Array.from(JSON.parse(contents)) + + return Keypair.fromSecretKey(bs) + } catch { + console.log("Unable to read keypair...", filename) + } +} \ No newline at end of file From 03a6256e687cba61c1cafe1f2a6a0a021316516f Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 9 Aug 2023 11:06:34 +0200 Subject: [PATCH 060/205] Adding IDL dir --- cross-chain/solana/target/idl/tbtc.json | 561 ++++++++++ .../solana/target/idl/wormhole_gateway.json | 992 ++++++++++++++++++ 2 files changed, 1553 insertions(+) create mode 100644 cross-chain/solana/target/idl/tbtc.json create mode 100644 cross-chain/solana/target/idl/wormhole_gateway.json diff --git a/cross-chain/solana/target/idl/tbtc.json b/cross-chain/solana/target/idl/tbtc.json new file mode 100644 index 000000000..a56a15669 --- /dev/null +++ b/cross-chain/solana/target/idl/tbtc.json @@ -0,0 +1,561 @@ +{ + "version": "0.1.0", + "name": "tbtc", + "constants": [ + { + "name": "SEED_PREFIX_TBTC_MINT", + "type": "bytes", + "value": "[116, 98, 116, 99, 45, 109, 105, 110, 116]" + } + ], + "instructions": [ + { + "name": "initialize", + "accounts": [ + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "guardians", + "isMut": true, + "isSigner": false + }, + { + "name": "minters", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "tbtcMetadata", + "isMut": true, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "mplTokenMetadataProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "changeAuthority", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "newAuthority", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "cancelAuthorityChange", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "takeAuthority", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "pendingAuthority", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "addMinter", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "minters", + "isMut": true, + "isSigner": false + }, + { + "name": "minterInfo", + "isMut": true, + "isSigner": false + }, + { + "name": "minter", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "removeMinter", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "minters", + "isMut": true, + "isSigner": false + }, + { + "name": "minterInfo", + "isMut": true, + "isSigner": false + }, + { + "name": "minter", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "addGuardian", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "guardians", + "isMut": true, + "isSigner": false + }, + { + "name": "guardianInfo", + "isMut": true, + "isSigner": false + }, + { + "name": "guardian", + "isMut": false, + "isSigner": false, + "docs": [ + "`Guardians`." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "removeGuardian", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "guardians", + "isMut": true, + "isSigner": false + }, + { + "name": "guardianInfo", + "isMut": true, + "isSigner": false + }, + { + "name": "guardian", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "pause", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "guardianInfo", + "isMut": false, + "isSigner": false + }, + { + "name": "guardian", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "unpause", + "accounts": [ + { + "name": "config", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "mint", + "accounts": [ + { + "name": "mint", + "isMut": true, + "isSigner": false + }, + { + "name": "config", + "isMut": false, + "isSigner": false + }, + { + "name": "minterInfo", + "isMut": false, + "isSigner": false + }, + { + "name": "minter", + "isMut": false, + "isSigner": true + }, + { + "name": "recipientToken", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "Config", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "authority", + "docs": [ + "The authority over this program." + ], + "type": "publicKey" + }, + { + "name": "pendingAuthority", + "type": { + "option": "publicKey" + } + }, + { + "name": "mint", + "type": "publicKey" + }, + { + "name": "mintBump", + "type": "u8" + }, + { + "name": "numMinters", + "type": "u32" + }, + { + "name": "numGuardians", + "type": "u32" + }, + { + "name": "paused", + "type": "bool" + } + ] + } + }, + { + "name": "GuardianInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "guardian", + "type": "publicKey" + } + ] + } + }, + { + "name": "Guardians", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "keys", + "type": { + "vec": "publicKey" + } + } + ] + } + }, + { + "name": "MinterInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "minter", + "type": "publicKey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "Minters", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "keys", + "type": { + "vec": "publicKey" + } + } + ] + } + } + ], + "events": [ + { + "name": "MinterAdded", + "fields": [ + { + "name": "minter", + "type": "publicKey", + "index": false + } + ] + }, + { + "name": "MinterRemoved", + "fields": [ + { + "name": "minter", + "type": "publicKey", + "index": false + } + ] + }, + { + "name": "GuardianAdded", + "fields": [ + { + "name": "guardian", + "type": "publicKey", + "index": false + } + ] + }, + { + "name": "GuardianRemoved", + "fields": [ + { + "name": "guardian", + "type": "publicKey", + "index": false + } + ] + } + ], + "errors": [ + { + "code": 6032, + "name": "IsNotAuthority", + "msg": "Not valid authority to perform this action" + }, + { + "code": 6034, + "name": "IsNotPendingAuthority", + "msg": "Not valid pending authority to take authority" + }, + { + "code": 6036, + "name": "NoPendingAuthorityChange", + "msg": "No pending authority" + }, + { + "code": 6048, + "name": "GuardianAlreadyExists", + "msg": "This address is already a guardian" + }, + { + "code": 6050, + "name": "GuardianNonexistent", + "msg": "This address is not a guardian" + }, + { + "code": 6052, + "name": "SignerNotGuardian", + "msg": "Caller is not a guardian" + }, + { + "code": 6064, + "name": "MinterAlreadyExists", + "msg": "This address is already a minter" + }, + { + "code": 6066, + "name": "MinterNonexistent", + "msg": "This address is not a minter" + }, + { + "code": 6068, + "name": "SignerNotMinter", + "msg": "Caller is not a minter" + }, + { + "code": 6080, + "name": "IsPaused", + "msg": "Program is paused" + }, + { + "code": 6082, + "name": "IsNotPaused", + "msg": "Program is not paused" + } + ] +} \ No newline at end of file diff --git a/cross-chain/solana/target/idl/wormhole_gateway.json b/cross-chain/solana/target/idl/wormhole_gateway.json new file mode 100644 index 000000000..b7f578215 --- /dev/null +++ b/cross-chain/solana/target/idl/wormhole_gateway.json @@ -0,0 +1,992 @@ +{ + "version": "0.1.0", + "name": "wormhole_gateway", + "instructions": [ + { + "name": "initialize", + "accounts": [ + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "custodian", + "isMut": true, + "isSigner": false + }, + { + "name": "tbtcMint", + "isMut": false, + "isSigner": false, + "docs": [ + "TBTC Program's mint PDA address bump is saved in this program's config. Ordinarily, we would", + "not have to deserialize this account. But we do in this case to make sure the TBTC program", + "has been initialized before this program." + ] + }, + { + "name": "wrappedTbtcMint", + "isMut": false, + "isSigner": false + }, + { + "name": "wrappedTbtcToken", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenBridgeSender", + "isMut": false, + "isSigner": false, + "docs": [ + "sign for transferring via Token Bridge program with a message." + ] + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "mintingLimit", + "type": "u64" + } + ] + }, + { + "name": "changeAuthority", + "accounts": [ + { + "name": "custodian", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + }, + { + "name": "newAuthority", + "isMut": false, + "isSigner": false + } + ], + "args": [] + }, + { + "name": "cancelAuthorityChange", + "accounts": [ + { + "name": "custodian", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "takeAuthority", + "accounts": [ + { + "name": "custodian", + "isMut": true, + "isSigner": false + }, + { + "name": "pendingAuthority", + "isMut": false, + "isSigner": true + } + ], + "args": [] + }, + { + "name": "updateGatewayAddress", + "accounts": [ + { + "name": "custodian", + "isMut": false, + "isSigner": false + }, + { + "name": "gatewayInfo", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": true, + "isSigner": true + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "UpdateGatewayAddressArgs" + } + } + ] + }, + { + "name": "updateMintingLimit", + "accounts": [ + { + "name": "custodian", + "isMut": true, + "isSigner": false + }, + { + "name": "authority", + "isMut": false, + "isSigner": true + } + ], + "args": [ + { + "name": "newLimit", + "type": "u64" + } + ] + }, + { + "name": "receiveTbtc", + "accounts": [ + { + "name": "payer", + "isMut": true, + "isSigner": true + }, + { + "name": "custodian", + "isMut": true, + "isSigner": false + }, + { + "name": "postedVaa", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeClaim", + "isMut": true, + "isSigner": false, + "docs": [ + "transfer. By checking whether this account exists is a short-circuit way of bailing out", + "early if this transfer has already been redeemed (as opposed to letting the Token Bridge", + "instruction fail)." + ] + }, + { + "name": "wrappedTbtcToken", + "isMut": true, + "isSigner": false, + "docs": [ + "Custody account." + ] + }, + { + "name": "wrappedTbtcMint", + "isMut": true, + "isSigner": false, + "docs": [ + "This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the", + "custodian account." + ] + }, + { + "name": "tbtcMint", + "isMut": true, + "isSigner": false + }, + { + "name": "recipientToken", + "isMut": true, + "isSigner": false, + "docs": [ + "Token account for minted tBTC.", + "", + "NOTE: Because the recipient is encoded in the transfer message payload, we can check the", + "authority from the deserialized VAA. But we should still check whether the authority is the", + "zero address in access control." + ] + }, + { + "name": "recipient", + "isMut": false, + "isSigner": false, + "docs": [ + "be created for him." + ] + }, + { + "name": "recipientWrappedToken", + "isMut": true, + "isSigner": false, + "docs": [ + "The gateway will create an associated token account for the recipient if it doesn't exist.", + "", + "NOTE: When the minting limit increases, the recipient can use this token account to mint", + "tBTC using the deposit_wormhole_tbtc instruction." + ] + }, + { + "name": "tbtcConfig", + "isMut": false, + "isSigner": false + }, + { + "name": "tbtcMinterInfo", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeConfig", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeRegisteredEmitter", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeWrappedAsset", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeMintAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "tbtcProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "coreBridgeProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "associatedTokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "messageHash", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "sendTbtcGateway", + "accounts": [ + { + "name": "custodian", + "isMut": true, + "isSigner": false + }, + { + "name": "gatewayInfo", + "isMut": false, + "isSigner": false + }, + { + "name": "wrappedTbtcToken", + "isMut": true, + "isSigner": false, + "docs": [ + "Custody account." + ] + }, + { + "name": "wrappedTbtcMint", + "isMut": true, + "isSigner": false + }, + { + "name": "tbtcMint", + "isMut": true, + "isSigner": false + }, + { + "name": "senderToken", + "isMut": true, + "isSigner": false + }, + { + "name": "sender", + "isMut": true, + "isSigner": true + }, + { + "name": "tokenBridgeConfig", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeWrappedAsset", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeTransferAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "coreBridgeData", + "isMut": true, + "isSigner": false + }, + { + "name": "coreMessage", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenBridgeCoreEmitter", + "isMut": false, + "isSigner": false + }, + { + "name": "coreEmitterSequence", + "isMut": true, + "isSigner": false + }, + { + "name": "coreFeeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeSender", + "isMut": false, + "isSigner": false, + "docs": [ + "sign for transferring via Token Bridge program with a message." + ] + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "coreBridgeProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SendTbtcGatewayArgs" + } + } + ] + }, + { + "name": "sendTbtcWrapped", + "accounts": [ + { + "name": "custodian", + "isMut": true, + "isSigner": false + }, + { + "name": "wrappedTbtcToken", + "isMut": true, + "isSigner": false, + "docs": [ + "Custody account." + ] + }, + { + "name": "wrappedTbtcMint", + "isMut": true, + "isSigner": false + }, + { + "name": "tbtcMint", + "isMut": true, + "isSigner": false + }, + { + "name": "senderToken", + "isMut": true, + "isSigner": false + }, + { + "name": "sender", + "isMut": true, + "isSigner": true + }, + { + "name": "tokenBridgeConfig", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeWrappedAsset", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeTransferAuthority", + "isMut": false, + "isSigner": false + }, + { + "name": "coreBridgeData", + "isMut": true, + "isSigner": false + }, + { + "name": "coreMessage", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenBridgeCoreEmitter", + "isMut": false, + "isSigner": false + }, + { + "name": "coreEmitterSequence", + "isMut": true, + "isSigner": false + }, + { + "name": "coreFeeCollector", + "isMut": true, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenBridgeProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "coreBridgeProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "args", + "type": { + "defined": "SendTbtcWrappedArgs" + } + } + ] + }, + { + "name": "depositWormholeTbtc", + "accounts": [ + { + "name": "custodian", + "isMut": true, + "isSigner": false, + "docs": [ + "NOTE: This account also acts as a minter for the TBTC program." + ] + }, + { + "name": "wrappedTbtcToken", + "isMut": true, + "isSigner": false, + "docs": [ + "This token account is owned by this program, whose mint is the wrapped TBTC mint. This PDA", + "address is stored in the custodian account." + ] + }, + { + "name": "wrappedTbtcMint", + "isMut": false, + "isSigner": false, + "docs": [ + "This mint is owned by the Wormhole Token Bridge program. This PDA address is stored in the", + "custodian account." + ] + }, + { + "name": "tbtcMint", + "isMut": true, + "isSigner": false, + "docs": [ + "This mint is owned by the TBTC program. This PDA address is stored in the custodian account." + ] + }, + { + "name": "recipientWrappedToken", + "isMut": true, + "isSigner": false + }, + { + "name": "recipientToken", + "isMut": true, + "isSigner": false + }, + { + "name": "recipient", + "isMut": false, + "isSigner": true, + "docs": [ + "This program requires that the owner of the TBTC token account sign for TBTC being minted", + "into his account." + ] + }, + { + "name": "tbtcConfig", + "isMut": false, + "isSigner": false + }, + { + "name": "tbtcMinterInfo", + "isMut": false, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "tbtcProgram", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "Custodian", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "authority", + "type": "publicKey" + }, + { + "name": "pendingAuthority", + "type": { + "option": "publicKey" + } + }, + { + "name": "tbtcMint", + "type": "publicKey" + }, + { + "name": "wrappedTbtcMint", + "type": "publicKey" + }, + { + "name": "wrappedTbtcToken", + "type": "publicKey" + }, + { + "name": "tokenBridgeSender", + "type": "publicKey" + }, + { + "name": "tokenBridgeSenderBump", + "type": "u8" + }, + { + "name": "mintingLimit", + "type": "u64" + }, + { + "name": "mintedAmount", + "type": "u64" + } + ] + } + }, + { + "name": "GatewayInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + } + ], + "types": [ + { + "name": "UpdateGatewayAddressArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "chain", + "type": "u16" + }, + { + "name": "address", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "SendTbtcGatewayArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipientChain", + "type": "u16" + }, + { + "name": "recipient", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "nonce", + "type": "u32" + } + ] + } + }, + { + "name": "SendTbtcWrappedArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipientChain", + "type": "u16" + }, + { + "name": "recipient", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "arbiterFee", + "type": "u64" + }, + { + "name": "nonce", + "type": "u32" + } + ] + } + } + ], + "events": [ + { + "name": "WormholeTbtcReceived", + "fields": [ + { + "name": "receiver", + "type": "publicKey", + "index": false + }, + { + "name": "amount", + "type": "u64", + "index": false + } + ] + }, + { + "name": "WormholeTbtcSent", + "fields": [ + { + "name": "amount", + "type": "u64", + "index": false + }, + { + "name": "recipientChain", + "type": "u16", + "index": false + }, + { + "name": "gateway", + "type": { + "array": [ + "u8", + 32 + ] + }, + "index": false + }, + { + "name": "recipient", + "type": { + "array": [ + "u8", + 32 + ] + }, + "index": false + }, + { + "name": "arbiterFee", + "type": "u64", + "index": false + }, + { + "name": "nonce", + "type": "u32", + "index": false + } + ] + }, + { + "name": "WormholeTbtcDeposited", + "fields": [ + { + "name": "depositor", + "type": "publicKey", + "index": false + }, + { + "name": "amount", + "type": "u64", + "index": false + } + ] + }, + { + "name": "GatewayAddressUpdated", + "fields": [ + { + "name": "chain", + "type": "u16", + "index": false + }, + { + "name": "gateway", + "type": { + "array": [ + "u8", + 32 + ] + }, + "index": false + } + ] + }, + { + "name": "MintingLimitUpdated", + "fields": [ + { + "name": "mintingLimit", + "type": "u64", + "index": false + } + ] + } + ], + "errors": [ + { + "code": 6016, + "name": "MintingLimitExceeded", + "msg": "Cannot mint more than the minting limit" + }, + { + "code": 6032, + "name": "IsNotAuthority", + "msg": "Only custodian authority is permitted for this action" + }, + { + "code": 6034, + "name": "IsNotPendingAuthority", + "msg": "Not valid pending authority to take authority" + }, + { + "code": 6036, + "name": "NoPendingAuthorityChange", + "msg": "No pending authority" + }, + { + "code": 6048, + "name": "ZeroRecipient", + "msg": "0x0 recipient not allowed" + }, + { + "code": 6064, + "name": "NotEnoughWrappedTbtc", + "msg": "Not enough wormhole tBTC in the gateway to bridge" + }, + { + "code": 6080, + "name": "ZeroAmount", + "msg": "Amount must not be 0" + }, + { + "code": 6112, + "name": "TransferAlreadyRedeemed", + "msg": "Token Bridge transfer already redeemed" + }, + { + "code": 6128, + "name": "InvalidEthereumTbtc", + "msg": "Token chain and address do not match Ethereum's tBTC" + }, + { + "code": 6144, + "name": "NoTbtcTransferred", + "msg": "No tBTC transferred" + }, + { + "code": 6160, + "name": "RecipientZeroAddress", + "msg": "0x0 receiver not allowed" + }, + { + "code": 6176, + "name": "MintedAmountUnderflow", + "msg": "Not enough minted by the gateway to satisfy sending tBTC" + }, + { + "code": 6178, + "name": "MintedAmountOverflow", + "msg": "Minted amount after deposit exceeds u64" + } + ] +} \ No newline at end of file From c8067b714cf2eb7796721a87996d05123d4b9835 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 9 Aug 2023 11:06:54 +0200 Subject: [PATCH 061/205] Unignoring IDL dir --- cross-chain/solana/.gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cross-chain/solana/.gitignore b/cross-chain/solana/.gitignore index 05e8d8768..626d5686f 100644 --- a/cross-chain/solana/.gitignore +++ b/cross-chain/solana/.gitignore @@ -2,10 +2,12 @@ .anchor .prettierrc.json .DS_Store -target +/target/* **/*.rs.bk node_modules test-ledger artifacts-mainnet artifacts-testnet -.env \ No newline at end of file +.env +!/target/idl/ +!/target/idl/* \ No newline at end of file From 3fd417c1bb8be12db4f713c13f1c2e3f7c569fd4 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 9 Aug 2023 16:20:11 +0200 Subject: [PATCH 062/205] Chains mapping Mapped Arbitrum, Optimism, Polygon and Base for testnet and mainnet. Added addresses to consts file. Added addresses of TBTC wrapped token. --- cross-chain/solana/deploy/helpers/consts.ts | 38 ++++ cross-chain/solana/deploy/init.ts | 215 +++++++++++++------- 2 files changed, 185 insertions(+), 68 deletions(-) create mode 100644 cross-chain/solana/deploy/helpers/consts.ts diff --git a/cross-chain/solana/deploy/helpers/consts.ts b/cross-chain/solana/deploy/helpers/consts.ts new file mode 100644 index 000000000..1a6fceed5 --- /dev/null +++ b/cross-chain/solana/deploy/helpers/consts.ts @@ -0,0 +1,38 @@ +import { WRAPPED_TBTC_MINT } from "./../../tests/helpers/consts" +export const WH_ARBITRUM_CHAIN_ID = 23 + +export const WH_OPTIMISM_CHAIN_ID = 24 + +export const WH_POLYGON_CHAIN_ID = 5 + +export const WH_BASE_CHAIN_ID = 30 + +// EVM addresses converted to 32 bytes. 0x is trimmed intentionally as the input +// param requires it without leading 0x. + +export const ARBITRUM_GATEWAY_ADDRESS_TESTNET = + "00000000000000000000000031a15e213b59e230b45e8c5c99dafac3d1236ee2" +export const ARBITRUM_GATEWAY_ADDRESS_MAINNET = + "0000000000000000000000001293a54e160d1cd7075487898d65266081a15458" + +export const OPTIMISM_GATEWAY_ADDRESS_TESTNET = + "0000000000000000000000006449F4381f3d63bDfb36B3bDc375724aD3cD4621" +export const OPTIMISM_GATEWAY_ADDRESS_MAINNET = + "0000000000000000000000001293a54e160D1cd7075487898d65266081A15458" + +export const POLYGON_GATEWAY_ADDRESS_TESTNET = + "00000000000000000000000091Fe7128f74dBd4F031ea3D90FC5Ea4DCfD81818" // testnet +export const POLYGON_GATEWAY_ADDRESS_MAINNET = + "00000000000000000000000009959798B95d00a3183d20FaC298E4594E599eab" + +export const BASE_GATEWAY_ADDRESS_TESTNET = + "000000000000000000000000e3e0511EEbD87F08FbaE4486419cb5dFB06e1343" +export const BASE_GATEWAY_ADDRESS_MAINNET = + "00000000000000000000000009959798B95d00a3183d20FaC298E4594E599eab" + +// deriveWrappedMintKey("DZnkkTmCiFWfYTfT41X3Rd1kDgozqzxWaHqsw6W4x2oe", 2, "0x679874fbe6d4e7cc54a59e315ff1eb266686a937") +export const WRAPPED_TBTC_MINT_TESTNET = + "FMYvcyMJJ22whB9m3T5g1oPKwM6jpLnFBXnrY6eXmCrp" +// deriveWrappedMintKey("wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb", 2, "0x18084fbA666a33d37592fA2633fD49a74DD93a88") +export const WRAPPED_TBTC_MINT_MAINNET = + "25rXTx9zDZcHyTav5sRqM6YBvTGu9pPH9yv83uAEqbgG" diff --git a/cross-chain/solana/deploy/init.ts b/cross-chain/solana/deploy/init.ts index 70e1c8a1d..3bf42a760 100644 --- a/cross-chain/solana/deploy/init.ts +++ b/cross-chain/solana/deploy/init.ts @@ -2,55 +2,56 @@ import * as anchor from "@coral-xyz/anchor" import fs from "fs" import { PublicKey, Keypair } from "@solana/web3.js" import dotenv from "dotenv" -import { Program } from "@coral-xyz/anchor"; -import { Tbtc } from "../target/types/tbtc"; -import { WormholeGateway } from "../target/types/wormhole_gateway"; -import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata"; +import { Program } from "@coral-xyz/anchor" +import { Tbtc } from "../target/types/tbtc" +import { WormholeGateway } from "../target/types/wormhole_gateway" +import { PROGRAM_ID as METADATA_PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata" +import * as consts from "./helpers/consts" async function run(): Promise { dotenv.config({ path: "../solana.env" }) - anchor.setProvider(anchor.AnchorProvider.env()); + anchor.setProvider(anchor.AnchorProvider.env()) - const tbtcProgram = anchor.workspace.Tbtc as Program; - const wormholeGatewayProgram = anchor.workspace.WormholeGateway as Program; + const tbtcProgram = anchor.workspace.Tbtc as Program + const wormholeGatewayProgram = anchor.workspace + .WormholeGateway as Program console.log("tbtcProgram.programId", tbtcProgram.programId) - console.log("wormholeGatewayProgram.programId", wormholeGatewayProgram.programId) + console.log( + "wormholeGatewayProgram.programId", + wormholeGatewayProgram.programId + ) // This wallet deployed the program and is also an authority - const authority = (loadKey(process.env.AUTHORITY)).publicKey + const authority = loadKey(process.env.AUTHORITY).publicKey const mint = PublicKey.findProgramAddressSync( [Buffer.from("tbtc-mint")], tbtcProgram.programId - )[0]; + )[0] const config = PublicKey.findProgramAddressSync( [Buffer.from("config")], tbtcProgram.programId - )[0]; + )[0] const guardians = PublicKey.findProgramAddressSync( [Buffer.from("guardians")], tbtcProgram.programId - )[0]; + )[0] const minters = PublicKey.findProgramAddressSync( [Buffer.from("minters")], tbtcProgram.programId - )[0]; + )[0] const tbtcMetadata = PublicKey.findProgramAddressSync( - [ - Buffer.from("metadata"), - METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - ], + [Buffer.from("metadata"), METADATA_PROGRAM_ID.toBuffer(), mint.toBuffer()], METADATA_PROGRAM_ID - )[0]; + )[0] - const mplTokenMetadataProgram = METADATA_PROGRAM_ID; + const mplTokenMetadataProgram = METADATA_PROGRAM_ID // Initalize tbtc program await tbtcProgram.methods @@ -62,9 +63,9 @@ async function run(): Promise { minters, authority, tbtcMetadata, - mplTokenMetadataProgram + mplTokenMetadataProgram, }) - .instruction() + .rpc() const minter = PublicKey.findProgramAddressSync( [Buffer.from("redeemer")], @@ -72,10 +73,11 @@ async function run(): Promise { )[0] const mintingLimit = 10000 // Arbitrary big number of TBTC - // TODO: verify with WH team if the address is correct - const WRAPPED_TBTC_MINT = new PublicKey( - "25rXTx9zDZcHyTav5sRqM6YBvTGu9pPH9yv83uAEqbgG" - ); + let WRAPPED_TBTC = consts.WRAPPED_TBTC_MINT_TESTNET + if (process.env.CLUSTER === "mainnet-beta") { + WRAPPED_TBTC = consts.WRAPPED_TBTC_MINT_MAINNET + } + const WRAPPED_TBTC_MINT = new PublicKey(WRAPPED_TBTC) const gatewayWrappedTbtcToken = PublicKey.findProgramAddressSync( [Buffer.from("wrapped-token")], @@ -87,6 +89,7 @@ async function run(): Promise { wormholeGatewayProgram.programId )[0] + // Initialize wormhole gateway await wormholeGatewayProgram.methods .initialize(new anchor.BN(mintingLimit)) .accounts({ @@ -97,53 +100,129 @@ async function run(): Promise { wrappedTbtcToken: gatewayWrappedTbtcToken, tokenBridgeSender, }) - .rpc(); + .rpc() const minterInfo = PublicKey.findProgramAddressSync( [Buffer.from("minter-info"), minter.toBuffer()], tbtcProgram.programId )[0] - // // Adding a minter (wormholeGateway) - // await tbtcProgram.methods - // .addMinter() - // .accounts({ - // config, - // authority, - // minters, - // minterInfo, - // minter, - // }) - // .instruction(); - - // // update mappings (self?, arbitrum, optimism, polygon, base) - - // // arbitrum chain ID: 23 - // // ETH Goerli address: 0x00000000000000000000000031a15e213b59e230b45e8c5c99dafac3d1236ee2 - // // ETH Mainnet address: 0x0000000000000000000000001293a54e160d1cd7075487898d65266081a15458 - // const arbitrumChain = 23 - // const arbiArgs = { - // chain: arbitrumChain, - // address: Array.from(Buffer.alloc(32, "00000000000000000000000031a15e213b59e230b45e8c5c99dafac3d1236ee2", "hex")) - // } - - // const encodedChain = Buffer.alloc(2); - // encodedChain.writeUInt16LE(arbitrumChain); - // const gatewayInfo = PublicKey.findProgramAddressSync( - // [Buffer.from("gateway-info"), encodedChain], - // wormholeGatewayProgram.programId - // )[0] - - // wormholeGatewayProgram.methods - // .updateGatewayAddress(arbiArgs) - // .accounts({ - // custodian: minter, - // gatewayInfo, - // authority, - // }) - // .instruction(); - - console.log("success") + // Adding a minter (wormholeGateway) + await tbtcProgram.methods + .addMinter() + .accounts({ + config, + authority, + minters, + minterInfo, + minter, + }) + .rpc() + + // Point to devnet addresses by default + let ARBITRUM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET + let OPTIMISM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET + let POLYGON_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET + let BASE_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET + if (process.env.CLUSTER === "mainnet-beta") { + ARBITRUM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_MAINNET + OPTIMISM_GATEWAY = consts.OPTIMISM_GATEWAY_ADDRESS_MAINNET + POLYGON_GATEWAY = consts.POLYGON_GATEWAY_ADDRESS_MAINNET + BASE_GATEWAY = consts.BASE_GATEWAY_ADDRESS_MAINNET + } + + // Updating with Arbitrum + const arbiArgs = { + chain: consts.WH_ARBITRUM_CHAIN_ID, + address: Array.from(Buffer.alloc(32, ARBITRUM_GATEWAY, "hex")), + } + + const encodedArbiChain = Buffer.alloc(2) + encodedArbiChain.writeUInt16LE(consts.WH_ARBITRUM_CHAIN_ID) + const gatewayArbiInfo = PublicKey.findProgramAddressSync( + [Buffer.from("gateway-info"), encodedArbiChain], + wormholeGatewayProgram.programId + )[0] + + wormholeGatewayProgram.methods + .updateGatewayAddress(arbiArgs) + .accounts({ + custodian: minter, + gatewayInfo: gatewayArbiInfo, + authority, + }) + .rpc() + + // Updating with Optimism + const optiArgs = { + chain: consts.WH_OPTIMISM_CHAIN_ID, + address: Array.from(Buffer.alloc(32, OPTIMISM_GATEWAY, "hex")), + } + + const encodedOptiChain = Buffer.alloc(2) + encodedOptiChain.writeUInt16LE(consts.WH_OPTIMISM_CHAIN_ID) + const gatewayOptiInfo = PublicKey.findProgramAddressSync( + [Buffer.from("gateway-info"), encodedOptiChain], + wormholeGatewayProgram.programId + )[0] + + wormholeGatewayProgram.methods + .updateGatewayAddress(optiArgs) + .accounts({ + custodian: minter, + gatewayInfo: gatewayOptiInfo, + authority, + }) + .rpc() + + // Updating with Polygon + const polyArgs = { + chain: consts.WH_POLYGON_CHAIN_ID, + address: Array.from(Buffer.alloc(32, POLYGON_GATEWAY, "hex")), + } + + const encodedPolyChain = Buffer.alloc(2) + encodedPolyChain.writeUInt16LE(consts.WH_POLYGON_CHAIN_ID) + const gatewayPolyInfo = PublicKey.findProgramAddressSync( + [Buffer.from("gateway-info"), encodedPolyChain], + wormholeGatewayProgram.programId + )[0] + + wormholeGatewayProgram.methods + .updateGatewayAddress(polyArgs) + .accounts({ + custodian: minter, + gatewayInfo: gatewayPolyInfo, + authority, + }) + .rpc() + + // Updating with BASE + const baseArgs = { + chain: consts.WH_BASE_CHAIN_ID, + address: Array.from(Buffer.alloc(32, BASE_GATEWAY, "hex")), + } + + const encodedBaseChain = Buffer.alloc(2) + encodedBaseChain.writeUInt16LE(consts.WH_BASE_CHAIN_ID) + const gatewayBaseInfo = PublicKey.findProgramAddressSync( + [Buffer.from("gateway-info"), encodedBaseChain], + wormholeGatewayProgram.programId + )[0] + + wormholeGatewayProgram.methods + .updateGatewayAddress(baseArgs) + .accounts({ + custodian: minter, + gatewayInfo: gatewayBaseInfo, + authority, + }) + .rpc() + + // TODO: confirm with the WH team if Solana gateway should be self updated just + // like we do on EVMs, i.e updateGatewayAddress(solanaArgs) + + console.log("Done initializing programs!") } ;(async () => { @@ -163,4 +242,4 @@ function loadKey(filename: string): Keypair { } catch { console.log("Unable to read keypair...", filename) } -} \ No newline at end of file +} From 9b678f898288785559f53a7b8ff5dadeb2f2261e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 9 Aug 2023 20:12:50 +0200 Subject: [PATCH 063/205] Updating with Solana gateway --- cross-chain/solana/deploy/helpers/consts.ts | 9 +++++- cross-chain/solana/deploy/init.ts | 33 +++++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/cross-chain/solana/deploy/helpers/consts.ts b/cross-chain/solana/deploy/helpers/consts.ts index 1a6fceed5..71c42e176 100644 --- a/cross-chain/solana/deploy/helpers/consts.ts +++ b/cross-chain/solana/deploy/helpers/consts.ts @@ -7,11 +7,14 @@ export const WH_POLYGON_CHAIN_ID = 5 export const WH_BASE_CHAIN_ID = 30 +export const WH_SOLANA_CHAIN_ID = 1 + // EVM addresses converted to 32 bytes. 0x is trimmed intentionally as the input // param requires it without leading 0x. export const ARBITRUM_GATEWAY_ADDRESS_TESTNET = "00000000000000000000000031a15e213b59e230b45e8c5c99dafac3d1236ee2" + export const ARBITRUM_GATEWAY_ADDRESS_MAINNET = "0000000000000000000000001293a54e160d1cd7075487898d65266081a15458" @@ -21,7 +24,7 @@ export const OPTIMISM_GATEWAY_ADDRESS_MAINNET = "0000000000000000000000001293a54e160D1cd7075487898d65266081A15458" export const POLYGON_GATEWAY_ADDRESS_TESTNET = - "00000000000000000000000091Fe7128f74dBd4F031ea3D90FC5Ea4DCfD81818" // testnet + "00000000000000000000000091Fe7128f74dBd4F031ea3D90FC5Ea4DCfD81818" export const POLYGON_GATEWAY_ADDRESS_MAINNET = "00000000000000000000000009959798B95d00a3183d20FaC298E4594E599eab" @@ -36,3 +39,7 @@ export const WRAPPED_TBTC_MINT_TESTNET = // deriveWrappedMintKey("wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb", 2, "0x18084fbA666a33d37592fA2633fD49a74DD93a88") export const WRAPPED_TBTC_MINT_MAINNET = "25rXTx9zDZcHyTav5sRqM6YBvTGu9pPH9yv83uAEqbgG" + +export const SOLANA_GATEWAY_ADDRESS_TESTNET = + "Gj93RRt6QB7FjmyokAD5rcMAku7pq3Fk2Aa8y6nNbwsV" +// export const SOLANA_GATEWAY_ADDRESS_MAINNET = "tbd" diff --git a/cross-chain/solana/deploy/init.ts b/cross-chain/solana/deploy/init.ts index 3bf42a760..78dcb4d1c 100644 --- a/cross-chain/solana/deploy/init.ts +++ b/cross-chain/solana/deploy/init.ts @@ -124,11 +124,13 @@ async function run(): Promise { let OPTIMISM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET let POLYGON_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET let BASE_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET + let SOLANA_GATEWAY = consts.SOLANA_GATEWAY_ADDRESS_TESTNET if (process.env.CLUSTER === "mainnet-beta") { ARBITRUM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_MAINNET OPTIMISM_GATEWAY = consts.OPTIMISM_GATEWAY_ADDRESS_MAINNET POLYGON_GATEWAY = consts.POLYGON_GATEWAY_ADDRESS_MAINNET BASE_GATEWAY = consts.BASE_GATEWAY_ADDRESS_MAINNET + // TODO: add SOLANA_GATEWAY_ADDRESS_MAINNET once it's deployed } // Updating with Arbitrum @@ -144,7 +146,7 @@ async function run(): Promise { wormholeGatewayProgram.programId )[0] - wormholeGatewayProgram.methods + await wormholeGatewayProgram.methods .updateGatewayAddress(arbiArgs) .accounts({ custodian: minter, @@ -166,7 +168,7 @@ async function run(): Promise { wormholeGatewayProgram.programId )[0] - wormholeGatewayProgram.methods + await wormholeGatewayProgram.methods .updateGatewayAddress(optiArgs) .accounts({ custodian: minter, @@ -188,7 +190,7 @@ async function run(): Promise { wormholeGatewayProgram.programId )[0] - wormholeGatewayProgram.methods + await wormholeGatewayProgram.methods .updateGatewayAddress(polyArgs) .accounts({ custodian: minter, @@ -210,7 +212,7 @@ async function run(): Promise { wormholeGatewayProgram.programId )[0] - wormholeGatewayProgram.methods + await wormholeGatewayProgram.methods .updateGatewayAddress(baseArgs) .accounts({ custodian: minter, @@ -219,8 +221,27 @@ async function run(): Promise { }) .rpc() - // TODO: confirm with the WH team if Solana gateway should be self updated just - // like we do on EVMs, i.e updateGatewayAddress(solanaArgs) + // Updating with self (SOLANA) + const solanaArgs = { + chain: consts.WH_SOLANA_CHAIN_ID, + address: Array.from(new PublicKey(SOLANA_GATEWAY).toBuffer()), + } + + const encodedSolanaChain = Buffer.alloc(2) + encodedSolanaChain.writeUInt16LE(consts.WH_SOLANA_CHAIN_ID) + const gatewaySolanaInfo = PublicKey.findProgramAddressSync( + [Buffer.from("gateway-info"), encodedSolanaChain], + wormholeGatewayProgram.programId + )[0] + + await wormholeGatewayProgram.methods + .updateGatewayAddress(solanaArgs) + .accounts({ + custodian: minter, + gatewayInfo: gatewaySolanaInfo, + authority, + }) + .rpc() console.log("Done initializing programs!") } From 125653e4e986328e426160841cbb15700df91601 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 9 Aug 2023 20:14:05 +0200 Subject: [PATCH 064/205] Linting only --- cross-chain/solana/migrations/deploy.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cross-chain/solana/migrations/deploy.ts b/cross-chain/solana/migrations/deploy.ts index 448a1b3f2..ba714d66e 100644 --- a/cross-chain/solana/migrations/deploy.ts +++ b/cross-chain/solana/migrations/deploy.ts @@ -2,10 +2,10 @@ // single deploy script that's invoked from the CLI, injecting a provider // configured from the workspace's Anchor.toml. -const anchor = require("@coral-xyz/anchor"); +const anchor = require("@coral-xyz/anchor") module.exports = async function (provider) { // Configure client to use the provider. - anchor.setProvider(provider); + anchor.setProvider(provider) // Add your deploy script here. -}; \ No newline at end of file +} From 0e46206cb577de27d5928bd4165cdfdd7f2139f3 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 9 Aug 2023 20:16:46 +0200 Subject: [PATCH 065/205] Replacing IDLs with program addresses --- cross-chain/solana/target/idl/tbtc.json | 5 ++++- cross-chain/solana/target/idl/wormhole_gateway.json | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cross-chain/solana/target/idl/tbtc.json b/cross-chain/solana/target/idl/tbtc.json index a56a15669..64859138c 100644 --- a/cross-chain/solana/target/idl/tbtc.json +++ b/cross-chain/solana/target/idl/tbtc.json @@ -557,5 +557,8 @@ "name": "IsNotPaused", "msg": "Program is not paused" } - ] + ], + "metadata": { + "address": "Gj93RRt6QB7FjmyokAD5rcMAku7pq3Fk2Aa8y6nNbwsV" + } } \ No newline at end of file diff --git a/cross-chain/solana/target/idl/wormhole_gateway.json b/cross-chain/solana/target/idl/wormhole_gateway.json index b7f578215..2ace740b4 100644 --- a/cross-chain/solana/target/idl/wormhole_gateway.json +++ b/cross-chain/solana/target/idl/wormhole_gateway.json @@ -988,5 +988,8 @@ "name": "MintedAmountOverflow", "msg": "Minted amount after deposit exceeds u64" } - ] + ], + "metadata": { + "address": "87MEvHZCXE3ML5rrmh5uX1FbShHmRXXS32xJDGbQ7h5t" + } } \ No newline at end of file From 29c1025ed34f3001b0528cfb932334873d48adc0 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 9 Aug 2023 20:40:12 +0200 Subject: [PATCH 066/205] Updating deploy.sh script with deployment descriptions --- cross-chain/solana/scripts/deploy.sh | 33 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/cross-chain/solana/scripts/deploy.sh b/cross-chain/solana/scripts/deploy.sh index 19d2dcd55..92ff61c06 100755 --- a/cross-chain/solana/scripts/deploy.sh +++ b/cross-chain/solana/scripts/deploy.sh @@ -22,11 +22,32 @@ then ARTIFACTS_PATH=artifacts-mainnet fi -echo "Building workspace for cluster: $NETWORK ..." -make build +# Build and deploy process should be split in a couple of steps. Here is a +# checklist: -echo "Deploying TBTC program for cluster: $CLUSTER ..." -solana program deploy --url $CLUSTER --keypair $AUTHORITY ./$ARTIFACTS_PATH/tbtc.so +## First run the following 'make build' +# echo "Building workspace for cluster: $NETWORK ..." +# make build -echo "Deploying WORMHOLE_GATEWAY program for cluster: $CLUSTER ..." -solana program deploy --url $CLUSTER --keypair $AUTHORITY ./$ARTIFACTS_PATH/wormhole_gateway.so +## Now check the program IDs by running +## `solana-keygen pubkey target/deploy/tbtc-keypair.json` +## `solana-keygen pubkey target/deploy/wormhole_gateway-keypair.json` +## Copy and paste these addresses in both programs 'lib.rs' and in Anchor.toml +## In Anchor toml make sure that cluster and program point to the right network: +## e.g. devnet, mainnet-beta + +## Now run the build again to. his step is to include the new program id in the binary. +# anchor build --arch sbf -- --features "" -- --no-default-features +## where NETWORK can be one of the following: solana-devnet OR mainnet + +## Deploy programs +# echo "Deploying program(s) for cluster: $CLUSTER ..." +# anchor deploy --provider.cluster $CLUSTER --provider.wallet $AUTHORITY + +## And now it's time to initialize tbtc and wormhole_gatewa programs +# make init_programs + +## The last step is to transfer authority to the Threshold Council. (for mainnet only) +# make transfer_authority + +## Also run transfer_authority.sh script to transfer upgrade authority. (for mainnet only) \ No newline at end of file From f4aae4cdce747167554164bb422ed168bb768813 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 9 Aug 2023 23:09:34 +0200 Subject: [PATCH 067/205] Adding Solana gateway address for supported x-chains --- .../00_resolve_solana_wormhole_gateway.ts | 28 +++++++++++++ ...with_solana_in_wormhole_gateway_mapping.ts | 39 +++++++++++++++++++ .../arbitrumGoerli/SolanaWormholeGateway.json | 3 ++ .../arbitrumOne/SolanaWormholeGateway.json | 3 ++ .../00_resolve_solana_wormhole_gateway.ts | 28 +++++++++++++ ...with_solana_in_wormhole_gateway_mapping.ts | 39 +++++++++++++++++++ .../external/base/SolanaWormholeGateway.json | 3 ++ .../baseGoerli/SolanaWormholeGateway.json | 3 ++ .../00_resolve_solana_wormhole_gateway.ts | 28 +++++++++++++ ...with_solana_in_wormhole_gateway_mapping.ts | 39 +++++++++++++++++++ .../optimism/SolanaWormholeGateway.json | 3 ++ .../optimismGoerli/SolanaWormholeGateway.json | 3 ++ .../00_resolve_solana_wormhole_gateway.ts | 28 +++++++++++++ ...with_solana_in_wormhole_gateway_mapping.ts | 39 +++++++++++++++++++ .../mumbai/SolanaWormholeGateway.json | 3 ++ .../polygon/SolanaWormholeGateway.json | 3 ++ 16 files changed, 292 insertions(+) create mode 100644 cross-chain/arbitrum/deploy_l2/00_resolve_solana_wormhole_gateway.ts create mode 100644 cross-chain/arbitrum/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/arbitrum/external/arbitrumGoerli/SolanaWormholeGateway.json create mode 100644 cross-chain/arbitrum/external/arbitrumOne/SolanaWormholeGateway.json create mode 100644 cross-chain/base/deploy_l2/00_resolve_solana_wormhole_gateway.ts create mode 100644 cross-chain/base/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/base/external/base/SolanaWormholeGateway.json create mode 100644 cross-chain/base/external/baseGoerli/SolanaWormholeGateway.json create mode 100644 cross-chain/optimism/deploy_l2/00_resolve_solana_wormhole_gateway.ts create mode 100644 cross-chain/optimism/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/optimism/external/optimism/SolanaWormholeGateway.json create mode 100644 cross-chain/optimism/external/optimismGoerli/SolanaWormholeGateway.json create mode 100644 cross-chain/polygon/deploy_sidechain/00_resolve_solana_wormhole_gateway.ts create mode 100644 cross-chain/polygon/deploy_sidechain/16_update_with_solana_in_wormhole_gateway_mapping.ts create mode 100644 cross-chain/polygon/external/mumbai/SolanaWormholeGateway.json create mode 100644 cross-chain/polygon/external/polygon/SolanaWormholeGateway.json diff --git a/cross-chain/arbitrum/deploy_l2/00_resolve_solana_wormhole_gateway.ts b/cross-chain/arbitrum/deploy_l2/00_resolve_solana_wormhole_gateway.ts new file mode 100644 index 000000000..3e6d35e5d --- /dev/null +++ b/cross-chain/arbitrum/deploy_l2/00_resolve_solana_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const SolanaWormholeGateway = await deployments.getOrNull( + "SolanaWormholeGateway" + ) + + if ( + SolanaWormholeGateway && + helpers.address.isValid(SolanaWormholeGateway.address) + ) { + log( + `using existing SolanaWormholeGateway at ${SolanaWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake SolanaWormholeGateway for hardhat network") + } else { + throw new Error("deployed SolanaWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["SolanaWormholeGateway"] diff --git a/cross-chain/arbitrum/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts b/cross-chain/arbitrum/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..c8d15ccab --- /dev/null +++ b/cross-chain/arbitrum/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts @@ -0,0 +1,39 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake SolanaWormholeGateway for local development purposes only. + const fakeSolanaWormholeGateway = + "0x11a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" + + // See https://docs.wormhole.com/wormhole/blockchain-environments/solana + // This ID is valid for both Solana Devnet and Mainnet + const solanaWormholeChainID = 1 + + const solanaWormholeGateway = await deployments.getOrNull( + "SolanaWormholeGateway" + ) + + let solanaWormholeGatewayAddress = solanaWormholeGateway?.address + if (!solanaWormholeGatewayAddress && hre.network.name === "hardhat") { + solanaWormholeGatewayAddress = fakeSolanaWormholeGateway + log(`fake SolanaWormholeGateway address ${solanaWormholeGatewayAddress}`) + } + + await execute( + "ArbitrumWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + solanaWormholeChainID, + solanaWormholeGatewayAddress + ) +} + +export default func + +func.tags = ["SetSolanaGatewayAddress"] +func.dependencies = ["ArbitrumWormholeGateway"] diff --git a/cross-chain/arbitrum/external/arbitrumGoerli/SolanaWormholeGateway.json b/cross-chain/arbitrum/external/arbitrumGoerli/SolanaWormholeGateway.json new file mode 100644 index 000000000..dee25fa3e --- /dev/null +++ b/cross-chain/arbitrum/external/arbitrumGoerli/SolanaWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" +} diff --git a/cross-chain/arbitrum/external/arbitrumOne/SolanaWormholeGateway.json b/cross-chain/arbitrum/external/arbitrumOne/SolanaWormholeGateway.json new file mode 100644 index 000000000..95e933073 --- /dev/null +++ b/cross-chain/arbitrum/external/arbitrumOne/SolanaWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "tbd" +} diff --git a/cross-chain/base/deploy_l2/00_resolve_solana_wormhole_gateway.ts b/cross-chain/base/deploy_l2/00_resolve_solana_wormhole_gateway.ts new file mode 100644 index 000000000..3e6d35e5d --- /dev/null +++ b/cross-chain/base/deploy_l2/00_resolve_solana_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const SolanaWormholeGateway = await deployments.getOrNull( + "SolanaWormholeGateway" + ) + + if ( + SolanaWormholeGateway && + helpers.address.isValid(SolanaWormholeGateway.address) + ) { + log( + `using existing SolanaWormholeGateway at ${SolanaWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake SolanaWormholeGateway for hardhat network") + } else { + throw new Error("deployed SolanaWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["SolanaWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..338b1b070 --- /dev/null +++ b/cross-chain/base/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts @@ -0,0 +1,39 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake SolanaWormholeGateway for local development purposes only. + const fakeSolanaWormholeGateway = + "0x11a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" + + // See https://docs.wormhole.com/wormhole/blockchain-environments/solana + // This ID is valid for both Solana Devnet and Mainnet + const solanaWormholeChainID = 1 + + const solanaWormholeGateway = await deployments.getOrNull( + "SolanaWormholeGateway" + ) + + let solanaWormholeGatewayAddress = solanaWormholeGateway?.address + if (!solanaWormholeGatewayAddress && hre.network.name === "hardhat") { + solanaWormholeGatewayAddress = fakeSolanaWormholeGateway + log(`fake SolanaWormholeGateway address ${solanaWormholeGatewayAddress}`) + } + + await execute( + "BaseWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + solanaWormholeChainID, + solanaWormholeGatewayAddress + ) +} + +export default func + +func.tags = ["SetSolanaGatewayAddress"] +func.dependencies = ["BaseWormholeGateway"] diff --git a/cross-chain/base/external/base/SolanaWormholeGateway.json b/cross-chain/base/external/base/SolanaWormholeGateway.json new file mode 100644 index 000000000..95e933073 --- /dev/null +++ b/cross-chain/base/external/base/SolanaWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "tbd" +} diff --git a/cross-chain/base/external/baseGoerli/SolanaWormholeGateway.json b/cross-chain/base/external/baseGoerli/SolanaWormholeGateway.json new file mode 100644 index 000000000..dee25fa3e --- /dev/null +++ b/cross-chain/base/external/baseGoerli/SolanaWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" +} diff --git a/cross-chain/optimism/deploy_l2/00_resolve_solana_wormhole_gateway.ts b/cross-chain/optimism/deploy_l2/00_resolve_solana_wormhole_gateway.ts new file mode 100644 index 000000000..3e6d35e5d --- /dev/null +++ b/cross-chain/optimism/deploy_l2/00_resolve_solana_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const SolanaWormholeGateway = await deployments.getOrNull( + "SolanaWormholeGateway" + ) + + if ( + SolanaWormholeGateway && + helpers.address.isValid(SolanaWormholeGateway.address) + ) { + log( + `using existing SolanaWormholeGateway at ${SolanaWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake SolanaWormholeGateway for hardhat network") + } else { + throw new Error("deployed SolanaWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["SolanaWormholeGateway"] diff --git a/cross-chain/optimism/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts b/cross-chain/optimism/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..487c70c0e --- /dev/null +++ b/cross-chain/optimism/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts @@ -0,0 +1,39 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake SolanaWormholeGateway for local development purposes only. + const fakeSolanaWormholeGateway = + "0x11a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" + + // See https://docs.wormhole.com/wormhole/blockchain-environments/solana + // This ID is valid for both Solana Devnet and Mainnet + const solanaWormholeChainID = 1 + + const solanaWormholeGateway = await deployments.getOrNull( + "SolanaWormholeGateway" + ) + + let solanaWormholeGatewayAddress = solanaWormholeGateway?.address + if (!solanaWormholeGatewayAddress && hre.network.name === "hardhat") { + solanaWormholeGatewayAddress = fakeSolanaWormholeGateway + log(`fake SolanaWormholeGateway address ${solanaWormholeGatewayAddress}`) + } + + await execute( + "OptimismWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + solanaWormholeChainID, + solanaWormholeGatewayAddress + ) +} + +export default func + +func.tags = ["SetSolanaGatewayAddress"] +func.dependencies = ["OptimismWormholeGateway"] diff --git a/cross-chain/optimism/external/optimism/SolanaWormholeGateway.json b/cross-chain/optimism/external/optimism/SolanaWormholeGateway.json new file mode 100644 index 000000000..95e933073 --- /dev/null +++ b/cross-chain/optimism/external/optimism/SolanaWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "tbd" +} diff --git a/cross-chain/optimism/external/optimismGoerli/SolanaWormholeGateway.json b/cross-chain/optimism/external/optimismGoerli/SolanaWormholeGateway.json new file mode 100644 index 000000000..dee25fa3e --- /dev/null +++ b/cross-chain/optimism/external/optimismGoerli/SolanaWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" +} diff --git a/cross-chain/polygon/deploy_sidechain/00_resolve_solana_wormhole_gateway.ts b/cross-chain/polygon/deploy_sidechain/00_resolve_solana_wormhole_gateway.ts new file mode 100644 index 000000000..3e6d35e5d --- /dev/null +++ b/cross-chain/polygon/deploy_sidechain/00_resolve_solana_wormhole_gateway.ts @@ -0,0 +1,28 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { helpers, deployments } = hre + const { log } = deployments + + const SolanaWormholeGateway = await deployments.getOrNull( + "SolanaWormholeGateway" + ) + + if ( + SolanaWormholeGateway && + helpers.address.isValid(SolanaWormholeGateway.address) + ) { + log( + `using existing SolanaWormholeGateway at ${SolanaWormholeGateway.address}` + ) + } else if (hre.network.name === "hardhat") { + log("using fake SolanaWormholeGateway for hardhat network") + } else { + throw new Error("deployed SolanaWormholeGateway contract not found") + } +} + +export default func + +func.tags = ["SolanaWormholeGateway"] diff --git a/cross-chain/polygon/deploy_sidechain/16_update_with_solana_in_wormhole_gateway_mapping.ts b/cross-chain/polygon/deploy_sidechain/16_update_with_solana_in_wormhole_gateway_mapping.ts new file mode 100644 index 000000000..ab950da84 --- /dev/null +++ b/cross-chain/polygon/deploy_sidechain/16_update_with_solana_in_wormhole_gateway_mapping.ts @@ -0,0 +1,39 @@ +import type { HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction } from "hardhat-deploy/types" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre + const { execute, log } = deployments + const { deployer } = await getNamedAccounts() + + // Fake SolanaWormholeGateway for local development purposes only. + const fakeSolanaWormholeGateway = + "0x11a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" + + // See https://docs.wormhole.com/wormhole/blockchain-environments/solana + // This ID is valid for both Solana Devnet and Mainnet + const solanaWormholeChainID = 1 + + const solanaWormholeGateway = await deployments.getOrNull( + "SolanaWormholeGateway" + ) + + let solanaWormholeGatewayAddress = solanaWormholeGateway?.address + if (!solanaWormholeGatewayAddress && hre.network.name === "hardhat") { + solanaWormholeGatewayAddress = fakeSolanaWormholeGateway + log(`fake SolanaWormholeGateway address ${solanaWormholeGatewayAddress}`) + } + + await execute( + "PolygonWormholeGateway", + { from: deployer, log: true, waitConfirmations: 1 }, + "updateGatewayAddress", + solanaWormholeChainID, + solanaWormholeGatewayAddress + ) +} + +export default func + +func.tags = ["SetSolanaGatewayAddress"] +func.dependencies = ["PolygonWormholeGateway"] diff --git a/cross-chain/polygon/external/mumbai/SolanaWormholeGateway.json b/cross-chain/polygon/external/mumbai/SolanaWormholeGateway.json new file mode 100644 index 000000000..dee25fa3e --- /dev/null +++ b/cross-chain/polygon/external/mumbai/SolanaWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" +} diff --git a/cross-chain/polygon/external/polygon/SolanaWormholeGateway.json b/cross-chain/polygon/external/polygon/SolanaWormholeGateway.json new file mode 100644 index 000000000..95e933073 --- /dev/null +++ b/cross-chain/polygon/external/polygon/SolanaWormholeGateway.json @@ -0,0 +1,3 @@ +{ + "address": "tbd" +} From a749e9401eb3b9f4e1bbb5beb5c0a7f8c0634856 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 10 Aug 2023 14:27:18 +0200 Subject: [PATCH 068/205] Fixing Gateway var names for devnet --- cross-chain/solana/deploy/init.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cross-chain/solana/deploy/init.ts b/cross-chain/solana/deploy/init.ts index 78dcb4d1c..bf5d3bc71 100644 --- a/cross-chain/solana/deploy/init.ts +++ b/cross-chain/solana/deploy/init.ts @@ -17,12 +17,6 @@ async function run(): Promise { const wormholeGatewayProgram = anchor.workspace .WormholeGateway as Program - console.log("tbtcProgram.programId", tbtcProgram.programId) - console.log( - "wormholeGatewayProgram.programId", - wormholeGatewayProgram.programId - ) - // This wallet deployed the program and is also an authority const authority = loadKey(process.env.AUTHORITY).publicKey @@ -121,9 +115,9 @@ async function run(): Promise { // Point to devnet addresses by default let ARBITRUM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET - let OPTIMISM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET - let POLYGON_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET - let BASE_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET + let OPTIMISM_GATEWAY = consts.OPTIMISM_GATEWAY_ADDRESS_TESTNET + let POLYGON_GATEWAY = consts.POLYGON_GATEWAY_ADDRESS_TESTNET + let BASE_GATEWAY = consts.BASE_GATEWAY_ADDRESS_TESTNET let SOLANA_GATEWAY = consts.SOLANA_GATEWAY_ADDRESS_TESTNET if (process.env.CLUSTER === "mainnet-beta") { ARBITRUM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_MAINNET From 73bedec1a860a971867ee92bf825ed8c81dbbde6 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 10 Aug 2023 14:38:23 +0200 Subject: [PATCH 069/205] Adding anchor command for publishing IDL to Solana ecosystem --- cross-chain/solana/scripts/deploy.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cross-chain/solana/scripts/deploy.sh b/cross-chain/solana/scripts/deploy.sh index 92ff61c06..0b48b6177 100755 --- a/cross-chain/solana/scripts/deploy.sh +++ b/cross-chain/solana/scripts/deploy.sh @@ -50,4 +50,7 @@ fi ## The last step is to transfer authority to the Threshold Council. (for mainnet only) # make transfer_authority -## Also run transfer_authority.sh script to transfer upgrade authority. (for mainnet only) \ No newline at end of file +## Also run transfer_authority.sh script to transfer upgrade authority. (for mainnet only) + +## Publishing IDL so that Solana ecosystem can detect and display data nicely (nice to have) +# anchor idl init --provider.cluster $CLUSTER --provider.wallet $AUTHORITY -f target/idl/.json \ No newline at end of file From 89af22bfcd37b24391fec5c46f4f6362b5f6647e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 10 Aug 2023 23:11:08 +0200 Subject: [PATCH 070/205] Adding ownership transfer scripts --- .../solana/deploy/transfer_authority.ts | 24 ++++++++++++++++--- cross-chain/solana/scripts/deploy.sh | 5 ---- .../solana/scripts/transfer_authority.sh | 12 ++++++---- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/cross-chain/solana/deploy/transfer_authority.ts b/cross-chain/solana/deploy/transfer_authority.ts index 8146d0e83..b2ff6be6f 100644 --- a/cross-chain/solana/deploy/transfer_authority.ts +++ b/cross-chain/solana/deploy/transfer_authority.ts @@ -1,3 +1,4 @@ +import { WormholeGateway } from "./../target/types/wormhole_gateway" import * as anchor from "@coral-xyz/anchor" import fs from "fs" import { PublicKey, Keypair } from "@solana/web3.js" @@ -6,15 +7,23 @@ import dotenv from "dotenv" async function run(): Promise { dotenv.config({ path: "solana.env" }) + anchor.setProvider(anchor.AnchorProvider.env()) + const authority = loadKey(process.env.AUTHORITY) const newAuthority = process.env.THRESHOLD_COUNCIL_MULTISIG const tbtcProgram = anchor.workspace.Tbtc + const wormholeGatewayProgram = anchor.workspace.WormholeGateway const config = PublicKey.findProgramAddressSync( [Buffer.from("config")], tbtcProgram.programId - )[0]; + )[0] + + const custodian = PublicKey.findProgramAddressSync( + [Buffer.from("redeemer")], + wormholeGatewayProgram.programId + )[0] await tbtcProgram.methods .changeAuthority() @@ -23,7 +32,16 @@ async function run(): Promise { authority, newAuthority, }) - .instruction(); + .rpc() + + await wormholeGatewayProgram.methods + .changeAuthority() + .accounts({ + custodian, + authority, + newAuthority, + }) + .rpc() } ;(async () => { @@ -43,4 +61,4 @@ function loadKey(filename: string): Keypair { } catch { console.log("Unable to read keypair...", filename) } -} \ No newline at end of file +} diff --git a/cross-chain/solana/scripts/deploy.sh b/cross-chain/solana/scripts/deploy.sh index 0b48b6177..a6118ee7f 100755 --- a/cross-chain/solana/scripts/deploy.sh +++ b/cross-chain/solana/scripts/deploy.sh @@ -47,10 +47,5 @@ fi ## And now it's time to initialize tbtc and wormhole_gatewa programs # make init_programs -## The last step is to transfer authority to the Threshold Council. (for mainnet only) -# make transfer_authority - -## Also run transfer_authority.sh script to transfer upgrade authority. (for mainnet only) - ## Publishing IDL so that Solana ecosystem can detect and display data nicely (nice to have) # anchor idl init --provider.cluster $CLUSTER --provider.wallet $AUTHORITY -f target/idl/.json \ No newline at end of file diff --git a/cross-chain/solana/scripts/transfer_authority.sh b/cross-chain/solana/scripts/transfer_authority.sh index 88edc0d55..703638816 100755 --- a/cross-chain/solana/scripts/transfer_authority.sh +++ b/cross-chain/solana/scripts/transfer_authority.sh @@ -1,12 +1,16 @@ #!/bin/bash set -eo pipefail +## FOR MAINNET ONLY + # Setting env variables in the current bash shell source solana.env -# TODO: transfer upgrade authority to Threshold Council Multisig +## Transfer authority to the Threshold Council Multisig. (for mainnet only) +# make transfer_authority + +## Transfer upgrade authority to Threshold Council Multisig # solana program set-upgrade-authority -k --new-upgrade-authority -# Transfer authority to the Threshold Council Multisig -# TODO: verify if the authority was actually transferred. -anchor run authority --provider.cluster $CLUSTER \ No newline at end of file +## Threshold Council Multisig has to accept the ownership by executing +## `takeAuthority` instruction \ No newline at end of file From 9e2b7a790d7f15c40d6db4dcb01f87f46f851202 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 11 Aug 2023 11:08:51 +0200 Subject: [PATCH 071/205] Fixing gateway address. It pointed to tbtc, not gateway. --- cross-chain/solana/deploy/helpers/consts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-chain/solana/deploy/helpers/consts.ts b/cross-chain/solana/deploy/helpers/consts.ts index 71c42e176..a9a4f17d2 100644 --- a/cross-chain/solana/deploy/helpers/consts.ts +++ b/cross-chain/solana/deploy/helpers/consts.ts @@ -41,5 +41,5 @@ export const WRAPPED_TBTC_MINT_MAINNET = "25rXTx9zDZcHyTav5sRqM6YBvTGu9pPH9yv83uAEqbgG" export const SOLANA_GATEWAY_ADDRESS_TESTNET = - "Gj93RRt6QB7FjmyokAD5rcMAku7pq3Fk2Aa8y6nNbwsV" + "87MEvHZCXE3ML5rrmh5uX1FbShHmRXXS32xJDGbQ7h5t" // export const SOLANA_GATEWAY_ADDRESS_MAINNET = "tbd" From 3c567812483c21bcb18882dc5b8451bebf003e28 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 11 Aug 2023 11:38:45 +0200 Subject: [PATCH 072/205] Smaller description improvements on authority transfer --- cross-chain/solana/scripts/transfer_authority.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cross-chain/solana/scripts/transfer_authority.sh b/cross-chain/solana/scripts/transfer_authority.sh index 703638816..df45a5605 100755 --- a/cross-chain/solana/scripts/transfer_authority.sh +++ b/cross-chain/solana/scripts/transfer_authority.sh @@ -9,8 +9,11 @@ source solana.env ## Transfer authority to the Threshold Council Multisig. (for mainnet only) # make transfer_authority -## Transfer upgrade authority to Threshold Council Multisig +## Transfer upgrade authority to Threshold Council Multisig for tbtc +# solana program set-upgrade-authority -k --new-upgrade-authority + +## Transfer upgrade authority to Threshold Council Multisig for wormhole_gateway # solana program set-upgrade-authority -k --new-upgrade-authority ## Threshold Council Multisig has to accept the ownership by executing -## `takeAuthority` instruction \ No newline at end of file +## `takeAuthority` instruction (most likely in Squads) \ No newline at end of file From c77c1ba24050cfe588b8db7b9d7bcc0239decb0f Mon Sep 17 00:00:00 2001 From: Dmitry Date: Fri, 11 Aug 2023 17:45:13 +0200 Subject: [PATCH 073/205] Updating a minting limit to max unsigned int 64 --- cross-chain/solana/deploy/init.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cross-chain/solana/deploy/init.ts b/cross-chain/solana/deploy/init.ts index bf5d3bc71..97ba91bca 100644 --- a/cross-chain/solana/deploy/init.ts +++ b/cross-chain/solana/deploy/init.ts @@ -66,7 +66,7 @@ async function run(): Promise { wormholeGatewayProgram.programId )[0] - const mintingLimit = 10000 // Arbitrary big number of TBTC + const mintingLimit = "18446744073709551615" // Max u64 let WRAPPED_TBTC = consts.WRAPPED_TBTC_MINT_TESTNET if (process.env.CLUSTER === "mainnet-beta") { WRAPPED_TBTC = consts.WRAPPED_TBTC_MINT_MAINNET From c2bdc924cd2b3583405aedda10377c18bc07fc04 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Sat, 12 Aug 2023 11:53:28 +0200 Subject: [PATCH 074/205] Minor updates in logs and description --- cross-chain/solana/.env.template | 2 +- cross-chain/solana/deploy/helpers/consts.ts | 9 ++--- cross-chain/solana/deploy/init.ts | 40 +++++++++++++++++++-- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/cross-chain/solana/.env.template b/cross-chain/solana/.env.template index 564120216..c39ee6ef5 100644 --- a/cross-chain/solana/.env.template +++ b/cross-chain/solana/.env.template @@ -1,6 +1,6 @@ export AUTHORITY= export THRESHOLD_COUNCIL_MULTISIG= export NETWORK= -export CLUSTER= +export CLUSTER= export ANCHOR_PROVIDER_URL= export ANCHOR_WALLET= \ No newline at end of file diff --git a/cross-chain/solana/deploy/helpers/consts.ts b/cross-chain/solana/deploy/helpers/consts.ts index a9a4f17d2..6a36dafe8 100644 --- a/cross-chain/solana/deploy/helpers/consts.ts +++ b/cross-chain/solana/deploy/helpers/consts.ts @@ -33,13 +33,14 @@ export const BASE_GATEWAY_ADDRESS_TESTNET = export const BASE_GATEWAY_ADDRESS_MAINNET = "00000000000000000000000009959798B95d00a3183d20FaC298E4594E599eab" +export const SOLANA_GATEWAY_ADDRESS_TESTNET = + "87MEvHZCXE3ML5rrmh5uX1FbShHmRXXS32xJDGbQ7h5t" +export const SOLANA_GATEWAY_ADDRESS_MAINNET = + "87MEvHZCXE3ML5rrmh5uX1FbShHmRXXS32xJDGbQ7h5t" + // deriveWrappedMintKey("DZnkkTmCiFWfYTfT41X3Rd1kDgozqzxWaHqsw6W4x2oe", 2, "0x679874fbe6d4e7cc54a59e315ff1eb266686a937") export const WRAPPED_TBTC_MINT_TESTNET = "FMYvcyMJJ22whB9m3T5g1oPKwM6jpLnFBXnrY6eXmCrp" // deriveWrappedMintKey("wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb", 2, "0x18084fbA666a33d37592fA2633fD49a74DD93a88") export const WRAPPED_TBTC_MINT_MAINNET = "25rXTx9zDZcHyTav5sRqM6YBvTGu9pPH9yv83uAEqbgG" - -export const SOLANA_GATEWAY_ADDRESS_TESTNET = - "87MEvHZCXE3ML5rrmh5uX1FbShHmRXXS32xJDGbQ7h5t" -// export const SOLANA_GATEWAY_ADDRESS_MAINNET = "tbd" diff --git a/cross-chain/solana/deploy/init.ts b/cross-chain/solana/deploy/init.ts index 97ba91bca..3a9d674eb 100644 --- a/cross-chain/solana/deploy/init.ts +++ b/cross-chain/solana/deploy/init.ts @@ -68,7 +68,7 @@ async function run(): Promise { const mintingLimit = "18446744073709551615" // Max u64 let WRAPPED_TBTC = consts.WRAPPED_TBTC_MINT_TESTNET - if (process.env.CLUSTER === "mainnet-beta") { + if (process.env.CLUSTER === "mainnet") { WRAPPED_TBTC = consts.WRAPPED_TBTC_MINT_MAINNET } const WRAPPED_TBTC_MINT = new PublicKey(WRAPPED_TBTC) @@ -83,6 +83,11 @@ async function run(): Promise { wormholeGatewayProgram.programId )[0] + // NOTE: It might happen on mainnet that tbtc won't be initialized if running this + // script in one shot. + // The simplest solution is just to wait a bit and then proceed with wormhole_gateway + // initializtion. + // Initialize wormhole gateway await wormholeGatewayProgram.methods .initialize(new anchor.BN(mintingLimit)) @@ -96,6 +101,8 @@ async function run(): Promise { }) .rpc() + console.log("Initialized wormhole gateway program..") + const minterInfo = PublicKey.findProgramAddressSync( [Buffer.from("minter-info"), minter.toBuffer()], tbtcProgram.programId @@ -113,18 +120,20 @@ async function run(): Promise { }) .rpc() + console.log("Added a minter..") + // Point to devnet addresses by default let ARBITRUM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_TESTNET let OPTIMISM_GATEWAY = consts.OPTIMISM_GATEWAY_ADDRESS_TESTNET let POLYGON_GATEWAY = consts.POLYGON_GATEWAY_ADDRESS_TESTNET let BASE_GATEWAY = consts.BASE_GATEWAY_ADDRESS_TESTNET let SOLANA_GATEWAY = consts.SOLANA_GATEWAY_ADDRESS_TESTNET - if (process.env.CLUSTER === "mainnet-beta") { + if (process.env.CLUSTER === "mainnet") { ARBITRUM_GATEWAY = consts.ARBITRUM_GATEWAY_ADDRESS_MAINNET OPTIMISM_GATEWAY = consts.OPTIMISM_GATEWAY_ADDRESS_MAINNET POLYGON_GATEWAY = consts.POLYGON_GATEWAY_ADDRESS_MAINNET BASE_GATEWAY = consts.BASE_GATEWAY_ADDRESS_MAINNET - // TODO: add SOLANA_GATEWAY_ADDRESS_MAINNET once it's deployed + SOLANA_GATEWAY = consts.SOLANA_GATEWAY_ADDRESS_MAINNET } // Updating with Arbitrum @@ -149,6 +158,11 @@ async function run(): Promise { }) .rpc() + console.log( + "Updated Solana gateway with Arbitrum..", + Array.from(new PublicKey(ARBITRUM_GATEWAY).toBuffer()) + ) + // Updating with Optimism const optiArgs = { chain: consts.WH_OPTIMISM_CHAIN_ID, @@ -171,6 +185,11 @@ async function run(): Promise { }) .rpc() + console.log( + "Updated Solana gateway with Optimism..", + Array.from(new PublicKey(OPTIMISM_GATEWAY).toBuffer()) + ) + // Updating with Polygon const polyArgs = { chain: consts.WH_POLYGON_CHAIN_ID, @@ -193,6 +212,11 @@ async function run(): Promise { }) .rpc() + console.log( + "Updated Solana gateway with Polygon..", + Array.from(new PublicKey(POLYGON_GATEWAY).toBuffer()) + ) + // Updating with BASE const baseArgs = { chain: consts.WH_BASE_CHAIN_ID, @@ -215,6 +239,11 @@ async function run(): Promise { }) .rpc() + console.log( + "Updated Solana gateway with Base..", + Array.from(Buffer.alloc(32, BASE_GATEWAY, "hex")) + ) + // Updating with self (SOLANA) const solanaArgs = { chain: consts.WH_SOLANA_CHAIN_ID, @@ -237,6 +266,11 @@ async function run(): Promise { }) .rpc() + console.log( + "Updated Solana gateway with self (Solana)..", + Array.from(new PublicKey(SOLANA_GATEWAY).toBuffer()) + ) + console.log("Done initializing programs!") } From a736dadc7e18c7ff61ba8421b04f32a4f3fd5671 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 14 Aug 2023 15:54:35 +0200 Subject: [PATCH 075/205] Updating with Solana mainnet address --- .../arbitrum/external/arbitrumOne/SolanaWormholeGateway.json | 2 +- cross-chain/base/external/base/SolanaWormholeGateway.json | 2 +- .../optimism/external/optimism/SolanaWormholeGateway.json | 2 +- cross-chain/polygon/external/polygon/SolanaWormholeGateway.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cross-chain/arbitrum/external/arbitrumOne/SolanaWormholeGateway.json b/cross-chain/arbitrum/external/arbitrumOne/SolanaWormholeGateway.json index 95e933073..dee25fa3e 100644 --- a/cross-chain/arbitrum/external/arbitrumOne/SolanaWormholeGateway.json +++ b/cross-chain/arbitrum/external/arbitrumOne/SolanaWormholeGateway.json @@ -1,3 +1,3 @@ { - "address": "tbd" + "address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" } diff --git a/cross-chain/base/external/base/SolanaWormholeGateway.json b/cross-chain/base/external/base/SolanaWormholeGateway.json index 95e933073..dee25fa3e 100644 --- a/cross-chain/base/external/base/SolanaWormholeGateway.json +++ b/cross-chain/base/external/base/SolanaWormholeGateway.json @@ -1,3 +1,3 @@ { - "address": "tbd" + "address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" } diff --git a/cross-chain/optimism/external/optimism/SolanaWormholeGateway.json b/cross-chain/optimism/external/optimism/SolanaWormholeGateway.json index 95e933073..dee25fa3e 100644 --- a/cross-chain/optimism/external/optimism/SolanaWormholeGateway.json +++ b/cross-chain/optimism/external/optimism/SolanaWormholeGateway.json @@ -1,3 +1,3 @@ { - "address": "tbd" + "address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" } diff --git a/cross-chain/polygon/external/polygon/SolanaWormholeGateway.json b/cross-chain/polygon/external/polygon/SolanaWormholeGateway.json index 95e933073..dee25fa3e 100644 --- a/cross-chain/polygon/external/polygon/SolanaWormholeGateway.json +++ b/cross-chain/polygon/external/polygon/SolanaWormholeGateway.json @@ -1,3 +1,3 @@ { - "address": "tbd" + "address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b" } From feb345b5cf7bd4affe636bd3fe691a7f066511f6 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 14 Aug 2023 16:08:01 +0200 Subject: [PATCH 076/205] Removing build and npm scripts because Makefile already covers these scripts --- cross-chain/solana/package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cross-chain/solana/package.json b/cross-chain/solana/package.json index 7e59b5895..af041dfc5 100644 --- a/cross-chain/solana/package.json +++ b/cross-chain/solana/package.json @@ -4,12 +4,10 @@ "description": "tBTC v2 on Solana", "license": "GPL-3.0-only", "scripts": { - "build": "anchor build", "format": "npm run lint", "format:fix": "npm run lint:fix", "lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w", - "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check", - "test": "anchor test" + "lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check" }, "dependencies": { "@coral-xyz/anchor": "^0.28.0" From d9a4e7c2e459501926111e699d321131f84f953b Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 14 Aug 2023 16:24:16 +0200 Subject: [PATCH 077/205] Adding SolanaWormholeGateway tag dependency for EVMs --- .../16_update_with_solana_in_wormhole_gateway_mapping.ts | 2 +- .../16_update_with_solana_in_wormhole_gateway_mapping.ts | 2 +- .../16_update_with_solana_in_wormhole_gateway_mapping.ts | 2 +- .../16_update_with_solana_in_wormhole_gateway_mapping.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cross-chain/arbitrum/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts b/cross-chain/arbitrum/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts index c8d15ccab..0f026846b 100644 --- a/cross-chain/arbitrum/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts +++ b/cross-chain/arbitrum/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts @@ -36,4 +36,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { export default func func.tags = ["SetSolanaGatewayAddress"] -func.dependencies = ["ArbitrumWormholeGateway"] +func.dependencies = ["ArbitrumWormholeGateway", "SolanaWormholeGateway"] diff --git a/cross-chain/base/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts b/cross-chain/base/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts index 338b1b070..8a2e06762 100644 --- a/cross-chain/base/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts +++ b/cross-chain/base/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts @@ -36,4 +36,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { export default func func.tags = ["SetSolanaGatewayAddress"] -func.dependencies = ["BaseWormholeGateway"] +func.dependencies = ["BaseWormholeGateway", "SolanaWormholeGateway"] diff --git a/cross-chain/optimism/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts b/cross-chain/optimism/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts index 487c70c0e..2d5c85dca 100644 --- a/cross-chain/optimism/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts +++ b/cross-chain/optimism/deploy_l2/16_update_with_solana_in_wormhole_gateway_mapping.ts @@ -36,4 +36,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { export default func func.tags = ["SetSolanaGatewayAddress"] -func.dependencies = ["OptimismWormholeGateway"] +func.dependencies = ["OptimismWormholeGateway", "SolanaWormholeGateway"] diff --git a/cross-chain/polygon/deploy_sidechain/16_update_with_solana_in_wormhole_gateway_mapping.ts b/cross-chain/polygon/deploy_sidechain/16_update_with_solana_in_wormhole_gateway_mapping.ts index ab950da84..1814f79c4 100644 --- a/cross-chain/polygon/deploy_sidechain/16_update_with_solana_in_wormhole_gateway_mapping.ts +++ b/cross-chain/polygon/deploy_sidechain/16_update_with_solana_in_wormhole_gateway_mapping.ts @@ -36,4 +36,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { export default func func.tags = ["SetSolanaGatewayAddress"] -func.dependencies = ["PolygonWormholeGateway"] +func.dependencies = ["PolygonWormholeGateway", "SolanaWormholeGateway"] From d3fc84b6b99b590fdd043ef08278754c87d4c447 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 5 Sep 2023 13:52:22 +0200 Subject: [PATCH 078/205] Delaying reveal process It happens that a reveal process starts when a deposit is not captured by the Bitcoin chain because it's out of sync. A delay is added to wait for a chain to sync. --- system-tests/test/minting-unminting.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/system-tests/test/minting-unminting.test.ts b/system-tests/test/minting-unminting.test.ts index 3328fda52..bb6776add 100644 --- a/system-tests/test/minting-unminting.test.ts +++ b/system-tests/test/minting-unminting.test.ts @@ -153,6 +153,12 @@ describe("System Test - Minting and unminting", () => { - Output index: ${depositUtxo.outputIndex} `) + // It happens from time to time that a deposit reveal process starts when + // a deposit is not captured by the Bitcoin chain yet and a deposit is + // revealed with a non-existing Bitcoin tx. We should wait some time so + // the Bitcoin chain is in sync and then start the revealing process. + await new Promise((r) => setTimeout(r, 3000)) + // Since the reveal deposit logic does not perform SPV proof, we // can reveal the deposit transaction immediately without waiting // for confirmations. From e022bdc38f7ecbbdd8cbb0403c1ed1cf7e996f7b Mon Sep 17 00:00:00 2001 From: Rafal Czajkowski Date: Wed, 6 Sep 2023 16:01:07 +0200 Subject: [PATCH 079/205] Get rid of `bcrypto` dependency We use `bcrypto` to compute hashes, but since this library is a bit problematic, here we replace it with hashing algorithms from the `ethers` library. `ethers` has no `hash160` algorithm but under the hood `HASH160 = RIPEMD160(SHA256(X))` so it's possible to compute `hash160` using `ethers`. --- typescript/package.json | 1 - typescript/src/bitcoin.ts | 16 ++++++++++------ typescript/src/electrum.ts | 8 +++++--- typescript/typings.d.ts | 2 -- typescript/yarn.lock | 2 +- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index b1be0c883..936b81f28 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -28,7 +28,6 @@ "@keep-network/ecdsa": "development", "@keep-network/tbtc-v2": "development", "bcoin": "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8", - "bcrypto": "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0", "bufio": "^1.0.6", "electrum-client-js": "git+https://github.com/keep-network/electrum-client-js.git#v0.1.1", "ethers": "^5.5.2", diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index a46a4792b..88284dcad 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -1,9 +1,7 @@ import bcoin, { TX, Script } from "bcoin" import wif from "wif" import bufio from "bufio" -import hash160 from "bcrypto/lib/hash160" -import sha256 from "bcrypto/lib/sha256-browser.js" -import { BigNumber } from "ethers" +import { BigNumber, utils } from "ethers" import { Hex } from "./hex" import { BitcoinNetwork, toBcoinNetwork } from "./bitcoin-network" @@ -525,7 +523,12 @@ export function createKeyRing( * @returns Hash as a 20-byte un-prefixed hex string. */ export function computeHash160(text: string): string { - return hash160.digest(Buffer.from(text, "hex")).toString("hex") + const sha256Hash = utils.sha256( + Hex.from(Buffer.from(text, "hex")).toPrefixedString() + ) + const hash160 = utils.ripemd160(sha256Hash) + + return Hex.from(hash160).toString() } /** @@ -534,8 +537,9 @@ export function computeHash160(text: string): string { * @returns Hash as a 32-byte un-prefixed hex string. */ export function computeHash256(text: Hex): Hex { - const firstHash: Buffer = sha256.digest(text.toBuffer()) - const secondHash: Buffer = sha256.digest(firstHash) + const firstHash = utils.sha256(text.toPrefixedString()) + const secondHash = utils.sha256(firstHash) + return Hex.from(secondHash) } diff --git a/typescript/src/electrum.ts b/typescript/src/electrum.ts index 022ccce2a..e942aac3b 100644 --- a/typescript/src/electrum.ts +++ b/typescript/src/electrum.ts @@ -13,8 +13,7 @@ import { } from "./bitcoin" import { BitcoinNetwork } from "./bitcoin-network" import Electrum from "electrum-client-js" -import sha256 from "bcrypto/lib/sha256-browser.js" -import { BigNumber } from "ethers" +import { BigNumber, utils } from "ethers" import { URL } from "url" import { Hex } from "./hex" import { backoffRetrier, RetrierFn } from "./backoff" @@ -557,5 +556,8 @@ export class Client implements BitcoinClient { * @returns Electrum script hash as a hex string. */ function computeScriptHash(script: string): string { - return sha256.digest(Buffer.from(script, "hex")).reverse().toString("hex") + const _script = Hex.from(Buffer.from(script, "hex")).toPrefixedString() + const hash256 = utils.sha256(_script) + + return Hex.from(hash256).reverse().toString() } diff --git a/typescript/typings.d.ts b/typescript/typings.d.ts index 7517bbb08..2558e6a79 100644 --- a/typescript/typings.d.ts +++ b/typescript/typings.d.ts @@ -3,8 +3,6 @@ * don't provide their own typings. */ declare module "bcoin" -declare module "bcrypto/lib/hash160" -declare module "bcrypto/lib/sha256-browser.js" declare module "bufio" declare module "electrum-client-js" declare module "wif" diff --git a/typescript/yarn.lock b/typescript/yarn.lock index 561d0069a..d305c9069 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -1522,7 +1522,7 @@ "@openzeppelin/upgrades" "^2.7.2" openzeppelin-solidity "2.4.0" -"@keep-network/keep-ecdsa@1.9.0-dev.1", "@keep-network/keep-ecdsa@>1.9.0-dev <1.9.0-ropsten": +"@keep-network/keep-ecdsa@>1.9.0-dev <1.9.0-ropsten": version "1.9.0-dev.1" resolved "https://registry.yarnpkg.com/@keep-network/keep-ecdsa/-/keep-ecdsa-1.9.0-dev.1.tgz#7522b47dd639ddd7479a0e71dc328a9e0bba7cae" integrity sha512-FRIDejTUiQO7c9gBXgjtTp2sXkEQKFBBqVjYoZE20OCGRxbgum9FbgD/B5RWIctBy4GGr5wJHnA1789iaK3X6A== From bbfa3c6382412db545f86b8bc63055a11ba1831f Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 15 Sep 2023 16:05:19 +0200 Subject: [PATCH 080/205] Added bitcoinjs-lib in version 6.0.2 --- typescript/package.json | 1 + typescript/yarn.lock | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index b1be0c883..f4b6de321 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -29,6 +29,7 @@ "@keep-network/tbtc-v2": "development", "bcoin": "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8", "bcrypto": "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0", + "bitcoinjs-lib": "6.0.2", "bufio": "^1.0.6", "electrum-client-js": "git+https://github.com/keep-network/electrum-client-js.git#v0.1.1", "ethers": "^5.5.2", diff --git a/typescript/yarn.lock b/typescript/yarn.lock index 561d0069a..f2778ae49 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -1522,7 +1522,7 @@ "@openzeppelin/upgrades" "^2.7.2" openzeppelin-solidity "2.4.0" -"@keep-network/keep-ecdsa@1.9.0-dev.1", "@keep-network/keep-ecdsa@>1.9.0-dev <1.9.0-ropsten": +"@keep-network/keep-ecdsa@>1.9.0-dev <1.9.0-ropsten": version "1.9.0-dev.1" resolved "https://registry.yarnpkg.com/@keep-network/keep-ecdsa/-/keep-ecdsa-1.9.0-dev.1.tgz#7522b47dd639ddd7479a0e71dc328a9e0bba7cae" integrity sha512-FRIDejTUiQO7c9gBXgjtTp2sXkEQKFBBqVjYoZE20OCGRxbgum9FbgD/B5RWIctBy4GGr5wJHnA1789iaK3X6A== @@ -2575,6 +2575,11 @@ bech32@1.1.4: resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== +bech32@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355" + integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg== + "bevent@git+https://github.com/bcoin-org/bevent.git#semver:~0.1.5": version "0.1.5" resolved "git+https://github.com/bcoin-org/bevent.git#60fb503de3ea1292d29ce438bfba80f0bc5ccb60" @@ -2639,6 +2644,11 @@ bindings@^1.3.0: bs32 "~0.1.5" bsert "~0.0.10" +bip174@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/bip174/-/bip174-2.1.1.tgz#ef3e968cf76de234a546962bcf572cc150982f9f" + integrity sha512-mdFV5+/v0XyNYXjBS6CQPLo9ekCx4gtKZFnJm5PMto7Fs9hTTDpkkzOB7/FtluRI6JbUUAu+snTYfJRgHLZbZQ== + bip32@2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/bip32/-/bip32-2.0.5.tgz#e3808a9e97a880dbafd0f5f09ca4a1e14ee275d2" @@ -2681,6 +2691,20 @@ bip39@3.0.4: pbkdf2 "^3.0.9" randombytes "^2.0.1" +bitcoinjs-lib@6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.0.2.tgz#0fdf6c41978d93641b936d66f4afce44bb9b7f35" + integrity sha512-I994pGt9cL5s5OA6mkv1e8IuYcsKN2ORXnWbkqAXLNGvEnOHBhKBSvCjFl7YC2uVoJnfr/iwq7JMrq575SYO5w== + dependencies: + bech32 "^2.0.0" + bip174 "^2.0.1" + bs58check "^2.1.2" + create-hash "^1.1.0" + ripemd160 "^2.0.2" + typeforce "^1.11.3" + varuint-bitcoin "^1.1.2" + wif "^2.0.1" + bl@^1.0.0: version "1.2.3" resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.3.tgz#1e8dd80142eac80d7158c9dccc047fb620e035e7" @@ -6902,7 +6926,7 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -ripemd160@^2.0.0, ripemd160@^2.0.1: +ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== @@ -7746,7 +7770,7 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typeforce@^1.11.5: +typeforce@^1.11.3, typeforce@^1.11.5: version "1.18.0" resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc" integrity sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g== @@ -7932,6 +7956,13 @@ varint@^5.0.0: resolved "https://registry.yarnpkg.com/varint/-/varint-5.0.2.tgz#5b47f8a947eb668b848e034dcfa87d0ff8a7f7a4" integrity sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow== +varuint-bitcoin@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/varuint-bitcoin/-/varuint-bitcoin-1.1.2.tgz#e76c138249d06138b480d4c5b40ef53693e24e92" + integrity sha512-4EVb+w4rx+YfVM32HQX42AbbT7/1f5zwAYhIujKXKk8NQK+JfRVl3pqT3hjNn/L+RstigmGGKVwHA/P0wgITZw== + dependencies: + safe-buffer "^5.1.1" + vary@^1, vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" @@ -8770,7 +8801,7 @@ wide-align@1.1.3: dependencies: string-width "^1.0.2 || 2" -wif@2.0.6, wif@^2.0.6: +wif@2.0.6, wif@^2.0.1, wif@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/wif/-/wif-2.0.6.tgz#08d3f52056c66679299726fade0d432ae74b4704" integrity sha1-CNP1IFbGZnkplyb63g1DKudLRwQ= From b9f8ce418892a72ffb536c7035631b9cdf31670f Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 18 Sep 2023 11:01:16 +0200 Subject: [PATCH 081/205] Build deposit script using bitcoinjs-lib --- typescript/src/deposit.ts | 55 ++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index a441346ab..59d8606ec 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -1,5 +1,6 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" +import { Stack, script, opcodes } from "bitcoinjs-lib" import { Client as BitcoinClient, decomposeRawTransaction, @@ -13,8 +14,6 @@ import { BitcoinNetwork, toBcoinNetwork } from "./bitcoin-network" import { Bridge, Event, Identifier } from "./chain" import { Hex } from "./hex" -const { opcodes } = bcoin.script.common - // TODO: Replace all properties that are expected to be un-prefixed hexadecimal // strings with a Hex type. @@ -244,33 +243,31 @@ export async function assembleDepositScript( ): Promise { validateDepositScriptParameters(deposit) - // All HEXes pushed to the script must be un-prefixed. - const script = new bcoin.Script() - script.clear() - script.pushData(Buffer.from(deposit.depositor.identifierHex, "hex")) - script.pushOp(opcodes.OP_DROP) - script.pushData(Buffer.from(deposit.blindingFactor, "hex")) - script.pushOp(opcodes.OP_DROP) - script.pushOp(opcodes.OP_DUP) - script.pushOp(opcodes.OP_HASH160) - script.pushData(Buffer.from(deposit.walletPublicKeyHash, "hex")) - script.pushOp(opcodes.OP_EQUAL) - script.pushOp(opcodes.OP_IF) - script.pushOp(opcodes.OP_CHECKSIG) - script.pushOp(opcodes.OP_ELSE) - script.pushOp(opcodes.OP_DUP) - script.pushOp(opcodes.OP_HASH160) - script.pushData(Buffer.from(deposit.refundPublicKeyHash, "hex")) - script.pushOp(opcodes.OP_EQUALVERIFY) - script.pushData(Buffer.from(deposit.refundLocktime, "hex")) - script.pushOp(opcodes.OP_CHECKLOCKTIMEVERIFY) - script.pushOp(opcodes.OP_DROP) - script.pushOp(opcodes.OP_CHECKSIG) - script.pushOp(opcodes.OP_ENDIF) - script.compile() - - // Return script as HEX string. - return script.toRaw().toString("hex") + const chunks: Stack = [] + + // All HEXes pushed to the script must be un-prefixed + chunks.push(Buffer.from(deposit.depositor.identifierHex, "hex")) + chunks.push(opcodes.OP_DROP) + chunks.push(Buffer.from(deposit.blindingFactor, "hex")) + chunks.push(opcodes.OP_DROP) + chunks.push(opcodes.OP_DUP) + chunks.push(opcodes.OP_HASH160) + chunks.push(Buffer.from(deposit.walletPublicKeyHash, "hex")) + chunks.push(opcodes.OP_EQUAL) + chunks.push(opcodes.OP_IF) + chunks.push(opcodes.OP_CHECKSIG) + chunks.push(opcodes.OP_ELSE) + chunks.push(opcodes.OP_DUP) + chunks.push(opcodes.OP_HASH160) + chunks.push(Buffer.from(deposit.refundPublicKeyHash, "hex")) + chunks.push(opcodes.OP_EQUALVERIFY) + chunks.push(Buffer.from(deposit.refundLocktime, "hex")) + chunks.push(opcodes.OP_CHECKLOCKTIMEVERIFY) + chunks.push(opcodes.OP_DROP) + chunks.push(opcodes.OP_CHECKSIG) + chunks.push(opcodes.OP_ENDIF) + + return script.compile(chunks).toString("hex") } // eslint-disable-next-line valid-jsdoc From 85567ff506cbb5c94c7efba8d518cb22c2460930 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 18 Sep 2023 11:43:28 +0200 Subject: [PATCH 082/205] Added functionalities for checking input type --- typescript/src/bitcoin.ts | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index a46a4792b..7c6bd59c4 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -6,6 +6,7 @@ import sha256 from "bcrypto/lib/sha256-browser.js" import { BigNumber } from "ethers" import { Hex } from "./hex" import { BitcoinNetwork, toBcoinNetwork } from "./bitcoin-network" +import { payments } from "bitcoinjs-lib" /** * Represents a transaction hash (or transaction ID) as an un-prefixed hex @@ -679,3 +680,59 @@ export function readCompactSizeUint(varLenData: Hex): { } } } + +/** + * Checks if the provided script comes from a P2PKH input. + * @param script The script to be checked. + * @returns True if the script is P2PKH, false otherwise. + */ +export function isP2PKH(script: Buffer): boolean { + try { + payments.p2pkh({ output: script }); + return true; + } catch (err) { + return false; + } +} + +/** + * Checks if the provided script comes from a P2WPKH input. + * @param script The script to be checked. + * @returns True if the script is P2WPKH, false otherwise. + */ +export function isP2WPKH(script: Buffer): boolean { + try { + payments.p2wpkh({ output: script }); + return true; + } catch (err) { + return false; + } +} + +/** + * Checks if the provided script comes from a P2SH input. + * @param script The script to be checked. + * @returns True if the script is P2SH, false otherwise. + */ +export function isP2SH(script: Buffer): boolean { + try { + payments.p2sh({ output: script }); + return true; + } catch (err) { + return false; + } +} + +/** + * Checks if the provided script comes from a P2PKH input. + * @param script The script to be checked. + * @returns True if the script is P2WSH, false otherwise. + */ +export function isP2WSH(script: Buffer): boolean { + try { + payments.p2wsh({ output: script }); + return true; + } catch (err) { + return false; + } +} From f0c5dc2161836391e640c5f66a9e7b8c8fe39e3b Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 18 Sep 2023 12:21:39 +0200 Subject: [PATCH 083/205] Added basic structure for assembling deposit sweep transaction --- typescript/src/bitcoin.ts | 24 ++--- typescript/src/deposit-sweep.ts | 176 ++++++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+), 12 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 7c6bd59c4..473dc61ad 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -688,10 +688,10 @@ export function readCompactSizeUint(varLenData: Hex): { */ export function isP2PKH(script: Buffer): boolean { try { - payments.p2pkh({ output: script }); - return true; + payments.p2pkh({ output: script }) + return true } catch (err) { - return false; + return false } } @@ -702,10 +702,10 @@ export function isP2PKH(script: Buffer): boolean { */ export function isP2WPKH(script: Buffer): boolean { try { - payments.p2wpkh({ output: script }); - return true; + payments.p2wpkh({ output: script }) + return true } catch (err) { - return false; + return false } } @@ -716,10 +716,10 @@ export function isP2WPKH(script: Buffer): boolean { */ export function isP2SH(script: Buffer): boolean { try { - payments.p2sh({ output: script }); - return true; + payments.p2sh({ output: script }) + return true } catch (err) { - return false; + return false } } @@ -730,9 +730,9 @@ export function isP2SH(script: Buffer): boolean { */ export function isP2WSH(script: Buffer): boolean { try { - payments.p2wsh({ output: script }); - return true; + payments.p2wsh({ output: script }) + return true } catch (err) { - return false; + return false } } diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 36f3eb4e4..fbc38f54c 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,4 +1,5 @@ import bcoin from "bcoin" +import { Transaction, address } from "bitcoinjs-lib" import { BigNumber } from "ethers" import { RawTransaction, @@ -9,6 +10,10 @@ import { createKeyRing, TransactionHash, computeHash160, + isP2PKH, + isP2WPKH, + isP2SH, + isP2WSH, } from "./bitcoin" import { assembleDepositScript, Deposit } from "./deposit" import { Bridge, Identifier } from "./chain" @@ -235,6 +240,149 @@ export async function assembleDepositSweepTransaction( } } +/** + * Assembles a Bitcoin P2WPKH deposit sweep transaction. + * @dev The caller is responsible for ensuring the provided UTXOs are correctly + * formed, can be spent by the wallet and their combined value is greater + * then the fee. + * @param fee - the value that should be subtracted from the sum of the UTXOs + * values and used as the transaction fee. + * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. + * @param witness - The parameter used to decide about the type of the new main + * UTXO output. P2WPKH if `true`, P2PKH if `false`. + * @param utxos - UTXOs from new deposit transactions. Must be P2(W)SH. + * @param deposits - Array of deposits. Each element corresponds to UTXO. + * The number of UTXOs and deposit elements must equal. + * @param mainUtxo - main UTXO of the wallet, which is a P2WKH UTXO resulting + * from the previous wallet transaction (optional). + * @returns The outcome consisting of: + * - the sweep transaction hash, + * - the new wallet's main UTXO produced by this transaction. + * - the sweep transaction in the raw format + */ +// TODO: Rename once it's finished. +export async function assembleDepositSweepTransactionBitcoinJsLib( + fee: BigNumber, + walletPrivateKey: string, + witness: boolean, + utxos: (UnspentTransactionOutput & RawTransaction)[], + deposits: Deposit[], + mainUtxo?: UnspentTransactionOutput & RawTransaction +): Promise<{ + transactionHash: TransactionHash + newMainUtxo: UnspentTransactionOutput + rawTransaction: RawTransaction +}> { + if (utxos.length < 1) { + throw new Error("There must be at least one deposit UTXO to sweep") + } + + if (utxos.length != deposits.length) { + throw new Error("Number of UTXOs must equal the number of deposit elements") + } + + // TODO: Replace keyring with bitcoinjs-lib functionalities for managing + // keys (ecpair). + const walletKeyRing = createKeyRing(walletPrivateKey, witness) + const walletAddress = walletKeyRing.getAddress("string") + + const transaction = new Transaction() + let totalInputValue = BigNumber.from(0) + + if (mainUtxo) { + const prevTx = Transaction.fromHex(mainUtxo.transactionHex) + const scriptSig = prevTx.outs[mainUtxo.outputIndex].script + transaction.addInput( + mainUtxo.transactionHash.toBuffer(), + mainUtxo.outputIndex, + undefined, + scriptSig + ) + totalInputValue = totalInputValue.add(mainUtxo.value) + } + + for (const utxo of utxos) { + const prevTx = Transaction.fromHex(utxo.transactionHex) + const scriptSig = prevTx.outs[utxo.outputIndex].script + transaction.addInput( + utxo.transactionHash.toBuffer(), + utxo.outputIndex, + undefined, + scriptSig + ) + totalInputValue = totalInputValue.add(utxo.value) + } + + // TODO: Verify that output script is properly created from both testnet + // and mainnet addresses. + const scriptPubKey = address.toOutputScript(walletAddress) + transaction.addOutput(scriptPubKey, totalInputValue.toNumber()) + + // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any + // order + const utxosWithDeposits: (UnspentTransactionOutput & + RawTransaction & + Deposit)[] = utxos.map((utxo, index) => ({ + ...utxo, + ...deposits[index], + })) + + for (let i = 0; i < transaction.ins.length; i++) { + // P2(W)PKH (main UTXO) + if ( + isP2PKH(transaction.ins[i].script) || + isP2WPKH(transaction.ins[i].script) + ) { + signMainUtxoInputBitcoinJsLib(transaction, i, walletKeyRing) + continue + } + + const utxoWithDeposit = utxosWithDeposits.find( + (u) => + u.transactionHash.toString() === + transaction.ins[i].hash.toString("hex") && + u.outputIndex == transaction.ins[i].index + ) + if (!utxoWithDeposit) { + throw new Error("Unknown input") + } + + if (isP2SH(transaction.ins[i].script)) { + // P2SH (deposit UTXO) + signP2SHDepositInputBitcoinJsLib( + transaction, + i, + utxoWithDeposit, + walletKeyRing + ) + } else if (isP2WSH(transaction.ins[i].script)) { + // P2WSH (deposit UTXO) + signP2WSHDepositInputBitcoinJsLib( + transaction, + i, + utxoWithDeposit, + walletKeyRing + ) + } else { + throw new Error("Unsupported UTXO script type") + } + } + + const transactionHash = TransactionHash.from(transaction.getId()) + + return { + transactionHash, + newMainUtxo: { + transactionHash, + outputIndex: 0, // There is only one output. + value: BigNumber.from(transaction.outs[0].value), + }, + rawTransaction: { + transactionHex: transaction.toHex(), + }, + } +} + /** * Creates script for the transaction input at the given index and signs the * input. @@ -332,6 +480,34 @@ async function signP2WSHDepositInput( transaction.inputs[inputIndex].witness = witness } +async function signMainUtxoInputBitcoinJsLib( + transaction: any, + inputIndex: number, + walletKeyRing: any +) { + // TODO: Implement +} + +// TODO: Rename once the function is implemented. +async function signP2SHDepositInputBitcoinJsLib( + transaction: Transaction, + inputIndex: number, + deposit: Deposit, + walletKeyRing: any +) { + // TODO: Implement +} + +// TODO: Rename once the function is implemented. +async function signP2WSHDepositInputBitcoinJsLib( + transaction: Transaction, + inputIndex: number, + deposit: Deposit, + walletKeyRing: any +) { + // TODO: Implement +} + /** * Creates data needed to sign a deposit input. * @param transaction - Mutable transaction containing the input. From 450579a00d25b1fe8b318dcf4dff25c5063e45fd Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 18 Sep 2023 14:43:39 +0200 Subject: [PATCH 084/205] Added ecpair for handling keys --- typescript/package.json | 2 ++ typescript/src/deposit-sweep.ts | 58 +++++++++++++++++++++++++++++---- typescript/yarn.lock | 23 ++++++++++++- 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index f4b6de321..0812c3261 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -31,9 +31,11 @@ "bcrypto": "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0", "bitcoinjs-lib": "6.0.2", "bufio": "^1.0.6", + "ecpair": "^2.1.0", "electrum-client-js": "git+https://github.com/keep-network/electrum-client-js.git#v0.1.1", "ethers": "^5.5.2", "p-timeout": "^4.1.0", + "tiny-secp256k1": "^2.2.3", "wif": "2.0.6" }, "devDependencies": { diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index fbc38f54c..8b7297a6a 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,5 +1,5 @@ import bcoin from "bcoin" -import { Transaction, address } from "bitcoinjs-lib" +import { Transaction, address, networks } from "bitcoinjs-lib" import { BigNumber } from "ethers" import { RawTransaction, @@ -18,6 +18,8 @@ import { import { assembleDepositScript, Deposit } from "./deposit" import { Bridge, Identifier } from "./chain" import { assembleTransactionProof } from "./proof" +import { ECPairFactory, ECPairInterface } from "ecpair" +import * as tinysecp from "tiny-secp256k1" /** * Submits a deposit sweep by combining all the provided P2(W)SH UTXOs and @@ -286,6 +288,10 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( const walletKeyRing = createKeyRing(walletPrivateKey, witness) const walletAddress = walletKeyRing.getAddress("string") + const ecPairApi = ECPairFactory(tinysecp); + // TODO: Pass appropriate network type (testnet vs mainnet). + const ecPair = ecPairApi.fromWIF(walletPrivateKey, networks.testnet) + const transaction = new Transaction() let totalInputValue = BigNumber.from(0) @@ -302,6 +308,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( } for (const utxo of utxos) { + // TODO: Validate that the utxo's value is the same as the value in deposit const prevTx = Transaction.fromHex(utxo.transactionHex) const scriptSig = prevTx.outs[utxo.outputIndex].script transaction.addInput( @@ -313,6 +320,9 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( totalInputValue = totalInputValue.add(utxo.value) } + // Subtract fee from the output + totalInputValue = totalInputValue.sub(fee) + // TODO: Verify that output script is properly created from both testnet // and mainnet addresses. const scriptPubKey = address.toOutputScript(walletAddress) @@ -333,7 +343,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( isP2PKH(transaction.ins[i].script) || isP2WPKH(transaction.ins[i].script) ) { - signMainUtxoInputBitcoinJsLib(transaction, i, walletKeyRing) + signMainUtxoInputBitcoinJsLib(transaction, i, ecPair) continue } @@ -353,7 +363,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( transaction, i, utxoWithDeposit, - walletKeyRing + ecPair ) } else if (isP2WSH(transaction.ins[i].script)) { // P2WSH (deposit UTXO) @@ -361,7 +371,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( transaction, i, utxoWithDeposit, - walletKeyRing + ecPair ) } else { throw new Error("Unsupported UTXO script type") @@ -483,7 +493,7 @@ async function signP2WSHDepositInput( async function signMainUtxoInputBitcoinJsLib( transaction: any, inputIndex: number, - walletKeyRing: any + ecPair: ECPairInterface ) { // TODO: Implement } @@ -493,7 +503,7 @@ async function signP2SHDepositInputBitcoinJsLib( transaction: Transaction, inputIndex: number, deposit: Deposit, - walletKeyRing: any + ecPair: ECPairInterface ) { // TODO: Implement } @@ -508,6 +518,42 @@ async function signP2WSHDepositInputBitcoinJsLib( // TODO: Implement } +async function prepareInputSignDataBitcoinIsLib( + deposit: Deposit, + ecPair: ECPairInterface +): Promise<{ + walletPublicKey: string + depositScript: any + previousOutputValue: number +}> { + const walletPublicKey = ecPair.publicKey.toString("hex") + + if ( + computeHash160(walletPublicKey) != deposit.walletPublicKeyHash + ) { + throw new Error( + "Wallet public key does not correspond to wallet private key" + ) + } + + if (!isCompressedPublicKey(walletPublicKey)) { + throw new Error("Wallet public key must be compressed") + } + + // eslint-disable-next-line no-unused-vars + const { amount, vault, ...depositScriptParameters } = deposit + + const depositScript = Buffer.from( + await assembleDepositScript(depositScriptParameters) + ) + + return { + walletPublicKey, + depositScript: depositScript, + previousOutputValue: deposit.amount.toNumber(), + } +} + /** * Creates data needed to sign a deposit input. * @param transaction - Mutable transaction containing the input. diff --git a/typescript/yarn.lock b/typescript/yarn.lock index f2778ae49..05897068f 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -3762,6 +3762,15 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" +ecpair@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/ecpair/-/ecpair-2.1.0.tgz#673f826b1d80d5eb091b8e2010c6b588e8d2cb45" + integrity sha512-cL/mh3MtJutFOvFc27GPZE2pWL3a3k4YvzUWEOvilnfZVlH3Jwgx/7d6tlD7/75tNk8TG2m+7Kgtz0SI1tWcqw== + dependencies: + randombytes "^2.1.0" + typeforce "^1.18.0" + wif "^2.0.6" + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -7570,6 +7579,13 @@ tiny-secp256k1@^1.1.3: elliptic "^6.4.0" nan "^2.13.2" +tiny-secp256k1@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/tiny-secp256k1/-/tiny-secp256k1-2.2.3.tgz#fe1dde11a64fcee2091157d4b78bcb300feb9b65" + integrity sha512-SGcL07SxcPN2nGKHTCvRMkQLYPSoeFcvArUSCYtjVARiFAWU44cCIqYS0mYAU6nY7XfvwURuTIGo2Omt3ZQr0Q== + dependencies: + uint8array-tools "0.0.7" + tmp@0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -7770,7 +7786,7 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typeforce@^1.11.3, typeforce@^1.11.5: +typeforce@^1.11.3, typeforce@^1.11.5, typeforce@^1.18.0: version "1.18.0" resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc" integrity sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g== @@ -7795,6 +7811,11 @@ typical@^5.2.0: resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066" integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg== +uint8array-tools@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/uint8array-tools/-/uint8array-tools-0.0.7.tgz#a7a2bb5d8836eae2fade68c771454e6a438b390d" + integrity sha512-vrrNZJiusLWoFWBqz5Y5KMCgP9W9hnjZHzZiZRT8oNAkq3d5Z5Oe76jAvVVSRh4U8GGR90N2X1dWtrhvx6L8UQ== + ultron@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" From 85c1a4564c3ffd1113f57c705c012fa08e0b8b8a Mon Sep 17 00:00:00 2001 From: michalsmiarowski Date: Tue, 19 Sep 2023 11:02:52 +0200 Subject: [PATCH 085/205] Add basic tests to compute hashes functions Adds basic tests to `computeHash160`, `computeHash256` and `computeScriptHash` functions so that we are sure they are working exactly the same as when we used `bcrypto` library inside them. --- typescript/src/electrum.ts | 2 +- typescript/test/bitcoin.test.ts | 27 +++++++++++++++++++++++++++ typescript/test/electrum.test.ts | 11 +++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/typescript/src/electrum.ts b/typescript/src/electrum.ts index e942aac3b..70d47d256 100644 --- a/typescript/src/electrum.ts +++ b/typescript/src/electrum.ts @@ -555,7 +555,7 @@ export class Client implements BitcoinClient { * @param script - Bitcoin script as hex string * @returns Electrum script hash as a hex string. */ -function computeScriptHash(script: string): string { +export function computeScriptHash(script: string): string { const _script = Hex.from(Buffer.from(script, "hex")).toPrefixedString() const hash256 = utils.sha256(_script) diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 748e39004..80eebfda5 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -14,6 +14,8 @@ import { createOutputScriptFromAddress, createAddressFromOutputScript, readCompactSizeUint, + computeHash160, + computeHash256, } from "../src/bitcoin" import { calculateDepositRefundLocktime } from "../src/deposit" import { BitcoinNetwork } from "../src/bitcoin-network" @@ -66,6 +68,31 @@ describe("Bitcoin", () => { }) }) + describe("computeHash160", () => { + it("should compute hash160 correctly", () => { + const compressedPublicKey = + "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + const expectedHash160 = "3e1dfbd72483fb3964ca828ee71cf3270cafdc65" + + expect(computeHash160(compressedPublicKey)).to.be.equal(expectedHash160) + }) + }) + + describe("computeHash256", () => { + it("should compute hash256 correctly", () => { + const hexValue = Hex.from( + "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + ) + const expectedHash256 = Hex.from( + "9f0b7447ca6ea11b8badd8a60a4dec1b846451551ef455975b1720f52bc90546" + ) + + expect(computeHash256(hexValue).toString()).to.be.equal( + expectedHash256.toString() + ) + }) + }) + describe("P2PKH <-> public key hash conversion", () => { const publicKeyHash = "3a38d44d6a0c8d0bb84e0232cc632b7e48c72e0e" const P2WPKHAddress = "bc1q8gudgnt2pjxshwzwqgevccet0eyvwtswt03nuy" diff --git a/typescript/test/electrum.test.ts b/typescript/test/electrum.test.ts index 09fca2c2d..e0ad8909b 100644 --- a/typescript/test/electrum.test.ts +++ b/typescript/test/electrum.test.ts @@ -1,6 +1,7 @@ import { Credentials as ElectrumCredentials, Client as ElectrumClient, + computeScriptHash, } from "../src/electrum" import { BitcoinNetwork } from "../src/bitcoin-network" import { @@ -217,6 +218,16 @@ describe("Electrum", () => { expect(result).to.be.eql(testnetTransactionMerkleBranch) }) }) + + describe("computeScriptHash", () => { + it("should convert Bitcoin script to an Electrum script hash correctly", () => { + const script = "00144b47c798d12edd17dfb4ea98e5447926f664731c" + const expectedScriptHash = + "cabdea0bfc10fb3521721dde503487dd1f0e41dd6609da228066757563f292ab" + + expect(computeScriptHash(script)).to.be.equal(expectedScriptHash) + }) + }) }) }) From 53a4bbb84a384078c158ade5187f0bedf86d86dc Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 19 Sep 2023 19:52:56 +0200 Subject: [PATCH 086/205] Added signing of P2SH and P2WSH inputs --- typescript/src/deposit-sweep.ts | 127 ++++++++++++++++++++++++-------- 1 file changed, 95 insertions(+), 32 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 8b7297a6a..fec293b32 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,5 +1,5 @@ import bcoin from "bcoin" -import { Transaction, address, networks } from "bitcoinjs-lib" +import { Transaction, Stack, address, script, networks } from "bitcoinjs-lib" import { BigNumber } from "ethers" import { RawTransaction, @@ -292,39 +292,38 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( // TODO: Pass appropriate network type (testnet vs mainnet). const ecPair = ecPairApi.fromWIF(walletPrivateKey, networks.testnet) - const transaction = new Transaction() + // Calculate the value of transaction's output. Note that the value of fee + // needs to be subtracted from the sum. let totalInputValue = BigNumber.from(0) + if (mainUtxo) { + totalInputValue = totalInputValue.add(mainUtxo.value) + } + for (const utxo of utxos) { + totalInputValue = totalInputValue.add(utxo.value) + } + totalInputValue = totalInputValue.sub(fee) + + // Create the transaction. + const transaction = new Transaction() + // Add the transaction's inputs. if (mainUtxo) { - const prevTx = Transaction.fromHex(mainUtxo.transactionHex) - const scriptSig = prevTx.outs[mainUtxo.outputIndex].script transaction.addInput( - mainUtxo.transactionHash.toBuffer(), + mainUtxo.transactionHash.reverse().toBuffer(), mainUtxo.outputIndex, - undefined, - scriptSig ) - totalInputValue = totalInputValue.add(mainUtxo.value) } - for (const utxo of utxos) { // TODO: Validate that the utxo's value is the same as the value in deposit - const prevTx = Transaction.fromHex(utxo.transactionHex) - const scriptSig = prevTx.outs[utxo.outputIndex].script transaction.addInput( - utxo.transactionHash.toBuffer(), - utxo.outputIndex, - undefined, - scriptSig + utxo.transactionHash.reverse().toBuffer(), + utxo.outputIndex ) - totalInputValue = totalInputValue.add(utxo.value) } - // Subtract fee from the output - totalInputValue = totalInputValue.sub(fee) - // TODO: Verify that output script is properly created from both testnet // and mainnet addresses. + // Add transaction output. const scriptPubKey = address.toOutputScript(walletAddress) transaction.addOutput(scriptPubKey, totalInputValue.toNumber()) @@ -338,18 +337,23 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( })) for (let i = 0; i < transaction.ins.length; i++) { + const previousOutput = findPreviousOutput( + TransactionHash.from(transaction.ins[i].hash).reverse(), + transaction.ins[i].index, + utxos, + mainUtxo + ) + const previousOutputScript = previousOutput.script + // P2(W)PKH (main UTXO) - if ( - isP2PKH(transaction.ins[i].script) || - isP2WPKH(transaction.ins[i].script) - ) { + if (isP2PKH(previousOutputScript) || isP2WPKH(previousOutputScript)) { signMainUtxoInputBitcoinJsLib(transaction, i, ecPair) continue } const utxoWithDeposit = utxosWithDeposits.find( (u) => - u.transactionHash.toString() === + u.transactionHash.reverse().toString() === transaction.ins[i].hash.toString("hex") && u.outputIndex == transaction.ins[i].index ) @@ -357,17 +361,17 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( throw new Error("Unknown input") } - if (isP2SH(transaction.ins[i].script)) { + if (isP2SH(previousOutputScript)) { // P2SH (deposit UTXO) - signP2SHDepositInputBitcoinJsLib( + await signP2SHDepositInputBitcoinJsLib( transaction, i, utxoWithDeposit, ecPair ) - } else if (isP2WSH(transaction.ins[i].script)) { + } else if (isP2WSH(previousOutputScript)) { // P2WSH (deposit UTXO) - signP2WSHDepositInputBitcoinJsLib( + await signP2WSHDepositInputBitcoinJsLib( transaction, i, utxoWithDeposit, @@ -393,6 +397,27 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( } } +function findPreviousOutput( + inputHash: TransactionHash, + inputIndex: number, + utxos: (UnspentTransactionOutput & RawTransaction)[], + mainUtxo?: UnspentTransactionOutput & RawTransaction +) { + if (mainUtxo && + mainUtxo.transactionHash.equals(inputHash) && + mainUtxo.outputIndex === inputIndex) { + return Transaction.fromHex(mainUtxo.transactionHex).outs[mainUtxo.outputIndex] + } + + for (const utxo of utxos) { + if (utxo.transactionHash.equals(inputHash) && utxo.outputIndex === inputIndex) { + return Transaction.fromHex(utxo.transactionHex).outs[utxo.outputIndex] + } + } + + throw new Error("Unknown input") +} + /** * Creates script for the transaction input at the given index and signs the * input. @@ -505,7 +530,25 @@ async function signP2SHDepositInputBitcoinJsLib( deposit: Deposit, ecPair: ECPairInterface ) { - // TODO: Implement + const { walletPublicKey, depositScript } = + await prepareInputSignDataBitcoinIsLib(deposit, ecPair) + + const sigHashType = Transaction.SIGHASH_ALL + + const sigHash = transaction.hashForSignature( + inputIndex, + depositScript, + sigHashType + ) + + const signature = script.signature.encode(ecPair.sign(sigHash), sigHashType) + + const scriptSig: Stack = [] + scriptSig.push(signature) + scriptSig.push(Buffer.from(walletPublicKey, "hex")) + scriptSig.push(depositScript) + + transaction.ins[inputIndex].script = script.compile(scriptSig) } // TODO: Rename once the function is implemented. @@ -513,9 +556,28 @@ async function signP2WSHDepositInputBitcoinJsLib( transaction: Transaction, inputIndex: number, deposit: Deposit, - walletKeyRing: any + ecPair: ECPairInterface ) { - // TODO: Implement + const { walletPublicKey, depositScript, previousOutputValue } = + await prepareInputSignDataBitcoinIsLib(deposit, ecPair) + + const sigHashType = Transaction.SIGHASH_ALL + + const sigHash = transaction.hashForWitnessV0( + inputIndex, + depositScript, + previousOutputValue, + sigHashType + ) + + const signature = script.signature.encode(ecPair.sign(sigHash), sigHashType) + + const witness: Buffer[] = [] + witness.push(signature) + witness.push(Buffer.from(walletPublicKey, "hex")) + witness.push(depositScript) + + transaction.ins[inputIndex].witness = witness } async function prepareInputSignDataBitcoinIsLib( @@ -544,7 +606,8 @@ async function prepareInputSignDataBitcoinIsLib( const { amount, vault, ...depositScriptParameters } = deposit const depositScript = Buffer.from( - await assembleDepositScript(depositScriptParameters) + await assembleDepositScript(depositScriptParameters), + "hex" ) return { From e609cee0db388546f6f92fb3d9c6f816ec574690 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 20 Sep 2023 10:21:35 +0200 Subject: [PATCH 087/205] Lint fixes --- typescript/src/deposit-sweep.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index fec293b32..659f1d69c 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -18,7 +18,7 @@ import { import { assembleDepositScript, Deposit } from "./deposit" import { Bridge, Identifier } from "./chain" import { assembleTransactionProof } from "./proof" -import { ECPairFactory, ECPairInterface } from "ecpair" +import { ECPairFactory as ecFactory, ECPairInterface } from "ecpair" import * as tinysecp from "tiny-secp256k1" /** @@ -288,7 +288,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( const walletKeyRing = createKeyRing(walletPrivateKey, witness) const walletAddress = walletKeyRing.getAddress("string") - const ecPairApi = ECPairFactory(tinysecp); + const ecPairApi = ecFactory(tinysecp) // TODO: Pass appropriate network type (testnet vs mainnet). const ecPair = ecPairApi.fromWIF(walletPrivateKey, networks.testnet) @@ -310,7 +310,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( if (mainUtxo) { transaction.addInput( mainUtxo.transactionHash.reverse().toBuffer(), - mainUtxo.outputIndex, + mainUtxo.outputIndex ) } for (const utxo of utxos) { @@ -403,14 +403,21 @@ function findPreviousOutput( utxos: (UnspentTransactionOutput & RawTransaction)[], mainUtxo?: UnspentTransactionOutput & RawTransaction ) { - if (mainUtxo && + if ( + mainUtxo && mainUtxo.transactionHash.equals(inputHash) && - mainUtxo.outputIndex === inputIndex) { - return Transaction.fromHex(mainUtxo.transactionHex).outs[mainUtxo.outputIndex] + mainUtxo.outputIndex === inputIndex + ) { + return Transaction.fromHex(mainUtxo.transactionHex).outs[ + mainUtxo.outputIndex + ] } for (const utxo of utxos) { - if (utxo.transactionHash.equals(inputHash) && utxo.outputIndex === inputIndex) { + if ( + utxo.transactionHash.equals(inputHash) && + utxo.outputIndex === inputIndex + ) { return Transaction.fromHex(utxo.transactionHex).outs[utxo.outputIndex] } } @@ -559,7 +566,7 @@ async function signP2WSHDepositInputBitcoinJsLib( ecPair: ECPairInterface ) { const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignDataBitcoinIsLib(deposit, ecPair) + await prepareInputSignDataBitcoinIsLib(deposit, ecPair) const sigHashType = Transaction.SIGHASH_ALL @@ -590,9 +597,7 @@ async function prepareInputSignDataBitcoinIsLib( }> { const walletPublicKey = ecPair.publicKey.toString("hex") - if ( - computeHash160(walletPublicKey) != deposit.walletPublicKeyHash - ) { + if (computeHash160(walletPublicKey) != deposit.walletPublicKeyHash) { throw new Error( "Wallet public key does not correspond to wallet private key" ) From e019dd104ecc962a765fe7989b7b6c1fb0ff5c42 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 15 Sep 2023 16:05:19 +0200 Subject: [PATCH 088/205] Added bitcoinjs-lib in version 6.0.2 --- typescript/package.json | 1 + typescript/yarn.lock | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index 936b81f28..7cecbf2c0 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -28,6 +28,7 @@ "@keep-network/ecdsa": "development", "@keep-network/tbtc-v2": "development", "bcoin": "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8", + "bitcoinjs-lib": "6.0.2", "bufio": "^1.0.6", "electrum-client-js": "git+https://github.com/keep-network/electrum-client-js.git#v0.1.1", "ethers": "^5.5.2", diff --git a/typescript/yarn.lock b/typescript/yarn.lock index d305c9069..f2778ae49 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -2575,6 +2575,11 @@ bech32@1.1.4: resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== +bech32@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355" + integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg== + "bevent@git+https://github.com/bcoin-org/bevent.git#semver:~0.1.5": version "0.1.5" resolved "git+https://github.com/bcoin-org/bevent.git#60fb503de3ea1292d29ce438bfba80f0bc5ccb60" @@ -2639,6 +2644,11 @@ bindings@^1.3.0: bs32 "~0.1.5" bsert "~0.0.10" +bip174@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/bip174/-/bip174-2.1.1.tgz#ef3e968cf76de234a546962bcf572cc150982f9f" + integrity sha512-mdFV5+/v0XyNYXjBS6CQPLo9ekCx4gtKZFnJm5PMto7Fs9hTTDpkkzOB7/FtluRI6JbUUAu+snTYfJRgHLZbZQ== + bip32@2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/bip32/-/bip32-2.0.5.tgz#e3808a9e97a880dbafd0f5f09ca4a1e14ee275d2" @@ -2681,6 +2691,20 @@ bip39@3.0.4: pbkdf2 "^3.0.9" randombytes "^2.0.1" +bitcoinjs-lib@6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.0.2.tgz#0fdf6c41978d93641b936d66f4afce44bb9b7f35" + integrity sha512-I994pGt9cL5s5OA6mkv1e8IuYcsKN2ORXnWbkqAXLNGvEnOHBhKBSvCjFl7YC2uVoJnfr/iwq7JMrq575SYO5w== + dependencies: + bech32 "^2.0.0" + bip174 "^2.0.1" + bs58check "^2.1.2" + create-hash "^1.1.0" + ripemd160 "^2.0.2" + typeforce "^1.11.3" + varuint-bitcoin "^1.1.2" + wif "^2.0.1" + bl@^1.0.0: version "1.2.3" resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.3.tgz#1e8dd80142eac80d7158c9dccc047fb620e035e7" @@ -6902,7 +6926,7 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -ripemd160@^2.0.0, ripemd160@^2.0.1: +ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== @@ -7746,7 +7770,7 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typeforce@^1.11.5: +typeforce@^1.11.3, typeforce@^1.11.5: version "1.18.0" resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc" integrity sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g== @@ -7932,6 +7956,13 @@ varint@^5.0.0: resolved "https://registry.yarnpkg.com/varint/-/varint-5.0.2.tgz#5b47f8a947eb668b848e034dcfa87d0ff8a7f7a4" integrity sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow== +varuint-bitcoin@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/varuint-bitcoin/-/varuint-bitcoin-1.1.2.tgz#e76c138249d06138b480d4c5b40ef53693e24e92" + integrity sha512-4EVb+w4rx+YfVM32HQX42AbbT7/1f5zwAYhIujKXKk8NQK+JfRVl3pqT3hjNn/L+RstigmGGKVwHA/P0wgITZw== + dependencies: + safe-buffer "^5.1.1" + vary@^1, vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" @@ -8770,7 +8801,7 @@ wide-align@1.1.3: dependencies: string-width "^1.0.2 || 2" -wif@2.0.6, wif@^2.0.6: +wif@2.0.6, wif@^2.0.1, wif@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/wif/-/wif-2.0.6.tgz#08d3f52056c66679299726fade0d432ae74b4704" integrity sha1-CNP1IFbGZnkplyb63g1DKudLRwQ= From acc089c04608d3208584b14ec489b816d5e971da Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 21 Sep 2023 16:22:15 +0200 Subject: [PATCH 089/205] Added signing of main UTXO --- typescript/src/deposit-sweep.ts | 112 +++++++++++++++++++++++++------- 1 file changed, 90 insertions(+), 22 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 659f1d69c..536857955 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,5 +1,13 @@ import bcoin from "bcoin" -import { Transaction, Stack, address, script, networks } from "bitcoinjs-lib" +import { + Transaction, + Stack, + Signer, + payments, + address, + script, + networks, +} from "bitcoinjs-lib" import { BigNumber } from "ethers" import { RawTransaction, @@ -18,7 +26,7 @@ import { import { assembleDepositScript, Deposit } from "./deposit" import { Bridge, Identifier } from "./chain" import { assembleTransactionProof } from "./proof" -import { ECPairFactory as ecFactory, ECPairInterface } from "ecpair" +import { ECPairFactory as ecFactory } from "ecpair" import * as tinysecp from "tiny-secp256k1" /** @@ -288,9 +296,10 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( const walletKeyRing = createKeyRing(walletPrivateKey, witness) const walletAddress = walletKeyRing.getAddress("string") - const ecPairApi = ecFactory(tinysecp) - // TODO: Pass appropriate network type (testnet vs mainnet). - const ecPair = ecPairApi.fromWIF(walletPrivateKey, networks.testnet) + const keyPair = ecFactory(tinysecp).fromWIF( + walletPrivateKey, + networks.testnet + ) // Calculate the value of transaction's output. Note that the value of fee // needs to be subtracted from the sum. @@ -338,16 +347,23 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( for (let i = 0; i < transaction.ins.length; i++) { const previousOutput = findPreviousOutput( - TransactionHash.from(transaction.ins[i].hash).reverse(), + TransactionHash.from(transaction.ins[i].hash), transaction.ins[i].index, utxos, mainUtxo ) const previousOutputScript = previousOutput.script + const previousOutputValue = previousOutput.value // P2(W)PKH (main UTXO) if (isP2PKH(previousOutputScript) || isP2WPKH(previousOutputScript)) { - signMainUtxoInputBitcoinJsLib(transaction, i, ecPair) + signMainUtxoInputBitcoinJsLib( + transaction, + i, + previousOutputScript, + previousOutputValue, + keyPair + ) continue } @@ -367,7 +383,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( transaction, i, utxoWithDeposit, - ecPair + keyPair ) } else if (isP2WSH(previousOutputScript)) { // P2WSH (deposit UTXO) @@ -375,7 +391,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( transaction, i, utxoWithDeposit, - ecPair + keyPair ) } else { throw new Error("Unsupported UTXO script type") @@ -405,7 +421,7 @@ function findPreviousOutput( ) { if ( mainUtxo && - mainUtxo.transactionHash.equals(inputHash) && + mainUtxo.transactionHash.reverse().equals(inputHash) && mainUtxo.outputIndex === inputIndex ) { return Transaction.fromHex(mainUtxo.transactionHex).outs[ @@ -415,14 +431,14 @@ function findPreviousOutput( for (const utxo of utxos) { if ( - utxo.transactionHash.equals(inputHash) && + utxo.transactionHash.reverse().equals(inputHash) && utxo.outputIndex === inputIndex ) { return Transaction.fromHex(utxo.transactionHex).outs[utxo.outputIndex] } } - throw new Error("Unknown input") + throw new Error("Could not find previous output") } /** @@ -523,11 +539,63 @@ async function signP2WSHDepositInput( } async function signMainUtxoInputBitcoinJsLib( - transaction: any, + transaction: Transaction, inputIndex: number, - ecPair: ECPairInterface + prevOutScript: Buffer, + prevOutValue: number, + keyPair: Signer ) { - // TODO: Implement + const sigHashType = Transaction.SIGHASH_ALL + + if (isP2PKH(prevOutScript)) { + // P2PKH + const sigHash = transaction.hashForSignature( + inputIndex, + prevOutScript, + sigHashType + ) + + const signature = script.signature.encode( + keyPair.sign(sigHash), + sigHashType + ) + + const scriptSig = payments.p2pkh({ + signature: signature, + pubkey: keyPair.publicKey, + }).input! + + transaction.ins[inputIndex].script = scriptSig + } else { + // P2WPKH + const decompiledScript = script.decompile(prevOutScript) + if ( + !decompiledScript || + decompiledScript.length !== 2 || + decompiledScript[0] !== 0x00 || + !Buffer.isBuffer(decompiledScript[1]) || + decompiledScript[1].length !== 20 + ) { + throw new Error("Invalid script format") + } + + const publicKeyHash = decompiledScript[1] + const p2pkhScript = payments.p2pkh({ hash: publicKeyHash }).output! + + const sigHash = transaction.hashForWitnessV0( + inputIndex, + p2pkhScript, + prevOutValue, + sigHashType + ) + + const signature = script.signature.encode( + keyPair.sign(sigHash), + sigHashType + ) + + transaction.ins[inputIndex].witness = [signature, keyPair.publicKey] + } } // TODO: Rename once the function is implemented. @@ -535,10 +603,10 @@ async function signP2SHDepositInputBitcoinJsLib( transaction: Transaction, inputIndex: number, deposit: Deposit, - ecPair: ECPairInterface + keyPair: Signer ) { const { walletPublicKey, depositScript } = - await prepareInputSignDataBitcoinIsLib(deposit, ecPair) + await prepareInputSignDataBitcoinIsLib(deposit, keyPair) const sigHashType = Transaction.SIGHASH_ALL @@ -548,7 +616,7 @@ async function signP2SHDepositInputBitcoinJsLib( sigHashType ) - const signature = script.signature.encode(ecPair.sign(sigHash), sigHashType) + const signature = script.signature.encode(keyPair.sign(sigHash), sigHashType) const scriptSig: Stack = [] scriptSig.push(signature) @@ -563,10 +631,10 @@ async function signP2WSHDepositInputBitcoinJsLib( transaction: Transaction, inputIndex: number, deposit: Deposit, - ecPair: ECPairInterface + keyPair: Signer ) { const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignDataBitcoinIsLib(deposit, ecPair) + await prepareInputSignDataBitcoinIsLib(deposit, keyPair) const sigHashType = Transaction.SIGHASH_ALL @@ -577,7 +645,7 @@ async function signP2WSHDepositInputBitcoinJsLib( sigHashType ) - const signature = script.signature.encode(ecPair.sign(sigHash), sigHashType) + const signature = script.signature.encode(keyPair.sign(sigHash), sigHashType) const witness: Buffer[] = [] witness.push(signature) @@ -589,7 +657,7 @@ async function signP2WSHDepositInputBitcoinJsLib( async function prepareInputSignDataBitcoinIsLib( deposit: Deposit, - ecPair: ECPairInterface + ecPair: Signer ): Promise<{ walletPublicKey: string depositScript: any From 841622949c0ee00bf767c5defa92f43d8fa6bafd Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 22 Sep 2023 15:33:14 +0200 Subject: [PATCH 090/205] Added check for mismatch between utxo and deposit values --- typescript/src/deposit-sweep.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 536857955..0340e646b 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -323,7 +323,6 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( ) } for (const utxo of utxos) { - // TODO: Validate that the utxo's value is the same as the value in deposit transaction.addInput( utxo.transactionHash.reverse().toBuffer(), utxo.outputIndex @@ -383,6 +382,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( transaction, i, utxoWithDeposit, + previousOutputValue, keyPair ) } else if (isP2WSH(previousOutputScript)) { @@ -391,6 +391,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( transaction, i, utxoWithDeposit, + previousOutputValue, keyPair ) } else { @@ -545,6 +546,7 @@ async function signMainUtxoInputBitcoinJsLib( prevOutValue: number, keyPair: Signer ) { + // TODO: Check that input the belongs to the wallet. const sigHashType = Transaction.SIGHASH_ALL if (isP2PKH(prevOutScript)) { @@ -603,10 +605,11 @@ async function signP2SHDepositInputBitcoinJsLib( transaction: Transaction, inputIndex: number, deposit: Deposit, + prevOutValue: number, keyPair: Signer ) { const { walletPublicKey, depositScript } = - await prepareInputSignDataBitcoinIsLib(deposit, keyPair) + await prepareInputSignDataBitcoinIsLib(deposit, prevOutValue, keyPair) const sigHashType = Transaction.SIGHASH_ALL @@ -631,10 +634,11 @@ async function signP2WSHDepositInputBitcoinJsLib( transaction: Transaction, inputIndex: number, deposit: Deposit, + prevOutValue: number, keyPair: Signer ) { const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignDataBitcoinIsLib(deposit, keyPair) + await prepareInputSignDataBitcoinIsLib(deposit, prevOutValue, keyPair) const sigHashType = Transaction.SIGHASH_ALL @@ -657,12 +661,17 @@ async function signP2WSHDepositInputBitcoinJsLib( async function prepareInputSignDataBitcoinIsLib( deposit: Deposit, + prevOutValue: number, ecPair: Signer ): Promise<{ walletPublicKey: string depositScript: any previousOutputValue: number }> { + if (prevOutValue != deposit.amount.toNumber()) { + throw new Error("Mismatch between amount in deposit and deposit tx") + } + const walletPublicKey = ecPair.publicKey.toString("hex") if (computeHash160(walletPublicKey) != deposit.walletPublicKeyHash) { From 6a06c63ccbd23a7f98a9c7e8b706b57feca9a81c Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 25 Sep 2023 14:17:46 +0200 Subject: [PATCH 091/205] Added Bitcoin network argument --- typescript/src/bitcoin-network.ts | 17 +++++++++++++++++ typescript/src/deposit-sweep.ts | 12 ++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/typescript/src/bitcoin-network.ts b/typescript/src/bitcoin-network.ts index f14dd5ed4..1f6bf50a9 100644 --- a/typescript/src/bitcoin-network.ts +++ b/typescript/src/bitcoin-network.ts @@ -1,4 +1,5 @@ import { Hex } from "./hex" +import { networks } from "bitcoinjs-lib" /** * Bitcoin networks. @@ -64,3 +65,19 @@ export function toBcoinNetwork(bitcoinNetwork: BitcoinNetwork): string { } } } + +export function toBitcoinJsLibNetwork( + bitcoinNetwork: BitcoinNetwork +): networks.Network { + switch (bitcoinNetwork) { + case BitcoinNetwork.Mainnet: { + return networks.bitcoin + } + case BitcoinNetwork.Testnet: { + return networks.testnet + } + default: { + throw new Error(`network not supported`) + } + } +} diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 0340e646b..7a646ab82 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -6,7 +6,6 @@ import { payments, address, script, - networks, } from "bitcoinjs-lib" import { BigNumber } from "ethers" import { @@ -28,6 +27,7 @@ import { Bridge, Identifier } from "./chain" import { assembleTransactionProof } from "./proof" import { ECPairFactory as ecFactory } from "ecpair" import * as tinysecp from "tiny-secp256k1" +import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" /** * Submits a deposit sweep by combining all the provided P2(W)SH UTXOs and @@ -272,6 +272,7 @@ export async function assembleDepositSweepTransaction( */ // TODO: Rename once it's finished. export async function assembleDepositSweepTransactionBitcoinJsLib( + bitcoinNetwork: BitcoinNetwork, fee: BigNumber, walletPrivateKey: string, witness: boolean, @@ -291,15 +292,14 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( throw new Error("Number of UTXOs must equal the number of deposit elements") } + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + // TODO: Replace keyring with bitcoinjs-lib functionalities for managing // keys (ecpair). const walletKeyRing = createKeyRing(walletPrivateKey, witness) const walletAddress = walletKeyRing.getAddress("string") - const keyPair = ecFactory(tinysecp).fromWIF( - walletPrivateKey, - networks.testnet - ) + const keyPair = ecFactory(tinysecp).fromWIF(walletPrivateKey, network) // Calculate the value of transaction's output. Note that the value of fee // needs to be subtracted from the sum. @@ -332,7 +332,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( // TODO: Verify that output script is properly created from both testnet // and mainnet addresses. // Add transaction output. - const scriptPubKey = address.toOutputScript(walletAddress) + const scriptPubKey = address.toOutputScript(walletAddress, network) transaction.addOutput(scriptPubKey, totalInputValue.toNumber()) // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any From dcf7314f4ad1a1b2fb4ce8e01806a0344c7a7ae9 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 25 Sep 2023 15:42:01 +0200 Subject: [PATCH 092/205] Added address extraction from key pair --- typescript/src/bitcoin-network.ts | 1 + typescript/src/bitcoin.ts | 18 +++++++++++++++++- typescript/src/deposit-sweep.ts | 8 ++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/typescript/src/bitcoin-network.ts b/typescript/src/bitcoin-network.ts index 1f6bf50a9..c2805c9f7 100644 --- a/typescript/src/bitcoin-network.ts +++ b/typescript/src/bitcoin-network.ts @@ -66,6 +66,7 @@ export function toBcoinNetwork(bitcoinNetwork: BitcoinNetwork): string { } } +// TODO: Description export function toBitcoinJsLibNetwork( bitcoinNetwork: BitcoinNetwork ): networks.Network { diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 2e4e0fb08..2f7df7a12 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -4,7 +4,8 @@ import bufio from "bufio" import { BigNumber, utils } from "ethers" import { Hex } from "./hex" import { BitcoinNetwork, toBcoinNetwork } from "./bitcoin-network" -import { payments } from "bitcoinjs-lib" +import { payments, networks } from "bitcoinjs-lib" +import { ECPairInterface } from "ecpair" /** * Represents a transaction hash (or transaction ID) as an un-prefixed hex @@ -740,3 +741,18 @@ export function isP2WSH(script: Buffer): boolean { return false } } + +// TODO: Description and unit tests. +export function addressFromKeyPair( + keyPair: ECPairInterface, + network: networks.Network, + witness: boolean +): string { + if (witness) { + // P2WPKH (SegWit) + return payments.p2wpkh({ pubkey: keyPair.publicKey, network }).address! + } else { + // P2PKH (Legacy) + return payments.p2pkh({ pubkey: keyPair.publicKey, network }).address! + } +} diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 7a646ab82..85ad6e02b 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -15,6 +15,7 @@ import { decomposeRawTransaction, isCompressedPublicKey, createKeyRing, + addressFromKeyPair, TransactionHash, computeHash160, isP2PKH, @@ -293,13 +294,8 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( } const network = toBitcoinJsLibNetwork(bitcoinNetwork) - - // TODO: Replace keyring with bitcoinjs-lib functionalities for managing - // keys (ecpair). - const walletKeyRing = createKeyRing(walletPrivateKey, witness) - const walletAddress = walletKeyRing.getAddress("string") - const keyPair = ecFactory(tinysecp).fromWIF(walletPrivateKey, network) + const walletAddress = addressFromKeyPair(keyPair, network, witness) // Calculate the value of transaction's output. Note that the value of fee // needs to be subtracted from the sum. From e63197b5a2f0968fa804301afba7b31394e262ae Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 25 Sep 2023 17:38:28 +0200 Subject: [PATCH 093/205] Added check for own UTXO --- typescript/src/bitcoin.ts | 4 +-- typescript/src/deposit-sweep.ts | 49 ++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 2f7df7a12..55f668c00 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -5,7 +5,7 @@ import { BigNumber, utils } from "ethers" import { Hex } from "./hex" import { BitcoinNetwork, toBcoinNetwork } from "./bitcoin-network" import { payments, networks } from "bitcoinjs-lib" -import { ECPairInterface } from "ecpair" +import { Signer } from "ecpair" /** * Represents a transaction hash (or transaction ID) as an un-prefixed hex @@ -744,7 +744,7 @@ export function isP2WSH(script: Buffer): boolean { // TODO: Description and unit tests. export function addressFromKeyPair( - keyPair: ECPairInterface, + keyPair: Signer, network: networks.Network, witness: boolean ): string { diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 85ad6e02b..4d2c6f994 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -6,6 +6,7 @@ import { payments, address, script, + networks, } from "bitcoinjs-lib" import { BigNumber } from "ethers" import { @@ -352,12 +353,13 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( // P2(W)PKH (main UTXO) if (isP2PKH(previousOutputScript) || isP2WPKH(previousOutputScript)) { - signMainUtxoInputBitcoinJsLib( + await signMainUtxoInputBitcoinJsLib( transaction, i, previousOutputScript, previousOutputValue, - keyPair + keyPair, + network ) continue } @@ -540,9 +542,13 @@ async function signMainUtxoInputBitcoinJsLib( inputIndex: number, prevOutScript: Buffer, prevOutValue: number, - keyPair: Signer + keyPair: Signer, + network: networks.Network ) { - // TODO: Check that input the belongs to the wallet. + if (!ownsUtxo(keyPair, prevOutScript, network)) { + throw new Error("UTXO does not belong to the wallet") + } + const sigHashType = Transaction.SIGHASH_ALL if (isP2PKH(prevOutScript)) { @@ -783,3 +789,38 @@ export async function submitDepositSweepProof( vault ) } + +// TODO: Description and unit test. +export function ownsUtxo( + keyPair: Signer, + prevOutScript: Buffer, + network: networks.Network +): boolean { + // Derive P2PKH and P2WPKH addresses from the public key. + const p2pkhAddress = + payments.p2pkh({ pubkey: keyPair.publicKey, network }).address || "" + const p2wpkhAddress = + payments.p2wpkh({ pubkey: keyPair.publicKey, network }).address || "" + + // Try to extract an address from the provided prevOutScript. + let addressFromOutput = "" + try { + addressFromOutput = + payments.p2pkh({ output: prevOutScript, network }).address || "" + } catch (e) { + // If not P2PKH, try P2WPKH. + try { + addressFromOutput = + payments.p2wpkh({ output: prevOutScript, network }).address || "" + } catch (err) { + // If neither p2pkh nor p2wpkh address can be derived, assume the previous + // output script comes from a different UTXO type or is corrupted. + return false + } + } + + // Check if the UTXO's address matches either of the derived addresses. + return ( + addressFromOutput === p2pkhAddress || addressFromOutput === p2wpkhAddress + ) +} From da9856a0702bea8b1fc8fced832f9faa1d05079e Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Mon, 25 Sep 2023 18:07:13 +0200 Subject: [PATCH 094/205] Updated unit tests for assembleDepositSweepTransaction --- typescript/src/deposit-sweep.ts | 318 +------------------------- typescript/test/data/deposit-sweep.ts | 29 ++- typescript/test/deposit-sweep.test.ts | 51 +++-- 3 files changed, 55 insertions(+), 343 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 4d2c6f994..196361025 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,4 +1,3 @@ -import bcoin from "bcoin" import { Transaction, Stack, @@ -15,7 +14,6 @@ import { Client as BitcoinClient, decomposeRawTransaction, isCompressedPublicKey, - createKeyRing, addressFromKeyPair, TransactionHash, computeHash160, @@ -89,8 +87,11 @@ export async function submitDepositSweepTransaction( } } + const bitcoinNetwork = await bitcoinClient.getNetwork() + const { transactionHash, newMainUtxo, rawTransaction } = await assembleDepositSweepTransaction( + bitcoinNetwork, fee, walletPrivateKey, witness, @@ -128,152 +129,6 @@ export async function submitDepositSweepTransaction( * - the sweep transaction in the raw format */ export async function assembleDepositSweepTransaction( - fee: BigNumber, - walletPrivateKey: string, - witness: boolean, - utxos: (UnspentTransactionOutput & RawTransaction)[], - deposits: Deposit[], - mainUtxo?: UnspentTransactionOutput & RawTransaction -): Promise<{ - transactionHash: TransactionHash - newMainUtxo: UnspentTransactionOutput - rawTransaction: RawTransaction -}> { - if (utxos.length < 1) { - throw new Error("There must be at least one deposit UTXO to sweep") - } - - if (utxos.length != deposits.length) { - throw new Error("Number of UTXOs must equal the number of deposit elements") - } - - const walletKeyRing = createKeyRing(walletPrivateKey, witness) - const walletAddress = walletKeyRing.getAddress("string") - - const inputCoins = [] - let totalInputValue = BigNumber.from(0) - - if (mainUtxo) { - inputCoins.push( - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), - mainUtxo.outputIndex, - -1 - ) - ) - totalInputValue = totalInputValue.add(mainUtxo.value) - } - - for (const utxo of utxos) { - inputCoins.push( - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), - utxo.outputIndex, - -1 - ) - ) - totalInputValue = totalInputValue.add(utxo.value) - } - - const transaction = new bcoin.MTX() - - transaction.addOutput({ - script: bcoin.Script.fromAddress(walletAddress), - value: totalInputValue.toNumber(), - }) - - await transaction.fund(inputCoins, { - changeAddress: walletAddress, - hardFee: fee.toNumber(), - subtractFee: true, - }) - - if (transaction.outputs.length != 1) { - throw new Error("Deposit sweep transaction must have only one output") - } - - // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any - // order - const utxosWithDeposits: (UnspentTransactionOutput & - RawTransaction & - Deposit)[] = utxos.map((utxo, index) => ({ - ...utxo, - ...deposits[index], - })) - - for (let i = 0; i < transaction.inputs.length; i++) { - const previousOutpoint = transaction.inputs[i].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - const previousScript = previousOutput.script - - // P2(W)PKH (main UTXO) - if (previousScript.isPubkeyhash() || previousScript.isWitnessPubkeyhash()) { - await signMainUtxoInput(transaction, i, walletKeyRing) - continue - } - - const utxoWithDeposit = utxosWithDeposits.find( - (u) => - u.transactionHash.toString() === previousOutpoint.txid() && - u.outputIndex == previousOutpoint.index - ) - if (!utxoWithDeposit) { - throw new Error("Unknown input") - } - - if (previousScript.isScripthash()) { - // P2SH (deposit UTXO) - await signP2SHDepositInput(transaction, i, utxoWithDeposit, walletKeyRing) - } else if (previousScript.isWitnessScripthash()) { - // P2WSH (deposit UTXO) - await signP2WSHDepositInput( - transaction, - i, - utxoWithDeposit, - walletKeyRing - ) - } else { - throw new Error("Unsupported UTXO script type") - } - } - - const transactionHash = TransactionHash.from(transaction.txid()) - - return { - transactionHash, - newMainUtxo: { - transactionHash, - outputIndex: 0, // There is only one output. - value: BigNumber.from(transaction.outputs[0].value), - }, - rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), - }, - } -} - -/** - * Assembles a Bitcoin P2WPKH deposit sweep transaction. - * @dev The caller is responsible for ensuring the provided UTXOs are correctly - * formed, can be spent by the wallet and their combined value is greater - * then the fee. - * @param fee - the value that should be subtracted from the sum of the UTXOs - * values and used as the transaction fee. - * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. - * @param witness - The parameter used to decide about the type of the new main - * UTXO output. P2WPKH if `true`, P2PKH if `false`. - * @param utxos - UTXOs from new deposit transactions. Must be P2(W)SH. - * @param deposits - Array of deposits. Each element corresponds to UTXO. - * The number of UTXOs and deposit elements must equal. - * @param mainUtxo - main UTXO of the wallet, which is a P2WKH UTXO resulting - * from the previous wallet transaction (optional). - * @returns The outcome consisting of: - * - the sweep transaction hash, - * - the new wallet's main UTXO produced by this transaction. - * - the sweep transaction in the raw format - */ -// TODO: Rename once it's finished. -export async function assembleDepositSweepTransactionBitcoinJsLib( bitcoinNetwork: BitcoinNetwork, fee: BigNumber, walletPrivateKey: string, @@ -326,14 +181,13 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( ) } - // TODO: Verify that output script is properly created from both testnet - // and mainnet addresses. // Add transaction output. const scriptPubKey = address.toOutputScript(walletAddress, network) transaction.addOutput(scriptPubKey, totalInputValue.toNumber()) // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any // order + // TODO: Most likely remove. const utxosWithDeposits: (UnspentTransactionOutput & RawTransaction & Deposit)[] = utxos.map((utxo, index) => ({ @@ -353,7 +207,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( // P2(W)PKH (main UTXO) if (isP2PKH(previousOutputScript) || isP2WPKH(previousOutputScript)) { - await signMainUtxoInputBitcoinJsLib( + await signMainUtxoInput( transaction, i, previousOutputScript, @@ -376,7 +230,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( if (isP2SH(previousOutputScript)) { // P2SH (deposit UTXO) - await signP2SHDepositInputBitcoinJsLib( + await signP2SHDepositInput( transaction, i, utxoWithDeposit, @@ -385,7 +239,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib( ) } else if (isP2WSH(previousOutputScript)) { // P2WSH (deposit UTXO) - await signP2WSHDepositInputBitcoinJsLib( + await signP2WSHDepositInput( transaction, i, utxoWithDeposit, @@ -440,104 +294,7 @@ function findPreviousOutput( throw new Error("Could not find previous output") } -/** - * Creates script for the transaction input at the given index and signs the - * input. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Empty promise. - */ async function signMainUtxoInput( - transaction: any, - inputIndex: number, - walletKeyRing: any -) { - const previousOutpoint = transaction.inputs[inputIndex].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - if (!walletKeyRing.ownOutput(previousOutput)) { - throw new Error("UTXO does not belong to the wallet") - } - // Build script and set it as input's witness - transaction.scriptInput(inputIndex, previousOutput, walletKeyRing) - // Build signature and add it in front of script in input's witness - transaction.signInput(inputIndex, previousOutput, walletKeyRing) -} - -/** - * Creates and sets `scriptSig` for the transaction input at the given index by - * combining signature, wallet public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Empty promise. - */ -async function signP2SHDepositInput( - transaction: any, - inputIndex: number, - deposit: Deposit, - walletKeyRing: any -): Promise { - const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData(transaction, inputIndex, deposit, walletKeyRing) - - const signature: Buffer = transaction.signature( - inputIndex, - depositScript, - previousOutputValue, - walletKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 0 // legacy sighash version - ) - const scriptSig = new bcoin.Script() - scriptSig.clear() - scriptSig.pushData(signature) - scriptSig.pushData(Buffer.from(walletPublicKey, "hex")) - scriptSig.pushData(depositScript.toRaw()) - scriptSig.compile() - - transaction.inputs[inputIndex].script = scriptSig -} - -/** - * Creates and sets witness script for the transaction input at the given index - * by combining signature, wallet public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Empty promise. - */ -async function signP2WSHDepositInput( - transaction: any, - inputIndex: number, - deposit: Deposit, - walletKeyRing: any -): Promise { - const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData(transaction, inputIndex, deposit, walletKeyRing) - - const signature: Buffer = transaction.signature( - inputIndex, - depositScript, - previousOutputValue, - walletKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 1 // segwit sighash version - ) - - const witness = new bcoin.Witness() - witness.clear() - witness.pushData(signature) - witness.pushData(Buffer.from(walletPublicKey, "hex")) - witness.pushData(depositScript.toRaw()) - witness.compile() - - transaction.inputs[inputIndex].witness = witness -} - -async function signMainUtxoInputBitcoinJsLib( transaction: Transaction, inputIndex: number, prevOutScript: Buffer, @@ -602,8 +359,8 @@ async function signMainUtxoInputBitcoinJsLib( } } -// TODO: Rename once the function is implemented. -async function signP2SHDepositInputBitcoinJsLib( +// TODO: Description. +async function signP2SHDepositInput( transaction: Transaction, inputIndex: number, deposit: Deposit, @@ -631,8 +388,8 @@ async function signP2SHDepositInputBitcoinJsLib( transaction.ins[inputIndex].script = script.compile(scriptSig) } -// TODO: Rename once the function is implemented. -async function signP2WSHDepositInputBitcoinJsLib( +// TODO: Description. +async function signP2WSHDepositInput( transaction: Transaction, inputIndex: number, deposit: Deposit, @@ -701,59 +458,6 @@ async function prepareInputSignDataBitcoinIsLib( } } -/** - * Creates data needed to sign a deposit input. - * @param transaction - Mutable transaction containing the input. - * @param inputIndex - Index that points to the input. - * @param deposit - Data of the deposit. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Data needed to sign the input. - */ -async function prepareInputSignData( - transaction: any, - inputIndex: number, - deposit: Deposit, - walletKeyRing: any -): Promise<{ - walletPublicKey: string - depositScript: any - previousOutputValue: number -}> { - const previousOutpoint = transaction.inputs[inputIndex].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - - if (previousOutput.value != deposit.amount.toNumber()) { - throw new Error("Mismatch between amount in deposit and deposit tx") - } - - const walletPublicKey = walletKeyRing.getPublicKey("hex") - if ( - computeHash160(walletKeyRing.getPublicKey("hex")) != - deposit.walletPublicKeyHash - ) { - throw new Error( - "Wallet public key does not correspond to wallet private key" - ) - } - - if (!isCompressedPublicKey(walletPublicKey)) { - throw new Error("Wallet public key must be compressed") - } - - // eslint-disable-next-line no-unused-vars - const { amount, vault, ...depositScriptParameters } = deposit - - const depositScript = bcoin.Script.fromRaw( - Buffer.from(await assembleDepositScript(depositScriptParameters), "hex") - ) - - return { - walletPublicKey, - depositScript: depositScript, - previousOutputValue: previousOutput.value, - } -} - /** * Prepares the proof of a deposit sweep transaction and submits it to the * Bridge on-chain contract. diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index 59e3f5770..74e001b6b 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -350,24 +350,23 @@ export const depositSweepWithNonWitnessMainUtxoAndWitnessOutput: DepositSweepTes witness: true, expectedSweep: { transactionHash: TransactionHash.from( - "7831d0dfde7e160f3b9bb66c433710f0d3110d73ea78b9db65e81c091a6718a0" + "1933781f01f27f086c3a31c4a53035ebc7c4688e1f4b316babefa8f6dab77dc2" ), transaction: { transactionHex: - "01000000000102173a201f597a2c8ccd7842303a6653bb87437fb08dae671731a0" + - "75403b32a2fd0000000000ffffffffe19612be756bf7e740b47bec0e24845089ac" + - "e48c78d473cb34949b3007c4a2c8000000006a47304402204382deb051f9f3e2b5" + - "39e4bac2d1a50faf8d66bc7a3a3f3d286dabd96d92b58b02207c74c6aaf48e25d0" + - "7e02bb4039606d77ecfd80c492c050ab2486af6027fc2d5a012103989d253b17a6" + - "a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9ffffffff010884" + - "0000000000001600148db50eb52063ea9d98b3eac91489a90f738986f603483045" + - "022100c52bc876cdee80a3061ace3ffbce5e860942d444cd38e00e5f63fd8e818d" + - "7e7c022040a7017bb8213991697705e7092c481526c788a4731d06e582dc1c57be" + - "d7243b012103989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc2" + - "9dcf8581d95c14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508f9f0c90d" + - "000395237576a9148db50eb52063ea9d98b3eac91489a90f738986f68763ac6776" + - "a914e257eccafbc07c381642ce6e7e55120fb077fbed880448f2b262b175ac6800" + - "00000000", + "01000000000102e19612be756bf7e740b47bec0e24845089ace48c78d473cb34949" + + "b3007c4a2c8000000006a473044022013787be70eda0620002fa55c92abfcd32257" + + "d64fa652dd32bac65d705162a95902203407fea1abc99a9273ead3179ce60f60a34" + + "33fb2e93f58569e4bee9f63c0d679012103989d253b17a6a0f41838b84ff0d20e88" + + "98f9d7b1a98f2564da4cc29dcf8581d9ffffffff173a201f597a2c8ccd7842303a6" + + "653bb87437fb08dae671731a075403b32a2fd0000000000ffffffff010884000000" + + "0000001600148db50eb52063ea9d98b3eac91489a90f738986f6000348304502210" + + "0804f0fa989d632cda99a24159e28b8d31d4033c2d5de47d8207ea2767273d10a02" + + "20278e82d0714867b31eb013762306e2b97c2c1cc74b8135bee78d565e72ee630e0" + + "12103989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581" + + "d95c14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508f9f0c90d000395237" + + "576a9148db50eb52063ea9d98b3eac91489a90f738986f68763ac6776a914e257ec" + + "cafbc07c381642ce6e7e55120fb077fbed880448f2b262b175ac6800000000", }, }, } diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index 494aa24c5..0d429efd3 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -31,6 +31,7 @@ import { submitDepositSweepProof, submitDepositSweepTransaction, } from "../src/deposit-sweep" +import { BitcoinNetwork } from "../src/bitcoin-network" describe("Sweep", () => { const fee = BigNumber.from(1600) @@ -39,8 +40,6 @@ describe("Sweep", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() }) @@ -379,6 +378,7 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -508,6 +508,7 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -658,6 +659,7 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -686,25 +688,7 @@ describe("Sweep", () => { // Validate inputs. expect(txJSON.inputs.length).to.be.equal(2) - const p2wshInput = txJSON.inputs[0] - expect(p2wshInput.prevout.hash).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() - ) - expect(p2wshInput.prevout.index).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0] - .utxo.outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wshInput.witness.length).to.be.greaterThan(0) - expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2wshInput.address).to.be.equal( - "tb1qk8urugnf08wfle6wslmdxq7mkz9z0gw8e6gkvspn7dx87tfpfntshdm7qr" - ) - - const p2pkhInput = txJSON.inputs[1] // main UTXO + const p2pkhInput = txJSON.inputs[0] // main UTXO expect(p2pkhInput.prevout.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() ) @@ -722,6 +706,24 @@ describe("Sweep", () => { "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" ) + const p2wshInput = txJSON.inputs[1] + expect(p2wshInput.prevout.hash).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() + ) + expect(p2wshInput.prevout.index).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0] + .utxo.outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wshInput.witness.length).to.be.greaterThan(0) + expect(p2wshInput.script.length).to.be.equal(0) + // Input's address should be set to the address generated from deposit + // script hash + expect(p2wshInput.address).to.be.equal( + "tb1qk8urugnf08wfle6wslmdxq7mkz9z0gw8e6gkvspn7dx87tfpfntshdm7qr" + ) + // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -791,6 +793,7 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -878,6 +881,7 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, true, @@ -906,6 +910,7 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -931,6 +936,7 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, true, @@ -970,6 +976,7 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, true, @@ -994,6 +1001,7 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, anotherPrivateKey, true, @@ -1027,6 +1035,7 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, true, From 4bc749f31f705b6288a4712dfddf450222543dee Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 26 Sep 2023 12:14:24 +0200 Subject: [PATCH 095/205] Simplified signing inputs --- typescript/src/deposit-sweep.ts | 109 +++++++++++--------------------- 1 file changed, 36 insertions(+), 73 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 196361025..a37de71b9 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -185,64 +185,53 @@ export async function assembleDepositSweepTransaction( const scriptPubKey = address.toOutputScript(walletAddress, network) transaction.addOutput(scriptPubKey, totalInputValue.toNumber()) - // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any - // order - // TODO: Most likely remove. - const utxosWithDeposits: (UnspentTransactionOutput & - RawTransaction & - Deposit)[] = utxos.map((utxo, index) => ({ - ...utxo, - ...deposits[index], - })) - - for (let i = 0; i < transaction.ins.length; i++) { - const previousOutput = findPreviousOutput( - TransactionHash.from(transaction.ins[i].hash), - transaction.ins[i].index, - utxos, - mainUtxo + // Sign the main UTXO input if there is main UTXO. + if (mainUtxo) { + const inputIndex = 0 // Main UTXO is the first input. + const previousOutput = Transaction.fromHex(mainUtxo.transactionHex).outs[ + mainUtxo.outputIndex + ] + + await signMainUtxoInput( + transaction, + inputIndex, + previousOutput.script, + previousOutput.value, + keyPair, + network ) - const previousOutputScript = previousOutput.script - const previousOutputValue = previousOutput.value + } - // P2(W)PKH (main UTXO) - if (isP2PKH(previousOutputScript) || isP2WPKH(previousOutputScript)) { - await signMainUtxoInput( - transaction, - i, - previousOutputScript, - previousOutputValue, - keyPair, - network - ) - continue - } + // Sign the deposit inputs. + for (let depositIndex = 0; depositIndex < deposits.length; depositIndex++) { + // If there is a main UTXO index, we must adjust input index as the first + // input is the main UTXO input. + const inputIndex = mainUtxo ? depositIndex + 1 : depositIndex - const utxoWithDeposit = utxosWithDeposits.find( - (u) => - u.transactionHash.reverse().toString() === - transaction.ins[i].hash.toString("hex") && - u.outputIndex == transaction.ins[i].index - ) - if (!utxoWithDeposit) { - throw new Error("Unknown input") - } + const utxo = utxos[depositIndex] + const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ + utxo.outputIndex + ] + const previousOutputValue = previousOutput.value + const previousOutputScript = previousOutput.script + + const deposit = deposits[depositIndex] if (isP2SH(previousOutputScript)) { // P2SH (deposit UTXO) await signP2SHDepositInput( transaction, - i, - utxoWithDeposit, - previousOutputValue, + inputIndex, + deposit, + previousOutput.value, keyPair ) } else if (isP2WSH(previousOutputScript)) { // P2WSH (deposit UTXO) await signP2WSHDepositInput( transaction, - i, - utxoWithDeposit, + inputIndex, + deposit, previousOutputValue, keyPair ) @@ -266,34 +255,6 @@ export async function assembleDepositSweepTransaction( } } -function findPreviousOutput( - inputHash: TransactionHash, - inputIndex: number, - utxos: (UnspentTransactionOutput & RawTransaction)[], - mainUtxo?: UnspentTransactionOutput & RawTransaction -) { - if ( - mainUtxo && - mainUtxo.transactionHash.reverse().equals(inputHash) && - mainUtxo.outputIndex === inputIndex - ) { - return Transaction.fromHex(mainUtxo.transactionHex).outs[ - mainUtxo.outputIndex - ] - } - - for (const utxo of utxos) { - if ( - utxo.transactionHash.reverse().equals(inputHash) && - utxo.outputIndex === inputIndex - ) { - return Transaction.fromHex(utxo.transactionHex).outs[utxo.outputIndex] - } - } - - throw new Error("Could not find previous output") -} - async function signMainUtxoInput( transaction: Transaction, inputIndex: number, @@ -327,7 +288,7 @@ async function signMainUtxoInput( }).input! transaction.ins[inputIndex].script = scriptSig - } else { + } else if (isP2WPKH(prevOutScript)) { // P2WPKH const decompiledScript = script.decompile(prevOutScript) if ( @@ -356,6 +317,8 @@ async function signMainUtxoInput( ) transaction.ins[inputIndex].witness = [signature, keyPair.publicKey] + } else { + throw new Error("Unknown type of main UTXO") } } From d1a8c9ab23d4c0ec3895a4791be55cc314cf0197 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 26 Sep 2023 13:04:09 +0200 Subject: [PATCH 096/205] Added function descriptions --- typescript/src/bitcoin-network.ts | 8 ++- typescript/src/bitcoin.ts | 11 ++- typescript/src/deposit-sweep.ts | 99 +++++++++++++++++++++------ typescript/test/deposit-sweep.test.ts | 2 - 4 files changed, 95 insertions(+), 25 deletions(-) diff --git a/typescript/src/bitcoin-network.ts b/typescript/src/bitcoin-network.ts index c2805c9f7..c59a134f2 100644 --- a/typescript/src/bitcoin-network.ts +++ b/typescript/src/bitcoin-network.ts @@ -66,7 +66,13 @@ export function toBcoinNetwork(bitcoinNetwork: BitcoinNetwork): string { } } -// TODO: Description +/** + * Converts the provided {@link BitcoinNetwork} enumeration to a format expected + * by the `bitcoinjs-lib` library. + * @param bitcoinNetwork - Specified Bitcoin network. + * @returns Network representation compatible with the `bitcoinjs-lib` library. + * @throws An error if the network is not supported by `bitcoinjs-lib`. + */ export function toBitcoinJsLibNetwork( bitcoinNetwork: BitcoinNetwork ): networks.Network { diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 55f668c00..63936a464 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -742,7 +742,16 @@ export function isP2WSH(script: Buffer): boolean { } } -// TODO: Description and unit tests. +/** + * Generates a Bitcoin address based on the provided key pair and network. + * Can produce either SegWit (P2WPKH) or Legacy (P2PKH) addresses. + * @param keyPair - The key pair used to derive the Bitcoin address. + * @param network - Specified Bitcoin network. + * @param witness - Boolean flag indicating if the address should be SegWit + * (P2WPKH) or not (P2PKH). + * @returns The generated Bitcoin address as a string. + */ +// TODO: Unit tests. export function addressFromKeyPair( keyPair: Signer, network: networks.Network, diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index a37de71b9..06f769115 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -109,24 +109,25 @@ export async function submitDepositSweepTransaction( } /** - * Assembles a Bitcoin P2WPKH deposit sweep transaction. + * Constructs a Bitcoin deposit sweep transaction using provided UTXOs. * @dev The caller is responsible for ensuring the provided UTXOs are correctly * formed, can be spent by the wallet and their combined value is greater * then the fee. - * @param fee - the value that should be subtracted from the sum of the UTXOs - * values and used as the transaction fee. + * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). + * @param fee - Transaction fee to be subtracted from the sum of the UTXOs' + * values. * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. - * @param witness - The parameter used to decide about the type of the new main - * UTXO output. P2WPKH if `true`, P2PKH if `false`. + * @param witness - Determines the type of the new main UTXO output: P2WPKH if + * `true`, P2PKH if `false`. * @param utxos - UTXOs from new deposit transactions. Must be P2(W)SH. - * @param deposits - Array of deposits. Each element corresponds to UTXO. - * The number of UTXOs and deposit elements must equal. - * @param mainUtxo - main UTXO of the wallet, which is a P2WKH UTXO resulting - * from the previous wallet transaction (optional). - * @returns The outcome consisting of: - * - the sweep transaction hash, - * - the new wallet's main UTXO produced by this transaction. - * - the sweep transaction in the raw format + * @param deposits - Deposit data corresponding to each UTXO. The number of + * UTXOs and deposits must match. + * @param mainUtxo - The wallet's main UTXO (optional), which is a P2(W)PKH UTXO + * from a previous transaction. + * @returns An object containing the sweep transaction hash, new wallet's main + * UTXO, and the raw deposit sweep transaction representation. + * @throws Error if the provided UTXOs and deposits mismatch or if an unsupported + * UTXO script type is encountered. */ export async function assembleDepositSweepTransaction( bitcoinNetwork: BitcoinNetwork, @@ -223,7 +224,7 @@ export async function assembleDepositSweepTransaction( transaction, inputIndex, deposit, - previousOutput.value, + previousOutputValue, keyPair ) } else if (isP2WSH(previousOutputScript)) { @@ -255,6 +256,19 @@ export async function assembleDepositSweepTransaction( } } +/** + * Signs the main UTXO transaction input and sets the appropriate script or + * witness data. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param prevOutScript - The previous output script for the input. + * @param prevOutValue - The value from the previous transaction output. + * @param keyPair - A Signer object with the public and private key pair. + * @param network - The Bitcoin network type (mainnet or testnet). + * @returns An empty promise upon successful signing. + * @throws Error if the UTXO doesn't belong to the wallet, or if the script + * format is invalid or unknown. + */ async function signMainUtxoInput( transaction: Transaction, inputIndex: number, @@ -322,7 +336,15 @@ async function signMainUtxoInput( } } -// TODO: Description. +/** + * Signs a P2SH deposit transaction input and sets the `scriptSig`. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param deposit - Details of the deposit transaction. + * @param prevOutValue - The value from the previous transaction output. + * @param keyPair - A Signer object with the public and private key pair. + * @returns An empty promise upon successful signing. + */ async function signP2SHDepositInput( transaction: Transaction, inputIndex: number, @@ -330,8 +352,11 @@ async function signP2SHDepositInput( prevOutValue: number, keyPair: Signer ) { - const { walletPublicKey, depositScript } = - await prepareInputSignDataBitcoinIsLib(deposit, prevOutValue, keyPair) + const { walletPublicKey, depositScript } = await prepareInputSignData( + deposit, + prevOutValue, + keyPair + ) const sigHashType = Transaction.SIGHASH_ALL @@ -351,7 +376,15 @@ async function signP2SHDepositInput( transaction.ins[inputIndex].script = script.compile(scriptSig) } -// TODO: Description. +/** + * Signs a P2WSH deposit transaction input and sets the witness script. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param deposit - Details of the deposit transaction. + * @param prevOutValue - The value from the previous transaction output. + * @param keyPair - A Signer object with the public and private key pair. + * @returns An empty promise upon successful signing. + */ async function signP2WSHDepositInput( transaction: Transaction, inputIndex: number, @@ -360,7 +393,7 @@ async function signP2WSHDepositInput( keyPair: Signer ) { const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignDataBitcoinIsLib(deposit, prevOutValue, keyPair) + await prepareInputSignData(deposit, prevOutValue, keyPair) const sigHashType = Transaction.SIGHASH_ALL @@ -381,7 +414,18 @@ async function signP2WSHDepositInput( transaction.ins[inputIndex].witness = witness } -async function prepareInputSignDataBitcoinIsLib( +/** + * Prepares data for signing a deposit transaction input. + * @param deposit - The deposit details. + * @param prevOutValue - The value from the previous transaction output. + * @param ecPair - A Signer object with the public and private key pair. + * @returns A Promise resolving to: + * - walletPublicKey: Hexstring representation of the wallet's public key. + * - depositScript: Buffer containing the assembled deposit script. + * - previousOutputValue: Numeric value of the prior transaction output. + * @throws Error if there are discrepancies in values or key formats. + */ +async function prepareInputSignData( deposit: Deposit, prevOutValue: number, ecPair: Signer @@ -457,7 +501,20 @@ export async function submitDepositSweepProof( ) } -// TODO: Description and unit test. +/** + * Checks if a UTXO is owned by a provided key pair based on its previous output + * script. + * @dev The function assumes previous output script comes form the P2PKH or + * P2WPKH UTXO. + * @param keyPair - A Signer object containing the public key and private key + * pair. + * @param prevOutScript - A Buffer containing the previous output script of the + * UTXO. + * @param network - The Bitcoin network configuration, i.e. mainnet or testnet. + * @returns A boolean indicating whether the derived address from the UTXO's + * previous output script matches either of the P2PKH or P2WPKH + * addresses derived from the provided key pair. + */ export function ownsUtxo( keyPair: Signer, prevOutScript: Buffer, diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index 0d429efd3..be41c9a81 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -1052,8 +1052,6 @@ describe("Sweep", () => { let bridge: MockBridge beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() bridge = new MockBridge() From 6fe7ceaba981edb9176f1f578873ab70bbda6d77 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 26 Sep 2023 17:49:54 +0200 Subject: [PATCH 097/205] Updated calculating of deposit address --- typescript/src/deposit.ts | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 59d8606ec..c95726283 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -1,6 +1,6 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" -import { Stack, script, opcodes } from "bitcoinjs-lib" +import { Stack, payments, script, opcodes } from "bitcoinjs-lib" import { Client as BitcoinClient, decomposeRawTransaction, @@ -10,7 +10,10 @@ import { TransactionHash, isPublicKeyHashLength, } from "./bitcoin" -import { BitcoinNetwork, toBcoinNetwork } from "./bitcoin-network" +import { + BitcoinNetwork, + toBitcoinJsLibNetwork, +} from "./bitcoin-network" import { Bridge, Event, Identifier } from "./chain" import { Hex } from "./hex" @@ -361,10 +364,27 @@ export async function calculateDepositAddress( witness: boolean ): Promise { const scriptHash = await calculateDepositScriptHash(deposit, witness) - const address = witness - ? bcoin.Address.fromWitnessScripthash(scriptHash) - : bcoin.Address.fromScripthash(scriptHash) - return address.toString(toBcoinNetwork(network)) + const bitcoinNetwork = toBitcoinJsLibNetwork(network) + + if (witness) { + // OP_0 + const p2wshOutput = Buffer.concat([ + Buffer.from([opcodes.OP_0, 0x20]), + scriptHash, + ]) + + return payments.p2wsh({ output: p2wshOutput, network: bitcoinNetwork }) + .address! + } + + // OP_HASH160 OP_EQUAL + const p2shOutput = Buffer.concat([ + Buffer.from([opcodes.OP_HASH160, 0x14]), + scriptHash, + Buffer.from([opcodes.OP_EQUAL]), + ]) + + return payments.p2sh({ output: p2shOutput, network: bitcoinNetwork }).address! } /** From ec8a4996ce1cee5e98381c6fde0ea17fd9def5d7 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 26 Sep 2023 18:25:50 +0200 Subject: [PATCH 098/205] Updated calculating of deposit script hash --- typescript/src/bitcoin.ts | 12 ++++++++++++ typescript/src/deposit.ts | 15 ++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 63936a464..75b0f4163 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -524,6 +524,7 @@ export function createKeyRing( * @param text - Text the HASH160 is computed for. * @returns Hash as a 20-byte un-prefixed hex string. */ +// TODO: Make it use Hex for input and return values. export function computeHash160(text: string): string { const sha256Hash = utils.sha256( Hex.from(Buffer.from(text, "hex")).toPrefixedString() @@ -533,6 +534,17 @@ export function computeHash160(text: string): string { return Hex.from(hash160).toString() } +/** + * Computes the single SHA256 for the given text. + * @param text - Text the single SHA256 is computed for. + * @returns Hash as a 32-byte un-prefixed hex string. + */ +// TODO: Consider adding unit tests. +export function computeSha256(text: Hex): Hex { + const hash = utils.sha256(text.toPrefixedString()) + return Hex.from(hash) +} + /** * Computes the double SHA256 for the given text. * @param text - Text the double SHA256 is computed for. diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index c95726283..a30c13bf7 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -9,11 +9,10 @@ import { UnspentTransactionOutput, TransactionHash, isPublicKeyHashLength, + computeSha256, + computeHash160, } from "./bitcoin" -import { - BitcoinNetwork, - toBitcoinJsLibNetwork, -} from "./bitcoin-network" +import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" import { Bridge, Event, Identifier } from "./chain" import { Hex } from "./hex" @@ -343,11 +342,13 @@ export async function calculateDepositScriptHash( witness: boolean ): Promise { const script = await assembleDepositScript(deposit) - // Parse the script from HEX string. - const parsedScript = bcoin.Script.fromRaw(Buffer.from(script, "hex")) // If witness script hash should be produced, SHA256 should be used. // Legacy script hash needs HASH160. - return witness ? parsedScript.sha256() : parsedScript.hash160() + if (witness) { + return computeSha256(Hex.from(script)).toBuffer() + } + + return Buffer.from(computeHash160(script), "hex") } /** From bc969a945b64bb6f37d2586bd96a0a3e1000e223 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 10:32:49 +0200 Subject: [PATCH 099/205] Renamed functions for checking script type --- typescript/src/bitcoin.ts | 8 ++++---- typescript/src/deposit-sweep.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 63936a464..83f868ea5 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -691,7 +691,7 @@ export function readCompactSizeUint(varLenData: Hex): { * @param script The script to be checked. * @returns True if the script is P2PKH, false otherwise. */ -export function isP2PKH(script: Buffer): boolean { +export function isP2PKHScript(script: Buffer): boolean { try { payments.p2pkh({ output: script }) return true @@ -705,7 +705,7 @@ export function isP2PKH(script: Buffer): boolean { * @param script The script to be checked. * @returns True if the script is P2WPKH, false otherwise. */ -export function isP2WPKH(script: Buffer): boolean { +export function isP2WPKHScript(script: Buffer): boolean { try { payments.p2wpkh({ output: script }) return true @@ -719,7 +719,7 @@ export function isP2WPKH(script: Buffer): boolean { * @param script The script to be checked. * @returns True if the script is P2SH, false otherwise. */ -export function isP2SH(script: Buffer): boolean { +export function isP2SHScript(script: Buffer): boolean { try { payments.p2sh({ output: script }) return true @@ -733,7 +733,7 @@ export function isP2SH(script: Buffer): boolean { * @param script The script to be checked. * @returns True if the script is P2WSH, false otherwise. */ -export function isP2WSH(script: Buffer): boolean { +export function isP2WSHScript(script: Buffer): boolean { try { payments.p2wsh({ output: script }) return true diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 06f769115..70c42c42a 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -17,10 +17,10 @@ import { addressFromKeyPair, TransactionHash, computeHash160, - isP2PKH, - isP2WPKH, - isP2SH, - isP2WSH, + isP2PKHScript, + isP2WPKHScript, + isP2SHScript, + isP2WSHScript, } from "./bitcoin" import { assembleDepositScript, Deposit } from "./deposit" import { Bridge, Identifier } from "./chain" @@ -218,7 +218,7 @@ export async function assembleDepositSweepTransaction( const deposit = deposits[depositIndex] - if (isP2SH(previousOutputScript)) { + if (isP2SHScript(previousOutputScript)) { // P2SH (deposit UTXO) await signP2SHDepositInput( transaction, @@ -227,7 +227,7 @@ export async function assembleDepositSweepTransaction( previousOutputValue, keyPair ) - } else if (isP2WSH(previousOutputScript)) { + } else if (isP2WSHScript(previousOutputScript)) { // P2WSH (deposit UTXO) await signP2WSHDepositInput( transaction, @@ -283,7 +283,7 @@ async function signMainUtxoInput( const sigHashType = Transaction.SIGHASH_ALL - if (isP2PKH(prevOutScript)) { + if (isP2PKHScript(prevOutScript)) { // P2PKH const sigHash = transaction.hashForSignature( inputIndex, @@ -302,7 +302,7 @@ async function signMainUtxoInput( }).input! transaction.ins[inputIndex].script = scriptSig - } else if (isP2WPKH(prevOutScript)) { + } else if (isP2WPKHScript(prevOutScript)) { // P2WPKH const decompiledScript = script.decompile(prevOutScript) if ( From 3fee28303edea7886229914ae8fa6c909c3daa84 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 10:40:57 +0200 Subject: [PATCH 100/205] Disabled linitng error --- typescript/src/deposit-sweep.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 70c42c42a..d2e6b452e 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -25,7 +25,7 @@ import { import { assembleDepositScript, Deposit } from "./deposit" import { Bridge, Identifier } from "./chain" import { assembleTransactionProof } from "./proof" -import { ECPairFactory as ecFactory } from "ecpair" +import { ECPairFactory } from "ecpair" import * as tinysecp from "tiny-secp256k1" import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" @@ -151,7 +151,8 @@ export async function assembleDepositSweepTransaction( } const network = toBitcoinJsLibNetwork(bitcoinNetwork) - const keyPair = ecFactory(tinysecp).fromWIF(walletPrivateKey, network) + // eslint-disable-next-line new-cap + const keyPair = ECPairFactory(tinysecp).fromWIF(walletPrivateKey, network) const walletAddress = addressFromKeyPair(keyPair, network, witness) // Calculate the value of transaction's output. Note that the value of fee From d021ddc33d40a28768021528180d8d0c088b8c02 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 11:01:32 +0200 Subject: [PATCH 101/205] Refactored address generating function --- typescript/src/bitcoin.ts | 37 +++++++++++++++++++-------------- typescript/src/deposit-sweep.ts | 9 ++++++-- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 83f868ea5..4679c9bde 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -3,9 +3,12 @@ import wif from "wif" import bufio from "bufio" import { BigNumber, utils } from "ethers" import { Hex } from "./hex" -import { BitcoinNetwork, toBcoinNetwork } from "./bitcoin-network" -import { payments, networks } from "bitcoinjs-lib" -import { Signer } from "ecpair" +import { + BitcoinNetwork, + toBcoinNetwork, + toBitcoinJsLibNetwork, +} from "./bitcoin-network" +import { payments } from "bitcoinjs-lib" /** * Represents a transaction hash (or transaction ID) as an un-prefixed hex @@ -743,25 +746,27 @@ export function isP2WSHScript(script: Buffer): boolean { } /** - * Generates a Bitcoin address based on the provided key pair and network. - * Can produce either SegWit (P2WPKH) or Legacy (P2PKH) addresses. - * @param keyPair - The key pair used to derive the Bitcoin address. - * @param network - Specified Bitcoin network. - * @param witness - Boolean flag indicating if the address should be SegWit - * (P2WPKH) or not (P2PKH). - * @returns The generated Bitcoin address as a string. + * Generates a Bitcoin address from a public key. Supports SegWit (P2WPKH) and + * Legacy (P2PKH) formats. + * @param publicKey - Public key used to derive the Bitcoin address. + * @param bitcoinNetwork - Target Bitcoin network. + * @param witness - Flag to determine address format: true for SegWit (P2WPKH) + * and false for Legacy (P2PKH). Default is true. + * @returns The derived Bitcoin address. */ // TODO: Unit tests. -export function addressFromKeyPair( - keyPair: Signer, - network: networks.Network, - witness: boolean +export function publicKeyToAddress( + publicKey: Hex, + bitcoinNetwork: BitcoinNetwork, + witness: boolean = true ): string { + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + if (witness) { // P2WPKH (SegWit) - return payments.p2wpkh({ pubkey: keyPair.publicKey, network }).address! + return payments.p2wpkh({ pubkey: publicKey.toBuffer(), network }).address! } else { // P2PKH (Legacy) - return payments.p2pkh({ pubkey: keyPair.publicKey, network }).address! + return payments.p2pkh({ pubkey: publicKey.toBuffer(), network }).address! } } diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index d2e6b452e..0e744c370 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -8,13 +8,14 @@ import { networks, } from "bitcoinjs-lib" import { BigNumber } from "ethers" +import { Hex } from "./hex" import { RawTransaction, UnspentTransactionOutput, Client as BitcoinClient, decomposeRawTransaction, isCompressedPublicKey, - addressFromKeyPair, + publicKeyToAddress, TransactionHash, computeHash160, isP2PKHScript, @@ -153,7 +154,11 @@ export async function assembleDepositSweepTransaction( const network = toBitcoinJsLibNetwork(bitcoinNetwork) // eslint-disable-next-line new-cap const keyPair = ECPairFactory(tinysecp).fromWIF(walletPrivateKey, network) - const walletAddress = addressFromKeyPair(keyPair, network, witness) + const walletAddress = publicKeyToAddress( + Hex.from(keyPair.publicKey), + bitcoinNetwork, + witness + ) // Calculate the value of transaction's output. Note that the value of fee // needs to be subtracted from the sum. From 770032c86d128432817958704bb94decda957f84 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 11:07:41 +0200 Subject: [PATCH 102/205] Renamed UTXO value sum variable --- typescript/src/deposit-sweep.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 0e744c370..8021be431 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -160,16 +160,14 @@ export async function assembleDepositSweepTransaction( witness ) - // Calculate the value of transaction's output. Note that the value of fee - // needs to be subtracted from the sum. - let totalInputValue = BigNumber.from(0) + let outputValue = BigNumber.from(0) if (mainUtxo) { - totalInputValue = totalInputValue.add(mainUtxo.value) + outputValue = outputValue.add(mainUtxo.value) } for (const utxo of utxos) { - totalInputValue = totalInputValue.add(utxo.value) + outputValue = outputValue.add(utxo.value) } - totalInputValue = totalInputValue.sub(fee) + outputValue = outputValue.sub(fee) // Create the transaction. const transaction = new Transaction() @@ -190,7 +188,7 @@ export async function assembleDepositSweepTransaction( // Add transaction output. const scriptPubKey = address.toOutputScript(walletAddress, network) - transaction.addOutput(scriptPubKey, totalInputValue.toNumber()) + transaction.addOutput(scriptPubKey, outputValue.toNumber()) // Sign the main UTXO input if there is main UTXO. if (mainUtxo) { From 039b2a9ed4f01ff7f0d9e92ec38685f1f29e5433 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 11:12:50 +0200 Subject: [PATCH 103/205] Moved input adding and output value calculation under the same loop --- typescript/src/deposit-sweep.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 8021be431..bf001cbd7 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -160,33 +160,25 @@ export async function assembleDepositSweepTransaction( witness ) - let outputValue = BigNumber.from(0) - if (mainUtxo) { - outputValue = outputValue.add(mainUtxo.value) - } - for (const utxo of utxos) { - outputValue = outputValue.add(utxo.value) - } - outputValue = outputValue.sub(fee) - - // Create the transaction. const transaction = new Transaction() - // Add the transaction's inputs. + let outputValue = BigNumber.from(0) if (mainUtxo) { transaction.addInput( mainUtxo.transactionHash.reverse().toBuffer(), mainUtxo.outputIndex ) + outputValue = outputValue.add(mainUtxo.value) } for (const utxo of utxos) { transaction.addInput( utxo.transactionHash.reverse().toBuffer(), utxo.outputIndex ) + outputValue = outputValue.add(utxo.value) } + outputValue = outputValue.sub(fee) - // Add transaction output. const scriptPubKey = address.toOutputScript(walletAddress, network) transaction.addOutput(scriptPubKey, outputValue.toNumber()) From 536c989a83f164165d5ab435ea2f307654c0cac5 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 11:24:12 +0200 Subject: [PATCH 104/205] Used createOutputScriptFromAddress --- typescript/src/deposit-sweep.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index bf001cbd7..4ef9be88a 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -3,7 +3,6 @@ import { Stack, Signer, payments, - address, script, networks, } from "bitcoinjs-lib" @@ -22,6 +21,7 @@ import { isP2WPKHScript, isP2SHScript, isP2WSHScript, + createOutputScriptFromAddress, } from "./bitcoin" import { assembleDepositScript, Deposit } from "./deposit" import { Bridge, Identifier } from "./chain" @@ -179,8 +179,8 @@ export async function assembleDepositSweepTransaction( } outputValue = outputValue.sub(fee) - const scriptPubKey = address.toOutputScript(walletAddress, network) - transaction.addOutput(scriptPubKey, outputValue.toNumber()) + const outputScript = createOutputScriptFromAddress(walletAddress) + transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) // Sign the main UTXO input if there is main UTXO. if (mainUtxo) { From 59fb549db1ebf7f92310cd5c1ac05dbdf9f34630 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 11:34:30 +0200 Subject: [PATCH 105/205] Key pair variable rename --- typescript/src/deposit-sweep.ts | 49 +++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 4ef9be88a..a49a47f29 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -153,9 +153,12 @@ export async function assembleDepositSweepTransaction( const network = toBitcoinJsLibNetwork(bitcoinNetwork) // eslint-disable-next-line new-cap - const keyPair = ECPairFactory(tinysecp).fromWIF(walletPrivateKey, network) + const walletKeyPair = ECPairFactory(tinysecp).fromWIF( + walletPrivateKey, + network + ) const walletAddress = publicKeyToAddress( - Hex.from(keyPair.publicKey), + Hex.from(walletKeyPair.publicKey), bitcoinNetwork, witness ) @@ -194,7 +197,7 @@ export async function assembleDepositSweepTransaction( inputIndex, previousOutput.script, previousOutput.value, - keyPair, + walletKeyPair, network ) } @@ -221,7 +224,7 @@ export async function assembleDepositSweepTransaction( inputIndex, deposit, previousOutputValue, - keyPair + walletKeyPair ) } else if (isP2WSHScript(previousOutputScript)) { // P2WSH (deposit UTXO) @@ -230,7 +233,7 @@ export async function assembleDepositSweepTransaction( inputIndex, deposit, previousOutputValue, - keyPair + walletKeyPair ) } else { throw new Error("Unsupported UTXO script type") @@ -259,7 +262,7 @@ export async function assembleDepositSweepTransaction( * @param inputIndex - Index pointing to the input within the transaction. * @param prevOutScript - The previous output script for the input. * @param prevOutValue - The value from the previous transaction output. - * @param keyPair - A Signer object with the public and private key pair. + * @param walletKeyPair - A Signer object with the public and private key pair. * @param network - The Bitcoin network type (mainnet or testnet). * @returns An empty promise upon successful signing. * @throws Error if the UTXO doesn't belong to the wallet, or if the script @@ -270,10 +273,10 @@ async function signMainUtxoInput( inputIndex: number, prevOutScript: Buffer, prevOutValue: number, - keyPair: Signer, + walletKeyPair: Signer, network: networks.Network ) { - if (!ownsUtxo(keyPair, prevOutScript, network)) { + if (!ownsUtxo(walletKeyPair, prevOutScript, network)) { throw new Error("UTXO does not belong to the wallet") } @@ -288,13 +291,13 @@ async function signMainUtxoInput( ) const signature = script.signature.encode( - keyPair.sign(sigHash), + walletKeyPair.sign(sigHash), sigHashType ) const scriptSig = payments.p2pkh({ signature: signature, - pubkey: keyPair.publicKey, + pubkey: walletKeyPair.publicKey, }).input! transaction.ins[inputIndex].script = scriptSig @@ -322,11 +325,11 @@ async function signMainUtxoInput( ) const signature = script.signature.encode( - keyPair.sign(sigHash), + walletKeyPair.sign(sigHash), sigHashType ) - transaction.ins[inputIndex].witness = [signature, keyPair.publicKey] + transaction.ins[inputIndex].witness = [signature, walletKeyPair.publicKey] } else { throw new Error("Unknown type of main UTXO") } @@ -338,7 +341,7 @@ async function signMainUtxoInput( * @param inputIndex - Index pointing to the input within the transaction. * @param deposit - Details of the deposit transaction. * @param prevOutValue - The value from the previous transaction output. - * @param keyPair - A Signer object with the public and private key pair. + * @param walletKeyPair - A Signer object with the public and private key pair. * @returns An empty promise upon successful signing. */ async function signP2SHDepositInput( @@ -346,12 +349,12 @@ async function signP2SHDepositInput( inputIndex: number, deposit: Deposit, prevOutValue: number, - keyPair: Signer + walletKeyPair: Signer ) { const { walletPublicKey, depositScript } = await prepareInputSignData( deposit, prevOutValue, - keyPair + walletKeyPair ) const sigHashType = Transaction.SIGHASH_ALL @@ -362,7 +365,10 @@ async function signP2SHDepositInput( sigHashType ) - const signature = script.signature.encode(keyPair.sign(sigHash), sigHashType) + const signature = script.signature.encode( + walletKeyPair.sign(sigHash), + sigHashType + ) const scriptSig: Stack = [] scriptSig.push(signature) @@ -378,7 +384,7 @@ async function signP2SHDepositInput( * @param inputIndex - Index pointing to the input within the transaction. * @param deposit - Details of the deposit transaction. * @param prevOutValue - The value from the previous transaction output. - * @param keyPair - A Signer object with the public and private key pair. + * @param walletKeyPair - A Signer object with the public and private key pair. * @returns An empty promise upon successful signing. */ async function signP2WSHDepositInput( @@ -386,10 +392,10 @@ async function signP2WSHDepositInput( inputIndex: number, deposit: Deposit, prevOutValue: number, - keyPair: Signer + walletKeyPair: Signer ) { const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData(deposit, prevOutValue, keyPair) + await prepareInputSignData(deposit, prevOutValue, walletKeyPair) const sigHashType = Transaction.SIGHASH_ALL @@ -400,7 +406,10 @@ async function signP2WSHDepositInput( sigHashType ) - const signature = script.signature.encode(keyPair.sign(sigHash), sigHashType) + const signature = script.signature.encode( + walletKeyPair.sign(sigHash), + sigHashType + ) const witness: Buffer[] = [] witness.push(signature) From be1b1fe44aa1784fb28c630a62dcc1b10a85e0a6 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 11:40:06 +0200 Subject: [PATCH 106/205] Replaced network type with Bitcoin Network --- typescript/src/deposit-sweep.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index a49a47f29..2b4ec06cd 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,11 +1,4 @@ -import { - Transaction, - Stack, - Signer, - payments, - script, - networks, -} from "bitcoinjs-lib" +import { Transaction, Stack, Signer, payments, script } from "bitcoinjs-lib" import { BigNumber } from "ethers" import { Hex } from "./hex" import { @@ -198,7 +191,7 @@ export async function assembleDepositSweepTransaction( previousOutput.script, previousOutput.value, walletKeyPair, - network + bitcoinNetwork ) } @@ -263,7 +256,7 @@ export async function assembleDepositSweepTransaction( * @param prevOutScript - The previous output script for the input. * @param prevOutValue - The value from the previous transaction output. * @param walletKeyPair - A Signer object with the public and private key pair. - * @param network - The Bitcoin network type (mainnet or testnet). + * @param bitcoinNetwork - The Bitcoin network type. * @returns An empty promise upon successful signing. * @throws Error if the UTXO doesn't belong to the wallet, or if the script * format is invalid or unknown. @@ -274,9 +267,9 @@ async function signMainUtxoInput( prevOutScript: Buffer, prevOutValue: number, walletKeyPair: Signer, - network: networks.Network + bitcoinNetwork: BitcoinNetwork ) { - if (!ownsUtxo(walletKeyPair, prevOutScript, network)) { + if (!ownsUtxo(walletKeyPair, prevOutScript, bitcoinNetwork)) { throw new Error("UTXO does not belong to the wallet") } @@ -515,7 +508,7 @@ export async function submitDepositSweepProof( * pair. * @param prevOutScript - A Buffer containing the previous output script of the * UTXO. - * @param network - The Bitcoin network configuration, i.e. mainnet or testnet. + * @param bitcoinNetwork - The Bitcoin network type. * @returns A boolean indicating whether the derived address from the UTXO's * previous output script matches either of the P2PKH or P2WPKH * addresses derived from the provided key pair. @@ -523,8 +516,10 @@ export async function submitDepositSweepProof( export function ownsUtxo( keyPair: Signer, prevOutScript: Buffer, - network: networks.Network + bitcoinNetwork: BitcoinNetwork ): boolean { + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + // Derive P2PKH and P2WPKH addresses from the public key. const p2pkhAddress = payments.p2pkh({ pubkey: keyPair.publicKey, network }).address || "" From 783a3bb9d9328e550f738ed4be9b1ba588859cb9 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 11:46:46 +0200 Subject: [PATCH 107/205] Passed whole previous output instead of splitting --- typescript/src/deposit-sweep.ts | 39 +++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 2b4ec06cd..4355293c5 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,4 +1,11 @@ -import { Transaction, Stack, Signer, payments, script } from "bitcoinjs-lib" +import { + Transaction, + TxOutput, + Stack, + Signer, + payments, + script, +} from "bitcoinjs-lib" import { BigNumber } from "ethers" import { Hex } from "./hex" import { @@ -188,8 +195,7 @@ export async function assembleDepositSweepTransaction( await signMainUtxoInput( transaction, inputIndex, - previousOutput.script, - previousOutput.value, + previousOutput, walletKeyPair, bitcoinNetwork ) @@ -253,9 +259,9 @@ export async function assembleDepositSweepTransaction( * witness data. * @param transaction - The transaction containing the input to be signed. * @param inputIndex - Index pointing to the input within the transaction. - * @param prevOutScript - The previous output script for the input. - * @param prevOutValue - The value from the previous transaction output. - * @param walletKeyPair - A Signer object with the public and private key pair. + * @param previousOutput - The previous output for the main UTXO input. + * @param walletKeyPair - A Signer object with the wallet's public and private + * key pair. * @param bitcoinNetwork - The Bitcoin network type. * @returns An empty promise upon successful signing. * @throws Error if the UTXO doesn't belong to the wallet, or if the script @@ -264,22 +270,21 @@ export async function assembleDepositSweepTransaction( async function signMainUtxoInput( transaction: Transaction, inputIndex: number, - prevOutScript: Buffer, - prevOutValue: number, + previousOutput: TxOutput, walletKeyPair: Signer, bitcoinNetwork: BitcoinNetwork ) { - if (!ownsUtxo(walletKeyPair, prevOutScript, bitcoinNetwork)) { + if (!ownsUtxo(walletKeyPair, previousOutput.script, bitcoinNetwork)) { throw new Error("UTXO does not belong to the wallet") } const sigHashType = Transaction.SIGHASH_ALL - if (isP2PKHScript(prevOutScript)) { + if (isP2PKHScript(previousOutput.script)) { // P2PKH const sigHash = transaction.hashForSignature( inputIndex, - prevOutScript, + previousOutput.script, sigHashType ) @@ -294,9 +299,9 @@ async function signMainUtxoInput( }).input! transaction.ins[inputIndex].script = scriptSig - } else if (isP2WPKHScript(prevOutScript)) { + } else if (isP2WPKHScript(previousOutput.script)) { // P2WPKH - const decompiledScript = script.decompile(prevOutScript) + const decompiledScript = script.decompile(previousOutput.script) if ( !decompiledScript || decompiledScript.length !== 2 || @@ -313,7 +318,7 @@ async function signMainUtxoInput( const sigHash = transaction.hashForWitnessV0( inputIndex, p2pkhScript, - prevOutValue, + previousOutput.value, sigHashType ) @@ -334,7 +339,8 @@ async function signMainUtxoInput( * @param inputIndex - Index pointing to the input within the transaction. * @param deposit - Details of the deposit transaction. * @param prevOutValue - The value from the previous transaction output. - * @param walletKeyPair - A Signer object with the public and private key pair. + * @param walletKeyPair - A Signer object with the wallet's public and private + * key pair. * @returns An empty promise upon successful signing. */ async function signP2SHDepositInput( @@ -377,7 +383,8 @@ async function signP2SHDepositInput( * @param inputIndex - Index pointing to the input within the transaction. * @param deposit - Details of the deposit transaction. * @param prevOutValue - The value from the previous transaction output. - * @param walletKeyPair - A Signer object with the public and private key pair. + * @param walletKeyPair - A Signer object with the wallet's public and private + * key pair. * @returns An empty promise upon successful signing. */ async function signP2WSHDepositInput( From 98b622a5628e24d69b073ce22d713a8995ce0b2a Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 12:03:32 +0200 Subject: [PATCH 108/205] Refactored deposit assembling --- typescript/src/deposit-sweep.ts | 57 +++++++++++++++------------------ 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 4355293c5..2ea592072 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -338,7 +338,7 @@ async function signMainUtxoInput( * @param transaction - The transaction containing the input to be signed. * @param inputIndex - Index pointing to the input within the transaction. * @param deposit - Details of the deposit transaction. - * @param prevOutValue - The value from the previous transaction output. + * @param previousOutputValue - The value from the previous transaction output. * @param walletKeyPair - A Signer object with the wallet's public and private * key pair. * @returns An empty promise upon successful signing. @@ -347,12 +347,12 @@ async function signP2SHDepositInput( transaction: Transaction, inputIndex: number, deposit: Deposit, - prevOutValue: number, + previousOutputValue: number, walletKeyPair: Signer ) { - const { walletPublicKey, depositScript } = await prepareInputSignData( + const depositScript = await prepareDepositScript( deposit, - prevOutValue, + previousOutputValue, walletKeyPair ) @@ -371,7 +371,7 @@ async function signP2SHDepositInput( const scriptSig: Stack = [] scriptSig.push(signature) - scriptSig.push(Buffer.from(walletPublicKey, "hex")) + scriptSig.push(walletKeyPair.publicKey) scriptSig.push(depositScript) transaction.ins[inputIndex].script = script.compile(scriptSig) @@ -382,7 +382,7 @@ async function signP2SHDepositInput( * @param transaction - The transaction containing the input to be signed. * @param inputIndex - Index pointing to the input within the transaction. * @param deposit - Details of the deposit transaction. - * @param prevOutValue - The value from the previous transaction output. + * @param previousOutputValue - The value from the previous transaction output. * @param walletKeyPair - A Signer object with the wallet's public and private * key pair. * @returns An empty promise upon successful signing. @@ -391,11 +391,14 @@ async function signP2WSHDepositInput( transaction: Transaction, inputIndex: number, deposit: Deposit, - prevOutValue: number, + previousOutputValue: number, walletKeyPair: Signer ) { - const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData(deposit, prevOutValue, walletKeyPair) + const depositScript = await prepareDepositScript( + deposit, + previousOutputValue, + walletKeyPair + ) const sigHashType = Transaction.SIGHASH_ALL @@ -413,37 +416,31 @@ async function signP2WSHDepositInput( const witness: Buffer[] = [] witness.push(signature) - witness.push(Buffer.from(walletPublicKey, "hex")) + witness.push(walletKeyPair.publicKey) witness.push(depositScript) transaction.ins[inputIndex].witness = witness } /** - * Prepares data for signing a deposit transaction input. + * Assembles the deposit script based on the given deposit details. Performs + * validations on values and key formats. * @param deposit - The deposit details. - * @param prevOutValue - The value from the previous transaction output. - * @param ecPair - A Signer object with the public and private key pair. - * @returns A Promise resolving to: - * - walletPublicKey: Hexstring representation of the wallet's public key. - * - depositScript: Buffer containing the assembled deposit script. - * - previousOutputValue: Numeric value of the prior transaction output. + * @param previousOutputValue - Value from the previous transaction output. + * @param walletKeyPair - Signer object containing the wallet's key pair. + * @returns A Promise resolving to the assembled deposit script as a Buffer. * @throws Error if there are discrepancies in values or key formats. */ -async function prepareInputSignData( +async function prepareDepositScript( deposit: Deposit, - prevOutValue: number, - ecPair: Signer -): Promise<{ - walletPublicKey: string - depositScript: any - previousOutputValue: number -}> { - if (prevOutValue != deposit.amount.toNumber()) { + previousOutputValue: number, + walletKeyPair: Signer +): Promise { + if (previousOutputValue != deposit.amount.toNumber()) { throw new Error("Mismatch between amount in deposit and deposit tx") } - const walletPublicKey = ecPair.publicKey.toString("hex") + const walletPublicKey = walletKeyPair.publicKey.toString("hex") if (computeHash160(walletPublicKey) != deposit.walletPublicKeyHash) { throw new Error( @@ -463,11 +460,7 @@ async function prepareInputSignData( "hex" ) - return { - walletPublicKey, - depositScript: depositScript, - previousOutputValue: deposit.amount.toNumber(), - } + return depositScript } /** From e5c6ea2969c82701458e928bf3ff34c8f9585585 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 12:09:01 +0200 Subject: [PATCH 109/205] Renamed output script variable --- typescript/src/deposit-sweep.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 2ea592072..bdd66a8c8 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -506,7 +506,7 @@ export async function submitDepositSweepProof( * P2WPKH UTXO. * @param keyPair - A Signer object containing the public key and private key * pair. - * @param prevOutScript - A Buffer containing the previous output script of the + * @param outputScript - A Buffer containing the previous output script of the * UTXO. * @param bitcoinNetwork - The Bitcoin network type. * @returns A boolean indicating whether the derived address from the UTXO's @@ -515,7 +515,7 @@ export async function submitDepositSweepProof( */ export function ownsUtxo( keyPair: Signer, - prevOutScript: Buffer, + outputScript: Buffer, bitcoinNetwork: BitcoinNetwork ): boolean { const network = toBitcoinJsLibNetwork(bitcoinNetwork) @@ -526,19 +526,19 @@ export function ownsUtxo( const p2wpkhAddress = payments.p2wpkh({ pubkey: keyPair.publicKey, network }).address || "" - // Try to extract an address from the provided prevOutScript. + // Try to extract an address from the provided output script. let addressFromOutput = "" try { addressFromOutput = - payments.p2pkh({ output: prevOutScript, network }).address || "" + payments.p2pkh({ output: outputScript, network }).address || "" } catch (e) { // If not P2PKH, try P2WPKH. try { addressFromOutput = - payments.p2wpkh({ output: prevOutScript, network }).address || "" + payments.p2wpkh({ output: outputScript, network }).address || "" } catch (err) { - // If neither p2pkh nor p2wpkh address can be derived, assume the previous - // output script comes from a different UTXO type or is corrupted. + // If neither p2pkh nor p2wpkh address can be derived, assume the output + // script comes from a different UTXO type or is corrupted. return false } } From 6099e46a5c0bac81e7d1c9776f5d41712d1581d0 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 12:15:49 +0200 Subject: [PATCH 110/205] Refactored UTXO ownership validation function --- typescript/src/deposit-sweep.ts | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index bdd66a8c8..323b67706 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -274,7 +274,13 @@ async function signMainUtxoInput( walletKeyPair: Signer, bitcoinNetwork: BitcoinNetwork ) { - if (!ownsUtxo(walletKeyPair, previousOutput.script, bitcoinNetwork)) { + if ( + !ownsUtxo( + Hex.from(walletKeyPair.publicKey), + previousOutput.script, + bitcoinNetwork + ) + ) { throw new Error("UTXO does not belong to the wallet") } @@ -500,21 +506,17 @@ export async function submitDepositSweepProof( } /** - * Checks if a UTXO is owned by a provided key pair based on its previous output - * script. - * @dev The function assumes previous output script comes form the P2PKH or - * P2WPKH UTXO. - * @param keyPair - A Signer object containing the public key and private key - * pair. - * @param outputScript - A Buffer containing the previous output script of the - * UTXO. + * Checks if the UTXO is owned by the provided public key based on its previous + * output script. + * @dev The function assumes output script comes form the P2PKH or P2WPKH UTXO. + * @param publicKey - Public key for UTXO ownership validation. + * @param outputScript - Buffer of the UTXO's previous output script. * @param bitcoinNetwork - The Bitcoin network type. - * @returns A boolean indicating whether the derived address from the UTXO's - * previous output script matches either of the P2PKH or P2WPKH - * addresses derived from the provided key pair. + * @returns True if the UTXO's address from the output script matches P2PKH + * or P2WPKH addresses derived from the key pair. False otherwise. */ export function ownsUtxo( - keyPair: Signer, + publicKey: Hex, outputScript: Buffer, bitcoinNetwork: BitcoinNetwork ): boolean { @@ -522,9 +524,9 @@ export function ownsUtxo( // Derive P2PKH and P2WPKH addresses from the public key. const p2pkhAddress = - payments.p2pkh({ pubkey: keyPair.publicKey, network }).address || "" + payments.p2pkh({ pubkey: publicKey.toBuffer(), network }).address || "" const p2wpkhAddress = - payments.p2wpkh({ pubkey: keyPair.publicKey, network }).address || "" + payments.p2wpkh({ pubkey: publicKey.toBuffer(), network }).address || "" // Try to extract an address from the provided output script. let addressFromOutput = "" From b0eac234470947361c8235fbff563bf48f96eb3d Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 14:46:14 +0200 Subject: [PATCH 111/205] Refactor function checking if UTXO can be spent --- typescript/src/deposit-sweep.ts | 65 ++++++++------------------------- 1 file changed, 15 insertions(+), 50 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 323b67706..8fb7e4687 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -196,8 +196,7 @@ export async function assembleDepositSweepTransaction( transaction, inputIndex, previousOutput, - walletKeyPair, - bitcoinNetwork + walletKeyPair ) } @@ -271,15 +270,10 @@ async function signMainUtxoInput( transaction: Transaction, inputIndex: number, previousOutput: TxOutput, - walletKeyPair: Signer, - bitcoinNetwork: BitcoinNetwork + walletKeyPair: Signer ) { if ( - !ownsUtxo( - Hex.from(walletKeyPair.publicKey), - previousOutput.script, - bitcoinNetwork - ) + !canSpendOutput(Hex.from(walletKeyPair.publicKey), previousOutput.script) ) { throw new Error("UTXO does not belong to the wallet") } @@ -506,47 +500,18 @@ export async function submitDepositSweepProof( } /** - * Checks if the UTXO is owned by the provided public key based on its previous - * output script. - * @dev The function assumes output script comes form the P2PKH or P2WPKH UTXO. - * @param publicKey - Public key for UTXO ownership validation. - * @param outputScript - Buffer of the UTXO's previous output script. - * @param bitcoinNetwork - The Bitcoin network type. - * @returns True if the UTXO's address from the output script matches P2PKH - * or P2WPKH addresses derived from the key pair. False otherwise. + * Determines if a UTXO's output script can be spent using the provided public + * key. + * @param publicKey - Public key used to derive the corresponding P2PKH and + * P2WPKH output scripts. + * @param outputScript - The output script of the UTXO in question. + * @returns True if the provided output script matches the P2PKH or P2WPKH + * output scripts derived from the given public key. False otherwise. */ -export function ownsUtxo( - publicKey: Hex, - outputScript: Buffer, - bitcoinNetwork: BitcoinNetwork -): boolean { - const network = toBitcoinJsLibNetwork(bitcoinNetwork) +function canSpendOutput(publicKey: Hex, outputScript: Buffer): boolean { + const pubkeyBuffer = publicKey.toBuffer() + const p2pkhOutput = payments.p2pkh({ pubkey: pubkeyBuffer }).output! + const p2wpkhOutput = payments.p2wpkh({ pubkey: pubkeyBuffer }).output! - // Derive P2PKH and P2WPKH addresses from the public key. - const p2pkhAddress = - payments.p2pkh({ pubkey: publicKey.toBuffer(), network }).address || "" - const p2wpkhAddress = - payments.p2wpkh({ pubkey: publicKey.toBuffer(), network }).address || "" - - // Try to extract an address from the provided output script. - let addressFromOutput = "" - try { - addressFromOutput = - payments.p2pkh({ output: outputScript, network }).address || "" - } catch (e) { - // If not P2PKH, try P2WPKH. - try { - addressFromOutput = - payments.p2wpkh({ output: outputScript, network }).address || "" - } catch (err) { - // If neither p2pkh nor p2wpkh address can be derived, assume the output - // script comes from a different UTXO type or is corrupted. - return false - } - } - - // Check if the UTXO's address matches either of the derived addresses. - return ( - addressFromOutput === p2pkhAddress || addressFromOutput === p2wpkhAddress - ) + return outputScript.equals(p2pkhOutput) || outputScript.equals(p2wpkhOutput) } From 3fa34d91cf1ded905b7f5abf9691f91144df09cb Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 15:58:51 +0200 Subject: [PATCH 112/205] Simplified script calculation for p2wpkh main UTXO --- typescript/src/deposit-sweep.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 8fb7e4687..386d1e3ff 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -301,18 +301,8 @@ async function signMainUtxoInput( transaction.ins[inputIndex].script = scriptSig } else if (isP2WPKHScript(previousOutput.script)) { // P2WPKH - const decompiledScript = script.decompile(previousOutput.script) - if ( - !decompiledScript || - decompiledScript.length !== 2 || - decompiledScript[0] !== 0x00 || - !Buffer.isBuffer(decompiledScript[1]) || - decompiledScript[1].length !== 20 - ) { - throw new Error("Invalid script format") - } - - const publicKeyHash = decompiledScript[1] + const publicKeyHash = payments.p2wpkh({ output: previousOutput.script }) + .hash! const p2pkhScript = payments.p2pkh({ hash: publicKeyHash }).output! const sigHash = transaction.hashForWitnessV0( From bfb593a632b1c42341bf63609010094878ef41d0 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 17:41:06 +0200 Subject: [PATCH 113/205] Added unit tests for createAddressFromPublicKey --- typescript/src/bitcoin.ts | 51 ++++++++++++++++----------------- typescript/src/deposit-sweep.ts | 4 +-- typescript/test/bitcoin.test.ts | 27 ++++++++++++++++- typescript/test/data/bitcoin.ts | 34 ++++++++++++++++++++++ 4 files changed, 87 insertions(+), 29 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 4679c9bde..8bf6b6a2e 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -649,6 +649,31 @@ export function createAddressFromOutputScript( ?.toString(toBcoinNetwork(network)) } +/** + * Creates the Bitcoin address from the public key. Supports SegWit (P2WPKH) and + * Legacy (P2PKH) formats. + * @param publicKey - Public key used to derive the Bitcoin address. + * @param bitcoinNetwork - Target Bitcoin network. + * @param witness - Flag to determine address format: true for SegWit (P2WPKH) + * and false for Legacy (P2PKH). Default is true. + * @returns The derived Bitcoin address. + */ +export function createAddressFromPublicKey( + publicKey: Hex, + bitcoinNetwork: BitcoinNetwork, + witness: boolean = true +): string { + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + + if (witness) { + // P2WPKH (SegWit) + return payments.p2wpkh({ pubkey: publicKey.toBuffer(), network }).address! + } else { + // P2PKH (Legacy) + return payments.p2pkh({ pubkey: publicKey.toBuffer(), network }).address! + } +} + /** * Reads the leading compact size uint from the provided variable length data. * @@ -744,29 +769,3 @@ export function isP2WSHScript(script: Buffer): boolean { return false } } - -/** - * Generates a Bitcoin address from a public key. Supports SegWit (P2WPKH) and - * Legacy (P2PKH) formats. - * @param publicKey - Public key used to derive the Bitcoin address. - * @param bitcoinNetwork - Target Bitcoin network. - * @param witness - Flag to determine address format: true for SegWit (P2WPKH) - * and false for Legacy (P2PKH). Default is true. - * @returns The derived Bitcoin address. - */ -// TODO: Unit tests. -export function publicKeyToAddress( - publicKey: Hex, - bitcoinNetwork: BitcoinNetwork, - witness: boolean = true -): string { - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - - if (witness) { - // P2WPKH (SegWit) - return payments.p2wpkh({ pubkey: publicKey.toBuffer(), network }).address! - } else { - // P2PKH (Legacy) - return payments.p2pkh({ pubkey: publicKey.toBuffer(), network }).address! - } -} diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 386d1e3ff..0627382d7 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -14,7 +14,7 @@ import { Client as BitcoinClient, decomposeRawTransaction, isCompressedPublicKey, - publicKeyToAddress, + createAddressFromPublicKey, TransactionHash, computeHash160, isP2PKHScript, @@ -157,7 +157,7 @@ export async function assembleDepositSweepTransaction( walletPrivateKey, network ) - const walletAddress = publicKeyToAddress( + const walletAddress = createAddressFromPublicKey( Hex.from(walletKeyPair.publicKey), bitcoinNetwork, witness diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 80eebfda5..c8a243f87 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -13,6 +13,7 @@ import { targetToDifficulty, createOutputScriptFromAddress, createAddressFromOutputScript, + createAddressFromPublicKey, readCompactSizeUint, computeHash160, computeHash256, @@ -21,7 +22,7 @@ import { calculateDepositRefundLocktime } from "../src/deposit" import { BitcoinNetwork } from "../src/bitcoin-network" import { Hex } from "../src/hex" import { BigNumber } from "ethers" -import { btcAddresses } from "./data/bitcoin" +import { btcAddresses, btcAddressFromPublicKey } from "./data/bitcoin" describe("Bitcoin", () => { describe("compressPublicKey", () => { @@ -535,6 +536,30 @@ describe("Bitcoin", () => { }) }) + describe("createAddressFromPublicKey", () => { + Object.entries(btcAddressFromPublicKey).forEach( + ([bitcoinNetwork, addressData]) => { + context(`with ${bitcoinNetwork} addresses`, () => { + Object.entries(addressData).forEach( + ([addressType, { publicKey, address }]) => { + it(`should return correct ${addressType} address for ${bitcoinNetwork}`, () => { + const witness = addressType === "P2WPKH" + const result = createAddressFromPublicKey( + publicKey, + bitcoinNetwork === "mainnet" + ? BitcoinNetwork.Mainnet + : BitcoinNetwork.Testnet, + witness + ) + expect(result).to.eq(address) + }) + } + ) + }) + } + ) + }) + describe("readCompactSizeUint", () => { context("when the compact size uint is 1-byte", () => { it("should return the the uint value and byte length", () => { diff --git a/typescript/test/data/bitcoin.ts b/typescript/test/data/bitcoin.ts index d44b4b737..b04baad81 100644 --- a/typescript/test/data/bitcoin.ts +++ b/typescript/test/data/bitcoin.ts @@ -70,3 +70,37 @@ export const btcAddresses: Record< }, }, } + +export const btcAddressFromPublicKey: Record< + Exclude, + Record +> = { + testnet: { + P2PKH: { + publicKey: Hex.from( + "0304cc460f320822d17d567a9a1b1039f765ff72512758605b5962226b3d8e5329" + ), + address: "msVQ3CCdqffxc5BtxUrtHFPq6CoZSTaJTq", + }, + P2WPKH: { + publicKey: Hex.from( + "0304cc460f320822d17d567a9a1b1039f765ff72512758605b5962226b3d8e5329" + ), + address: "tb1qsdtz442y5fmay39rj39vancf7jm0jrf40qkulw", + }, + }, + mainnet: { + P2PKH: { + publicKey: Hex.from( + "0304cc460f320822d17d567a9a1b1039f765ff72512758605b5962226b3d8e5329" + ), + address: "1CySk97f2eEhpxiHEutWTLBWEDCrZDbSCr", + }, + P2WPKH: { + publicKey: Hex.from( + "0304cc460f320822d17d567a9a1b1039f765ff72512758605b5962226b3d8e5329" + ), + address: "bc1qsdtz442y5fmay39rj39vancf7jm0jrf49xd0ya", + }, + }, +} From 96c204a239af9b51cbb57c9a4f334c04974bc64f Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 17:55:56 +0200 Subject: [PATCH 114/205] Added unit tests for toBitcoinJsLibNetwork --- typescript/test/bitcoin-network.test.ts | 34 +++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/typescript/test/bitcoin-network.test.ts b/typescript/test/bitcoin-network.test.ts index d2ff7b370..e610c2ee9 100644 --- a/typescript/test/bitcoin-network.test.ts +++ b/typescript/test/bitcoin-network.test.ts @@ -1,6 +1,11 @@ import { expect } from "chai" -import { BitcoinNetwork, toBcoinNetwork } from "../src/bitcoin-network" +import { + BitcoinNetwork, + toBcoinNetwork, + toBitcoinJsLibNetwork, +} from "../src/bitcoin-network" import { TransactionHash } from "../src/bitcoin" +import { networks } from "bitcoinjs-lib" describe("BitcoinNetwork", () => { const testData = [ @@ -10,6 +15,7 @@ describe("BitcoinNetwork", () => { // any value that doesn't match other supported networks genesisHash: TransactionHash.from("0x00010203"), expectedToBcoinResult: new Error("network not supported"), + expectedToBitcoinJsLibResult: new Error("network not supported"), }, { enumKey: BitcoinNetwork.Testnet, @@ -18,6 +24,7 @@ describe("BitcoinNetwork", () => { "0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" ), expectedToBcoinResult: "testnet", + expectedToBitcoinJsLibResult: networks.testnet, }, { enumKey: BitcoinNetwork.Mainnet, @@ -26,11 +33,18 @@ describe("BitcoinNetwork", () => { "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" ), expectedToBcoinResult: "main", + expectedToBitcoinJsLibResult: networks.bitcoin, }, ] testData.forEach( - ({ enumKey, enumValue, genesisHash, expectedToBcoinResult }) => { + ({ + enumKey, + enumValue, + genesisHash, + expectedToBcoinResult, + expectedToBitcoinJsLibResult, + }) => { context(enumKey, async () => { describe(`toString`, async () => { it(`should return correct value`, async () => { @@ -59,6 +73,22 @@ describe("BitcoinNetwork", () => { }) } }) + + describe(`toBitcoinJsLibNetwork`, async () => { + if (expectedToBitcoinJsLibResult instanceof Error) { + it(`should throw an error`, async () => { + expect(() => toBitcoinJsLibNetwork(enumKey)).to.throw( + expectedToBitcoinJsLibResult.message + ) + }) + } else { + it(`should return ${expectedToBitcoinJsLibResult}`, async () => { + expect(toBitcoinJsLibNetwork(enumKey)).to.be.equal( + expectedToBitcoinJsLibResult + ) + }) + } + }) }) } ) From a5ef9e89e617931fcda77bcf214e3ca3d7ae4208 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 27 Sep 2023 18:25:03 +0200 Subject: [PATCH 115/205] Added unit tests for script type functions --- typescript/test/bitcoin.test.ts | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index c8a243f87..0bcc335ba 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -17,6 +17,10 @@ import { readCompactSizeUint, computeHash160, computeHash256, + isP2PKHScript, + isP2WPKHScript, + isP2SHScript, + isP2WSHScript, } from "../src/bitcoin" import { calculateDepositRefundLocktime } from "../src/deposit" import { BitcoinNetwork } from "../src/bitcoin-network" @@ -596,4 +600,57 @@ describe("Bitcoin", () => { }) }) }) + + describe("Bitcoin Script Type", () => { + const testData = [ + { + testFunction: isP2PKHScript, + validScript: Buffer.from( + "76a9148db50eb52063ea9d98b3eac91489a90f738986f688ac", + "hex" + ), + name: "P2PKH", + }, + { + testFunction: isP2WPKHScript, + validScript: Buffer.from( + "00148db50eb52063ea9d98b3eac91489a90f738986f6", + "hex" + ), + name: "P2WPKH", + }, + { + testFunction: isP2SHScript, + validScript: Buffer.from( + "a914a9a5f97d5d3c4687a52e90718168270005b369c487", + "hex" + ), + name: "P2SH", + }, + { + testFunction: isP2WSHScript, + validScript: Buffer.from( + "0020b1f83e226979dc9fe74e87f6d303dbb08a27a1c7ce91664033f34c7f2d214cd7", + "hex" + ), + name: "P2WSH", + }, + ] + + testData.forEach(({ testFunction, validScript, name }) => { + describe(`is${name}Script`, () => { + it(`should return true for a valid ${name} script`, () => { + expect(testFunction(validScript)).to.be.true + }) + + it("should return false for other scripts", () => { + testData.forEach((data) => { + if (data.name !== name) { + expect(testFunction(data.validScript)).to.be.false + } + }) + }) + }) + }) + }) }) From c61a158f247532954dd7f3faa483bb86f8291d15 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 28 Sep 2023 17:03:16 +0200 Subject: [PATCH 116/205] Added coinselect library --- typescript/package.json | 1 + typescript/typings.d.ts | 1 + typescript/yarn.lock | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/typescript/package.json b/typescript/package.json index 806339a53..077d75b03 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -30,6 +30,7 @@ "bcoin": "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8", "bitcoinjs-lib": "6.0.2", "bufio": "^1.0.6", + "coinselect": "^3.1.13", "ecpair": "^2.1.0", "electrum-client-js": "git+https://github.com/keep-network/electrum-client-js.git#v0.1.1", "ethers": "^5.5.2", diff --git a/typescript/typings.d.ts b/typescript/typings.d.ts index 2558e6a79..82aae9dd0 100644 --- a/typescript/typings.d.ts +++ b/typescript/typings.d.ts @@ -4,5 +4,6 @@ */ declare module "bcoin" declare module "bufio" +declare module "coinselect" declare module "electrum-client-js" declare module "wif" diff --git a/typescript/yarn.lock b/typescript/yarn.lock index 05897068f..3eb3e707f 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -3261,6 +3261,11 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= +coinselect@^3.1.13: + version "3.1.13" + resolved "https://registry.yarnpkg.com/coinselect/-/coinselect-3.1.13.tgz#b88c7f9659ed4891d1f1d0c894105b1c10ef89a1" + integrity sha512-iJOrKH/7N9gX0jRkxgOHuGjvzvoxUMSeylDhH1sHn+CjLjdin5R0Hz2WEBu/jrZV5OrHcm+6DMzxwu9zb5mSZg== + color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" From f44861073501423e2c81c9ae430d435ef4857993 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 28 Sep 2023 17:12:15 +0200 Subject: [PATCH 117/205] Created inputs and outputs for the deposit transaction --- typescript/src/deposit.ts | 78 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index a30c13bf7..7fa3b61a3 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -1,8 +1,10 @@ import bcoin from "bcoin" +import coinSelect from "coinselect" import { BigNumber } from "ethers" import { Stack, payments, script, opcodes } from "bitcoinjs-lib" import { Client as BitcoinClient, + createAddressFromPublicKey, decomposeRawTransaction, createKeyRing, RawTransaction, @@ -15,6 +17,8 @@ import { import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" import { Bridge, Event, Identifier } from "./chain" import { Hex } from "./hex" +import { ECPairFactory } from "ecpair" +import * as tinysecp from "tiny-secp256k1" // TODO: Replace all properties that are expected to be un-prefixed hexadecimal // strings with a Hex type. @@ -235,6 +239,80 @@ export async function assembleDepositTransaction( } } +// TODO: Description and name change. +export async function assembleDepositTransactionBitcoinJsLib( + bitcoinNetwork: BitcoinNetwork, + deposit: Deposit, + utxos: (UnspentTransactionOutput & RawTransaction)[], + depositorPrivateKey: string, + witness: boolean +): Promise<{ + transactionHash: TransactionHash + depositUtxo: UnspentTransactionOutput + rawTransaction: RawTransaction +}> { + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + // eslint-disable-next-line new-cap + const depositorKeyPair = ECPairFactory(tinysecp).fromWIF( + depositorPrivateKey, + network + ) + const depositorAddress = createAddressFromPublicKey( + Hex.from(depositorKeyPair.publicKey), + BitcoinNetwork.Mainnet + ) + console.log("depositor address", depositorAddress) + + // TODO: Think what this value should be. It seems to be the default + // value used by `bcoin`. Think if it should be fixed or based on the + // network current conditions. + const feeRate = 10000 + + const inputUtxos = [] + for (const utxo of utxos) { + inputUtxos.push({ + txId: utxo.transactionHash.reverse().toBuffer(), + vout: utxo.outputIndex, + value: utxo.value.toNumber(), + }) + } + + const depositAddress = await calculateDepositAddress( + deposit, + bitcoinNetwork, + witness + ) + const depositOutput = { + address: depositAddress, + value: deposit.amount.toNumber(), + } + const { inputs, outputs /* fee*/ } = coinSelect( + inputUtxos, + [depositOutput], + feeRate + ) + + if (!inputs || !outputs) { + throw new Error("Transaction could not be built from the provided UTXOs") + } + + // TODO: Fill with correct values. + const transactionHash = Hex.from("") + const transactionHex = "" + + return { + transactionHash, + depositUtxo: { + transactionHash, + outputIndex: 0, // The deposit is always the first output. + value: deposit.amount, + }, + rawTransaction: { + transactionHex: transactionHex, + }, + } +} + /** * Assembles a Bitcoin locking script for P2(W)SH deposit transaction. * @param deposit - Details of the deposit. From c1d3f0f1d35b7e7388e8a8142949bb607ebe8088 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 29 Sep 2023 10:28:03 +0200 Subject: [PATCH 118/205] Replaced bcoin with bitcoinjs-lib for redemptions --- typescript/src/redemption.ts | 121 +++++++++++++++-------------- typescript/test/redemption.test.ts | 31 ++++---- 2 files changed, 80 insertions(+), 72 deletions(-) diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index ab713199a..15632452a 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -1,17 +1,22 @@ -import bcoin from "bcoin" import { BigNumber } from "ethers" import { createKeyRing, + createAddressFromPublicKey, decomposeRawTransaction, RawTransaction, UnspentTransactionOutput, Client as BitcoinClient, TransactionHash, + isP2PKHScript, + isP2WPKHScript, } from "./bitcoin" import { Bridge, Event, Identifier, TBTCToken } from "./chain" import { assembleTransactionProof } from "./proof" import { determineWalletMainUtxo, WalletState } from "./wallet" -import { BitcoinNetwork } from "./bitcoin-network" +import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" +import { Psbt, Transaction } from "bitcoinjs-lib" +import { ECPairFactory } from "ecpair" +import * as tinysecp from "tiny-secp256k1" import { Hex } from "./hex" /** @@ -147,8 +152,11 @@ export async function submitRedemptionTransaction( "pending" ) + const bitcoinNetwork = await bitcoinClient.getNetwork() + const { transactionHash, newMainUtxo, rawTransaction } = - await assembleRedemptionTransaction( + await assembleRedemptionTransactionBitcoinJsLib( + bitcoinNetwork, walletPrivateKey, mainUtxoWithRaw, redemptionRequests, @@ -231,29 +239,9 @@ async function getWalletRedemptionRequests( return redemptionRequests } -/** - * Assembles a Bitcoin redemption transaction. - * The transaction will have a single input (main UTXO of the wallet making - * the redemption), an output for each redemption request provided, and a change - * output if the redemption requests do not consume the entire amount of the - * single input. - * @dev The caller is responsible for ensuring the redemption request list is - * correctly formed: - * - there is at least one redemption - * - the `requestedAmount` in each redemption request is greater than - * the sum of its `txFee` and `treasuryFee` - * @param walletPrivateKey - The private key of the wallet in the WIF format - * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO held - * by the on-chain Bridge contract - * @param redemptionRequests - The list of redemption requests - * @param witness - The parameter used to decide the type of the change output. - * P2WPKH if `true`, P2PKH if `false` - * @returns The outcome consisting of: - * - the redemption transaction hash, - * - the optional new wallet's main UTXO produced by this transaction. - * - the redemption transaction in the raw format - */ -export async function assembleRedemptionTransaction( +// TODO: Description. +export async function assembleRedemptionTransactionBitcoinJsLib( + bitcoinNetwork: BitcoinNetwork, walletPrivateKey: string, mainUtxo: UnspentTransactionOutput & RawTransaction, redemptionRequests: RedemptionRequest[], @@ -267,19 +255,46 @@ export async function assembleRedemptionTransaction( throw new Error("There must be at least one request to redeem") } - const walletKeyRing = createKeyRing(walletPrivateKey, witness) - const walletAddress = walletKeyRing.getAddress("string") + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + // eslint-disable-next-line new-cap + const walletKeyPair = ECPairFactory(tinysecp).fromWIF( + walletPrivateKey, + network + ) + const walletAddress = createAddressFromPublicKey( + Hex.from(walletKeyPair.publicKey), + bitcoinNetwork, + witness + ) - // Use the main UTXO as the single transaction input - const inputCoins = [ - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), - mainUtxo.outputIndex, - -1 - ), - ] + const psbt = new Psbt({ network }) + psbt.setVersion(1) - const transaction = new bcoin.MTX() + // Add input (current main UTXO). + const previousOutput = Transaction.fromHex(mainUtxo.transactionHex).outs[ + mainUtxo.outputIndex + ] + const previousOutputScript = previousOutput.script + const previousOutputValue = previousOutput.value + + if (isP2PKHScript(previousOutputScript)) { + psbt.addInput({ + hash: mainUtxo.transactionHash.reverse().toBuffer(), + index: mainUtxo.outputIndex, + nonWitnessUtxo: Buffer.from(mainUtxo.transactionHex), + }) + } else if (isP2WPKHScript(previousOutputScript)) { + psbt.addInput({ + hash: mainUtxo.transactionHash.reverse().toBuffer(), + index: mainUtxo.outputIndex, + witnessUtxo: { + script: previousOutputScript, + value: previousOutputValue, + }, + }) + } else { + throw new Error("Unexpected main UTXO type") + } let txTotalFee = BigNumber.from(0) let totalOutputsValue = BigNumber.from(0) @@ -303,44 +318,34 @@ export async function assembleRedemptionTransaction( // use the proposed fee and add the difference to outputs proportionally. txTotalFee = txTotalFee.add(request.txMaxFee) - transaction.addOutput({ - script: bcoin.Script.fromRaw( - Buffer.from(request.redeemerOutputScript, "hex") - ), + psbt.addOutput({ + script: Buffer.from(request.redeemerOutputScript, "hex"), value: outputValue.toNumber(), }) } - // If there is a change output, add it explicitly to the transaction. - // If we did not add this output explicitly, the bcoin library would add it - // anyway during funding, but if the value of the change output was very low, - // the library would consider it "dust" and add it to the fee rather than - // create a new output. + // If there is a change output, add it to the transaction. const changeOutputValue = mainUtxo.value .sub(totalOutputsValue) .sub(txTotalFee) if (changeOutputValue.gt(0)) { - transaction.addOutput({ - script: bcoin.Script.fromAddress(walletAddress), + psbt.addOutput({ + address: walletAddress, value: changeOutputValue.toNumber(), }) } - await transaction.fund(inputCoins, { - changeAddress: walletAddress, - hardFee: txTotalFee.toNumber(), - subtractFee: false, - }) - - transaction.sign(walletKeyRing) + psbt.signAllInputs(walletKeyPair) + psbt.finalizeAllInputs() - const transactionHash = TransactionHash.from(transaction.txid()) + const transaction = psbt.extractTransaction() + const transactionHash = TransactionHash.from(transaction.getId()) // If there is a change output, it will be the new wallet's main UTXO. const newMainUtxo = changeOutputValue.gt(0) ? { transactionHash, // It was the last output added to the transaction. - outputIndex: transaction.outputs.length - 1, + outputIndex: transaction.outs.length - 1, value: changeOutputValue, } : undefined @@ -349,7 +354,7 @@ export async function assembleRedemptionTransaction( transactionHash, newMainUtxo, rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), + transactionHex: transaction.toHex(), }, } } diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index 58bac10cc..c65f6c32d 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -23,7 +23,7 @@ import { findWalletForRedemptionData, } from "./data/redemption" import { - assembleRedemptionTransaction, + assembleRedemptionTransactionBitcoinJsLib, findWalletForRedemption, getRedemptionRequest, RedemptionRequest, @@ -53,8 +53,6 @@ describe("Redemption", () => { const token: MockTBTCToken = new MockTBTCToken() beforeEach(async () => { - bcoin.set("testnet") - await requestRedemption( walletPublicKey, mainUtxo, @@ -82,7 +80,6 @@ describe("Redemption", () => { let bridge: MockBridge beforeEach(async () => { - bcoin.set("testnet") bitcoinClient = new MockBitcoinClient() bridge = new MockBridge() }) @@ -497,7 +494,8 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransaction( + } = await assembleRedemptionTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -610,7 +608,8 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransaction( + } = await assembleRedemptionTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -722,7 +721,8 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransaction( + } = await assembleRedemptionTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -834,7 +834,8 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransaction( + } = await assembleRedemptionTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -945,7 +946,8 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransaction( + } = await assembleRedemptionTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -1102,7 +1104,8 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransaction( + } = await assembleRedemptionTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -1208,7 +1211,8 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransaction( + } = await assembleRedemptionTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -1297,7 +1301,8 @@ describe("Redemption", () => { it("should revert", async () => { await expect( - assembleRedemptionTransaction( + assembleRedemptionTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, [], // empty list of redemption requests @@ -1321,8 +1326,6 @@ describe("Redemption", () => { let bridge: MockBridge beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() bridge = new MockBridge() From 17f4917198e8778597255b38198ea4be26f0f548 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 29 Sep 2023 11:12:38 +0200 Subject: [PATCH 119/205] Added description and renamed function --- typescript/src/redemption.ts | 28 +++++++++++++++++++++++++--- typescript/test/redemption.test.ts | 18 +++++++++--------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index 15632452a..a304312f7 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -155,7 +155,7 @@ export async function submitRedemptionTransaction( const bitcoinNetwork = await bitcoinClient.getNetwork() const { transactionHash, newMainUtxo, rawTransaction } = - await assembleRedemptionTransactionBitcoinJsLib( + await assembleRedemptionTransaction( bitcoinNetwork, walletPrivateKey, mainUtxoWithRaw, @@ -239,8 +239,30 @@ async function getWalletRedemptionRequests( return redemptionRequests } -// TODO: Description. -export async function assembleRedemptionTransactionBitcoinJsLib( +/** + * Assembles a Bitcoin redemption transaction. + * The transaction will have a single input (main UTXO of the wallet making + * the redemption), an output for each redemption request provided, and a change + * output if the redemption requests do not consume the entire amount of the + * single input. + * @dev The caller is responsible for ensuring the redemption request list is + * correctly formed: + * - there is at least one redemption + * - the `requestedAmount` in each redemption request is greater than + * the sum of its `txFee` and `treasuryFee` + * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). + * @param walletPrivateKey - The private key of the wallet in the WIF format + * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO held + * by the on-chain Bridge contract + * @param redemptionRequests - The list of redemption requests + * @param witness - The parameter used to decide the type of the change output. + * P2WPKH if `true`, P2PKH if `false` + * @returns The outcome consisting of: + * - the redemption transaction hash, + * - the optional new wallet's main UTXO produced by this transaction. + * - the redemption transaction in the raw format + */ +export async function assembleRedemptionTransaction( bitcoinNetwork: BitcoinNetwork, walletPrivateKey: string, mainUtxo: UnspentTransactionOutput & RawTransaction, diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index c65f6c32d..874d0fd26 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -23,7 +23,7 @@ import { findWalletForRedemptionData, } from "./data/redemption" import { - assembleRedemptionTransactionBitcoinJsLib, + assembleRedemptionTransaction, findWalletForRedemption, getRedemptionRequest, RedemptionRequest, @@ -494,7 +494,7 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransactionBitcoinJsLib( + } = await assembleRedemptionTransaction( BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, @@ -608,7 +608,7 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransactionBitcoinJsLib( + } = await assembleRedemptionTransaction( BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, @@ -721,7 +721,7 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransactionBitcoinJsLib( + } = await assembleRedemptionTransaction( BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, @@ -834,7 +834,7 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransactionBitcoinJsLib( + } = await assembleRedemptionTransaction( BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, @@ -946,7 +946,7 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransactionBitcoinJsLib( + } = await assembleRedemptionTransaction( BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, @@ -1104,7 +1104,7 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransactionBitcoinJsLib( + } = await assembleRedemptionTransaction( BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, @@ -1211,7 +1211,7 @@ describe("Redemption", () => { transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransactionBitcoinJsLib( + } = await assembleRedemptionTransaction( BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, @@ -1301,7 +1301,7 @@ describe("Redemption", () => { it("should revert", async () => { await expect( - assembleRedemptionTransactionBitcoinJsLib( + assembleRedemptionTransaction( BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, From ab4a3c6c5ba6909762bb94a22f9f6309cbc0dcc0 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 29 Sep 2023 11:26:42 +0200 Subject: [PATCH 120/205] Replaced keyring with key pair --- typescript/src/redemption.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index a304312f7..aba9b7fe4 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -1,6 +1,5 @@ import { BigNumber } from "ethers" import { - createKeyRing, createAddressFromPublicKey, decomposeRawTransaction, RawTransaction, @@ -145,15 +144,22 @@ export async function submitRedemptionTransaction( transactionHex: mainUtxoRawTransaction.transactionHex, } + const bitcoinNetwork = await bitcoinClient.getNetwork() + + // eslint-disable-next-line new-cap + const walletKeyPair = ECPairFactory(tinysecp).fromWIF( + walletPrivateKey, + toBitcoinJsLibNetwork(bitcoinNetwork) + ) + const walletPublicKey = walletKeyPair.publicKey.toString("hex") + const redemptionRequests = await getWalletRedemptionRequests( bridge, - createKeyRing(walletPrivateKey).getPublicKey().toString("hex"), + walletPublicKey, redeemerOutputScripts, "pending" ) - const bitcoinNetwork = await bitcoinClient.getNetwork() - const { transactionHash, newMainUtxo, rawTransaction } = await assembleRedemptionTransaction( bitcoinNetwork, From c2cb19fd7f59680e1a08bbb55d1d5e3761f062ac Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 29 Sep 2023 18:32:55 +0200 Subject: [PATCH 121/205] Replaced bcoin with bitcoinjs-lib for deposits --- typescript/src/deposit.ts | 196 +++++++++++++------------------- typescript/test/deposit.test.ts | 57 ++++++---- 2 files changed, 112 insertions(+), 141 deletions(-) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 7fa3b61a3..8a24fe590 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -1,18 +1,23 @@ -import bcoin from "bcoin" -import coinSelect from "coinselect" import { BigNumber } from "ethers" -import { Stack, payments, script, opcodes } from "bitcoinjs-lib" +import { + Psbt, + Stack, + Transaction, + payments, + script, + opcodes, +} from "bitcoinjs-lib" import { Client as BitcoinClient, createAddressFromPublicKey, decomposeRawTransaction, - createKeyRing, RawTransaction, UnspentTransactionOutput, TransactionHash, isPublicKeyHashLength, computeSha256, computeHash160, + isP2WPKHScript, } from "./bitcoin" import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" import { Bridge, Event, Identifier } from "./chain" @@ -124,6 +129,9 @@ export type DepositRevealedEvent = Deposit & { * @param bitcoinClient - Bitcoin client used to interact with the network. * @param witness - If true, a witness (P2WSH) transaction will be created. * Otherwise, a legacy P2SH transaction will be made. + * @param utxos - UTXOs to be used for funding the deposit transaction. + * @param fee - the value that should be subtracted from the sum of the UTXOs + * values and used as the transaction fee. * @returns The outcome consisting of: * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. @@ -132,18 +140,13 @@ export async function submitDepositTransaction( deposit: Deposit, depositorPrivateKey: string, bitcoinClient: BitcoinClient, - witness: boolean + witness: boolean, + utxos: UnspentTransactionOutput[], + fee: BigNumber ): Promise<{ transactionHash: TransactionHash depositUtxo: UnspentTransactionOutput }> { - const depositorKeyRing = createKeyRing(depositorPrivateKey) - const depositorAddress = depositorKeyRing.getAddress("string") - - const utxos = await bitcoinClient.findAllUnspentTransactionOutputs( - depositorAddress - ) - const utxosWithRaw: (UnspentTransactionOutput & RawTransaction)[] = [] for (const utxo of utxos) { const utxoRawTransaction = await bitcoinClient.getRawTransaction( @@ -156,12 +159,16 @@ export async function submitDepositTransaction( }) } + const bitcoinNetwork = await bitcoinClient.getNetwork() + const { transactionHash, depositUtxo, rawTransaction } = - await assembleDepositTransaction( + await assembleDepositTransactionBitcoinJsLib( + bitcoinNetwork, deposit, - utxosWithRaw, depositorPrivateKey, - witness + witness, + utxosWithRaw, + fee ) await bitcoinClient.broadcast(rawTransaction) @@ -172,80 +179,14 @@ export async function submitDepositTransaction( } } -/** - * Assembles a Bitcoin P2(W)SH deposit transaction. - * @param deposit - Details of the deposit. - * @param utxos - UTXOs that should be used as transaction inputs. - * @param depositorPrivateKey - Bitcoin private key of the depositor. - * @param witness - If true, a witness (P2WSH) transaction will be created. - * Otherwise, a legacy P2SH transaction will be made. - * @returns The outcome consisting of: - * - the deposit transaction hash, - * - the deposit UTXO produced by this transaction. - * - the deposit transaction in the raw format - */ -export async function assembleDepositTransaction( - deposit: Deposit, - utxos: (UnspentTransactionOutput & RawTransaction)[], - depositorPrivateKey: string, - witness: boolean -): Promise<{ - transactionHash: TransactionHash - depositUtxo: UnspentTransactionOutput - rawTransaction: RawTransaction -}> { - const depositorKeyRing = createKeyRing(depositorPrivateKey) - const depositorAddress = depositorKeyRing.getAddress("string") - - const inputCoins = utxos.map((utxo) => - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), - utxo.outputIndex, - -1 - ) - ) - - const transaction = new bcoin.MTX() - - const scriptHash = await calculateDepositScriptHash(deposit, witness) - - transaction.addOutput({ - script: witness - ? bcoin.Script.fromProgram(0, scriptHash) - : bcoin.Script.fromScripthash(scriptHash), - value: deposit.amount.toNumber(), - }) - - await transaction.fund(inputCoins, { - rate: null, // set null explicitly to always use the default value - changeAddress: depositorAddress, - subtractFee: false, // do not subtract the fee from outputs - }) - - transaction.sign(depositorKeyRing) - - const transactionHash = TransactionHash.from(transaction.txid()) - - return { - transactionHash, - depositUtxo: { - transactionHash, - outputIndex: 0, // The deposit is always the first output. - value: deposit.amount, - }, - rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), - }, - } -} - // TODO: Description and name change. export async function assembleDepositTransactionBitcoinJsLib( bitcoinNetwork: BitcoinNetwork, deposit: Deposit, - utxos: (UnspentTransactionOutput & RawTransaction)[], depositorPrivateKey: string, - witness: boolean + witness: boolean, + utxos: (UnspentTransactionOutput & RawTransaction)[], + fee: BigNumber ): Promise<{ transactionHash: TransactionHash depositUtxo: UnspentTransactionOutput @@ -257,48 +198,67 @@ export async function assembleDepositTransactionBitcoinJsLib( depositorPrivateKey, network ) - const depositorAddress = createAddressFromPublicKey( - Hex.from(depositorKeyPair.publicKey), - BitcoinNetwork.Mainnet - ) - console.log("depositor address", depositorAddress) - // TODO: Think what this value should be. It seems to be the default - // value used by `bcoin`. Think if it should be fixed or based on the - // network current conditions. - const feeRate = 10000 + const psbt = new Psbt({ network }) + psbt.setVersion(1) + + let totalInputValue = BigNumber.from(0) - const inputUtxos = [] for (const utxo of utxos) { - inputUtxos.push({ - txId: utxo.transactionHash.reverse().toBuffer(), - vout: utxo.outputIndex, - value: utxo.value.toNumber(), - }) + const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ + utxo.outputIndex + ] + const previousOutputValue = previousOutput.value + const previousOutputScript = previousOutput.script + + // TODO: add support for other utxo types along with unit tests for the + // given type. + if (isP2WPKHScript(previousOutputScript)) { + psbt.addInput({ + hash: utxo.transactionHash.reverse().toBuffer(), + index: utxo.outputIndex, + witnessUtxo: { + script: previousOutputScript, + value: previousOutputValue, + }, + }) + + totalInputValue = totalInputValue.add(utxo.value) + } + // Skip UTXO if the type is unsupported. } - const depositAddress = await calculateDepositAddress( - deposit, - bitcoinNetwork, - witness - ) - const depositOutput = { - address: depositAddress, - value: deposit.amount.toNumber(), + // Sum of the selected UTXOs must be equal to or grater than the deposit + // amount plus fee. + const totalExpenses = deposit.amount.add(fee) + if (totalInputValue.lt(totalExpenses)) { + throw new Error("Not enough funds in selected UTXOs to fund transaction") } - const { inputs, outputs /* fee*/ } = coinSelect( - inputUtxos, - [depositOutput], - feeRate - ) - if (!inputs || !outputs) { - throw new Error("Transaction could not be built from the provided UTXOs") + // Add deposit output. + psbt.addOutput({ + address: await calculateDepositAddress(deposit, bitcoinNetwork, witness), + value: deposit.amount.toNumber(), + }) + + // Add change output if needed. + const changeValue = totalInputValue.sub(totalExpenses) + if (changeValue.gt(0)) { + const depositorAddress = createAddressFromPublicKey( + Hex.from(depositorKeyPair.publicKey), + bitcoinNetwork + ) + psbt.addOutput({ + address: depositorAddress, + value: changeValue.toNumber(), + }) } - // TODO: Fill with correct values. - const transactionHash = Hex.from("") - const transactionHex = "" + psbt.signAllInputs(depositorKeyPair) + psbt.finalizeAllInputs() + + const transaction = psbt.extractTransaction() + const transactionHash = TransactionHash.from(transaction.getId()) return { transactionHash, @@ -308,7 +268,7 @@ export async function assembleDepositTransactionBitcoinJsLib( value: deposit.amount, }, rawTransaction: { - transactionHex: transactionHex, + transactionHex: transaction.toHex(), }, } } diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index 981b6d8f5..f495d46c7 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -17,7 +17,7 @@ import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import bcoin from "bcoin" import { assembleDepositScript, - assembleDepositTransaction, + assembleDepositTransactionBitcoinJsLib, calculateDepositAddress, calculateDepositRefundLocktime, calculateDepositScriptHash, @@ -224,16 +224,8 @@ describe("Deposit", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() - // Tie used testnetAddress with testnetUTXO to use it during deposit - // creation. - const utxos = new Map() - utxos.set(testnetAddress, [testnetUTXO]) - bitcoinClient.unspentTransactionOutputs = utxos - // Tie testnetTransaction to testnetUTXO. This is needed since // submitDepositTransaction attach transaction data to each UTXO. const rawTransactions = new Map() @@ -246,11 +238,14 @@ describe("Deposit", () => { let depositUtxo: UnspentTransactionOutput beforeEach(async () => { + const fee = BigNumber.from(1520) ;({ transactionHash, depositUtxo } = await submitDepositTransaction( deposit, testnetPrivateKey, bitcoinClient, - true + true, + [testnetUTXO], + fee )) }) @@ -283,11 +278,15 @@ describe("Deposit", () => { let depositUtxo: UnspentTransactionOutput beforeEach(async () => { + const fee = BigNumber.from(1410) + ;({ transactionHash, depositUtxo } = await submitDepositTransaction( deposit, testnetPrivateKey, bitcoinClient, - false + false, + [testnetUTXO], + fee )) }) @@ -323,15 +322,18 @@ describe("Deposit", () => { let transaction: RawTransaction beforeEach(async () => { + const fee = BigNumber.from(1520) ;({ transactionHash, depositUtxo, rawTransaction: transaction, - } = await assembleDepositTransaction( + } = await assembleDepositTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, deposit, - [testnetUTXO], testnetPrivateKey, - true + true, + [testnetUTXO], + fee )) }) @@ -420,15 +422,18 @@ describe("Deposit", () => { let transaction: RawTransaction beforeEach(async () => { + const fee = BigNumber.from(1410) ;({ transactionHash, depositUtxo, rawTransaction: transaction, - } = await assembleDepositTransaction( + } = await assembleDepositTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, deposit, - [testnetUTXO], testnetPrivateKey, - false + false, + [testnetUTXO], + fee )) }) @@ -698,11 +703,14 @@ describe("Deposit", () => { beforeEach(async () => { // Create a deposit transaction. - const result = await assembleDepositTransaction( + const fee = BigNumber.from(1520) + const result = await assembleDepositTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, deposit, - [testnetUTXO], testnetPrivateKey, - true + true, + [testnetUTXO], + fee ) transaction = result.rawTransaction @@ -740,11 +748,14 @@ describe("Deposit", () => { beforeEach(async () => { // Create a deposit transaction. - ;({ depositUtxo } = await assembleDepositTransaction( + const fee = BigNumber.from(1520) + ;({ depositUtxo } = await assembleDepositTransactionBitcoinJsLib( + BitcoinNetwork.Testnet, deposit, - [testnetUTXO], testnetPrivateKey, - true + true, + [testnetUTXO], + fee )) revealedDeposit = { From 3baf5368253a78f774176ce96fdca3ac7a60aea7 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 29 Sep 2023 18:45:04 +0200 Subject: [PATCH 122/205] Function rename and description added --- typescript/src/deposit.ts | 20 +++++++++++++++++--- typescript/test/deposit.test.ts | 10 +++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 8a24fe590..781d23b7a 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -162,7 +162,7 @@ export async function submitDepositTransaction( const bitcoinNetwork = await bitcoinClient.getNetwork() const { transactionHash, depositUtxo, rawTransaction } = - await assembleDepositTransactionBitcoinJsLib( + await assembleDepositTransaction( bitcoinNetwork, deposit, depositorPrivateKey, @@ -179,8 +179,22 @@ export async function submitDepositTransaction( } } -// TODO: Description and name change. -export async function assembleDepositTransactionBitcoinJsLib( +/** + * Assembles a Bitcoin P2(W)SH deposit transaction. + * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). + * @param deposit - Details of the deposit. + * @param depositorPrivateKey - Bitcoin private key of the depositor. + * @param witness - If true, a witness (P2WSH) transaction will be created. + * Otherwise, a legacy P2SH transaction will be made. + * @param utxos - UTXOs that should be used as transaction inputs. + * @param fee - Transaction fee to be subtracted from the sum of the UTXOs' + * values. + * @returns The outcome consisting of: + * - the deposit transaction hash, + * - the deposit UTXO produced by this transaction. + * - the deposit transaction in the raw format + */ +export async function assembleDepositTransaction( bitcoinNetwork: BitcoinNetwork, deposit: Deposit, depositorPrivateKey: string, diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index f495d46c7..27bb5eadd 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -17,7 +17,7 @@ import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import bcoin from "bcoin" import { assembleDepositScript, - assembleDepositTransactionBitcoinJsLib, + assembleDepositTransaction, calculateDepositAddress, calculateDepositRefundLocktime, calculateDepositScriptHash, @@ -327,7 +327,7 @@ describe("Deposit", () => { transactionHash, depositUtxo, rawTransaction: transaction, - } = await assembleDepositTransactionBitcoinJsLib( + } = await assembleDepositTransaction( BitcoinNetwork.Testnet, deposit, testnetPrivateKey, @@ -427,7 +427,7 @@ describe("Deposit", () => { transactionHash, depositUtxo, rawTransaction: transaction, - } = await assembleDepositTransactionBitcoinJsLib( + } = await assembleDepositTransaction( BitcoinNetwork.Testnet, deposit, testnetPrivateKey, @@ -704,7 +704,7 @@ describe("Deposit", () => { beforeEach(async () => { // Create a deposit transaction. const fee = BigNumber.from(1520) - const result = await assembleDepositTransactionBitcoinJsLib( + const result = await assembleDepositTransaction( BitcoinNetwork.Testnet, deposit, testnetPrivateKey, @@ -749,7 +749,7 @@ describe("Deposit", () => { beforeEach(async () => { // Create a deposit transaction. const fee = BigNumber.from(1520) - ;({ depositUtxo } = await assembleDepositTransactionBitcoinJsLib( + ;({ depositUtxo } = await assembleDepositTransaction( BitcoinNetwork.Testnet, deposit, testnetPrivateKey, From f5a998ab7d2f1a5f340ef543a68c6576a35818ba Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 29 Sep 2023 18:52:19 +0200 Subject: [PATCH 123/205] Break when enough funds collected --- typescript/src/deposit.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 781d23b7a..b8119e05d 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -216,6 +216,7 @@ export async function assembleDepositTransaction( const psbt = new Psbt({ network }) psbt.setVersion(1) + const totalExpenses = deposit.amount.add(fee) let totalInputValue = BigNumber.from(0) for (const utxo of utxos) { @@ -238,13 +239,15 @@ export async function assembleDepositTransaction( }) totalInputValue = totalInputValue.add(utxo.value) + if (totalInputValue.gte(totalExpenses)) { + break + } } // Skip UTXO if the type is unsupported. } // Sum of the selected UTXOs must be equal to or grater than the deposit // amount plus fee. - const totalExpenses = deposit.amount.add(fee) if (totalInputValue.lt(totalExpenses)) { throw new Error("Not enough funds in selected UTXOs to fund transaction") } From d868a2f6d3601fef64ba8f4daca52f17d57b06a1 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 29 Sep 2023 18:58:38 +0200 Subject: [PATCH 124/205] Removed coinselect package --- typescript/package.json | 1 - typescript/typings.d.ts | 1 - typescript/yarn.lock | 5 ----- 3 files changed, 7 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index 077d75b03..806339a53 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -30,7 +30,6 @@ "bcoin": "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8", "bitcoinjs-lib": "6.0.2", "bufio": "^1.0.6", - "coinselect": "^3.1.13", "ecpair": "^2.1.0", "electrum-client-js": "git+https://github.com/keep-network/electrum-client-js.git#v0.1.1", "ethers": "^5.5.2", diff --git a/typescript/typings.d.ts b/typescript/typings.d.ts index 82aae9dd0..2558e6a79 100644 --- a/typescript/typings.d.ts +++ b/typescript/typings.d.ts @@ -4,6 +4,5 @@ */ declare module "bcoin" declare module "bufio" -declare module "coinselect" declare module "electrum-client-js" declare module "wif" diff --git a/typescript/yarn.lock b/typescript/yarn.lock index 3eb3e707f..05897068f 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -3261,11 +3261,6 @@ code-point-at@^1.0.0: resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= -coinselect@^3.1.13: - version "3.1.13" - resolved "https://registry.yarnpkg.com/coinselect/-/coinselect-3.1.13.tgz#b88c7f9659ed4891d1f1d0c894105b1c10ef89a1" - integrity sha512-iJOrKH/7N9gX0jRkxgOHuGjvzvoxUMSeylDhH1sHn+CjLjdin5R0Hz2WEBu/jrZV5OrHcm+6DMzxwu9zb5mSZg== - color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" From 04e8d75630ac21c1dd19a18ac73e2690c4e2c628 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 29 Sep 2023 19:17:01 +0200 Subject: [PATCH 125/205] Added unit tests for sha256 --- typescript/src/bitcoin.ts | 2 -- typescript/test/bitcoin.test.ts | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 1c3e3751f..d7c04a2cf 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -527,7 +527,6 @@ export function createKeyRing( * @param text - Text the HASH160 is computed for. * @returns Hash as a 20-byte un-prefixed hex string. */ -// TODO: Make it use Hex for input and return values. export function computeHash160(text: string): string { const sha256Hash = utils.sha256( Hex.from(Buffer.from(text, "hex")).toPrefixedString() @@ -542,7 +541,6 @@ export function computeHash160(text: string): string { * @param text - Text the single SHA256 is computed for. * @returns Hash as a 32-byte un-prefixed hex string. */ -// TODO: Consider adding unit tests. export function computeSha256(text: Hex): Hex { const hash = utils.sha256(text.toPrefixedString()) return Hex.from(hash) diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 0bcc335ba..2c57ed006 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -16,6 +16,7 @@ import { createAddressFromPublicKey, readCompactSizeUint, computeHash160, + computeSha256, computeHash256, isP2PKHScript, isP2WPKHScript, @@ -98,6 +99,21 @@ describe("Bitcoin", () => { }) }) + describe("computeSha256", () => { + it("should compute hash256 correctly", () => { + const hexValue = Hex.from( + "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + ) + const expectedSha256 = Hex.from( + "c62e5cb26c97cb52fea7f9965e9ea1f8d41c97773688aa88674e64629fc02901" + ) + + expect(computeSha256(hexValue).toString()).to.be.equal( + expectedSha256.toString() + ) + }) + }) + describe("P2PKH <-> public key hash conversion", () => { const publicKeyHash = "3a38d44d6a0c8d0bb84e0232cc632b7e48c72e0e" const P2WPKHAddress = "bc1q8gudgnt2pjxshwzwqgevccet0eyvwtswt03nuy" From 5a6711b3c8d770bec12b1f52ccb18bb15664a7b4 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 29 Sep 2023 19:33:31 +0200 Subject: [PATCH 126/205] Updated function docstrings --- typescript/src/deposit.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index b8119e05d..078fee832 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -124,6 +124,9 @@ export type DepositRevealedEvent = Deposit & { /** * Submits a deposit by creating and broadcasting a Bitcoin P2(W)SH * deposit transaction. + * @dev UTXOs are selected for transaction funding based on their types. UTXOs + * with unsupported types are skipped. The selection process stops once + * the sum of the chosen UTXOs meets the required funding amount. * @param deposit - Details of the deposit. * @param depositorPrivateKey - Bitcoin private key of the depositor. * @param bitcoinClient - Bitcoin client used to interact with the network. @@ -135,6 +138,8 @@ export type DepositRevealedEvent = Deposit & { * @returns The outcome consisting of: * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. + * @throws {Error} When the sum of the selected UTXOs is insufficient to cover + * the deposit amount and transaction fee. */ export async function submitDepositTransaction( deposit: Deposit, @@ -181,6 +186,9 @@ export async function submitDepositTransaction( /** * Assembles a Bitcoin P2(W)SH deposit transaction. + * @dev UTXOs are selected for transaction funding based on their types. UTXOs + * with unsupported types are skipped. The selection process stops once + * the sum of the chosen UTXOs meets the required funding amount. * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). * @param deposit - Details of the deposit. * @param depositorPrivateKey - Bitcoin private key of the depositor. @@ -193,6 +201,8 @@ export async function submitDepositTransaction( * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. * - the deposit transaction in the raw format + * @throws {Error} When the sum of the selected UTXOs is insufficient to cover + * the deposit amount and transaction fee. */ export async function assembleDepositTransaction( bitcoinNetwork: BitcoinNetwork, @@ -226,7 +236,7 @@ export async function assembleDepositTransaction( const previousOutputValue = previousOutput.value const previousOutputScript = previousOutput.script - // TODO: add support for other utxo types along with unit tests for the + // TODO: Add support for other utxo types along with unit tests for the // given type. if (isP2WPKHScript(previousOutputScript)) { psbt.addInput({ @@ -246,7 +256,7 @@ export async function assembleDepositTransaction( // Skip UTXO if the type is unsupported. } - // Sum of the selected UTXOs must be equal to or grater than the deposit + // Sum of the selected UTXOs must be equal to or greater than the deposit // amount plus fee. if (totalInputValue.lt(totalExpenses)) { throw new Error("Not enough funds in selected UTXOs to fund transaction") From 14c9fc6180f6e5c3d4ca129bfee7f30b442eb08e Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 12:43:21 +0200 Subject: [PATCH 127/205] Fixed spending non-witness main UTXO --- typescript/src/redemption.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index aba9b7fe4..528c4627a 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -309,7 +309,7 @@ export async function assembleRedemptionTransaction( psbt.addInput({ hash: mainUtxo.transactionHash.reverse().toBuffer(), index: mainUtxo.outputIndex, - nonWitnessUtxo: Buffer.from(mainUtxo.transactionHex), + nonWitnessUtxo: Buffer.from(mainUtxo.transactionHex, "hex"), }) } else if (isP2WPKHScript(previousOutputScript)) { psbt.addInput({ From ba335fbad9b246603d9ae18d799b60c1cfdc7430 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 15:15:11 +0200 Subject: [PATCH 128/205] Variable rename and description update --- typescript/src/deposit.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 078fee832..17d9ad369 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -132,7 +132,8 @@ export type DepositRevealedEvent = Deposit & { * @param bitcoinClient - Bitcoin client used to interact with the network. * @param witness - If true, a witness (P2WSH) transaction will be created. * Otherwise, a legacy P2SH transaction will be made. - * @param utxos - UTXOs to be used for funding the deposit transaction. + * @param inputUtxos - UTXOs to be used for funding the deposit transaction. So + * far only P2WPKH UTXO inputs are supported. * @param fee - the value that should be subtracted from the sum of the UTXOs * values and used as the transaction fee. * @returns The outcome consisting of: @@ -146,14 +147,14 @@ export async function submitDepositTransaction( depositorPrivateKey: string, bitcoinClient: BitcoinClient, witness: boolean, - utxos: UnspentTransactionOutput[], + inputUtxos: UnspentTransactionOutput[], fee: BigNumber ): Promise<{ transactionHash: TransactionHash depositUtxo: UnspentTransactionOutput }> { const utxosWithRaw: (UnspentTransactionOutput & RawTransaction)[] = [] - for (const utxo of utxos) { + for (const utxo of inputUtxos) { const utxoRawTransaction = await bitcoinClient.getRawTransaction( utxo.transactionHash ) From 36ad06f55e9da48ceb1bd1ec1726dc327b526638 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 15:18:37 +0200 Subject: [PATCH 129/205] Updated docstring --- typescript/src/deposit.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 17d9ad369..38f50eda1 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -124,9 +124,6 @@ export type DepositRevealedEvent = Deposit & { /** * Submits a deposit by creating and broadcasting a Bitcoin P2(W)SH * deposit transaction. - * @dev UTXOs are selected for transaction funding based on their types. UTXOs - * with unsupported types are skipped. The selection process stops once - * the sum of the chosen UTXOs meets the required funding amount. * @param deposit - Details of the deposit. * @param depositorPrivateKey - Bitcoin private key of the depositor. * @param bitcoinClient - Bitcoin client used to interact with the network. @@ -139,6 +136,11 @@ export type DepositRevealedEvent = Deposit & { * @returns The outcome consisting of: * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. + * @dev UTXOs are selected for transaction funding based on their types. UTXOs + * with unsupported types are skipped. The selection process stops once + * the sum of the chosen UTXOs meets the required funding amount. + * Be aware that the function will attempt to broadcast the transaction, + * although successful broadcast is not guaranteed. * @throws {Error} When the sum of the selected UTXOs is insufficient to cover * the deposit amount and transaction fee. */ @@ -177,6 +179,9 @@ export async function submitDepositTransaction( fee ) + // Note that `broadcast` may fail silently (i.e. no error will be returned, + // even if the transaction is rejected by other nodes and does not enter the + // mempool, for example due to an UTXO being already spent). await bitcoinClient.broadcast(rawTransaction) return { @@ -187,9 +192,6 @@ export async function submitDepositTransaction( /** * Assembles a Bitcoin P2(W)SH deposit transaction. - * @dev UTXOs are selected for transaction funding based on their types. UTXOs - * with unsupported types are skipped. The selection process stops once - * the sum of the chosen UTXOs meets the required funding amount. * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). * @param deposit - Details of the deposit. * @param depositorPrivateKey - Bitcoin private key of the depositor. @@ -202,6 +204,9 @@ export async function submitDepositTransaction( * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. * - the deposit transaction in the raw format +* @dev UTXOs are selected for transaction funding based on their types. UTXOs + * with unsupported types are skipped. The selection process stops once + * the sum of the chosen UTXOs meets the required funding amount. * @throws {Error} When the sum of the selected UTXOs is insufficient to cover * the deposit amount and transaction fee. */ From ce7d1ee7a689ccc66605d9781ef81932e6e2a6de Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 15:36:43 +0200 Subject: [PATCH 130/205] Variable rename and docstring update --- typescript/src/deposit-sweep.ts | 2 +- typescript/src/deposit.ts | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 0627382d7..7c68008eb 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -114,7 +114,7 @@ export async function submitDepositSweepTransaction( * @dev The caller is responsible for ensuring the provided UTXOs are correctly * formed, can be spent by the wallet and their combined value is greater * then the fee. - * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). + * @param bitcoinNetwork - The target Bitcoin network. * @param fee - Transaction fee to be subtracted from the sum of the UTXOs' * values. * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 38f50eda1..f21731fb9 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -136,7 +136,7 @@ export type DepositRevealedEvent = Deposit & { * @returns The outcome consisting of: * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. - * @dev UTXOs are selected for transaction funding based on their types. UTXOs + * @dev UTXOs are selected for transaction funding based on their types. UTXOs * with unsupported types are skipped. The selection process stops once * the sum of the chosen UTXOs meets the required funding amount. * Be aware that the function will attempt to broadcast the transaction, @@ -192,19 +192,20 @@ export async function submitDepositTransaction( /** * Assembles a Bitcoin P2(W)SH deposit transaction. - * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). + * @param bitcoinNetwork - The target Bitcoin network. * @param deposit - Details of the deposit. * @param depositorPrivateKey - Bitcoin private key of the depositor. * @param witness - If true, a witness (P2WSH) transaction will be created. * Otherwise, a legacy P2SH transaction will be made. - * @param utxos - UTXOs that should be used as transaction inputs. + * @param inputUtxos - UTXOs to be used for funding the deposit transaction. So + * far only P2WPKH UTXO inputs are supported. * @param fee - Transaction fee to be subtracted from the sum of the UTXOs' * values. * @returns The outcome consisting of: * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. * - the deposit transaction in the raw format -* @dev UTXOs are selected for transaction funding based on their types. UTXOs + * @dev UTXOs are selected for transaction funding based on their types. UTXOs * with unsupported types are skipped. The selection process stops once * the sum of the chosen UTXOs meets the required funding amount. * @throws {Error} When the sum of the selected UTXOs is insufficient to cover @@ -215,7 +216,7 @@ export async function assembleDepositTransaction( deposit: Deposit, depositorPrivateKey: string, witness: boolean, - utxos: (UnspentTransactionOutput & RawTransaction)[], + inputUtxos: (UnspentTransactionOutput & RawTransaction)[], fee: BigNumber ): Promise<{ transactionHash: TransactionHash @@ -235,7 +236,7 @@ export async function assembleDepositTransaction( const totalExpenses = deposit.amount.add(fee) let totalInputValue = BigNumber.from(0) - for (const utxo of utxos) { + for (const utxo of inputUtxos) { const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ utxo.outputIndex ] From 332b0e772cc2eb9f5a61b678cb51a4ad15d16774 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 15:49:34 +0200 Subject: [PATCH 131/205] Minor refactor --- typescript/src/deposit.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index f21731fb9..f897dadbc 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -416,11 +416,9 @@ export async function calculateDepositScriptHash( const script = await assembleDepositScript(deposit) // If witness script hash should be produced, SHA256 should be used. // Legacy script hash needs HASH160. - if (witness) { - return computeSha256(Hex.from(script)).toBuffer() - } - - return Buffer.from(computeHash160(script), "hex") + return witness + ? computeSha256(Hex.from(script)).toBuffer() + : Buffer.from(computeHash160(script), "hex") } /** @@ -448,16 +446,17 @@ export async function calculateDepositAddress( return payments.p2wsh({ output: p2wshOutput, network: bitcoinNetwork }) .address! - } - - // OP_HASH160 OP_EQUAL - const p2shOutput = Buffer.concat([ - Buffer.from([opcodes.OP_HASH160, 0x14]), - scriptHash, - Buffer.from([opcodes.OP_EQUAL]), - ]) + } else { + // OP_HASH160 OP_EQUAL + const p2shOutput = Buffer.concat([ + Buffer.from([opcodes.OP_HASH160, 0x14]), + scriptHash, + Buffer.from([opcodes.OP_EQUAL]), + ]) - return payments.p2sh({ output: p2shOutput, network: bitcoinNetwork }).address! + return payments.p2sh({ output: p2shOutput, network: bitcoinNetwork }) + .address! + } } /** From e202330c56fc053c664d3396d6b2c63514ffa021 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 15:56:14 +0200 Subject: [PATCH 132/205] Minor update of docstring --- typescript/src/redemption.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index 528c4627a..7e99a85ea 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -256,7 +256,7 @@ async function getWalletRedemptionRequests( * - there is at least one redemption * - the `requestedAmount` in each redemption request is greater than * the sum of its `txFee` and `treasuryFee` - * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). + * @param bitcoinNetwork - The target Bitcoin network. * @param walletPrivateKey - The private key of the wallet in the WIF format * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO held * by the on-chain Bridge contract From d4838ea417664014791c79b539cb0c427571823a Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 14:50:05 +0200 Subject: [PATCH 133/205] Replaced bcoin with bitcoinjs-lib for deposit refunds --- typescript/src/deposit-refund.ts | 264 +++++++++++++------------ typescript/test/deposit-refund.test.ts | 3 - 2 files changed, 135 insertions(+), 132 deletions(-) diff --git a/typescript/src/deposit-refund.ts b/typescript/src/deposit-refund.ts index f307e4eec..e2eece714 100644 --- a/typescript/src/deposit-refund.ts +++ b/typescript/src/deposit-refund.ts @@ -1,19 +1,24 @@ -import bcoin from "bcoin" import { BigNumber } from "ethers" +import { Transaction, Stack, Signer, script } from "bitcoinjs-lib" import { - createKeyRing, RawTransaction, Client as BitcoinClient, TransactionHash, UnspentTransactionOutput, computeHash160, isCompressedPublicKey, + createOutputScriptFromAddress, + isP2SHScript, + isP2WSHScript, } from "./bitcoin" import { assembleDepositScript, Deposit, validateDepositScriptParameters, } from "./deposit" +import { ECPairFactory } from "ecpair" +import * as tinysecp from "tiny-secp256k1" +import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" /** * Submits a deposit refund by creating and broadcasting a Bitcoin P2(W)PKH @@ -52,8 +57,11 @@ export async function submitDepositRefundTransaction( transactionHex: utxoRawTransaction.transactionHex, } + const bitcoinNetwork = await bitcoinClient.getNetwork() + const { transactionHash, rawTransaction } = await assembleDepositRefundTransaction( + bitcoinNetwork, fee, utxoWithRaw, deposit, @@ -71,6 +79,7 @@ export async function submitDepositRefundTransaction( /** * Assembles a Bitcoin P2(W)PKH deposit refund transaction. + * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). * @param fee - the value that will be subtracted from the deposit UTXO being * refunded and used as the transaction fee. * @param utxo - UTXO that was created during depositing that needs be refunded. @@ -85,6 +94,7 @@ export async function submitDepositRefundTransaction( * - the refund transaction in the raw format. */ export async function assembleDepositRefundTransaction( + bitcoinNetwork: BitcoinNetwork, fee: BigNumber, utxo: UnspentTransactionOutput & RawTransaction, deposit: Deposit, @@ -96,101 +106,94 @@ export async function assembleDepositRefundTransaction( }> { validateInputParameters(deposit, utxo) - const refunderKeyRing = createKeyRing(refunderPrivateKey) + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + // eslint-disable-next-line new-cap + const refunderKeyPair = ECPairFactory(tinysecp).fromWIF( + refunderPrivateKey, + network + ) - const transaction = new bcoin.MTX() + const outputValue = utxo.value.sub(fee) - transaction.addOutput({ - script: bcoin.Script.fromAddress(refunderAddress), - value: utxo.value.toNumber(), - }) + const transaction = new Transaction() - const inputCoin = bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), - utxo.outputIndex, - -1 + transaction.addInput( + utxo.transactionHash.reverse().toBuffer(), + utxo.outputIndex ) - await transaction.fund([inputCoin], { - changeAddress: refunderAddress, - hardFee: fee.toNumber(), - subtractFee: true, - }) - - if (transaction.outputs.length != 1) { - throw new Error("Deposit refund transaction must have only one output") - } + const outputScript = createOutputScriptFromAddress(refunderAddress) + transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) // In order to be able to spend the UTXO being refunded the transaction's // locktime must be set to a value equal to or higher than the refund locktime. // Additionally, the input's sequence must be set to a value different than // `0xffffffff`. These requirements are the result of BIP-65. transaction.locktime = locktimeToUnixTimestamp(deposit.refundLocktime) - transaction.inputs[0].sequence = 0xfffffffe + transaction.ins[0].sequence = 0xfffffffe // Sign the input - const previousOutpoint = transaction.inputs[0].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - const previousScript = previousOutput.script - - if (previousScript.isScripthash()) { - // P2SH UTXO deposit input - await signP2SHDepositInput(transaction, 0, deposit, refunderKeyRing) - } else if (previousScript.isWitnessScripthash()) { - // P2WSH UTXO deposit input - await signP2WSHDepositInput(transaction, 0, deposit, refunderKeyRing) + const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ + utxo.outputIndex + ] + const previousOutputValue = previousOutput.value + const previousOutputScript = previousOutput.script + + if (isP2SHScript(previousOutputScript)) { + // P2SH deposit UTXO + await signP2SHDepositInput( + transaction, + 0, + deposit, + previousOutputValue, + refunderKeyPair + ) + } else if (isP2WSHScript(previousOutputScript)) { + // P2WSH deposit UTXO + await signP2WSHDepositInput( + transaction, + 0, + deposit, + previousOutputValue, + refunderKeyPair + ) } else { throw new Error("Unsupported UTXO script type") } - // Verify the transaction by executing its input scripts. - const tx = transaction.toTX() - if (!tx.verify(transaction.view)) { - throw new Error("Transaction verification failure") - } - - const transactionHash = TransactionHash.from(transaction.txid()) + const transactionHash = TransactionHash.from(transaction.getId()) return { transactionHash, rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), + transactionHex: transaction.toHex(), }, } } /** - * Creates data needed to sign a deposit input to be refunded. - * @param transaction - Mutable transaction containing the input to be refunded. - * @param inputIndex - Index that points to the input. - * @param deposit - Data of the deposit to be refunded. - * @param refunderKeyRing - Key ring created using the refunder's private key. - * @returns Data needed to sign the input. + * Assembles the deposit script based on the given deposit details. Performs + * validations on values and key formats. + * @param deposit - The deposit details. + * @param previousOutputValue - Value from the previous transaction output. + * @param refunderKeyPair - Signer object containing the refunder's key pair. + * @returns A Promise resolving to the assembled deposit script as a Buffer. + * @throws Error if there are discrepancies in values or key formats. */ -async function prepareInputSignData( - transaction: any, - inputIndex: number, +async function prepareDepositScript( deposit: Deposit, - refunderKeyRing: any -): Promise<{ - refunderPublicKey: string - depositScript: any - previousOutputValue: number -}> { - const previousOutpoint = transaction.inputs[inputIndex].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - - if (previousOutput.value != deposit.amount.toNumber()) { - throw new Error("Mismatch between amount in deposit and deposit refund tx") + previousOutputValue: number, + refunderKeyPair: Signer +): Promise { + if (previousOutputValue != deposit.amount.toNumber()) { + throw new Error("Mismatch between amount in deposit and deposit tx") } - const refunderPublicKey = refunderKeyRing.getPublicKey("hex") - if ( - computeHash160(refunderKeyRing.getPublicKey("hex")) != - deposit.refundPublicKeyHash - ) { + const refunderPublicKey = refunderKeyPair.publicKey.toString("hex") + + if (computeHash160(refunderPublicKey) != deposit.refundPublicKeyHash) { throw new Error( - "Refund public key does not correspond to the refunder private key" + "Refund public key does not correspond to wallet private key" ) } @@ -201,98 +204,101 @@ async function prepareInputSignData( // eslint-disable-next-line no-unused-vars const { amount, vault, ...depositScriptParameters } = deposit - const depositScript = bcoin.Script.fromRaw( - Buffer.from(await assembleDepositScript(depositScriptParameters), "hex") + const depositScript = Buffer.from( + await assembleDepositScript(depositScriptParameters), + "hex" ) - return { - refunderPublicKey: refunderPublicKey, - depositScript: depositScript, - previousOutputValue: previousOutput.value, - } + return depositScript } /** - * Creates and sets `scriptSig` for the transaction input at the given index by - * combining signature, refunder's public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param refunderKeyRing - Key ring created using the refunder's private key. - * @returns Empty return. + * Signs a P2SH deposit transaction input and sets the `scriptSig`. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param deposit - Details of the deposit transaction. + * @param previousOutputValue - The value from the previous transaction output. + * @param refunderKeyPair - A Signer object with the refunder's public and private + * key pair. + * @returns An empty promise upon successful signing. */ async function signP2SHDepositInput( - transaction: any, + transaction: Transaction, inputIndex: number, deposit: Deposit, - refunderKeyRing: any + previousOutputValue: number, + refunderKeyPair: Signer ) { - const { refunderPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData( - transaction, - inputIndex, - deposit, - refunderKeyRing - ) + const depositScript = await prepareDepositScript( + deposit, + previousOutputValue, + refunderKeyPair + ) - const signature: Buffer = transaction.signature( + const sigHashType = Transaction.SIGHASH_ALL + + const sigHash = transaction.hashForSignature( inputIndex, depositScript, - previousOutputValue, - refunderKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 0 // legacy sighash version + sigHashType ) - const scriptSig = new bcoin.Script() - scriptSig.clear() - scriptSig.pushData(signature) - scriptSig.pushData(Buffer.from(refunderPublicKey, "hex")) - scriptSig.pushData(depositScript.toRaw()) - scriptSig.compile() - - transaction.inputs[inputIndex].script = scriptSig + + const signature = script.signature.encode( + refunderKeyPair.sign(sigHash), + sigHashType + ) + + const scriptSig: Stack = [] + scriptSig.push(signature) + scriptSig.push(refunderKeyPair.publicKey) + scriptSig.push(depositScript) + + transaction.ins[inputIndex].script = script.compile(scriptSig) } /** - * Creates and sets witness script for the transaction input at the given index - * by combining signature, refunder public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param refunderKeyRing - Key ring created using the refunder's private key. - * @returns Empty return. + * Signs a P2WSH deposit transaction input and sets the witness script. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param deposit - Details of the deposit transaction. + * @param previousOutputValue - The value from the previous transaction output. + * @param refunderKeyPair - A Signer object with the refunder's public and private + * key pair. + * @returns An empty promise upon successful signing. */ async function signP2WSHDepositInput( - transaction: any, + transaction: Transaction, inputIndex: number, deposit: Deposit, - refunderKeyRing: any + previousOutputValue: number, + refunderKeyPair: Signer ) { - const { refunderPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData( - transaction, - inputIndex, - deposit, - refunderKeyRing - ) + const depositScript = await prepareDepositScript( + deposit, + previousOutputValue, + refunderKeyPair + ) + + const sigHashType = Transaction.SIGHASH_ALL - const signature: Buffer = transaction.signature( + const sigHash = transaction.hashForWitnessV0( inputIndex, depositScript, previousOutputValue, - refunderKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 1 // segwit sighash version + sigHashType + ) + + const signature = script.signature.encode( + refunderKeyPair.sign(sigHash), + sigHashType ) - const witness = new bcoin.Witness() - witness.clear() - witness.pushData(signature) - witness.pushData(Buffer.from(refunderPublicKey, "hex")) - witness.pushData(depositScript.toRaw()) - witness.compile() + const witness: Buffer[] = [] + witness.push(signature) + witness.push(refunderKeyPair.publicKey) + witness.push(depositScript) - transaction.inputs[inputIndex].witness = witness + transaction.ins[inputIndex].witness = witness } /** diff --git a/typescript/test/deposit-refund.test.ts b/typescript/test/deposit-refund.test.ts index dc668ae38..04111e4c5 100644 --- a/typescript/test/deposit-refund.test.ts +++ b/typescript/test/deposit-refund.test.ts @@ -1,6 +1,5 @@ import { BigNumber } from "ethers" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import bcoin from "bcoin" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) @@ -21,8 +20,6 @@ describe("Refund", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() }) From ec5682a31db8744020d5485c1c4c6c29786acbc9 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 16:20:01 +0200 Subject: [PATCH 134/205] Docstring update --- typescript/src/deposit-refund.ts | 2 +- typescript/src/deposit-sweep.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/src/deposit-refund.ts b/typescript/src/deposit-refund.ts index e2eece714..3b68f81a9 100644 --- a/typescript/src/deposit-refund.ts +++ b/typescript/src/deposit-refund.ts @@ -79,7 +79,7 @@ export async function submitDepositRefundTransaction( /** * Assembles a Bitcoin P2(W)PKH deposit refund transaction. - * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). + * @param bitcoinNetwork - The target Bitcoin network. * @param fee - the value that will be subtracted from the deposit UTXO being * refunded and used as the transaction fee. * @param utxo - UTXO that was created during depositing that needs be refunded. diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 0627382d7..7c68008eb 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -114,7 +114,7 @@ export async function submitDepositSweepTransaction( * @dev The caller is responsible for ensuring the provided UTXOs are correctly * formed, can be spent by the wallet and their combined value is greater * then the fee. - * @param bitcoinNetwork - The target Bitcoin network (mainnet or testnet). + * @param bitcoinNetwork - The target Bitcoin network. * @param fee - Transaction fee to be subtracted from the sum of the UTXOs' * values. * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. From ef82c8c496b9c66c29d01705c5590ac3bae0e6a2 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 16:58:19 +0200 Subject: [PATCH 135/205] Used bitcoinjs-lib for encodeToBitcoinAddress --- typescript/src/bitcoin.ts | 31 +++++-------------------------- typescript/test/bitcoin.test.ts | 20 ++++++++++++++++---- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index d7c04a2cf..2e269683e 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -1,5 +1,4 @@ import bcoin, { TX, Script } from "bcoin" -import wif from "wif" import bufio from "bufio" import { BigNumber, utils } from "ethers" import { Hex } from "./hex" @@ -502,26 +501,6 @@ export function compressPublicKey(publicKey: string | Hex): string { return `${prefix}${publicKeyX}` } -/** - * Creates a Bitcoin key ring based on the given private key. - * @param privateKey Private key that should be used to create the key ring - * @param witness Flag indicating whether the key ring will create witness - * or non-witness addresses - * @returns Bitcoin key ring. - */ -export function createKeyRing( - privateKey: string, - witness: boolean = true -): any { - const decodedPrivateKey = wif.decode(privateKey) - - return new bcoin.KeyRing({ - witness: witness, - privateKey: decodedPrivateKey.privateKey, - compressed: decodedPrivateKey.compressed, - }) -} - /** * Computes the HASH160 for the given text. * @param text - Text the HASH160 is computed for. @@ -580,13 +559,13 @@ export function hashLEToBigNumber(hash: Hex): BigNumber { export function encodeToBitcoinAddress( publicKeyHash: string, witness: boolean, - network: BitcoinNetwork + bitcoinNetwork: BitcoinNetwork ): string { - const buffer = Buffer.from(publicKeyHash, "hex") - const bcoinNetwork = toBcoinNetwork(network) + const hash = Buffer.from(publicKeyHash, "hex") + const network = toBitcoinJsLibNetwork(bitcoinNetwork) return witness - ? bcoin.Address.fromWitnessPubkeyhash(buffer).toString(bcoinNetwork) - : bcoin.Address.fromPubkeyhash(buffer).toString(bcoinNetwork) + ? payments.p2wpkh({ hash, network }).address! + : payments.p2pkh({ hash, network }).address! } /** diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 2c57ed006..3e43be062 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -146,7 +146,10 @@ describe("Bitcoin", () => { true, BitcoinNetwork.Mainnet ) - ).to.throw("P2WPKH must be 20 bytes") + ).to.throw( + 'Expected property "hash" of type Buffer(Length: 20), got ' + + "Buffer(Length: 21)" + ) }) }) }) @@ -174,7 +177,10 @@ describe("Bitcoin", () => { false, BitcoinNetwork.Mainnet ) - ).to.throw("P2PKH must be 20 bytes") + ).to.throw( + 'Expected property "hash" of type Buffer(Length: 20), got ' + + "Buffer(Length: 21)" + ) }) }) }) @@ -204,7 +210,10 @@ describe("Bitcoin", () => { true, BitcoinNetwork.Testnet ) - ).to.throw("P2WPKH must be 20 bytes") + ).to.throw( + 'Expected property "hash" of type Buffer(Length: 20), got ' + + "Buffer(Length: 21)" + ) }) }) }) @@ -232,7 +241,10 @@ describe("Bitcoin", () => { false, BitcoinNetwork.Testnet ) - ).to.throw("P2PKH must be 20 bytes") + ).to.throw( + 'Expected property "hash" of type Buffer(Length: 20), got ' + + "Buffer(Length: 21)" + ) }) }) }) From 4c28279a59ab83e990216cb54d7c2aba295107ec Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 17:28:54 +0200 Subject: [PATCH 136/205] Used bitcoinjs-lib for createAddressFromOutputScript --- typescript/src/bitcoin-network.ts | 21 ----------------- typescript/src/bitcoin.ts | 21 +++++++---------- typescript/test/bitcoin-network.test.ts | 31 ++----------------------- 3 files changed, 11 insertions(+), 62 deletions(-) diff --git a/typescript/src/bitcoin-network.ts b/typescript/src/bitcoin-network.ts index c59a134f2..c54c5da38 100644 --- a/typescript/src/bitcoin-network.ts +++ b/typescript/src/bitcoin-network.ts @@ -45,27 +45,6 @@ export namespace BitcoinNetwork { } } -/** - * Converts enumerated {@link BitcoinNetwork} to a string expected by the - * {@link https://github.com/keep-network/bcoin/blob/aba6841e43546e8a485e96dc0019d1e788eab2ee/lib/protocol/networks.js#L33| `bcoin` library} - * @param bitcoinNetwork Bitcoin network. - * @returns String representing the given network in bcoin library. - * @throws An error if the network is not supported by bcoin. - */ -export function toBcoinNetwork(bitcoinNetwork: BitcoinNetwork): string { - switch (bitcoinNetwork) { - case BitcoinNetwork.Mainnet: { - return "main" - } - case BitcoinNetwork.Testnet: { - return "testnet" - } - default: { - throw new Error(`network not supported`) - } - } -} - /** * Converts the provided {@link BitcoinNetwork} enumeration to a format expected * by the `bitcoinjs-lib` library. diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 2e269683e..78f99870b 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -2,12 +2,8 @@ import bcoin, { TX, Script } from "bcoin" import bufio from "bufio" import { BigNumber, utils } from "ethers" import { Hex } from "./hex" -import { - BitcoinNetwork, - toBcoinNetwork, - toBitcoinJsLibNetwork, -} from "./bitcoin-network" -import { payments } from "bitcoinjs-lib" +import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" +import { address, payments } from "bitcoinjs-lib" /** * Represents a transaction hash (or transaction ID) as an un-prefixed hex @@ -552,7 +548,7 @@ export function hashLEToBigNumber(hash: Hex): BigNumber { * unprefixed hex string (without 0x prefix). * @param witness - If true, a witness public key hash will be encoded and * P2WPKH address will be returned. Returns P2PKH address otherwise - * @param network - Network the address should be encoded for. + * @param bitcoinNetwork - Network the address should be encoded for. * @returns P2PKH or P2WPKH address encoded from the given public key hash * @throws Throws an error if network is not supported. */ @@ -626,16 +622,17 @@ export function createOutputScriptFromAddress(address: string): Hex { /** * Creates the Bitcoin address from the output script. * @param script The unprefixed and not prepended with length output script. - * @param network Bitcoin network. + * @param bitcoinNetwork Bitcoin network. * @returns The Bitcoin address. */ export function createAddressFromOutputScript( script: Hex, - network: BitcoinNetwork = BitcoinNetwork.Mainnet + bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.Mainnet ): string { - return Script.fromRaw(script.toString(), "hex") - .getAddress() - ?.toString(toBcoinNetwork(network)) + return address.fromOutputScript( + script.toBuffer(), + toBitcoinJsLibNetwork(bitcoinNetwork) + ) } /** diff --git a/typescript/test/bitcoin-network.test.ts b/typescript/test/bitcoin-network.test.ts index e610c2ee9..b283c5441 100644 --- a/typescript/test/bitcoin-network.test.ts +++ b/typescript/test/bitcoin-network.test.ts @@ -1,9 +1,5 @@ import { expect } from "chai" -import { - BitcoinNetwork, - toBcoinNetwork, - toBitcoinJsLibNetwork, -} from "../src/bitcoin-network" +import { BitcoinNetwork, toBitcoinJsLibNetwork } from "../src/bitcoin-network" import { TransactionHash } from "../src/bitcoin" import { networks } from "bitcoinjs-lib" @@ -14,7 +10,6 @@ describe("BitcoinNetwork", () => { enumValue: "unknown", // any value that doesn't match other supported networks genesisHash: TransactionHash.from("0x00010203"), - expectedToBcoinResult: new Error("network not supported"), expectedToBitcoinJsLibResult: new Error("network not supported"), }, { @@ -23,7 +18,6 @@ describe("BitcoinNetwork", () => { genesisHash: TransactionHash.from( "0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" ), - expectedToBcoinResult: "testnet", expectedToBitcoinJsLibResult: networks.testnet, }, { @@ -32,19 +26,12 @@ describe("BitcoinNetwork", () => { genesisHash: TransactionHash.from( "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" ), - expectedToBcoinResult: "main", expectedToBitcoinJsLibResult: networks.bitcoin, }, ] testData.forEach( - ({ - enumKey, - enumValue, - genesisHash, - expectedToBcoinResult, - expectedToBitcoinJsLibResult, - }) => { + ({ enumKey, enumValue, genesisHash, expectedToBitcoinJsLibResult }) => { context(enumKey, async () => { describe(`toString`, async () => { it(`should return correct value`, async () => { @@ -60,20 +47,6 @@ describe("BitcoinNetwork", () => { }) }) - describe(`toBcoinNetwork`, async () => { - if (expectedToBcoinResult instanceof Error) { - it(`should throw an error`, async () => { - expect(() => toBcoinNetwork(enumKey)).to.throw( - expectedToBcoinResult.message - ) - }) - } else { - it(`should return ${expectedToBcoinResult}`, async () => { - expect(toBcoinNetwork(enumKey)).to.be.equal(expectedToBcoinResult) - }) - } - }) - describe(`toBitcoinJsLibNetwork`, async () => { if (expectedToBitcoinJsLibResult instanceof Error) { it(`should throw an error`, async () => { From a21fc6f80adc75b09a443a5c1235a5dd8dbbe138 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Tue, 3 Oct 2023 18:03:58 +0200 Subject: [PATCH 137/205] Used bitcoinjs-lib for createOutputScriptFromAddress --- typescript/src/bitcoin.ts | 17 +++++++++++++---- typescript/src/deposit-refund.ts | 5 ++++- typescript/src/deposit-sweep.ts | 5 ++++- typescript/src/electrum.ts | 12 ++++++++++-- typescript/src/wallet.ts | 5 ++++- typescript/test/bitcoin.test.ts | 8 ++++++-- typescript/test/data/redemption.ts | 8 +++++--- 7 files changed, 46 insertions(+), 14 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 78f99870b..33df0dd4b 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -1,4 +1,4 @@ -import bcoin, { TX, Script } from "bcoin" +import bcoin, { TX } from "bcoin" import bufio from "bufio" import { BigNumber, utils } from "ethers" import { Hex } from "./hex" @@ -612,11 +612,20 @@ export function locktimeToNumber(locktimeLE: Buffer | string): number { /** * Creates the output script from the BTC address. - * @param address BTC address. + * @param bitcoinAddress Bitcoin address. + * @param bitcoinNetwork Bitcoin network. * @returns The un-prefixed and not prepended with length output script. */ -export function createOutputScriptFromAddress(address: string): Hex { - return Hex.from(Script.fromAddress(address).toRaw().toString("hex")) +export function createOutputScriptFromAddress( + bitcoinAddress: string, + bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.Mainnet +): Hex { + return Hex.from( + address.toOutputScript( + bitcoinAddress, + toBitcoinJsLibNetwork(bitcoinNetwork) + ) + ) } /** diff --git a/typescript/src/deposit-refund.ts b/typescript/src/deposit-refund.ts index 3b68f81a9..2f6b9ee88 100644 --- a/typescript/src/deposit-refund.ts +++ b/typescript/src/deposit-refund.ts @@ -122,7 +122,10 @@ export async function assembleDepositRefundTransaction( utxo.outputIndex ) - const outputScript = createOutputScriptFromAddress(refunderAddress) + const outputScript = createOutputScriptFromAddress( + refunderAddress, + bitcoinNetwork + ) transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) // In order to be able to spend the UTXO being refunded the transaction's diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 7c68008eb..03cfc5e13 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -182,7 +182,10 @@ export async function assembleDepositSweepTransaction( } outputValue = outputValue.sub(fee) - const outputScript = createOutputScriptFromAddress(walletAddress) + const outputScript = createOutputScriptFromAddress( + walletAddress, + bitcoinNetwork + ) transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) // Sign the main UTXO input if there is main UTXO. diff --git a/typescript/src/electrum.ts b/typescript/src/electrum.ts index 70d47d256..ba6380576 100644 --- a/typescript/src/electrum.ts +++ b/typescript/src/electrum.ts @@ -232,7 +232,11 @@ export class Client implements BitcoinClient { ): Promise { return this.withElectrum( async (electrum: Electrum) => { - const script = createOutputScriptFromAddress(address).toString() + const bitcoinNetwork = await this.getNetwork() + const script = createOutputScriptFromAddress( + address, + bitcoinNetwork + ).toString() // eslint-disable-next-line camelcase type UnspentOutput = { tx_pos: number; value: number; tx_hash: string } @@ -262,7 +266,11 @@ export class Client implements BitcoinClient { limit?: number ): Promise { return this.withElectrum(async (electrum: Electrum) => { - const script = createOutputScriptFromAddress(address).toString() + const bitcoinNetwork = await this.getNetwork() + const script = createOutputScriptFromAddress( + address, + bitcoinNetwork + ).toString() // eslint-disable-next-line camelcase type HistoryItem = { height: number; tx_hash: string } diff --git a/typescript/src/wallet.ts b/typescript/src/wallet.ts index 5c9a46ae1..947b95436 100644 --- a/typescript/src/wallet.ts +++ b/typescript/src/wallet.ts @@ -283,7 +283,10 @@ export async function determineWalletMainUtxo( // Get the wallet script based on the wallet address. This is required // to find transaction outputs that lock funds on the wallet. - const walletScript = createOutputScriptFromAddress(walletAddress) + const walletScript = createOutputScriptFromAddress( + walletAddress, + bitcoinNetwork + ) const isWalletOutput = (output: TransactionOutput) => walletScript.equals(output.scriptPubKey) diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 3e43be062..65fa8198f 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -537,7 +537,11 @@ describe("Bitcoin", () => { ).forEach( ([addressType, { address, scriptPubKey: expectedOutputScript }]) => { it(`should create correct output script for ${addressType} address type`, () => { - const result = createOutputScriptFromAddress(address) + const network = + bitcoinNetwork === "mainnet" + ? BitcoinNetwork.Mainnet + : BitcoinNetwork.Testnet + const result = createOutputScriptFromAddress(address, network) expect(result.toString()).to.eq(expectedOutputScript.toString()) }) @@ -547,7 +551,7 @@ describe("Bitcoin", () => { }) }) - describe("getAddressFromScriptPubKey", () => { + describe("createAddressFromOutputScript", () => { Object.keys(btcAddresses).forEach((bitcoinNetwork) => { context(`with ${bitcoinNetwork} addresses`, () => { Object.entries( diff --git a/typescript/test/data/redemption.ts b/typescript/test/data/redemption.ts index 958b9dcc2..d38780f78 100644 --- a/typescript/test/data/redemption.ts +++ b/typescript/test/data/redemption.ts @@ -11,7 +11,7 @@ import { } from "../../src/bitcoin" import { RedemptionRequest } from "../../src/redemption" import { Address } from "../../src/ethereum" -import { BitcoinTransaction, Hex } from "../../src" +import { BitcoinNetwork, BitcoinTransaction, Hex } from "../../src" import { WalletState } from "../../src/wallet" /** @@ -723,7 +723,8 @@ export const findWalletForRedemptionData: { outputIndex: 0, value: BigNumber.from("791613461"), scriptPubKey: createOutputScriptFromAddress( - "tb1qqwm566yn44rdlhgph8sw8vecta8uutg79afuja" + "tb1qqwm566yn44rdlhgph8sw8vecta8uutg79afuja", + BitcoinNetwork.Testnet ), }, ], @@ -848,7 +849,8 @@ export const findWalletForRedemptionData: { outputIndex: 0, value: BigNumber.from("3370000"), // 0.0337 BTC scriptPubKey: createOutputScriptFromAddress( - "tb1qx2xejtjltdcau5dpks8ucszkhxdg3fj88404lh" + "tb1qx2xejtjltdcau5dpks8ucszkhxdg3fj88404lh", + BitcoinNetwork.Testnet ), }, ], From ba404322d840dd0935d0a9ba0548aa3e35bd580d Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 4 Oct 2023 12:44:31 +0200 Subject: [PATCH 138/205] Updated transaction decomposition --- typescript/src/bitcoin.ts | 49 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 33df0dd4b..6f7e3c074 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -1,9 +1,9 @@ -import bcoin, { TX } from "bcoin" +import bcoin from "bcoin" import bufio from "bufio" import { BigNumber, utils } from "ethers" import { Hex } from "./hex" import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" -import { address, payments } from "bitcoinjs-lib" +import { Transaction as Tx, address, payments } from "bitcoinjs-lib" /** * Represents a transaction hash (or transaction ID) as an un-prefixed hex @@ -407,46 +407,53 @@ export interface Client { export function decomposeRawTransaction( rawTransaction: RawTransaction ): DecomposedRawTransaction { - const toHex = (bufferWriter: any) => { + const toHex = (bufferWriter: any): string => { return bufferWriter.render().toString("hex") } - const vectorToRaw = (elements: any[]) => { + const getTxInputVector = (tx: Tx): string => { const buffer = bufio.write() - buffer.writeVarint(elements.length) - for (const element of elements) { - element.toWriter(buffer) - } + buffer.writeVarint(tx.ins.length) + tx.ins.forEach((input) => { + buffer.writeHash(input.hash) + buffer.writeU32(input.index) + buffer.writeVarBytes(input.script) + buffer.writeU32(input.sequence) + }) return toHex(buffer) } - const getTxInputVector = (tx: any) => { - return vectorToRaw(tx.inputs) - } - - const getTxOutputVector = (tx: any) => { - return vectorToRaw(tx.outputs) + const getTxOutputVector = (tx: Tx): string => { + const buffer = bufio.write() + buffer.writeVarint(tx.outs.length) + tx.outs.forEach((output) => { + buffer.writeI64(output.value) + buffer.writeVarBytes(output.script) + }) + return toHex(buffer) } - const getTxVersion = (tx: any) => { + const getTxVersion = (tx: Tx): string => { const buffer = bufio.write() buffer.writeU32(tx.version) return toHex(buffer) } - const getTxLocktime = (tx: any) => { + const getTxLocktime = (tx: Tx): string => { const buffer = bufio.write() buffer.writeU32(tx.locktime) return toHex(buffer) } - const tx = TX.fromRaw(Buffer.from(rawTransaction.transactionHex, "hex"), null) + const transaction = Tx.fromBuffer( + Buffer.from(rawTransaction.transactionHex, "hex") + ) return { - version: getTxVersion(tx), - inputs: getTxInputVector(tx), - outputs: getTxOutputVector(tx), - locktime: getTxLocktime(tx), + version: getTxVersion(transaction), + inputs: getTxInputVector(transaction), + outputs: getTxOutputVector(transaction), + locktime: getTxLocktime(transaction), } } From ddfc0f5de0de7bc5ec273b114e99a0d7cc2d5861 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 4 Oct 2023 13:38:44 +0200 Subject: [PATCH 139/205] Used bitcoinjs-lib for decodeBitcoinAddress --- typescript/src/bitcoin.ts | 31 +++++++---- typescript/test/bitcoin.test.ts | 96 ++++++++++++++++++++++++--------- 2 files changed, 91 insertions(+), 36 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 6f7e3c074..3649327a6 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -1,4 +1,3 @@ -import bcoin from "bcoin" import bufio from "bufio" import { BigNumber, utils } from "ethers" import { Hex } from "./hex" @@ -574,20 +573,30 @@ export function encodeToBitcoinAddress( /** * Decodes P2PKH or P2WPKH address into a public key hash. Throws if the * provided address is not PKH-based. - * @param address - P2PKH or P2WPKH address that will be decoded. + * @param bitcoinAddress - P2PKH or P2WPKH address that will be decoded. + * @param bitcoinNetwork - Bitcoin network. * @returns Public key hash decoded from the address. This will be an unprefixed * hex string (without 0x prefix). */ -export function decodeBitcoinAddress(address: string): string { - const addressObject = new bcoin.Address(address) +export function decodeBitcoinAddress( + bitcoinAddress: string, + bitcoinNetwork: BitcoinNetwork +): string { + const network = toBitcoinJsLibNetwork(bitcoinNetwork) - const isPKH = - addressObject.isPubkeyhash() || addressObject.isWitnessPubkeyhash() - if (!isPKH) { - throw new Error("Address must be P2PKH or P2WPKH") - } + try { + // Try extracting hash from P2PKH address. + const hash = payments.p2pkh({ address: bitcoinAddress, network }).hash! + return hash.toString("hex") + } catch (err) {} + + try { + // Try extracting hash from P2WPKH address. + const hash = payments.p2wpkh({ address: bitcoinAddress, network }).hash! + return hash.toString("hex") + } catch (err) {} - return addressObject.getHash("hex") + throw new Error("Address must be P2PKH or P2WPKH valid for given network") } /** @@ -625,7 +634,7 @@ export function locktimeToNumber(locktimeLE: Buffer | string): number { */ export function createOutputScriptFromAddress( bitcoinAddress: string, - bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.Mainnet + bitcoinNetwork: BitcoinNetwork ): Hex { return Hex.from( address.toOutputScript( diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 65fa8198f..a6ea1c1ce 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -259,21 +259,21 @@ describe("Bitcoin", () => { }) }) - describe("decodeAddress", () => { + describe("decodeBitcoinAddress", () => { context("when network is mainnet", () => { context("when proper P2WPKH address is provided", () => { it("should decode P2WPKH adress correctly", () => { - expect(decodeBitcoinAddress(P2WPKHAddress)).to.be.equal( - publicKeyHash - ) + expect( + decodeBitcoinAddress(P2WPKHAddress, BitcoinNetwork.Mainnet) + ).to.be.equal(publicKeyHash) }) }) context("when proper P2PKH address is provided", () => { it("should decode P2PKH address correctly", () => { - expect(decodeBitcoinAddress(P2PKHAddress)).to.be.equal( - publicKeyHash - ) + expect( + decodeBitcoinAddress(P2PKHAddress, BitcoinNetwork.Mainnet) + ).to.be.equal(publicKeyHash) }) }) @@ -281,8 +281,10 @@ describe("Bitcoin", () => { it("should throw", () => { const bitcoinAddress = "123" + P2PKHAddress - expect(() => decodeBitcoinAddress(bitcoinAddress)).to.throw( - "Address is too long" + expect(() => + decodeBitcoinAddress(bitcoinAddress, BitcoinNetwork.Mainnet) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" ) }) }) @@ -290,8 +292,13 @@ describe("Bitcoin", () => { context("when unsupported P2SH address is provided", () => { it("should throw", () => { expect(() => - decodeBitcoinAddress("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX") - ).to.throw("Address must be P2PKH or P2WPKH") + decodeBitcoinAddress( + "3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX", + BitcoinNetwork.Mainnet + ) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) }) }) @@ -299,9 +306,25 @@ describe("Bitcoin", () => { it("should throw", () => { expect(() => decodeBitcoinAddress( - "bc1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhsdxuv4m" + "bc1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhsdxuv4m", + BitcoinNetwork.Mainnet ) - ).to.throw("Address must be P2PKH or P2WPKH") + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) + }) + }) + + context("when address from testnet network is provided", () => { + it("should throw", () => { + expect(() => + decodeBitcoinAddress( + "mkpoZkRvtd3SDGWgUDuXK1aEXZfHRM2gKw", + BitcoinNetwork.Mainnet + ) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) }) }) }) @@ -309,17 +332,17 @@ describe("Bitcoin", () => { context("when network is testnet", () => { context("when proper P2WPKH address is provided", () => { it("should decode P2WPKH adress correctly", () => { - expect(decodeBitcoinAddress(P2WPKHAddressTestnet)).to.be.equal( - publicKeyHash - ) + expect( + decodeBitcoinAddress(P2WPKHAddressTestnet, BitcoinNetwork.Testnet) + ).to.be.equal(publicKeyHash) }) }) context("when proper P2PKH address is provided", () => { it("should decode P2PKH address correctly", () => { - expect(decodeBitcoinAddress(P2PKHAddressTestnet)).to.be.equal( - publicKeyHash - ) + expect( + decodeBitcoinAddress(P2PKHAddressTestnet, BitcoinNetwork.Testnet) + ).to.be.equal(publicKeyHash) }) }) @@ -327,8 +350,10 @@ describe("Bitcoin", () => { it("should throw", () => { const bitcoinAddress = "123" + P2PKHAddressTestnet - expect(() => decodeBitcoinAddress(bitcoinAddress)).to.throw( - "Address is too long" + expect(() => + decodeBitcoinAddress(bitcoinAddress, BitcoinNetwork.Testnet) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" ) }) }) @@ -336,8 +361,13 @@ describe("Bitcoin", () => { context("when unsupported P2SH address is provided", () => { it("should throw", () => { expect(() => - decodeBitcoinAddress("2MyxShnGQ5NifGb8CHYrtmzosRySxZ9pZo5") - ).to.throw("Address must be P2PKH or P2WPKH") + decodeBitcoinAddress( + "2MyxShnGQ5NifGb8CHYrtmzosRySxZ9pZo5", + BitcoinNetwork.Testnet + ) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) }) }) @@ -345,9 +375,25 @@ describe("Bitcoin", () => { it("should throw", () => { expect(() => decodeBitcoinAddress( - "tb1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhs6w2r05" + "tb1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhs6w2r05", + BitcoinNetwork.Testnet ) - ).to.throw("Address must be P2PKH or P2WPKH") + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) + }) + }) + + context("when address from mainnet network is provided", () => { + it("should throw", () => { + expect(() => + decodeBitcoinAddress( + "bc1q8gudgnt2pjxshwzwqgevccet0eyvwtswt03nuy", + BitcoinNetwork.Testnet + ) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) }) }) }) From 3dcdbf98c988171ab2489d9400a2bad59845b201 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Wed, 4 Oct 2023 14:34:03 +0200 Subject: [PATCH 140/205] Used bitcoinjs-lib for electrum functionalities --- typescript/src/electrum.ts | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/typescript/src/electrum.ts b/typescript/src/electrum.ts index ba6380576..de21961ff 100644 --- a/typescript/src/electrum.ts +++ b/typescript/src/electrum.ts @@ -1,7 +1,8 @@ -import bcoin from "bcoin" +import { Transaction as Tx, TxInput, TxOutput } from "bitcoinjs-lib" import pTimeout from "p-timeout" import { Client as BitcoinClient, + computeSha256, createOutputScriptFromAddress, RawTransaction, Transaction, @@ -337,26 +338,26 @@ export class Client implements BitcoinClient { } // Decode the raw transaction. - const transaction = bcoin.TX.fromRaw(rawTransaction, "hex") + const transaction = Tx.fromHex(rawTransaction) - const inputs = transaction.inputs.map( - (input: any): TransactionInput => ({ - transactionHash: TransactionHash.from(input.prevout.hash).reverse(), - outputIndex: input.prevout.index, - scriptSig: Hex.from(input.script.toRaw()), + const inputs = transaction.ins.map( + (input: TxInput): TransactionInput => ({ + transactionHash: TransactionHash.from(input.hash).reverse(), + outputIndex: input.index, + scriptSig: Hex.from(input.script), }) ) - const outputs = transaction.outputs.map( - (output: any, i: number): TransactionOutput => ({ + const outputs = transaction.outs.map( + (output: TxOutput, i: number): TransactionOutput => ({ outputIndex: i, value: BigNumber.from(output.value), - scriptPubKey: Hex.from(output.script.toRaw()), + scriptPubKey: Hex.from(output.script), }) ) return { - transactionHash: TransactionHash.from(transaction.hash()).reverse(), + transactionHash: TransactionHash.from(transaction.getId()), inputs: inputs, outputs: outputs, } @@ -407,7 +408,7 @@ export class Client implements BitcoinClient { ) // Decode the raw transaction. - const transaction = bcoin.TX.fromRaw(rawTransaction, "hex") + const transaction = Tx.fromHex(rawTransaction) // As a workaround for the problem described in https://github.com/Blockstream/electrs/pull/36 // we need to calculate the number of confirmations based on the latest @@ -425,8 +426,10 @@ export class Client implements BitcoinClient { // If a transaction is unconfirmed (is still in the mempool) the height will // have a value of `0` or `-1`. let txBlockHeight: number = Math.min() - for (const output of transaction.outputs) { - const scriptHash: Buffer = output.script.sha256() + for (const output of transaction.outs) { + const scriptHash: Buffer = computeSha256( + Hex.from(output.script) + ).toBuffer() type HistoryEntry = { // eslint-disable-next-line camelcase From 23de326ed1e932c64c04b54dbf9d3bcc3f476c48 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 5 Oct 2023 12:15:53 +0200 Subject: [PATCH 141/205] Replaced bcoin with custom function for unit tests --- typescript/src/bitcoin.ts | 46 +++++++++++ typescript/test/data/deposit.ts | 12 --- typescript/test/deposit-sweep.test.ts | 110 +++++++++----------------- typescript/test/deposit.test.ts | 28 +++---- typescript/test/redemption.test.ts | 88 ++++++++++----------- 5 files changed, 140 insertions(+), 144 deletions(-) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 3649327a6..3745050da 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -780,3 +780,49 @@ export function isP2WSHScript(script: Buffer): boolean { return false } } + +interface TxJSON { + hash: string + version: number + locktime: number + inputs: { + hash: string + index: number + sequence: number + script: string + witness: string[] + }[] + outputs: { + value: number + script: string + address: string + }[] +} + +export function txToJSON( + rawTransaction: string, + bitcoinNetwork: BitcoinNetwork +): TxJSON { + const transaction = Tx.fromHex(rawTransaction) + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + + const txJSON: TxJSON = { + hash: transaction.getId(), + version: transaction.version, + locktime: transaction.locktime, + inputs: transaction.ins.map((input) => ({ + hash: Hex.from(input.hash).reverse().toString(), + index: input.index, + sequence: input.sequence, + script: input.script.toString("hex"), + witness: input.witness.map((w) => w.toString("hex")), + })), + outputs: transaction.outs.map((output) => ({ + value: output.value, + script: output.script.toString("hex"), + address: address.fromOutputScript(output.script, network), + })), + } + + return txJSON +} diff --git a/typescript/test/data/deposit.ts b/typescript/test/data/deposit.ts index 425c87204..61a9e7b46 100644 --- a/typescript/test/data/deposit.ts +++ b/typescript/test/data/deposit.ts @@ -60,15 +60,3 @@ export const testnetWalletPrivateKey = * Address corresponding to testnetWalletPrivateKey. */ export const testnetWalletAddress = "tb1q3k6sadfqv04fmx9naty3fzdfpaecnphkfm3cf3" - -/** - * Address generated from deposit script hash during deposit creation - */ -export const testnetDepositScripthashAddress = - "2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C" - -/** - * Address generated from deposit witness script hash during deposit creation - */ -export const testnetDepositWitnessScripthashAddress = - "tb1qs63s8nwjut4tr5t8nudgzwp4m3dpkefjzpmumn90pruce0cye2tq2jkq0y" diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index be41c9a81..103d86607 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -4,13 +4,9 @@ import { TransactionHash, UnspentTransactionOutput, Transaction, + txToJSON, } from "../src/bitcoin" -import { - testnetDepositScripthashAddress, - testnetDepositWitnessScripthashAddress, - testnetWalletAddress, - testnetWalletPrivateKey, -} from "./data/deposit" +import { testnetWalletAddress, testnetWalletPrivateKey } from "./data/deposit" import { depositSweepWithWitnessMainUtxoAndWitnessOutput, depositSweepWithNoMainUtxoAndWitnessOutput, @@ -21,7 +17,6 @@ import { } from "./data/deposit-sweep" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { MockBridge } from "./utils/mock-bridge" -import bcoin from "bcoin" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) @@ -394,8 +389,10 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() @@ -406,26 +403,23 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(2) const p2shInput = txJSON.inputs[0] - expect(p2shInput.prevout.hash).to.be.equal( + expect(p2shInput.hash).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2shInput.prevout.index).to.be.equal( + expect(p2shInput.index).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.equal("00") + expect(p2shInput.witness).to.be.empty expect(p2shInput.script.length).to.be.greaterThan(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2shInput.address).to.be.equal(testnetDepositScripthashAddress) const p2wshInput = txJSON.inputs[1] - expect(p2wshInput.prevout.hash).to.be.equal( + expect(p2wshInput.hash).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() ) - expect(p2wshInput.prevout.index).to.be.equal( + expect(p2wshInput.index).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo .outputIndex ) @@ -433,11 +427,6 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wshInput.witness.length).to.be.greaterThan(0) expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // witness script hash - expect(p2wshInput.address).to.be.equal( - testnetDepositWitnessScripthashAddress - ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -526,8 +515,10 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() @@ -538,10 +529,10 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(3) const p2wkhInput = txJSON.inputs[0] - expect(p2wkhInput.prevout.hash).to.be.equal( + expect(p2wkhInput.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() ) - expect(p2wkhInput.prevout.index).to.be.equal( + expect(p2wkhInput.index).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo .outputIndex ) @@ -549,33 +540,25 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wkhInput.witness.length).to.be.greaterThan(0) expect(p2wkhInput.script.length).to.be.equal(0) - // The input comes from the main UTXO so the input should be the - // wallet's address - expect(p2wkhInput.address).to.be.equal(testnetWalletAddress) const p2shInput = txJSON.inputs[1] - expect(p2shInput.prevout.hash).to.be.equal( + expect(p2shInput.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2shInput.prevout.index).to.be.equal( + expect(p2shInput.index).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.equal("00") + expect(p2shInput.witness).to.be.empty expect(p2shInput.script.length).to.be.greaterThan(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2shInput.address).to.be.equal( - testnetDepositScripthashAddress - ) const p2wshInput = txJSON.inputs[2] - expect(p2wshInput.prevout.hash).to.be.equal( + expect(p2wshInput.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() ) - expect(p2wshInput.prevout.index).to.be.equal( + expect(p2wshInput.index).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo .outputIndex ) @@ -583,11 +566,6 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wshInput.witness.length).to.be.greaterThan(0) expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // witness script hash - expect(p2wshInput.address).to.be.equal( - testnetDepositWitnessScripthashAddress - ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -677,8 +655,10 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() @@ -689,28 +669,23 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(2) const p2pkhInput = txJSON.inputs[0] // main UTXO - expect(p2pkhInput.prevout.hash).to.be.equal( + expect(p2pkhInput.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() ) - expect(p2pkhInput.prevout.index).to.be.equal( + expect(p2pkhInput.index).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2pkhInput.witness).to.be.equal("00") + expect(p2pkhInput.witness).to.be.empty expect(p2pkhInput.script.length).to.be.greaterThan(0) - // The input comes from the main UTXO so the input should be the - // wallet's address - expect(p2pkhInput.address).to.be.equal( - "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" - ) const p2wshInput = txJSON.inputs[1] - expect(p2wshInput.prevout.hash).to.be.equal( + expect(p2wshInput.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2wshInput.prevout.index).to.be.equal( + expect(p2wshInput.index).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0] .utxo.outputIndex ) @@ -718,11 +693,6 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wshInput.witness.length).to.be.greaterThan(0) expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2wshInput.address).to.be.equal( - "tb1qk8urugnf08wfle6wslmdxq7mkz9z0gw8e6gkvspn7dx87tfpfntshdm7qr" - ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -810,9 +780,10 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep.transactionHash.toString() ) @@ -822,22 +793,17 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(1) const p2shInput = txJSON.inputs[0] - expect(p2shInput.prevout.hash).to.be.equal( + expect(p2shInput.hash).to.be.equal( depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2shInput.prevout.index).to.be.equal( + expect(p2shInput.index).to.be.equal( depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.equal("00") + expect(p2shInput.witness).to.be.empty expect(p2shInput.script.length).to.be.greaterThan(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2shInput.address).to.be.equal( - "2N8iF1pRndihBzgLDna9MfRhmqktwTdHejA" - ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index 27bb5eadd..79f098230 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -12,9 +12,9 @@ import { RawTransaction, TransactionHash, UnspentTransactionOutput, + txToJSON, } from "../src/bitcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import bcoin from "bcoin" import { assembleDepositScript, assembleDepositTransaction, @@ -342,8 +342,10 @@ describe("Deposit", () => { expect(transaction).to.be.eql(expectedP2WSHDeposit.transaction) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( expectedP2WSHDeposit.transactionHash.toString() @@ -355,15 +357,12 @@ describe("Deposit", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( - testnetUTXO.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) + expect(input.hash).to.be.equal(testnetUTXO.transactionHash.toString()) + expect(input.index).to.be.equal(testnetUTXO.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(testnetAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -442,8 +441,10 @@ describe("Deposit", () => { expect(transaction).to.be.eql(expectedP2SHDeposit.transaction) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( expectedP2SHDeposit.transactionHash.toString() @@ -455,15 +456,12 @@ describe("Deposit", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( - testnetUTXO.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) + expect(input.hash).to.be.equal(testnetUTXO.transactionHash.toString()) + expect(input.index).to.be.equal(testnetUTXO.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(testnetAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index 874d0fd26..acbafa2bc 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -3,8 +3,8 @@ import { RawTransaction, TransactionHash, UnspentTransactionOutput, + txToJSON, } from "../src/bitcoin" -import bcoin from "bcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { walletPrivateKey, @@ -510,8 +510,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -523,17 +525,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -624,8 +623,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -637,17 +638,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -737,8 +735,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -750,17 +750,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -850,8 +847,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -863,17 +862,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -960,8 +956,10 @@ describe("Redemption", () => { expect(transaction).to.be.eql(data.expectedRedemption.transaction) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -973,15 +971,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(5) @@ -1118,8 +1115,10 @@ describe("Redemption", () => { expect(transaction).to.be.eql(data.expectedRedemption.transaction) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -1131,15 +1130,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -1225,9 +1223,10 @@ describe("Redemption", () => { expect(transaction).to.be.eql(data.expectedRedemption.transaction) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() ) @@ -1238,15 +1237,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) From 5be11800ef6f440a08974a86eb101f8860113455 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 5 Oct 2023 12:27:19 +0200 Subject: [PATCH 142/205] REmoved bcoin dependency --- typescript/package.json | 7 +- typescript/typings.d.ts | 1 - typescript/yarn.lock | 195 +--------------------------------------- 3 files changed, 2 insertions(+), 201 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index 806339a53..21d9a4fc9 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -13,8 +13,7 @@ "test": "mocha --exit --recursive 'test/**/*.test.ts'", "typechain": "rm -rf ./typechain && for i in $npm_package_config_contracts; do typechain --target ethers-v5 --out-dir ./typechain $i; done && rm ./typechain/index.ts", "build": "npm run typechain && tsc --project tsconfig.build.json", - "dev": "tsc --project tsconfig.build.json --watch", - "postinstall": "npm rebuild bcrypto" + "dev": "tsc --project tsconfig.build.json --watch" }, "files": [ "dist/", @@ -27,7 +26,6 @@ "dependencies": { "@keep-network/ecdsa": "development", "@keep-network/tbtc-v2": "development", - "bcoin": "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8", "bitcoinjs-lib": "6.0.2", "bufio": "^1.0.6", "ecpair": "^2.1.0", @@ -61,8 +59,5 @@ }, "engines": { "node": ">=14 <15" - }, - "browser": { - "bcoin": "bcoin/lib/bcoin-browser" } } diff --git a/typescript/typings.d.ts b/typescript/typings.d.ts index 2558e6a79..abe66d9f4 100644 --- a/typescript/typings.d.ts +++ b/typescript/typings.d.ts @@ -2,7 +2,6 @@ * Manually declare modules for imported third-party libraries that * don't provide their own typings. */ -declare module "bcoin" declare module "bufio" declare module "electrum-client-js" declare module "wif" diff --git a/typescript/yarn.lock b/typescript/yarn.lock index 05897068f..ba01c6262 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -2496,45 +2496,6 @@ base64-js@^1.3.1: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== -"bcfg@git+https://github.com/bcoin-org/bcfg.git#semver:~0.1.7": - version "0.1.7" - resolved "git+https://github.com/bcoin-org/bcfg.git#05122154b35baa82cd01dc9478ebee7346386ba1" - dependencies: - bsert "~0.0.10" - -"bcoin@git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8": - version "2.2.0" - resolved "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8" - dependencies: - bcfg "git+https://github.com/bcoin-org/bcfg.git#semver:~0.1.7" - bcrypto "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0" - bcurl "git+https://github.com/bcoin-org/bcurl.git#semver:^0.1.6" - bdb "git+https://github.com/bcoin-org/bdb.git#semver:~1.2.1" - bdns "git+https://github.com/bcoin-org/bdns.git#semver:~0.1.5" - bevent "git+https://github.com/bcoin-org/bevent.git#semver:~0.1.5" - bfile "git+https://github.com/bcoin-org/bfile.git#semver:~0.2.1" - bfilter "git+https://github.com/bcoin-org/bfilter.git#semver:~2.3.0" - bheep "git+https://github.com/bcoin-org/bheep.git#semver:~0.1.5" - binet "git+https://github.com/bcoin-org/binet.git#semver:~0.3.5" - blgr "git+https://github.com/bcoin-org/blgr.git#semver:~0.2.0" - blru "git+https://github.com/bcoin-org/blru.git#semver:~0.1.6" - blst "git+https://github.com/bcoin-org/blst.git#semver:~0.1.5" - bmutex "git+https://github.com/bcoin-org/bmutex.git#semver:~0.1.6" - brq "git+https://github.com/bcoin-org/brq.git#semver:~0.1.7" - bs32 "git+https://github.com/bcoin-org/bs32.git#semver:=0.1.6" - bsert "git+https://github.com/chjj/bsert.git#semver:~0.0.10" - bsock "git+https://github.com/bcoin-org/bsock.git#semver:~0.1.9" - bsocks "git+https://github.com/bcoin-org/bsocks.git#semver:~0.2.6" - btcp "git+https://github.com/bcoin-org/btcp.git#semver:~0.1.5" - buffer-map "git+https://github.com/chjj/buffer-map.git#semver:~0.0.7" - bufio "git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6" - bupnp "git+https://github.com/bcoin-org/bupnp.git#semver:~0.2.6" - bval "git+https://github.com/bcoin-org/bval.git#semver:~0.1.6" - bweb "git+https://github.com/bcoin-org/bweb.git#semver:=0.1.9" - loady "git+https://github.com/chjj/loady.git#semver:~0.0.1" - n64 "git+https://github.com/chjj/n64.git#semver:~0.2.10" - nan "git+https://github.com/braydonf/nan.git#semver:=2.14.0" - bcrypt-pbkdf@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" @@ -2542,34 +2503,6 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" -"bcrypto@git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0": - version "5.5.0" - resolved "git+https://github.com/bcoin-org/bcrypto.git#34738cf15033e3bce91a4f6f41ec1ebee3c2fdc8" - dependencies: - bufio "~1.0.7" - loady "~0.0.5" - -"bcurl@git+https://github.com/bcoin-org/bcurl.git#semver:^0.1.6": - version "0.1.10" - resolved "git+https://github.com/bcoin-org/bcurl.git#d7e088fad4c284fb5d6fd7205c6b903bd3e6bf83" - dependencies: - brq "~0.1.8" - bsert "~0.0.10" - bsock "~0.1.9" - -"bdb@git+https://github.com/bcoin-org/bdb.git#semver:~1.2.1": - version "1.2.2" - resolved "git+https://github.com/bcoin-org/bdb.git#2c8d48c8adca4b11260263472766cd4b7ae74ef7" - dependencies: - bsert "~0.0.10" - loady "~0.0.1" - -"bdns@git+https://github.com/bcoin-org/bdns.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/bdns.git#cb0b62a0075f7e1259fc50fa723ba644e9a07d14" - dependencies: - bsert "~0.0.10" - bech32@1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" @@ -2580,31 +2513,6 @@ bech32@^2.0.0: resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355" integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg== -"bevent@git+https://github.com/bcoin-org/bevent.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/bevent.git#60fb503de3ea1292d29ce438bfba80f0bc5ccb60" - dependencies: - bsert "~0.0.10" - -"bfile@git+https://github.com/bcoin-org/bfile.git#semver:~0.2.1": - version "0.2.2" - resolved "git+https://github.com/bcoin-org/bfile.git#c3075133a02830dc384f8353d8275d4499b8bff9" - -"bfilter@git+https://github.com/bcoin-org/bfilter.git#semver:~2.3.0": - version "2.3.0" - resolved "git+https://github.com/bcoin-org/bfilter.git#70e42125f877191d340e8838a1a90fabb750e680" - dependencies: - bcrypto "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0" - bsert "git+https://github.com/chjj/bsert.git#semver:~0.0.10" - bufio "git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6" - loady "git+https://github.com/chjj/loady.git#semver:~0.0.1" - -"bheep@git+https://github.com/bcoin-org/bheep.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/bheep.git#e59329d0a776ae71b2fb7a2876ee5b9fd3030fa2" - dependencies: - bsert "~0.0.10" - big-integer@^1.6.44: version "1.6.51" resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" @@ -2637,13 +2545,6 @@ bindings@^1.3.0: dependencies: file-uri-to-path "1.0.0" -"binet@git+https://github.com/bcoin-org/binet.git#semver:~0.3.5", binet@~0.3.5: - version "0.3.6" - resolved "git+https://github.com/bcoin-org/binet.git#d3decfb7a7257abdfb03c3a9c091499b2ebff0e1" - dependencies: - bs32 "~0.1.5" - bsert "~0.0.10" - bip174@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/bip174/-/bip174-2.1.1.tgz#ef3e968cf76de234a546962bcf572cc150982f9f" @@ -2718,18 +2619,6 @@ blakejs@^1.1.0: resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.2.1.tgz#5057e4206eadb4a97f7c0b6e197a505042fc3814" integrity sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ== -"blgr@git+https://github.com/bcoin-org/blgr.git#semver:~0.2.0": - version "0.2.0" - resolved "git+https://github.com/bcoin-org/blgr.git#050cbb587a1654a078468dbb92606330fdc4d120" - dependencies: - bsert "~0.0.10" - -"blru@git+https://github.com/bcoin-org/blru.git#semver:~0.1.6": - version "0.1.6" - resolved "git+https://github.com/bcoin-org/blru.git#c2c093e9475439333dfb87bfb2fdc3be6c98b080" - dependencies: - bsert "~0.0.10" - "bls12377js@https://github.com/celo-org/bls12377js#400bcaeec9e7620b040bfad833268f5289699cac": version "0.1.0" resolved "https://github.com/celo-org/bls12377js#400bcaeec9e7620b040bfad833268f5289699cac" @@ -2754,23 +2643,11 @@ blakejs@^1.1.0: ts-node "^8.4.1" typescript "^3.6.4" -"blst@git+https://github.com/bcoin-org/blst.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/blst.git#d588403edb18e628899e05aeba8c3a98a5cdedff" - dependencies: - bsert "~0.0.10" - bluebird@^3.5.0, bluebird@^3.5.2: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== -"bmutex@git+https://github.com/bcoin-org/bmutex.git#semver:~0.1.6": - version "0.1.6" - resolved "git+https://github.com/bcoin-org/bmutex.git#e50782323932a4946ecc05a74c6d45861adc2c25" - dependencies: - bsert "~0.0.10" - bn.js@4.11.6: version "4.11.6" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" @@ -2893,18 +2770,6 @@ browserify-sign@^4.0.0: readable-stream "^3.6.0" safe-buffer "^5.2.0" -"brq@git+https://github.com/bcoin-org/brq.git#semver:~0.1.7", brq@~0.1.7, brq@~0.1.8: - version "0.1.8" - resolved "git+https://github.com/bcoin-org/brq.git#534bb2c83fb366ba40ad80bc3de796a174503294" - dependencies: - bsert "~0.0.10" - -"bs32@git+https://github.com/bcoin-org/bs32.git#semver:=0.1.6", bs32@~0.1.5: - version "0.1.6" - resolved "git+https://github.com/bcoin-org/bs32.git#21cf9c724659dc15df722d2410548828c142f265" - dependencies: - bsert "~0.0.10" - bs58@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" @@ -2921,27 +2786,6 @@ bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: create-hash "^1.1.0" safe-buffer "^5.1.2" -"bsert@git+https://github.com/chjj/bsert.git#semver:~0.0.10", bsert@~0.0.10: - version "0.0.10" - resolved "git+https://github.com/chjj/bsert.git#bd09d49eab8644bca08ae8259a3d8756e7d453fc" - -"bsock@git+https://github.com/bcoin-org/bsock.git#semver:~0.1.9", bsock@~0.1.8, bsock@~0.1.9: - version "0.1.9" - resolved "git+https://github.com/bcoin-org/bsock.git#7cf76b3021ae7929c023d1170f789811e91ae528" - dependencies: - bsert "~0.0.10" - -"bsocks@git+https://github.com/bcoin-org/bsocks.git#semver:~0.2.6": - version "0.2.6" - resolved "git+https://github.com/bcoin-org/bsocks.git#6a8eb764dc4408e7f47da4f84e1afb1b393117e8" - dependencies: - binet "~0.3.5" - bsert "~0.0.10" - -"btcp@git+https://github.com/bcoin-org/btcp.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/btcp.git#4ea7e1ce5a43cd5348152c007aff76a419190a3a" - buffer-alloc-unsafe@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" @@ -2970,10 +2814,6 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== -"buffer-map@git+https://github.com/chjj/buffer-map.git#semver:~0.0.7": - version "0.0.7" - resolved "git+https://github.com/chjj/buffer-map.git#bad5863af9a520701937a17fc8fa2bd8ca8e73f3" - buffer-reverse@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-reverse/-/buffer-reverse-1.0.1.tgz#49283c8efa6f901bc01fa3304d06027971ae2f60" @@ -3026,31 +2866,10 @@ bufferutil@^4.0.1: dependencies: node-gyp-build "^4.3.0" -bufio@^1.0.6, "bufio@git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6", bufio@~1.0.7: +bufio@^1.0.6: version "1.0.7" resolved "git+https://github.com/bcoin-org/bufio.git#91ae6c93899ff9fad7d7cee9afd2a1c4933ca984" -"bupnp@git+https://github.com/bcoin-org/bupnp.git#semver:~0.2.6": - version "0.2.6" - resolved "git+https://github.com/bcoin-org/bupnp.git#c44fa7356aa297c9de96e8ad094a6816939cd688" - dependencies: - binet "~0.3.5" - brq "~0.1.7" - bsert "~0.0.10" - -"bval@git+https://github.com/bcoin-org/bval.git#semver:~0.1.6": - version "0.1.6" - resolved "git+https://github.com/bcoin-org/bval.git#c8cd14419ca46f63610dc48b797b076835e86f48" - dependencies: - bsert "~0.0.10" - -"bweb@git+https://github.com/bcoin-org/bweb.git#semver:=0.1.9": - version "0.1.9" - resolved "git+https://github.com/bcoin-org/bweb.git#31ae94ec9e97079610394e91928fe070d312c39d" - dependencies: - bsert "~0.0.10" - bsock "~0.1.8" - bytes@3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" @@ -5726,10 +5545,6 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" -"loady@git+https://github.com/chjj/loady.git#semver:~0.0.1", loady@~0.0.1, loady@~0.0.5: - version "0.0.5" - resolved "git+https://github.com/chjj/loady.git#b94958b7ee061518f4b85ea6da380e7ee93222d5" - locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -6148,19 +5963,11 @@ multihashes@^0.4.15, multihashes@~0.4.15: multibase "^0.7.0" varint "^5.0.0" -"n64@git+https://github.com/chjj/n64.git#semver:~0.2.10": - version "0.2.10" - resolved "git+https://github.com/chjj/n64.git#34f981f1441f569821d97a31f8cf21a3fc11b8f6" - nan@^2.13.2, nan@^2.14.0: version "2.15.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== -"nan@git+https://github.com/braydonf/nan.git#semver:=2.14.0": - version "2.14.0" - resolved "git+https://github.com/braydonf/nan.git#1dcc61bd06d84e389bfd5311b2b1492a14c74201" - nano-json-stream-parser@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz#0cc8f6d0e2b622b479c40d499c46d64b755c6f5f" From 6d15b27499fd2ac3f22e2202d3c6b5fa25200c31 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 5 Oct 2023 12:38:33 +0200 Subject: [PATCH 143/205] Added docstrings for transaction to JSON functionalities --- typescript/src/bitcoin.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index 3745050da..aea3d403f 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -781,6 +781,11 @@ export function isP2WSHScript(script: Buffer): boolean { } } +/** + * Represents a structured JSON format for a Bitcoin transaction. It includes + * detailed information about its inputs and outputs, as well as the transaction + * itself. + */ interface TxJSON { hash: string version: number @@ -799,6 +804,12 @@ interface TxJSON { }[] } +/** + * Converts a raw Bitcoin transaction into a structured JSON format. + * @param rawTransaction - A raw Bitcoin transaction in hexadecimal string format. + * @param bitcoinNetwork - Bitcoin network. + * @returns A structured JSON object representing the transaction. + */ export function txToJSON( rawTransaction: string, bitcoinNetwork: BitcoinNetwork From 9305eb0896791bb69cb126e4bbdfad9ffe5756c8 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 5 Oct 2023 13:27:19 +0200 Subject: [PATCH 144/205] Added unit tests for transaction to JSON functionalities --- typescript/test/bitcoin.test.ts | 94 ++++++++++++++++++++++++++++++++- typescript/test/data/bitcoin.ts | 25 +++++++++ 2 files changed, 118 insertions(+), 1 deletion(-) diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index a6ea1c1ce..eb8521e00 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -22,12 +22,18 @@ import { isP2WPKHScript, isP2SHScript, isP2WSHScript, + txToJSON, } from "../src/bitcoin" import { calculateDepositRefundLocktime } from "../src/deposit" import { BitcoinNetwork } from "../src/bitcoin-network" import { Hex } from "../src/hex" import { BigNumber } from "ethers" -import { btcAddresses, btcAddressFromPublicKey } from "./data/bitcoin" +import { + btcAddresses, + btcAddressFromPublicKey, + mainnetTransaction, + testnetTransaction, +} from "./data/bitcoin" describe("Bitcoin", () => { describe("compressPublicKey", () => { @@ -732,3 +738,89 @@ describe("Bitcoin", () => { }) }) }) + +describe("txToJSON", () => { + context("when network is mainnet", () => { + it("should return correct transaction JSON", () => { + const txJSON = txToJSON(mainnetTransaction, BitcoinNetwork.Mainnet) + + expect(txJSON.hash).to.be.equal( + "bb20b27fef136ab1e5ee866a73bc9b33a038c3e258162e6c03e94f6e22941e0e" + ) + expect(txJSON.version).to.be.equal(1) + expect(txJSON.locktime).to.be.equal(0) + + expect(txJSON.inputs.length).to.be.equal(1) + expect(txJSON.inputs[0].hash).to.be.equal( + "a4082d137ab5c5264efb9f616ca4ac1673015c1e0817cd5cdc1b0379161be95e" + ) + expect(txJSON.inputs[0].index).to.be.equal(5) + expect(txJSON.inputs[0].sequence).to.be.equal(4294967295) + expect(txJSON.inputs[0].script).to.be.equal("") + expect(txJSON.inputs[0].witness).to.deep.equal([ + "", + "3044022022c7d7546fc0bb96a26c04823d97f0aa4bbe5d9af54acc8f4bd898e88" + + "b86956002206b126720f42b2f200434c6ae770b78aded9b32da4f020aba37f099" + + "d804eab02701", + "304402202b60c2ef3ba68eb473b65564e0fd038884407dc684c98309e3141bb53" + + "233dfd7022078d14fb2e433c71c6c62bd2019dd83859173a3b6973c62444930c1" + + "5d86d4bd1601", + "52210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd929" + + "76b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff0187" + + "4496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c01" + + "1a32cf9f88053ae", + ]) + + expect(txJSON.outputs.length).to.be.equal(2) + expect(txJSON.outputs[0].value).to.be.equal(11991850) + expect(txJSON.outputs[0].script).to.be.equal( + "76a914ee4b7569e9063064323332ad07dd18bc32402a0c88ac" + ) + expect(txJSON.outputs[0].address).to.be.equal( + "1NizDcdk2mWE45yZr98JJ2dyi2W2zeZUn5" + ) + expect(txJSON.outputs[1].value).to.be.equal(1805173) + expect(txJSON.outputs[1].script).to.be.equal( + "0020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d" + ) + expect(txJSON.outputs[1].address).to.be.equal( + "bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej" + ) + }) + }) + + context("when network is testnet", () => { + it("should return correct transaction JSON", () => { + const txJSON = txToJSON(testnetTransaction, BitcoinNetwork.Testnet) + + expect(txJSON.hash).to.be.equal( + "873effe868161e09ab65e1a23c7cecdc2792995c90ec94973f2fdbc59728ba89" + ) + expect(txJSON.version).to.be.equal(1) + expect(txJSON.locktime).to.be.equal(0) + + expect(txJSON.inputs.length).to.be.equal(1) + expect(txJSON.inputs[0].hash).to.be.equal( + "c0a5ed42f574b4b969ef0df16a70edb60d4a464739c5011bc051a8dedbaab730" + ) + expect(txJSON.inputs[0].index).to.be.equal(0) + expect(txJSON.inputs[0].sequence).to.be.equal(4294967295) + expect(txJSON.inputs[0].script).to.be.equal( + "4830450221009ab9ba3a4c9d81c4ac4431c05eac57388c8332bb191507926a3424" + + "ec697ac23802203369c91742a7d5168ba3af429aed4f2d1022749a4ba5052b172b" + + "b6776d9a07c1012103548c7fe1d7a66f8e705a4299153b87f4874c80aaed2cf828" + + "cd552d6975a01b80" + ) + expect(txJSON.inputs[0].witness).to.deep.equal([]) + + expect(txJSON.outputs.length).to.be.equal(1) + expect(txJSON.outputs[0].value).to.be.equal(270150) + expect(txJSON.outputs[0].script).to.be.equal( + "76a914819850140920deeacfee3a63193807daea8fc5d288ac" + ) + expect(txJSON.outputs[0].address).to.be.equal( + "msLBvgMp45BN9CaQCoZ4ewjm71Fix7RgB2" + ) + }) + }) +}) diff --git a/typescript/test/data/bitcoin.ts b/typescript/test/data/bitcoin.ts index b04baad81..03fb6d8de 100644 --- a/typescript/test/data/bitcoin.ts +++ b/typescript/test/data/bitcoin.ts @@ -104,3 +104,28 @@ export const btcAddressFromPublicKey: Record< }, }, } + +// An arbitrary Bitcoin mainnet transaction: +// https://live.blockcypher.com/btc/tx/bb20b27fef136ab1e5ee866a73bc9b33a038c3e258162e6c03e94f6e22941e0e/ +export const mainnetTransaction = + "010000000001015ee91b1679031bdc5ccd17081e5c017316aca46c619ffb4e26c5b57a13" + + "2d08a40500000000ffffffff022afbb600000000001976a914ee4b7569e9063064323332" + + "ad07dd18bc32402a0c88ac758b1b0000000000220020701a8d401c84fb13e6baf169d596" + + "84e17abd9fa216c8cc5b9fc63d622ff8c58d0400473044022022c7d7546fc0bb96a26c04" + + "823d97f0aa4bbe5d9af54acc8f4bd898e88b86956002206b126720f42b2f200434c6ae77" + + "0b78aded9b32da4f020aba37f099d804eab0270147304402202b60c2ef3ba68eb473b655" + + "64e0fd038884407dc684c98309e3141bb53233dfd7022078d14fb2e433c71c6c62bd2019" + + "dd83859173a3b6973c62444930c15d86d4bd16016952210375e00eb72e29da82b8936794" + + "7f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce6632" + + "07659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84" + + "a8a48ad05bd8dbb395c011a32cf9f88053ae00000000" + +// An arbitrary Bitcoin testnet transaction: +// https://live.blockcypher.com/btc-testnet/tx/873effe868161e09ab65e1a23c7cecdc2792995c90ec94973f2fdbc59728ba89/ +export const testnetTransaction = + "010000000130b7aadbdea851c01b01c53947464a0db6ed706af10def69b9b474f542eda5" + + "c0000000006b4830450221009ab9ba3a4c9d81c4ac4431c05eac57388c8332bb19150792" + + "6a3424ec697ac23802203369c91742a7d5168ba3af429aed4f2d1022749a4ba5052b172b" + + "b6776d9a07c1012103548c7fe1d7a66f8e705a4299153b87f4874c80aaed2cf828cd552d" + + "6975a01b80ffffffff01461f0400000000001976a914819850140920deeacfee3a631938" + + "07daea8fc5d288ac00000000" From a44d18daba9f071b4c93ec54343ca2fa42392aa9 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 5 Oct 2023 16:28:32 +0200 Subject: [PATCH 145/205] Updated bitcoinjs-lib version --- typescript/package.json | 4 ++-- typescript/yarn.lock | 47 ++++++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index 21d9a4fc9..0f803bdc4 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -26,7 +26,7 @@ "dependencies": { "@keep-network/ecdsa": "development", "@keep-network/tbtc-v2": "development", - "bitcoinjs-lib": "6.0.2", + "bitcoinjs-lib": "^6.1.5", "bufio": "^1.0.6", "ecpair": "^2.1.0", "electrum-client-js": "git+https://github.com/keep-network/electrum-client-js.git#v0.1.1", @@ -58,6 +58,6 @@ "typescript": "^4.3.5" }, "engines": { - "node": ">=14 <15" + "node": ">=16" } } diff --git a/typescript/yarn.lock b/typescript/yarn.lock index ba01c6262..08928f090 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -1643,6 +1643,11 @@ resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-5.50.0.tgz#29c6419e8379d496ab6d0426eadf3c4d100cd186" integrity sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA== +"@noble/hashes@^1.2.0": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" + integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -2491,6 +2496,11 @@ base-x@^3.0.2, base-x@^3.0.8: dependencies: safe-buffer "^5.0.1" +base-x@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.0.tgz#d0e3b7753450c73f8ad2389b5c018a4af7b2224a" + integrity sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw== + base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" @@ -2545,7 +2555,7 @@ bindings@^1.3.0: dependencies: file-uri-to-path "1.0.0" -bip174@^2.0.1: +bip174@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/bip174/-/bip174-2.1.1.tgz#ef3e968cf76de234a546962bcf572cc150982f9f" integrity sha512-mdFV5+/v0XyNYXjBS6CQPLo9ekCx4gtKZFnJm5PMto7Fs9hTTDpkkzOB7/FtluRI6JbUUAu+snTYfJRgHLZbZQ== @@ -2592,19 +2602,17 @@ bip39@3.0.4: pbkdf2 "^3.0.9" randombytes "^2.0.1" -bitcoinjs-lib@6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.0.2.tgz#0fdf6c41978d93641b936d66f4afce44bb9b7f35" - integrity sha512-I994pGt9cL5s5OA6mkv1e8IuYcsKN2ORXnWbkqAXLNGvEnOHBhKBSvCjFl7YC2uVoJnfr/iwq7JMrq575SYO5w== +bitcoinjs-lib@^6.1.5: + version "6.1.5" + resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.1.5.tgz#3b03509ae7ddd80a440f10fc38c4a97f0a028d8c" + integrity sha512-yuf6xs9QX/E8LWE2aMJPNd0IxGofwfuVOiYdNUESkc+2bHHVKjhJd8qewqapeoolh9fihzHGoDCB5Vkr57RZCQ== dependencies: + "@noble/hashes" "^1.2.0" bech32 "^2.0.0" - bip174 "^2.0.1" - bs58check "^2.1.2" - create-hash "^1.1.0" - ripemd160 "^2.0.2" + bip174 "^2.1.1" + bs58check "^3.0.1" typeforce "^1.11.3" varuint-bitcoin "^1.1.2" - wif "^2.0.1" bl@^1.0.0: version "1.2.3" @@ -2777,6 +2785,13 @@ bs58@^4.0.0: dependencies: base-x "^3.0.2" +bs58@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279" + integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ== + dependencies: + base-x "^4.0.0" + bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" @@ -2786,6 +2801,14 @@ bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: create-hash "^1.1.0" safe-buffer "^5.1.2" +bs58check@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-3.0.1.tgz#2094d13720a28593de1cba1d8c4e48602fdd841c" + integrity sha512-hjuuJvoWEybo7Hn/0xOrczQKKEKD63WguEjlhLExYs2wUBcebDC1jDNK17eEAD2lYfw82d5ASC1d7K3SWszjaQ== + dependencies: + "@noble/hashes" "^1.2.0" + bs58 "^5.0.0" + buffer-alloc-unsafe@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" @@ -6742,7 +6765,7 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.2: +ripemd160@^2.0.0, ripemd160@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== @@ -8629,7 +8652,7 @@ wide-align@1.1.3: dependencies: string-width "^1.0.2 || 2" -wif@2.0.6, wif@^2.0.1, wif@^2.0.6: +wif@2.0.6, wif@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/wif/-/wif-2.0.6.tgz#08d3f52056c66679299726fade0d432ae74b4704" integrity sha1-CNP1IFbGZnkplyb63g1DKudLRwQ= From 38e970bd5ad75d9ca07fb78e064894ceef195910 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 5 Oct 2023 17:48:51 +0200 Subject: [PATCH 146/205] Added missing unit test for decomposeRawTransaction --- typescript/test/bitcoin.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index eb8521e00..791127c1e 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -23,6 +23,7 @@ import { isP2SHScript, isP2WSHScript, txToJSON, + decomposeRawTransaction, } from "../src/bitcoin" import { calculateDepositRefundLocktime } from "../src/deposit" import { BitcoinNetwork } from "../src/bitcoin-network" @@ -34,6 +35,7 @@ import { mainnetTransaction, testnetTransaction, } from "./data/bitcoin" +import { depositSweepWithNoMainUtxoAndWitnessOutput } from "./data/deposit-sweep" describe("Bitcoin", () => { describe("compressPublicKey", () => { @@ -824,3 +826,28 @@ describe("txToJSON", () => { }) }) }) + +describe("decomposeRawTransaction", () => { + it("should return correctly decomposed transaction", () => { + const rawTransaction = + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transaction + const decomposedTransaction = decomposeRawTransaction(rawTransaction) + + expect(decomposedTransaction.version).to.be.equal("01000000") + expect(decomposedTransaction.inputs).to.be.equal( + "02bc187be612bc3db8cfcdec56b75e9bc0262ab6eacfe27cc1a699bacd53e3d07400" + + "000000c948304502210089a89aaf3fec97ac9ffa91cdff59829f0cb3ef852a468153" + + "e2c0e2b473466d2e022072902bb923ef016ac52e941ced78f816bf27991c2b73211e" + + "227db27ec200bc0a012103989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f25" + + "64da4cc29dcf8581d94c5c14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508" + + "f9f0c90d000395237576a9148db50eb52063ea9d98b3eac91489a90f738986f68763" + + "ac6776a914e257eccafbc07c381642ce6e7e55120fb077fbed8804e0250162b175ac" + + "68ffffffffdc557e737b6688c5712649b86f7757a722dc3d42786f23b2fa826394df" + + "ec545c0000000000ffffffff" + ) + expect(decomposedTransaction.outputs).to.be.equal( + "01488a0000000000001600148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + expect(decomposedTransaction.locktime).to.be.equal("00000000") + }) +}) From 881e19de9fc41da0d3f8eaa0c5fb479870c49c04 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Thu, 5 Oct 2023 18:24:18 +0200 Subject: [PATCH 147/205] Moved txToJSON to test/utils/helpers --- typescript/src/bitcoin.ts | 57 ---------------- typescript/test/bitcoin.test.ts | 94 +-------------------------- typescript/test/data/bitcoin.ts | 25 ------- typescript/test/deposit-sweep.test.ts | 2 +- typescript/test/deposit.test.ts | 2 +- typescript/test/redemption.test.ts | 2 +- typescript/test/utils/helpers.ts | 63 ++++++++++++++++++ 7 files changed, 67 insertions(+), 178 deletions(-) create mode 100644 typescript/test/utils/helpers.ts diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts index aea3d403f..3649327a6 100644 --- a/typescript/src/bitcoin.ts +++ b/typescript/src/bitcoin.ts @@ -780,60 +780,3 @@ export function isP2WSHScript(script: Buffer): boolean { return false } } - -/** - * Represents a structured JSON format for a Bitcoin transaction. It includes - * detailed information about its inputs and outputs, as well as the transaction - * itself. - */ -interface TxJSON { - hash: string - version: number - locktime: number - inputs: { - hash: string - index: number - sequence: number - script: string - witness: string[] - }[] - outputs: { - value: number - script: string - address: string - }[] -} - -/** - * Converts a raw Bitcoin transaction into a structured JSON format. - * @param rawTransaction - A raw Bitcoin transaction in hexadecimal string format. - * @param bitcoinNetwork - Bitcoin network. - * @returns A structured JSON object representing the transaction. - */ -export function txToJSON( - rawTransaction: string, - bitcoinNetwork: BitcoinNetwork -): TxJSON { - const transaction = Tx.fromHex(rawTransaction) - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - - const txJSON: TxJSON = { - hash: transaction.getId(), - version: transaction.version, - locktime: transaction.locktime, - inputs: transaction.ins.map((input) => ({ - hash: Hex.from(input.hash).reverse().toString(), - index: input.index, - sequence: input.sequence, - script: input.script.toString("hex"), - witness: input.witness.map((w) => w.toString("hex")), - })), - outputs: transaction.outs.map((output) => ({ - value: output.value, - script: output.script.toString("hex"), - address: address.fromOutputScript(output.script, network), - })), - } - - return txJSON -} diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 791127c1e..03ab74305 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -22,19 +22,13 @@ import { isP2WPKHScript, isP2SHScript, isP2WSHScript, - txToJSON, decomposeRawTransaction, } from "../src/bitcoin" import { calculateDepositRefundLocktime } from "../src/deposit" import { BitcoinNetwork } from "../src/bitcoin-network" import { Hex } from "../src/hex" import { BigNumber } from "ethers" -import { - btcAddresses, - btcAddressFromPublicKey, - mainnetTransaction, - testnetTransaction, -} from "./data/bitcoin" +import { btcAddresses, btcAddressFromPublicKey } from "./data/bitcoin" import { depositSweepWithNoMainUtxoAndWitnessOutput } from "./data/deposit-sweep" describe("Bitcoin", () => { @@ -741,92 +735,6 @@ describe("Bitcoin", () => { }) }) -describe("txToJSON", () => { - context("when network is mainnet", () => { - it("should return correct transaction JSON", () => { - const txJSON = txToJSON(mainnetTransaction, BitcoinNetwork.Mainnet) - - expect(txJSON.hash).to.be.equal( - "bb20b27fef136ab1e5ee866a73bc9b33a038c3e258162e6c03e94f6e22941e0e" - ) - expect(txJSON.version).to.be.equal(1) - expect(txJSON.locktime).to.be.equal(0) - - expect(txJSON.inputs.length).to.be.equal(1) - expect(txJSON.inputs[0].hash).to.be.equal( - "a4082d137ab5c5264efb9f616ca4ac1673015c1e0817cd5cdc1b0379161be95e" - ) - expect(txJSON.inputs[0].index).to.be.equal(5) - expect(txJSON.inputs[0].sequence).to.be.equal(4294967295) - expect(txJSON.inputs[0].script).to.be.equal("") - expect(txJSON.inputs[0].witness).to.deep.equal([ - "", - "3044022022c7d7546fc0bb96a26c04823d97f0aa4bbe5d9af54acc8f4bd898e88" + - "b86956002206b126720f42b2f200434c6ae770b78aded9b32da4f020aba37f099" + - "d804eab02701", - "304402202b60c2ef3ba68eb473b65564e0fd038884407dc684c98309e3141bb53" + - "233dfd7022078d14fb2e433c71c6c62bd2019dd83859173a3b6973c62444930c1" + - "5d86d4bd1601", - "52210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd929" + - "76b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff0187" + - "4496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c01" + - "1a32cf9f88053ae", - ]) - - expect(txJSON.outputs.length).to.be.equal(2) - expect(txJSON.outputs[0].value).to.be.equal(11991850) - expect(txJSON.outputs[0].script).to.be.equal( - "76a914ee4b7569e9063064323332ad07dd18bc32402a0c88ac" - ) - expect(txJSON.outputs[0].address).to.be.equal( - "1NizDcdk2mWE45yZr98JJ2dyi2W2zeZUn5" - ) - expect(txJSON.outputs[1].value).to.be.equal(1805173) - expect(txJSON.outputs[1].script).to.be.equal( - "0020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d" - ) - expect(txJSON.outputs[1].address).to.be.equal( - "bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej" - ) - }) - }) - - context("when network is testnet", () => { - it("should return correct transaction JSON", () => { - const txJSON = txToJSON(testnetTransaction, BitcoinNetwork.Testnet) - - expect(txJSON.hash).to.be.equal( - "873effe868161e09ab65e1a23c7cecdc2792995c90ec94973f2fdbc59728ba89" - ) - expect(txJSON.version).to.be.equal(1) - expect(txJSON.locktime).to.be.equal(0) - - expect(txJSON.inputs.length).to.be.equal(1) - expect(txJSON.inputs[0].hash).to.be.equal( - "c0a5ed42f574b4b969ef0df16a70edb60d4a464739c5011bc051a8dedbaab730" - ) - expect(txJSON.inputs[0].index).to.be.equal(0) - expect(txJSON.inputs[0].sequence).to.be.equal(4294967295) - expect(txJSON.inputs[0].script).to.be.equal( - "4830450221009ab9ba3a4c9d81c4ac4431c05eac57388c8332bb191507926a3424" + - "ec697ac23802203369c91742a7d5168ba3af429aed4f2d1022749a4ba5052b172b" + - "b6776d9a07c1012103548c7fe1d7a66f8e705a4299153b87f4874c80aaed2cf828" + - "cd552d6975a01b80" - ) - expect(txJSON.inputs[0].witness).to.deep.equal([]) - - expect(txJSON.outputs.length).to.be.equal(1) - expect(txJSON.outputs[0].value).to.be.equal(270150) - expect(txJSON.outputs[0].script).to.be.equal( - "76a914819850140920deeacfee3a63193807daea8fc5d288ac" - ) - expect(txJSON.outputs[0].address).to.be.equal( - "msLBvgMp45BN9CaQCoZ4ewjm71Fix7RgB2" - ) - }) - }) -}) - describe("decomposeRawTransaction", () => { it("should return correctly decomposed transaction", () => { const rawTransaction = diff --git a/typescript/test/data/bitcoin.ts b/typescript/test/data/bitcoin.ts index 03fb6d8de..b04baad81 100644 --- a/typescript/test/data/bitcoin.ts +++ b/typescript/test/data/bitcoin.ts @@ -104,28 +104,3 @@ export const btcAddressFromPublicKey: Record< }, }, } - -// An arbitrary Bitcoin mainnet transaction: -// https://live.blockcypher.com/btc/tx/bb20b27fef136ab1e5ee866a73bc9b33a038c3e258162e6c03e94f6e22941e0e/ -export const mainnetTransaction = - "010000000001015ee91b1679031bdc5ccd17081e5c017316aca46c619ffb4e26c5b57a13" + - "2d08a40500000000ffffffff022afbb600000000001976a914ee4b7569e9063064323332" + - "ad07dd18bc32402a0c88ac758b1b0000000000220020701a8d401c84fb13e6baf169d596" + - "84e17abd9fa216c8cc5b9fc63d622ff8c58d0400473044022022c7d7546fc0bb96a26c04" + - "823d97f0aa4bbe5d9af54acc8f4bd898e88b86956002206b126720f42b2f200434c6ae77" + - "0b78aded9b32da4f020aba37f099d804eab0270147304402202b60c2ef3ba68eb473b655" + - "64e0fd038884407dc684c98309e3141bb53233dfd7022078d14fb2e433c71c6c62bd2019" + - "dd83859173a3b6973c62444930c15d86d4bd16016952210375e00eb72e29da82b8936794" + - "7f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce6632" + - "07659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84" + - "a8a48ad05bd8dbb395c011a32cf9f88053ae00000000" - -// An arbitrary Bitcoin testnet transaction: -// https://live.blockcypher.com/btc-testnet/tx/873effe868161e09ab65e1a23c7cecdc2792995c90ec94973f2fdbc59728ba89/ -export const testnetTransaction = - "010000000130b7aadbdea851c01b01c53947464a0db6ed706af10def69b9b474f542eda5" + - "c0000000006b4830450221009ab9ba3a4c9d81c4ac4431c05eac57388c8332bb19150792" + - "6a3424ec697ac23802203369c91742a7d5168ba3af429aed4f2d1022749a4ba5052b172b" + - "b6776d9a07c1012103548c7fe1d7a66f8e705a4299153b87f4874c80aaed2cf828cd552d" + - "6975a01b80ffffffff01461f0400000000001976a914819850140920deeacfee3a631938" + - "07daea8fc5d288ac00000000" diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index 103d86607..f37a961c6 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -4,7 +4,6 @@ import { TransactionHash, UnspentTransactionOutput, Transaction, - txToJSON, } from "../src/bitcoin" import { testnetWalletAddress, testnetWalletPrivateKey } from "./data/deposit" import { @@ -17,6 +16,7 @@ import { } from "./data/deposit-sweep" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { MockBridge } from "./utils/mock-bridge" +import { txToJSON } from "./utils/helpers" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index 79f098230..a1b2c705b 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -12,7 +12,6 @@ import { RawTransaction, TransactionHash, UnspentTransactionOutput, - txToJSON, } from "../src/bitcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { @@ -30,6 +29,7 @@ import { suggestDepositWallet, } from "../src/deposit" import { MockBridge } from "./utils/mock-bridge" +import { txToJSON } from "./utils/helpers" import { Address } from "../src/ethereum" import { BitcoinNetwork } from "../src" diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index acbafa2bc..802942f7b 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -3,7 +3,6 @@ import { RawTransaction, TransactionHash, UnspentTransactionOutput, - txToJSON, } from "../src/bitcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { @@ -31,6 +30,7 @@ import { submitRedemptionProof, submitRedemptionTransaction, } from "../src/redemption" +import { txToJSON } from "./utils/helpers" import { MockBridge } from "./utils/mock-bridge" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" diff --git a/typescript/test/utils/helpers.ts b/typescript/test/utils/helpers.ts new file mode 100644 index 000000000..59634d35b --- /dev/null +++ b/typescript/test/utils/helpers.ts @@ -0,0 +1,63 @@ +import { Hex } from "../../src/hex" +import { + BitcoinNetwork, + toBitcoinJsLibNetwork, +} from "../../src/bitcoin-network" +import { Transaction, address } from "bitcoinjs-lib" + +/** + * Represents a structured JSON format for a Bitcoin transaction. It includes + * detailed information about its inputs and outputs, as well as the transaction + * itself. + */ +interface TxJSON { + hash: string + version: number + locktime: number + inputs: { + hash: string + index: number + sequence: number + script: string + witness: string[] + }[] + outputs: { + value: number + script: string + address: string + }[] +} + +/** + * Converts a raw Bitcoin transaction into a structured JSON format. + * @param rawTransaction - A raw Bitcoin transaction in hexadecimal string format. + * @param bitcoinNetwork - Bitcoin network. + * @returns A structured JSON object representing the transaction. + */ +export function txToJSON( + rawTransaction: string, + bitcoinNetwork: BitcoinNetwork +): TxJSON { + const transaction = Transaction.fromHex(rawTransaction) + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + + const txJSON: TxJSON = { + hash: transaction.getId(), + version: transaction.version, + locktime: transaction.locktime, + inputs: transaction.ins.map((input) => ({ + hash: Hex.from(input.hash).reverse().toString(), + index: input.index, + sequence: input.sequence, + script: input.script.toString("hex"), + witness: input.witness.map((w) => w.toString("hex")), + })), + outputs: transaction.outs.map((output) => ({ + value: output.value, + script: output.script.toString("hex"), + address: address.fromOutputScript(output.script, network), + })), + } + + return txJSON +} From a6c16ce6b88b84ff6460505cb61d28c8044397d1 Mon Sep 17 00:00:00 2001 From: Tomasz Slabon Date: Fri, 6 Oct 2023 13:52:17 +0200 Subject: [PATCH 148/205] Updated typescript CI jobs config --- .github/workflows/typescript.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/typescript.yml b/.github/workflows/typescript.yml index f4ed3d750..210706d0a 100644 --- a/.github/workflows/typescript.yml +++ b/.github/workflows/typescript.yml @@ -53,7 +53,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: "14.x" + node-version: "18.x" cache: "yarn" cache-dependency-path: typescript/yarn.lock @@ -86,7 +86,7 @@ jobs: - uses: actions/setup-node@v2 with: - node-version: "14.x" + node-version: "18.x" cache: "yarn" cache-dependency-path: typescript/yarn.lock registry-url: "https://registry.npmjs.org" @@ -160,7 +160,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: "14.x" + node-version: "18.x" cache: "yarn" cache-dependency-path: typescript/yarn.lock From f996293aa9bed57efd5e6e7be9dd2f258e0a802c Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 9 Oct 2023 15:14:09 +0200 Subject: [PATCH 149/205] Remove `depositWormholeTbtc` function from `L2WormholeGateway` Here we remove the aforementioned function in order to simplify the contract and make `receiveTbtc` the only function allowed to mint canonical L2 TBTC. The `depositWormholeTbtc` function is not really needed and is just a convenience function that allows minting canonical L2 TBTC using Wormhole TBTC in rare cases when this cannot happen automatically, e.g. due to exceeded minting limits. However, even if minting does not happen automatically, the Wormhole TBTC tokens can be easily bridged back to L1 TBTC. That said, removing `depositWormholeTbtc` should not affect UX dramatically. In return, it greatly simplifies the contract and reduce potential attack surface. --- solidity/contracts/l2/L2WormholeGateway.sol | 21 ------ solidity/test/l2/L2WormholeGateway.test.ts | 71 --------------------- 2 files changed, 92 deletions(-) diff --git a/solidity/contracts/l2/L2WormholeGateway.sol b/solidity/contracts/l2/L2WormholeGateway.sol index 5f97b304f..5a1622f04 100644 --- a/solidity/contracts/l2/L2WormholeGateway.sol +++ b/solidity/contracts/l2/L2WormholeGateway.sol @@ -331,27 +331,6 @@ contract L2WormholeGateway is emit WormholeTbtcReceived(receiver, amount); } - /// @notice Allows to deposit Wormhole tBTC token in exchange for canonical - /// tBTC. Useful in a situation when user received wormhole tBTC - /// instead of canonical tBTC. One example of such situation is - /// when the minting limit was exceeded but the user minted anyway. - /// @dev Requirements: - /// - The sender must have at least `amount` of the Wormhole tBTC and - /// it has to be approved for L2WormholeGateway. - /// - The minting limit must allow for minting the given amount. - /// @param amount The amount of Wormhole tBTC to deposit. - function depositWormholeTbtc(uint256 amount) external { - require( - mintedAmount + amount <= mintingLimit, - "Minting limit exceeded" - ); - - emit WormholeTbtcDeposited(msg.sender, amount); - mintedAmount += amount; - bridgeToken.safeTransferFrom(msg.sender, address(this), amount); - tbtc.mint(msg.sender, amount); - } - /// @notice Lets the governance to update the tBTC gateway address on the /// chain with the given Wormhole ID. /// @dev Use toWormholeAddress function to convert between Ethereum and diff --git a/solidity/test/l2/L2WormholeGateway.test.ts b/solidity/test/l2/L2WormholeGateway.test.ts index 5cb91c83d..9c9be2723 100644 --- a/solidity/test/l2/L2WormholeGateway.test.ts +++ b/solidity/test/l2/L2WormholeGateway.test.ts @@ -665,77 +665,6 @@ describe("L2WormholeGateway", () => { }) }) - describe("depositWormholeTbtc", () => { - const amount = to1e18(129) - - context("when the minting limit is not exceeded", () => { - let tx: ContractTransaction - - before(async () => { - await createSnapshot() - - await wormholeBridgeStub.mintWormholeToken(depositor1.address, amount) - - await wormholeTbtc.connect(depositor1).approve(gateway.address, amount) - tx = await gateway.connect(depositor1).depositWormholeTbtc(amount) - }) - - after(async () => { - await restoreSnapshot() - }) - - it("should transfer wormhole tBTC from user to the gateway", async () => { - expect(tx) - .to.emit(wormholeTbtc, "Transfer") - .withArgs(depositor1.address, gateway.address, amount) - }) - - it("should mint canonical tBTC to the user", async () => { - expect(await canonicalTbtc.balanceOf(depositor1.address)).to.equal( - amount - ) - }) - - it("should emit the WormholeTbtcDeposited event", async () => { - await expect(tx) - .to.emit(gateway, "WormholeTbtcDeposited") - .withArgs(depositor1.address, amount) - }) - - it("should increase the minted amount counter", async () => { - expect(await gateway.mintedAmount()).to.equal(amount) - }) - }) - - context("when the minting limit is exceeded", () => { - before(async () => { - await createSnapshot() - - await gateway.connect(governance).updateMintingLimit(amount) - - await wormholeBridgeStub.mintWormholeToken( - depositor1.address, - amount.mul(2) - ) - await wormholeTbtc - .connect(depositor1) - .approve(gateway.address, amount.mul(2)) - - await gateway.connect(depositor1).depositWormholeTbtc(amount) - }) - - after(async () => { - await restoreSnapshot() - }) - - it("should revert", async () => { - await expect( - gateway.connect(depositor1).depositWormholeTbtc(amount) - ).to.be.revertedWith("Minting limit exceeded") - }) - }) - }) - describe("updateGatewayAddress", () => { context("when called by a third party", () => { it("should revert", async () => { From f6c7c13cd41e0e4841cc5f72960ba4bc8c8b9675 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 9 Oct 2023 15:30:10 +0200 Subject: [PATCH 150/205] Make `receiveTbtc` non-reentrant The Wormhole Token Bridge contract has protection against redeeming the same VAA again. When a Token Bridge VAA is redeemed, its message body hash is stored in a map. This map is used to check whether the hash has already been set in this map. For this reason, `receiveTbtc` does not have to be nonReentrant in theory. However, to make this function future-proof and non-dependent on Wormhole Bridge implementation, we are making it nonReentrant anyway. --- solidity/contracts/l2/L2WormholeGateway.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/solidity/contracts/l2/L2WormholeGateway.sol b/solidity/contracts/l2/L2WormholeGateway.sol index 5a1622f04..fa46dd066 100644 --- a/solidity/contracts/l2/L2WormholeGateway.sol +++ b/solidity/contracts/l2/L2WormholeGateway.sol @@ -285,10 +285,12 @@ contract L2WormholeGateway is /// the same VAA again. When a Token Bridge VAA is redeemed, its /// message body hash is stored in a map. This map is used to check /// whether the hash has already been set in this map. For this reason, - /// this function does not have to be nonReentrant. + /// this function does not have to be nonReentrant in theory. However, + /// to make this function non-dependent on Wormhole Bridge implementation, + /// we are making it nonReentrant anyway. /// @param encodedVm A byte array containing a Wormhole VAA signed by the /// guardians. - function receiveTbtc(bytes calldata encodedVm) external { + function receiveTbtc(bytes calldata encodedVm) external nonReentrant { // ITokenBridge.completeTransferWithPayload completes a contract-controlled // transfer of an ERC20 token. Calling this function is not enough to // ensure L2WormholeGateway received Wormhole tBTC representation. From d46ca3603609c28d5e61dcfecdbcf561c147e78c Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 9 Oct 2023 15:32:49 +0200 Subject: [PATCH 151/205] Adjust some comments around `receiveTbtc` --- solidity/contracts/l2/L2WormholeGateway.sol | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/solidity/contracts/l2/L2WormholeGateway.sol b/solidity/contracts/l2/L2WormholeGateway.sol index fa46dd066..88fec4514 100644 --- a/solidity/contracts/l2/L2WormholeGateway.sol +++ b/solidity/contracts/l2/L2WormholeGateway.sol @@ -281,6 +281,7 @@ contract L2WormholeGateway is /// - The receiver of the canonical tBTC should be abi-encoded in the /// payload. /// - The receiver of the canonical tBTC must not be the zero address. + /// /// The Wormhole Token Bridge contract has protection against redeeming /// the same VAA again. When a Token Bridge VAA is redeemed, its /// message body hash is stored in a map. This map is used to check @@ -320,15 +321,13 @@ contract L2WormholeGateway is if (mintedAmount + amount > mintingLimit) { bridgeToken.safeTransfer(receiver, amount); } else { - // The function is non-reentrant given bridge.completeTransferWithPayload - // call that does not allow to use the same VAA again. + // The function is non-reentrant. // slither-disable-next-line reentrancy-benign mintedAmount += amount; tbtc.mint(receiver, amount); } - // The function is non-reentrant given bridge.completeTransferWithPayload - // call that does not allow to use the same VAA again. + // The function is non-reentrant. // slither-disable-next-line reentrancy-events emit WormholeTbtcReceived(receiver, amount); } From 340578c6a7d1af36704e66172fee74f0a6348b86 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 9 Oct 2023 17:31:45 +0200 Subject: [PATCH 152/205] Upgrade `ArbitrumWormholeGateway` script --- ...anual_upgrade_arbitrum_wormhole_gateway.ts | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 cross-chain/arbitrum/deploy_l2/32_manual_upgrade_arbitrum_wormhole_gateway.ts diff --git a/cross-chain/arbitrum/deploy_l2/32_manual_upgrade_arbitrum_wormhole_gateway.ts b/cross-chain/arbitrum/deploy_l2/32_manual_upgrade_arbitrum_wormhole_gateway.ts new file mode 100644 index 000000000..573c475ca --- /dev/null +++ b/cross-chain/arbitrum/deploy_l2/32_manual_upgrade_arbitrum_wormhole_gateway.ts @@ -0,0 +1,77 @@ +import type { Artifact, HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction, Deployment } from "hardhat-deploy/types" +import { ContractFactory } from "ethers" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { ethers, helpers, deployments } = hre + + const { deployer } = await helpers.signers.getNamedSigners() + + const proxyDeployment: Deployment = await deployments.get( + "ArbitrumWormholeGateway" + ) + const implementationContractFactory: ContractFactory = + await ethers.getContractFactory("L2WormholeGateway", { + signer: deployer, + }) + + // Deploy new implementation contract + const newImplementationAddress: string = (await hre.upgrades.prepareUpgrade( + proxyDeployment, + implementationContractFactory, + { + kind: "transparent", + } + )) as string + + deployments.log( + `new implementation contract deployed at: ${newImplementationAddress}` + ) + + // Assemble proxy upgrade transaction. + const proxyAdmin = await hre.upgrades.admin.getInstance() + const proxyAdminOwner = await proxyAdmin.owner() + + const upgradeTxData = await proxyAdmin.interface.encodeFunctionData( + "upgrade", + [proxyDeployment.address, newImplementationAddress] + ) + + deployments.log( + `proxy admin owner ${proxyAdminOwner} is required to upgrade proxy implementation with transaction:\n` + + `\t\tfrom: ${proxyAdminOwner}\n` + + `\t\tto: ${proxyAdmin.address}\n` + + `\t\tdata: ${upgradeTxData}` + ) + + // Update Deployment Artifact + const gatewayArtifact: Artifact = + hre.artifacts.readArtifactSync("L2WormholeGateway") + + await deployments.save("ArbitrumWormholeGateway", { + ...proxyDeployment, + abi: gatewayArtifact.abi, + implementation: newImplementationAddress, + }) + + // Contracts can be verified on L2 Arbiscan in a similar way as we do it on + // L1 Etherscan + if (hre.network.tags.arbiscan) { + // We use `verify` instead of `verify:verify` as the `verify` task is defined + // in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation + // contract, the proxy itself and any proxy-related contracts, as well as + // link the proxy to the implementation contract’s ABI on (Ether)scan. + await hre.run("verify", { + address: newImplementationAddress, + constructorArgsParams: proxyDeployment.args, + }) + } +} + +export default func + +func.tags = ["ManualUpgradeArbitrumWormholeGateway"] + +// Comment this line when running an upgrade. +// yarn deploy --tags ManualUpgradeArbitrumWormholeGateway --network +func.skip = async () => true From 4ba4c23801d9d542437099a7d5f684977a6f617c Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 9 Oct 2023 17:31:54 +0200 Subject: [PATCH 153/205] Upgrade `BaseWormholeGateway` script --- ...24_manual_upgrade_base_wormhole_gateway.ts | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 cross-chain/base/deploy_l2/24_manual_upgrade_base_wormhole_gateway.ts diff --git a/cross-chain/base/deploy_l2/24_manual_upgrade_base_wormhole_gateway.ts b/cross-chain/base/deploy_l2/24_manual_upgrade_base_wormhole_gateway.ts new file mode 100644 index 000000000..e33277e4f --- /dev/null +++ b/cross-chain/base/deploy_l2/24_manual_upgrade_base_wormhole_gateway.ts @@ -0,0 +1,77 @@ +import type { Artifact, HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction, Deployment } from "hardhat-deploy/types" +import { ContractFactory } from "ethers" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { ethers, helpers, deployments } = hre + + const { deployer } = await helpers.signers.getNamedSigners() + + const proxyDeployment: Deployment = await deployments.get( + "BaseWormholeGateway" + ) + const implementationContractFactory: ContractFactory = + await ethers.getContractFactory("L2WormholeGateway", { + signer: deployer, + }) + + // Deploy new implementation contract + const newImplementationAddress: string = (await hre.upgrades.prepareUpgrade( + proxyDeployment, + implementationContractFactory, + { + kind: "transparent", + } + )) as string + + deployments.log( + `new implementation contract deployed at: ${newImplementationAddress}` + ) + + // Assemble proxy upgrade transaction. + const proxyAdmin = await hre.upgrades.admin.getInstance() + const proxyAdminOwner = await proxyAdmin.owner() + + const upgradeTxData = await proxyAdmin.interface.encodeFunctionData( + "upgrade", + [proxyDeployment.address, newImplementationAddress] + ) + + deployments.log( + `proxy admin owner ${proxyAdminOwner} is required to upgrade proxy implementation with transaction:\n` + + `\t\tfrom: ${proxyAdminOwner}\n` + + `\t\tto: ${proxyAdmin.address}\n` + + `\t\tdata: ${upgradeTxData}` + ) + + // Update Deployment Artifact + const gatewayArtifact: Artifact = + hre.artifacts.readArtifactSync("L2WormholeGateway") + + await deployments.save("BaseWormholeGateway", { + ...proxyDeployment, + abi: gatewayArtifact.abi, + implementation: newImplementationAddress, + }) + + // Contracts can be verified on L2 Basescan in a similar way as we do it on + // L1 Etherscan + if (hre.network.tags.basescan) { + // We use `verify` instead of `verify:verify` as the `verify` task is defined + // in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation + // contract, the proxy itself and any proxy-related contracts, as well as + // link the proxy to the implementation contract’s ABI on (Ether)scan. + await hre.run("verify", { + address: newImplementationAddress, + constructorArgsParams: proxyDeployment.args, + }) + } +} + +export default func + +func.tags = ["ManualUpgradeBaseWormholeGateway"] + +// Comment this line when running an upgrade. +// yarn deploy --tags ManualUpgradeBaseWormholeGateway --network +func.skip = async () => true From 9ff82128206966062d17850e979521661c888ded Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 9 Oct 2023 17:38:37 +0200 Subject: [PATCH 154/205] Upgrade `OptimismWormholeGateway` script --- ...anual_upgrade_optimism_wormhole_gateway.ts | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 cross-chain/optimism/deploy_l2/32_manual_upgrade_optimism_wormhole_gateway.ts diff --git a/cross-chain/optimism/deploy_l2/32_manual_upgrade_optimism_wormhole_gateway.ts b/cross-chain/optimism/deploy_l2/32_manual_upgrade_optimism_wormhole_gateway.ts new file mode 100644 index 000000000..0bfbfc0cd --- /dev/null +++ b/cross-chain/optimism/deploy_l2/32_manual_upgrade_optimism_wormhole_gateway.ts @@ -0,0 +1,77 @@ +import type { Artifact, HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction, Deployment } from "hardhat-deploy/types" +import { ContractFactory } from "ethers" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { ethers, helpers, deployments } = hre + + const { deployer } = await helpers.signers.getNamedSigners() + + const proxyDeployment: Deployment = await deployments.get( + "OptimismWormholeGateway" + ) + const implementationContractFactory: ContractFactory = + await ethers.getContractFactory("L2WormholeGateway", { + signer: deployer, + }) + + // Deploy new implementation contract + const newImplementationAddress: string = (await hre.upgrades.prepareUpgrade( + proxyDeployment, + implementationContractFactory, + { + kind: "transparent", + } + )) as string + + deployments.log( + `new implementation contract deployed at: ${newImplementationAddress}` + ) + + // Assemble proxy upgrade transaction. + const proxyAdmin = await hre.upgrades.admin.getInstance() + const proxyAdminOwner = await proxyAdmin.owner() + + const upgradeTxData = await proxyAdmin.interface.encodeFunctionData( + "upgrade", + [proxyDeployment.address, newImplementationAddress] + ) + + deployments.log( + `proxy admin owner ${proxyAdminOwner} is required to upgrade proxy implementation with transaction:\n` + + `\t\tfrom: ${proxyAdminOwner}\n` + + `\t\tto: ${proxyAdmin.address}\n` + + `\t\tdata: ${upgradeTxData}` + ) + + // Update Deployment Artifact + const gatewayArtifact: Artifact = + hre.artifacts.readArtifactSync("L2WormholeGateway") + + await deployments.save("OptimismWormholeGateway", { + ...proxyDeployment, + abi: gatewayArtifact.abi, + implementation: newImplementationAddress, + }) + + // Contracts can be verified on L2 Optimism Etherscan in a similar way as we do it on + // L1 Etherscan + if (hre.network.tags.optimism_etherscan) { + // We use `verify` instead of `verify:verify` as the `verify` task is defined + // in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation + // contract, the proxy itself and any proxy-related contracts, as well as + // link the proxy to the implementation contract’s ABI on (Ether)scan. + await hre.run("verify", { + address: newImplementationAddress, + constructorArgsParams: proxyDeployment.args, + }) + } +} + +export default func + +func.tags = ["ManualUpgradeOptimismWormholeGateway"] + +// Comment this line when running an upgrade. +// yarn deploy --tags ManualUpgradeOptimismWormholeGateway --network +func.skip = async () => true From b4204ba34af0422a5464bdc259add5db9718cccd Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 9 Oct 2023 17:48:33 +0200 Subject: [PATCH 155/205] Upgrade `PolygonWormholeGateway` script --- ...manual_upgrade_polygon_wormhole_gateway.ts | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 cross-chain/polygon/deploy_sidechain/32_manual_upgrade_polygon_wormhole_gateway.ts diff --git a/cross-chain/polygon/deploy_sidechain/32_manual_upgrade_polygon_wormhole_gateway.ts b/cross-chain/polygon/deploy_sidechain/32_manual_upgrade_polygon_wormhole_gateway.ts new file mode 100644 index 000000000..d5b381edb --- /dev/null +++ b/cross-chain/polygon/deploy_sidechain/32_manual_upgrade_polygon_wormhole_gateway.ts @@ -0,0 +1,83 @@ +import type { Artifact, HardhatRuntimeEnvironment } from "hardhat/types" +import type { DeployFunction, Deployment } from "hardhat-deploy/types" +import { ContractFactory } from "ethers" + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { ethers, helpers, deployments } = hre + + const { deployer } = await helpers.signers.getNamedSigners() + + const proxyDeployment: Deployment = await deployments.get( + "PolygonWormholeGateway" + ) + const implementationContractFactory: ContractFactory = + await ethers.getContractFactory("L2WormholeGateway", { + signer: deployer, + }) + + // Deploy new implementation contract + const newImplementationAddress: string = (await hre.upgrades.prepareUpgrade( + proxyDeployment, + implementationContractFactory, + { + kind: "transparent", + } + )) as string + + deployments.log( + `new implementation contract deployed at: ${newImplementationAddress}` + ) + + // Assemble proxy upgrade transaction. + const proxyAdmin = await hre.upgrades.admin.getInstance() + const proxyAdminOwner = await proxyAdmin.owner() + + const upgradeTxData = await proxyAdmin.interface.encodeFunctionData( + "upgrade", + [proxyDeployment.address, newImplementationAddress] + ) + + deployments.log( + `proxy admin owner ${proxyAdminOwner} is required to upgrade proxy implementation with transaction:\n` + + `\t\tfrom: ${proxyAdminOwner}\n` + + `\t\tto: ${proxyAdmin.address}\n` + + `\t\tdata: ${upgradeTxData}` + ) + + // Update Deployment Artifact + const gatewayArtifact: Artifact = + hre.artifacts.readArtifactSync("L2WormholeGateway") + + await deployments.save("PolygonWormholeGateway", { + ...proxyDeployment, + abi: gatewayArtifact.abi, + implementation: newImplementationAddress, + }) + + // Contracts can be verified on L2 Polygonscan in a similar way as we do it on + // L1 Etherscan + if (hre.network.tags.polygonscan) { + if (hre.network.name === "mumbai") { + // Polygonscan might not include the recently added proxy transaction right + // after deployment. We need to wait some time so that transaction is + // visible on Polygonscan. + await new Promise((resolve) => setTimeout(resolve, 10000)) // 10sec + } + // We use `verify` instead of `verify:verify` as the `verify` task is defined + // in "@openzeppelin/hardhat-upgrades" to verify the proxy’s implementation + // contract, the proxy itself and any proxy-related contracts, as well as + // link the proxy to the implementation contract’s ABI on (Ether)scan. + await hre.run("verify", { + address: newImplementationAddress, + constructorArgsParams: proxyDeployment.args, + }) + } +} + +export default func + +func.tags = ["ManualUpgradePolygonWormholeGateway"] + +// Comment this line when running an upgrade. +// yarn deploy --tags ManualUpgradePolygonWormholeGateway --network +func.skip = async () => true From 26ec1f0183b36a203f4db794d79e3686cb4cb1b9 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 22 Sep 2023 13:14:36 +0200 Subject: [PATCH 156/205] Transform `bitcoin.ts` file to `lib/bitcoin` shared lib The `bitcoin.ts` file is a bag for all Bitcoin related code which makes it hard to read and maintain. Here we split that file into smaller ones oriented around specific Bitcoin subdomains and move them to the new `lib/bitcoin` shared library module. --- typescript/src/bitcoin.ts | 782 ------------------ typescript/src/chain.ts | 2 +- typescript/src/deposit-refund.ts | 269 +++--- typescript/src/deposit-sweep.ts | 446 ++++------ typescript/src/deposit.ts | 244 ++---- typescript/src/electrum.ts | 47 +- typescript/src/ethereum.ts | 2 +- typescript/src/index.ts | 5 +- typescript/src/lib/bitcoin/address.ts | 68 ++ typescript/src/lib/bitcoin/block.ts | 143 ++++ typescript/src/lib/bitcoin/client.ts | 94 +++ typescript/src/lib/bitcoin/csuint.ts | 41 + typescript/src/lib/bitcoin/hash.ts | 37 + typescript/src/lib/bitcoin/index.ts | 9 + typescript/src/lib/bitcoin/key.ts | 80 ++ .../bitcoin/network.ts} | 21 +- typescript/src/lib/bitcoin/proof.ts | 44 + typescript/src/lib/bitcoin/transaction.ts | 195 +++++ typescript/src/optimistic-minting.ts | 2 +- typescript/src/wallet.ts | 4 +- typescript/test/bitcoin-network.test.ts | 30 +- typescript/test/bitcoin.test.ts | 255 +----- typescript/test/data/bitcoin.ts | 4 +- typescript/test/data/deposit-refund.ts | 2 +- typescript/test/data/deposit-sweep.ts | 2 +- typescript/test/data/deposit.ts | 2 +- typescript/test/data/electrum.ts | 2 +- typescript/test/data/proof.ts | 2 +- typescript/test/data/redemption.ts | 2 +- 29 files changed, 1189 insertions(+), 1647 deletions(-) delete mode 100644 typescript/src/bitcoin.ts create mode 100644 typescript/src/lib/bitcoin/address.ts create mode 100644 typescript/src/lib/bitcoin/block.ts create mode 100644 typescript/src/lib/bitcoin/client.ts create mode 100644 typescript/src/lib/bitcoin/csuint.ts create mode 100644 typescript/src/lib/bitcoin/hash.ts create mode 100644 typescript/src/lib/bitcoin/index.ts create mode 100644 typescript/src/lib/bitcoin/key.ts rename typescript/src/{bitcoin-network.ts => lib/bitcoin/network.ts} (70%) create mode 100644 typescript/src/lib/bitcoin/proof.ts create mode 100644 typescript/src/lib/bitcoin/transaction.ts diff --git a/typescript/src/bitcoin.ts b/typescript/src/bitcoin.ts deleted file mode 100644 index 3649327a6..000000000 --- a/typescript/src/bitcoin.ts +++ /dev/null @@ -1,782 +0,0 @@ -import bufio from "bufio" -import { BigNumber, utils } from "ethers" -import { Hex } from "./hex" -import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" -import { Transaction as Tx, address, payments } from "bitcoinjs-lib" - -/** - * Represents a transaction hash (or transaction ID) as an un-prefixed hex - * string. This hash is supposed to have the same byte order as used by the - * Bitcoin block explorers which is the opposite of the byte order used - * by the Bitcoin protocol internally. That means the hash must be reversed in - * the use cases that expect the Bitcoin internal byte order. - */ -export class TransactionHash extends Hex {} - -/** - * Represents a raw transaction. - */ -export interface RawTransaction { - /** - * The full transaction payload as an un-prefixed hex string. - */ - transactionHex: string -} - -/** - * Data about a transaction. - */ -export interface Transaction { - /** - * The transaction hash (or transaction ID) as an un-prefixed hex string. - */ - transactionHash: TransactionHash - - /** - * The vector of transaction inputs. - */ - inputs: TransactionInput[] - - /** - * The vector of transaction outputs. - */ - outputs: TransactionOutput[] -} - -/** - * Data about a transaction outpoint. - */ -export interface TransactionOutpoint { - /** - * The hash of the transaction the outpoint belongs to. - */ - transactionHash: TransactionHash - - /** - * The zero-based index of the output from the specified transaction. - */ - outputIndex: number -} - -/** - * Data about a transaction input. - */ -export type TransactionInput = TransactionOutpoint & { - /** - * The scriptSig that unlocks the specified outpoint for spending. - */ - scriptSig: Hex -} - -/** - * Data about a transaction output. - */ -export interface TransactionOutput { - /** - * The 0-based index of the output. - */ - outputIndex: number - - /** - * The value of the output in satoshis. - */ - value: BigNumber - - /** - * The receiving scriptPubKey. - */ - scriptPubKey: Hex -} - -/** - * Data about an unspent transaction output. - */ -export type UnspentTransactionOutput = TransactionOutpoint & { - /** - * The unspent value in satoshis. - */ - value: BigNumber -} - -/** - * Represents data of decomposed raw transaction. - */ -export interface DecomposedRawTransaction { - /** - * Transaction version as an un-prefixed hex string. - */ - version: string - - /** - * All transaction's inputs prepended by the number of transaction inputs, - * as an un-prefixed hex string. - */ - inputs: string - - /** - * All transaction's outputs prepended by the number of transaction outputs, - * as an un-prefixed hex string. - */ - outputs: string - - /** - * Transaction locktime as an un-prefixed hex string. - */ - locktime: string -} - -/** - * Data required to perform a proof that a given transaction was included in - * the Bitcoin blockchain. - */ -export interface Proof { - /** - * The merkle proof of transaction inclusion in a block, as an un-prefixed - * hex string. - */ - merkleProof: string - - /** - * Transaction index in the block (0-indexed). - */ - txIndexInBlock: number - - /** - * Single byte-string of 80-byte block headers, lowest height first, as an - * un-prefixed hex string. - */ - bitcoinHeaders: string -} - -/** - * Information about the merkle branch to a confirmed transaction. - */ -export interface TransactionMerkleBranch { - /** - * The height of the block the transaction was confirmed in. - */ - blockHeight: number - - /** - * A list of transaction hashes the current hash is paired with, recursively, - * in order to trace up to obtain the merkle root of the including block, - * deepest pairing first. Each hash is an unprefixed hex string. - */ - merkle: string[] - - /** - * The 0-based index of the transaction's position in the block. - */ - position: number -} - -/** - * BlockHeader represents the header of a Bitcoin block. For reference, see: - * https://developer.bitcoin.org/reference/block_chain.html#block-headers. - */ -export interface BlockHeader { - /** - * The block version number that indicates which set of block validation rules - * to follow. The field is 4-byte long. - */ - version: number - - /** - * The hash of the previous block's header. The field is 32-byte long. - */ - previousBlockHeaderHash: Hex - - /** - * The hash derived from the hashes of all transactions included in this block. - * The field is 32-byte long. - */ - merkleRootHash: Hex - - /** - * The Unix epoch time when the miner started hashing the header. The field is - * 4-byte long. - */ - time: number - - /** - * Bits that determine the target threshold this block's header hash must be - * less than or equal to. The field is 4-byte long. - */ - bits: number - - /** - * An arbitrary number miners change to modify the header hash in order to - * produce a hash less than or equal to the target threshold. The field is - * 4-byte long. - */ - nonce: number -} - -/** - * Serializes a BlockHeader to the raw representation. - * @param blockHeader - block header. - * @returns Serialized block header. - */ -export function serializeBlockHeader(blockHeader: BlockHeader): Hex { - const buffer = Buffer.alloc(80) - buffer.writeUInt32LE(blockHeader.version, 0) - blockHeader.previousBlockHeaderHash.toBuffer().copy(buffer, 4) - blockHeader.merkleRootHash.toBuffer().copy(buffer, 36) - buffer.writeUInt32LE(blockHeader.time, 68) - buffer.writeUInt32LE(blockHeader.bits, 72) - buffer.writeUInt32LE(blockHeader.nonce, 76) - return Hex.from(buffer) -} - -/** - * Deserializes a block header in the raw representation to BlockHeader. - * @param rawBlockHeader - BlockHeader in the raw format. - * @returns Block header as a BlockHeader. - */ -export function deserializeBlockHeader(rawBlockHeader: Hex): BlockHeader { - const buffer = rawBlockHeader.toBuffer() - const version = buffer.readUInt32LE(0) - const previousBlockHeaderHash = buffer.slice(4, 36) - const merkleRootHash = buffer.slice(36, 68) - const time = buffer.readUInt32LE(68) - const bits = buffer.readUInt32LE(72) - const nonce = buffer.readUInt32LE(76) - - return { - version: version, - previousBlockHeaderHash: Hex.from(previousBlockHeaderHash), - merkleRootHash: Hex.from(merkleRootHash), - time: time, - bits: bits, - nonce: nonce, - } -} - -/** - * Converts a block header's bits into target. - * @param bits - bits from block header. - * @returns Target as a BigNumber. - */ -export function bitsToTarget(bits: number): BigNumber { - // A serialized 80-byte block header stores the `bits` value as a 4-byte - // little-endian hexadecimal value in a slot including bytes 73, 74, 75, and - // 76. This function's input argument is expected to be a numerical - // representation of that 4-byte value reverted to the big-endian order. - // For example, if the `bits` little-endian value in the header is - // `0xcb04041b`, it must be reverted to the big-endian form `0x1b0404cb` and - // turned to a decimal number `453248203` in order to be used as this - // function's input. - // - // The `bits` 4-byte big-endian representation is a compact value that works - // like a base-256 version of scientific notation. It encodes the target - // exponent in the first byte and the target mantissa in the last three bytes. - // Referring to the previous example, if `bits = 453248203`, the hexadecimal - // representation is `0x1b0404cb` so the exponent is `0x1b` while the mantissa - // is `0x0404cb`. - // - // To extract the exponent, we need to shift right by 3 bytes (24 bits), - // extract the last byte of the result, and subtract 3 (because of the - // mantissa length): - // - 0x1b0404cb >>> 24 = 0x0000001b - // - 0x0000001b & 0xff = 0x1b - // - 0x1b - 3 = 24 (decimal) - // - // To extract the mantissa, we just need to take the last three bytes: - // - 0x1b0404cb & 0xffffff = 0x0404cb = 263371 (decimal) - // - // The final difficulty can be computed as mantissa * 256^exponent: - // - 263371 * 256^24 = - // 1653206561150525499452195696179626311675293455763937233695932416 (decimal) - // - // Sources: - // - https://developer.bitcoin.org/reference/block_chain.html#target-nbits - // - https://wiki.bitcoinsv.io/index.php/Target - - const exponent = ((bits >>> 24) & 0xff) - 3 - const mantissa = bits & 0xffffff - - const target = BigNumber.from(mantissa).mul(BigNumber.from(256).pow(exponent)) - return target -} - -/** - * Converts difficulty target to difficulty. - * @param target - difficulty target. - * @returns Difficulty as a BigNumber. - */ -export function targetToDifficulty(target: BigNumber): BigNumber { - const DIFF1_TARGET = BigNumber.from( - "0xffff0000000000000000000000000000000000000000000000000000" - ) - return DIFF1_TARGET.div(target) -} - -/** - * Represents a Bitcoin client. - */ -export interface Client { - /** - * Gets the network supported by the server the client connected to. - * @returns Bitcoin network. - */ - getNetwork(): Promise - - /** - * Finds all unspent transaction outputs (UTXOs) for given Bitcoin address. - * @param address - Bitcoin address UTXOs should be determined for. - * @returns List of UTXOs. - */ - findAllUnspentTransactionOutputs( - address: string - ): Promise - - /** - * Gets the history of confirmed transactions for given Bitcoin address. - * Returned transactions are sorted from oldest to newest. The returned - * result does not contain unconfirmed transactions living in the mempool - * at the moment of request. - * @param address - Bitcoin address transaction history should be determined for. - * @param limit - Optional parameter that can limit the resulting list to - * a specific number of last transaction. For example, limit = 5 will - * return only the last 5 transactions for the given address. - */ - getTransactionHistory(address: string, limit?: number): Promise - - /** - * Gets the full transaction object for given transaction hash. - * @param transactionHash - Hash of the transaction. - * @returns Transaction object. - */ - getTransaction(transactionHash: TransactionHash): Promise - - /** - * Gets the raw transaction data for given transaction hash. - * @param transactionHash - Hash of the transaction. - * @returns Raw transaction. - */ - getRawTransaction(transactionHash: TransactionHash): Promise - - /** - * Gets the number of confirmations that a given transaction has accumulated - * so far. - * @param transactionHash - Hash of the transaction. - * @returns The number of confirmations. - */ - getTransactionConfirmations(transactionHash: TransactionHash): Promise - - /** - * Gets height of the latest mined block. - * @return Height of the last mined block. - */ - latestBlockHeight(): Promise - - /** - * Gets concatenated chunk of block headers built on a starting block. - * @param blockHeight - Starting block height. - * @param chainLength - Number of subsequent blocks built on the starting - * block. - * @return Concatenation of block headers in a hexadecimal format. - */ - getHeadersChain(blockHeight: number, chainLength: number): Promise - - /** - * Get Merkle branch for a given transaction. - * @param transactionHash - Hash of a transaction. - * @param blockHeight - Height of the block where transaction was confirmed. - * @return Merkle branch. - */ - getTransactionMerkle( - transactionHash: TransactionHash, - blockHeight: number - ): Promise - - /** - * Broadcasts the given transaction over the network. - * @param transaction - Transaction to broadcast. - */ - broadcast(transaction: RawTransaction): Promise -} - -/** - * Decomposes a transaction in the raw representation into version, vector of - * inputs, vector of outputs and locktime. - * @param rawTransaction - Transaction in the raw format. - * @returns Transaction data with fields represented as un-prefixed hex strings. - */ -export function decomposeRawTransaction( - rawTransaction: RawTransaction -): DecomposedRawTransaction { - const toHex = (bufferWriter: any): string => { - return bufferWriter.render().toString("hex") - } - - const getTxInputVector = (tx: Tx): string => { - const buffer = bufio.write() - buffer.writeVarint(tx.ins.length) - tx.ins.forEach((input) => { - buffer.writeHash(input.hash) - buffer.writeU32(input.index) - buffer.writeVarBytes(input.script) - buffer.writeU32(input.sequence) - }) - return toHex(buffer) - } - - const getTxOutputVector = (tx: Tx): string => { - const buffer = bufio.write() - buffer.writeVarint(tx.outs.length) - tx.outs.forEach((output) => { - buffer.writeI64(output.value) - buffer.writeVarBytes(output.script) - }) - return toHex(buffer) - } - - const getTxVersion = (tx: Tx): string => { - const buffer = bufio.write() - buffer.writeU32(tx.version) - return toHex(buffer) - } - - const getTxLocktime = (tx: Tx): string => { - const buffer = bufio.write() - buffer.writeU32(tx.locktime) - return toHex(buffer) - } - - const transaction = Tx.fromBuffer( - Buffer.from(rawTransaction.transactionHex, "hex") - ) - - return { - version: getTxVersion(transaction), - inputs: getTxInputVector(transaction), - outputs: getTxOutputVector(transaction), - locktime: getTxLocktime(transaction), - } -} - -/** - * Checks whether given public key is a compressed Bitcoin public key. - * @param publicKey - Public key that should be checked. - * @returns True if the key is a compressed Bitcoin public key, false otherwise. - */ -export function isCompressedPublicKey(publicKey: string): boolean { - // Must have 33 bytes and 02 or 03 prefix. - return ( - publicKey.length == 66 && - (publicKey.substring(0, 2) == "02" || publicKey.substring(0, 2) == "03") - ) -} - -/** - * Compresses the given uncompressed Bitcoin public key. - * @param publicKey Uncompressed 64-byte public key as an unprefixed hex string. - * @returns Compressed 33-byte public key prefixed with 02 or 03. - */ -export function compressPublicKey(publicKey: string | Hex): string { - if (typeof publicKey === "string") { - publicKey = Hex.from(publicKey) - } - - publicKey = publicKey.toString() - - // Must have 64 bytes and no prefix. - if (publicKey.length != 128) { - throw new Error( - "The public key parameter must be 64-byte. Neither 0x nor 04 prefix is allowed" - ) - } - - // The X coordinate is the first 32 bytes. - const publicKeyX = publicKey.substring(0, 64) - // The Y coordinate is the next 32 bytes. - const publicKeyY = publicKey.substring(64) - - let prefix: string - if (BigNumber.from(`0x${publicKeyY}`).mod(2).eq(0)) { - prefix = "02" - } else { - prefix = "03" - } - - return `${prefix}${publicKeyX}` -} - -/** - * Computes the HASH160 for the given text. - * @param text - Text the HASH160 is computed for. - * @returns Hash as a 20-byte un-prefixed hex string. - */ -export function computeHash160(text: string): string { - const sha256Hash = utils.sha256( - Hex.from(Buffer.from(text, "hex")).toPrefixedString() - ) - const hash160 = utils.ripemd160(sha256Hash) - - return Hex.from(hash160).toString() -} - -/** - * Computes the single SHA256 for the given text. - * @param text - Text the single SHA256 is computed for. - * @returns Hash as a 32-byte un-prefixed hex string. - */ -export function computeSha256(text: Hex): Hex { - const hash = utils.sha256(text.toPrefixedString()) - return Hex.from(hash) -} - -/** - * Computes the double SHA256 for the given text. - * @param text - Text the double SHA256 is computed for. - * @returns Hash as a 32-byte un-prefixed hex string. - */ -export function computeHash256(text: Hex): Hex { - const firstHash = utils.sha256(text.toPrefixedString()) - const secondHash = utils.sha256(firstHash) - - return Hex.from(secondHash) -} - -/** - * Converts a hash in hex string in little endian to a BigNumber. - * @param hash - Hash in hex-string format. - * @returns BigNumber representation of the hash. - */ -export function hashLEToBigNumber(hash: Hex): BigNumber { - return BigNumber.from(hash.reverse().toPrefixedString()) -} - -/** - * Encodes a public key hash into a P2PKH/P2WPKH address. - * @param publicKeyHash - public key hash that will be encoded. Must be an - * unprefixed hex string (without 0x prefix). - * @param witness - If true, a witness public key hash will be encoded and - * P2WPKH address will be returned. Returns P2PKH address otherwise - * @param bitcoinNetwork - Network the address should be encoded for. - * @returns P2PKH or P2WPKH address encoded from the given public key hash - * @throws Throws an error if network is not supported. - */ -export function encodeToBitcoinAddress( - publicKeyHash: string, - witness: boolean, - bitcoinNetwork: BitcoinNetwork -): string { - const hash = Buffer.from(publicKeyHash, "hex") - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - return witness - ? payments.p2wpkh({ hash, network }).address! - : payments.p2pkh({ hash, network }).address! -} - -/** - * Decodes P2PKH or P2WPKH address into a public key hash. Throws if the - * provided address is not PKH-based. - * @param bitcoinAddress - P2PKH or P2WPKH address that will be decoded. - * @param bitcoinNetwork - Bitcoin network. - * @returns Public key hash decoded from the address. This will be an unprefixed - * hex string (without 0x prefix). - */ -export function decodeBitcoinAddress( - bitcoinAddress: string, - bitcoinNetwork: BitcoinNetwork -): string { - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - - try { - // Try extracting hash from P2PKH address. - const hash = payments.p2pkh({ address: bitcoinAddress, network }).hash! - return hash.toString("hex") - } catch (err) {} - - try { - // Try extracting hash from P2WPKH address. - const hash = payments.p2wpkh({ address: bitcoinAddress, network }).hash! - return hash.toString("hex") - } catch (err) {} - - throw new Error("Address must be P2PKH or P2WPKH valid for given network") -} - -/** - * Checks if given public key hash has proper length (20-byte) - * @param publicKeyHash - text that will be checked for the correct length - * @returns true if the given string is 20-byte long, false otherwise - */ -export function isPublicKeyHashLength(publicKeyHash: string): boolean { - return publicKeyHash.length === 40 -} - -/** - * Converts Bitcoin specific locktime value to a number. The number represents - * either a block height or an Unix timestamp depending on the value. - * - * If the number is less than 500 000 000 it is a block height. - * If the number is greater or equal 500 000 000 it is a Unix timestamp. - * - * @see {@link https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number Documentation} - * - * @param locktimeLE A 4-byte little-endian locktime as an un-prefixed - * hex string {@link: Deposit#refundLocktime}. - * @returns UNIX timestamp in seconds. - */ -export function locktimeToNumber(locktimeLE: Buffer | string): number { - const locktimeBE: Buffer = Hex.from(locktimeLE).reverse().toBuffer() - return BigNumber.from(locktimeBE).toNumber() -} - -/** - * Creates the output script from the BTC address. - * @param bitcoinAddress Bitcoin address. - * @param bitcoinNetwork Bitcoin network. - * @returns The un-prefixed and not prepended with length output script. - */ -export function createOutputScriptFromAddress( - bitcoinAddress: string, - bitcoinNetwork: BitcoinNetwork -): Hex { - return Hex.from( - address.toOutputScript( - bitcoinAddress, - toBitcoinJsLibNetwork(bitcoinNetwork) - ) - ) -} - -/** - * Creates the Bitcoin address from the output script. - * @param script The unprefixed and not prepended with length output script. - * @param bitcoinNetwork Bitcoin network. - * @returns The Bitcoin address. - */ -export function createAddressFromOutputScript( - script: Hex, - bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.Mainnet -): string { - return address.fromOutputScript( - script.toBuffer(), - toBitcoinJsLibNetwork(bitcoinNetwork) - ) -} - -/** - * Creates the Bitcoin address from the public key. Supports SegWit (P2WPKH) and - * Legacy (P2PKH) formats. - * @param publicKey - Public key used to derive the Bitcoin address. - * @param bitcoinNetwork - Target Bitcoin network. - * @param witness - Flag to determine address format: true for SegWit (P2WPKH) - * and false for Legacy (P2PKH). Default is true. - * @returns The derived Bitcoin address. - */ -export function createAddressFromPublicKey( - publicKey: Hex, - bitcoinNetwork: BitcoinNetwork, - witness: boolean = true -): string { - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - - if (witness) { - // P2WPKH (SegWit) - return payments.p2wpkh({ pubkey: publicKey.toBuffer(), network }).address! - } else { - // P2PKH (Legacy) - return payments.p2pkh({ pubkey: publicKey.toBuffer(), network }).address! - } -} - -/** - * Reads the leading compact size uint from the provided variable length data. - * - * WARNING: CURRENTLY, THIS FUNCTION SUPPORTS ONLY 1-BYTE COMPACT SIZE UINTS - * AND WILL THROW ON COMPACT SIZE UINTS OF DIFFERENT BYTE LENGTH. - * - * @param varLenData Variable length data preceded by a compact size uint. - * @returns An object holding the value of the compact size uint along with the - * compact size uint byte length. - */ -export function readCompactSizeUint(varLenData: Hex): { - value: number - byteLength: number -} { - // The varLenData is prefixed with the compact size uint. According to the docs - // (https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers) - // a compact size uint can be 1, 3, 5 or 9 bytes. To determine the exact length, - // we need to look at the discriminant byte which is always the first byte of - // the compact size uint. - const discriminant = varLenData.toString().slice(0, 2) - - switch (discriminant) { - case "ff": - case "fe": - case "fd": { - throw new Error( - "support for 3, 5 and 9 bytes compact size uints is not implemented yet" - ) - } - default: { - // The discriminant tells the compact size uint is 1 byte. That means - // the discriminant represent the value itself. - return { - value: parseInt(discriminant, 16), - byteLength: 1, - } - } - } -} - -/** - * Checks if the provided script comes from a P2PKH input. - * @param script The script to be checked. - * @returns True if the script is P2PKH, false otherwise. - */ -export function isP2PKHScript(script: Buffer): boolean { - try { - payments.p2pkh({ output: script }) - return true - } catch (err) { - return false - } -} - -/** - * Checks if the provided script comes from a P2WPKH input. - * @param script The script to be checked. - * @returns True if the script is P2WPKH, false otherwise. - */ -export function isP2WPKHScript(script: Buffer): boolean { - try { - payments.p2wpkh({ output: script }) - return true - } catch (err) { - return false - } -} - -/** - * Checks if the provided script comes from a P2SH input. - * @param script The script to be checked. - * @returns True if the script is P2SH, false otherwise. - */ -export function isP2SHScript(script: Buffer): boolean { - try { - payments.p2sh({ output: script }) - return true - } catch (err) { - return false - } -} - -/** - * Checks if the provided script comes from a P2PKH input. - * @param script The script to be checked. - * @returns True if the script is P2WSH, false otherwise. - */ -export function isP2WSHScript(script: Buffer): boolean { - try { - payments.p2wsh({ output: script }) - return true - } catch (err) { - return false - } -} diff --git a/typescript/src/chain.ts b/typescript/src/chain.ts index 3b4686dc5..0b840dabe 100644 --- a/typescript/src/chain.ts +++ b/typescript/src/chain.ts @@ -4,7 +4,7 @@ import { UnspentTransactionOutput, DecomposedRawTransaction, TransactionHash, -} from "./bitcoin" +} from "./lib/bitcoin" import { DepositRevealedEvent, DepositScriptParameters, diff --git a/typescript/src/deposit-refund.ts b/typescript/src/deposit-refund.ts index 2f6b9ee88..ec34038a1 100644 --- a/typescript/src/deposit-refund.ts +++ b/typescript/src/deposit-refund.ts @@ -1,24 +1,19 @@ +import bcoin from "bcoin" import { BigNumber } from "ethers" -import { Transaction, Stack, Signer, script } from "bitcoinjs-lib" import { + createKeyRing, RawTransaction, Client as BitcoinClient, TransactionHash, UnspentTransactionOutput, computeHash160, isCompressedPublicKey, - createOutputScriptFromAddress, - isP2SHScript, - isP2WSHScript, -} from "./bitcoin" +} from "./lib/bitcoin" import { assembleDepositScript, Deposit, validateDepositScriptParameters, } from "./deposit" -import { ECPairFactory } from "ecpair" -import * as tinysecp from "tiny-secp256k1" -import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" /** * Submits a deposit refund by creating and broadcasting a Bitcoin P2(W)PKH @@ -57,11 +52,8 @@ export async function submitDepositRefundTransaction( transactionHex: utxoRawTransaction.transactionHex, } - const bitcoinNetwork = await bitcoinClient.getNetwork() - const { transactionHash, rawTransaction } = await assembleDepositRefundTransaction( - bitcoinNetwork, fee, utxoWithRaw, deposit, @@ -79,7 +71,6 @@ export async function submitDepositRefundTransaction( /** * Assembles a Bitcoin P2(W)PKH deposit refund transaction. - * @param bitcoinNetwork - The target Bitcoin network. * @param fee - the value that will be subtracted from the deposit UTXO being * refunded and used as the transaction fee. * @param utxo - UTXO that was created during depositing that needs be refunded. @@ -94,7 +85,6 @@ export async function submitDepositRefundTransaction( * - the refund transaction in the raw format. */ export async function assembleDepositRefundTransaction( - bitcoinNetwork: BitcoinNetwork, fee: BigNumber, utxo: UnspentTransactionOutput & RawTransaction, deposit: Deposit, @@ -106,97 +96,101 @@ export async function assembleDepositRefundTransaction( }> { validateInputParameters(deposit, utxo) - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - // eslint-disable-next-line new-cap - const refunderKeyPair = ECPairFactory(tinysecp).fromWIF( - refunderPrivateKey, - network - ) + const refunderKeyRing = createKeyRing(refunderPrivateKey) - const outputValue = utxo.value.sub(fee) + const transaction = new bcoin.MTX() - const transaction = new Transaction() + transaction.addOutput({ + script: bcoin.Script.fromAddress(refunderAddress), + value: utxo.value.toNumber(), + }) - transaction.addInput( - utxo.transactionHash.reverse().toBuffer(), - utxo.outputIndex + const inputCoin = bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), + utxo.outputIndex, + -1 ) - const outputScript = createOutputScriptFromAddress( - refunderAddress, - bitcoinNetwork - ) - transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) + await transaction.fund([inputCoin], { + changeAddress: refunderAddress, + hardFee: fee.toNumber(), + subtractFee: true, + }) + + if (transaction.outputs.length != 1) { + throw new Error("Deposit refund transaction must have only one output") + } // In order to be able to spend the UTXO being refunded the transaction's // locktime must be set to a value equal to or higher than the refund locktime. // Additionally, the input's sequence must be set to a value different than // `0xffffffff`. These requirements are the result of BIP-65. transaction.locktime = locktimeToUnixTimestamp(deposit.refundLocktime) - transaction.ins[0].sequence = 0xfffffffe + transaction.inputs[0].sequence = 0xfffffffe // Sign the input - const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ - utxo.outputIndex - ] - const previousOutputValue = previousOutput.value - const previousOutputScript = previousOutput.script - - if (isP2SHScript(previousOutputScript)) { - // P2SH deposit UTXO - await signP2SHDepositInput( - transaction, - 0, - deposit, - previousOutputValue, - refunderKeyPair - ) - } else if (isP2WSHScript(previousOutputScript)) { - // P2WSH deposit UTXO - await signP2WSHDepositInput( - transaction, - 0, - deposit, - previousOutputValue, - refunderKeyPair - ) + const previousOutpoint = transaction.inputs[0].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) + const previousScript = previousOutput.script + + if (previousScript.isScripthash()) { + // P2SH UTXO deposit input + await signP2SHDepositInput(transaction, 0, deposit, refunderKeyRing) + } else if (previousScript.isWitnessScripthash()) { + // P2WSH UTXO deposit input + await signP2WSHDepositInput(transaction, 0, deposit, refunderKeyRing) } else { throw new Error("Unsupported UTXO script type") } - const transactionHash = TransactionHash.from(transaction.getId()) + // Verify the transaction by executing its input scripts. + const tx = transaction.toTX() + if (!tx.verify(transaction.view)) { + throw new Error("Transaction verification failure") + } + + const transactionHash = TransactionHash.from(transaction.txid()) return { transactionHash, rawTransaction: { - transactionHex: transaction.toHex(), + transactionHex: transaction.toRaw().toString("hex"), }, } } /** - * Assembles the deposit script based on the given deposit details. Performs - * validations on values and key formats. - * @param deposit - The deposit details. - * @param previousOutputValue - Value from the previous transaction output. - * @param refunderKeyPair - Signer object containing the refunder's key pair. - * @returns A Promise resolving to the assembled deposit script as a Buffer. - * @throws Error if there are discrepancies in values or key formats. + * Creates data needed to sign a deposit input to be refunded. + * @param transaction - Mutable transaction containing the input to be refunded. + * @param inputIndex - Index that points to the input. + * @param deposit - Data of the deposit to be refunded. + * @param refunderKeyRing - Key ring created using the refunder's private key. + * @returns Data needed to sign the input. */ -async function prepareDepositScript( +async function prepareInputSignData( + transaction: any, + inputIndex: number, deposit: Deposit, - previousOutputValue: number, - refunderKeyPair: Signer -): Promise { - if (previousOutputValue != deposit.amount.toNumber()) { - throw new Error("Mismatch between amount in deposit and deposit tx") - } + refunderKeyRing: any +): Promise<{ + refunderPublicKey: string + depositScript: any + previousOutputValue: number +}> { + const previousOutpoint = transaction.inputs[inputIndex].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) - const refunderPublicKey = refunderKeyPair.publicKey.toString("hex") + if (previousOutput.value != deposit.amount.toNumber()) { + throw new Error("Mismatch between amount in deposit and deposit refund tx") + } - if (computeHash160(refunderPublicKey) != deposit.refundPublicKeyHash) { + const refunderPublicKey = refunderKeyRing.getPublicKey("hex") + if ( + computeHash160(refunderKeyRing.getPublicKey("hex")) != + deposit.refundPublicKeyHash + ) { throw new Error( - "Refund public key does not correspond to wallet private key" + "Refund public key does not correspond to the refunder private key" ) } @@ -207,101 +201,98 @@ async function prepareDepositScript( // eslint-disable-next-line no-unused-vars const { amount, vault, ...depositScriptParameters } = deposit - const depositScript = Buffer.from( - await assembleDepositScript(depositScriptParameters), - "hex" + const depositScript = bcoin.Script.fromRaw( + Buffer.from(await assembleDepositScript(depositScriptParameters), "hex") ) - return depositScript + return { + refunderPublicKey: refunderPublicKey, + depositScript: depositScript, + previousOutputValue: previousOutput.value, + } } /** - * Signs a P2SH deposit transaction input and sets the `scriptSig`. - * @param transaction - The transaction containing the input to be signed. - * @param inputIndex - Index pointing to the input within the transaction. - * @param deposit - Details of the deposit transaction. - * @param previousOutputValue - The value from the previous transaction output. - * @param refunderKeyPair - A Signer object with the refunder's public and private - * key pair. - * @returns An empty promise upon successful signing. + * Creates and sets `scriptSig` for the transaction input at the given index by + * combining signature, refunder's public key and deposit script. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param deposit - Data of the deposit. + * @param refunderKeyRing - Key ring created using the refunder's private key. + * @returns Empty return. */ async function signP2SHDepositInput( - transaction: Transaction, + transaction: any, inputIndex: number, deposit: Deposit, - previousOutputValue: number, - refunderKeyPair: Signer + refunderKeyRing: any ) { - const depositScript = await prepareDepositScript( - deposit, - previousOutputValue, - refunderKeyPair - ) - - const sigHashType = Transaction.SIGHASH_ALL + const { refunderPublicKey, depositScript, previousOutputValue } = + await prepareInputSignData( + transaction, + inputIndex, + deposit, + refunderKeyRing + ) - const sigHash = transaction.hashForSignature( + const signature: Buffer = transaction.signature( inputIndex, depositScript, - sigHashType - ) - - const signature = script.signature.encode( - refunderKeyPair.sign(sigHash), - sigHashType + previousOutputValue, + refunderKeyRing.privateKey, + bcoin.Script.hashType.ALL, + 0 // legacy sighash version ) - - const scriptSig: Stack = [] - scriptSig.push(signature) - scriptSig.push(refunderKeyPair.publicKey) - scriptSig.push(depositScript) - - transaction.ins[inputIndex].script = script.compile(scriptSig) + const scriptSig = new bcoin.Script() + scriptSig.clear() + scriptSig.pushData(signature) + scriptSig.pushData(Buffer.from(refunderPublicKey, "hex")) + scriptSig.pushData(depositScript.toRaw()) + scriptSig.compile() + + transaction.inputs[inputIndex].script = scriptSig } /** - * Signs a P2WSH deposit transaction input and sets the witness script. - * @param transaction - The transaction containing the input to be signed. - * @param inputIndex - Index pointing to the input within the transaction. - * @param deposit - Details of the deposit transaction. - * @param previousOutputValue - The value from the previous transaction output. - * @param refunderKeyPair - A Signer object with the refunder's public and private - * key pair. - * @returns An empty promise upon successful signing. + * Creates and sets witness script for the transaction input at the given index + * by combining signature, refunder public key and deposit script. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param deposit - Data of the deposit. + * @param refunderKeyRing - Key ring created using the refunder's private key. + * @returns Empty return. */ async function signP2WSHDepositInput( - transaction: Transaction, + transaction: any, inputIndex: number, deposit: Deposit, - previousOutputValue: number, - refunderKeyPair: Signer + refunderKeyRing: any ) { - const depositScript = await prepareDepositScript( - deposit, - previousOutputValue, - refunderKeyPair - ) - - const sigHashType = Transaction.SIGHASH_ALL + const { refunderPublicKey, depositScript, previousOutputValue } = + await prepareInputSignData( + transaction, + inputIndex, + deposit, + refunderKeyRing + ) - const sigHash = transaction.hashForWitnessV0( + const signature: Buffer = transaction.signature( inputIndex, depositScript, previousOutputValue, - sigHashType - ) - - const signature = script.signature.encode( - refunderKeyPair.sign(sigHash), - sigHashType + refunderKeyRing.privateKey, + bcoin.Script.hashType.ALL, + 1 // segwit sighash version ) - const witness: Buffer[] = [] - witness.push(signature) - witness.push(refunderKeyPair.publicKey) - witness.push(depositScript) + const witness = new bcoin.Witness() + witness.clear() + witness.pushData(signature) + witness.pushData(Buffer.from(refunderPublicKey, "hex")) + witness.pushData(depositScript.toRaw()) + witness.compile() - transaction.ins[inputIndex].witness = witness + transaction.inputs[inputIndex].witness = witness } /** diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 03cfc5e13..9a1e00f7c 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,34 +1,18 @@ -import { - Transaction, - TxOutput, - Stack, - Signer, - payments, - script, -} from "bitcoinjs-lib" +import bcoin from "bcoin" import { BigNumber } from "ethers" -import { Hex } from "./hex" import { RawTransaction, UnspentTransactionOutput, Client as BitcoinClient, decomposeRawTransaction, isCompressedPublicKey, - createAddressFromPublicKey, + createKeyRing, TransactionHash, computeHash160, - isP2PKHScript, - isP2WPKHScript, - isP2SHScript, - isP2WSHScript, - createOutputScriptFromAddress, -} from "./bitcoin" +} from "./lib/bitcoin" import { assembleDepositScript, Deposit } from "./deposit" import { Bridge, Identifier } from "./chain" import { assembleTransactionProof } from "./proof" -import { ECPairFactory } from "ecpair" -import * as tinysecp from "tiny-secp256k1" -import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" /** * Submits a deposit sweep by combining all the provided P2(W)SH UTXOs and @@ -88,11 +72,8 @@ export async function submitDepositSweepTransaction( } } - const bitcoinNetwork = await bitcoinClient.getNetwork() - const { transactionHash, newMainUtxo, rawTransaction } = await assembleDepositSweepTransaction( - bitcoinNetwork, fee, walletPrivateKey, witness, @@ -110,28 +91,26 @@ export async function submitDepositSweepTransaction( } /** - * Constructs a Bitcoin deposit sweep transaction using provided UTXOs. + * Assembles a Bitcoin P2WPKH deposit sweep transaction. * @dev The caller is responsible for ensuring the provided UTXOs are correctly * formed, can be spent by the wallet and their combined value is greater * then the fee. - * @param bitcoinNetwork - The target Bitcoin network. - * @param fee - Transaction fee to be subtracted from the sum of the UTXOs' - * values. + * @param fee - the value that should be subtracted from the sum of the UTXOs + * values and used as the transaction fee. * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. - * @param witness - Determines the type of the new main UTXO output: P2WPKH if - * `true`, P2PKH if `false`. + * @param witness - The parameter used to decide about the type of the new main + * UTXO output. P2WPKH if `true`, P2PKH if `false`. * @param utxos - UTXOs from new deposit transactions. Must be P2(W)SH. - * @param deposits - Deposit data corresponding to each UTXO. The number of - * UTXOs and deposits must match. - * @param mainUtxo - The wallet's main UTXO (optional), which is a P2(W)PKH UTXO - * from a previous transaction. - * @returns An object containing the sweep transaction hash, new wallet's main - * UTXO, and the raw deposit sweep transaction representation. - * @throws Error if the provided UTXOs and deposits mismatch or if an unsupported - * UTXO script type is encountered. + * @param deposits - Array of deposits. Each element corresponds to UTXO. + * The number of UTXOs and deposit elements must equal. + * @param mainUtxo - main UTXO of the wallet, which is a P2WKH UTXO resulting + * from the previous wallet transaction (optional). + * @returns The outcome consisting of: + * - the sweep transaction hash, + * - the new wallet's main UTXO produced by this transaction. + * - the sweep transaction in the raw format */ export async function assembleDepositSweepTransaction( - bitcoinNetwork: BitcoinNetwork, fee: BigNumber, walletPrivateKey: string, witness: boolean, @@ -151,291 +130,238 @@ export async function assembleDepositSweepTransaction( throw new Error("Number of UTXOs must equal the number of deposit elements") } - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - // eslint-disable-next-line new-cap - const walletKeyPair = ECPairFactory(tinysecp).fromWIF( - walletPrivateKey, - network - ) - const walletAddress = createAddressFromPublicKey( - Hex.from(walletKeyPair.publicKey), - bitcoinNetwork, - witness - ) + const walletKeyRing = createKeyRing(walletPrivateKey, witness) + const walletAddress = walletKeyRing.getAddress("string") - const transaction = new Transaction() + const inputCoins = [] + let totalInputValue = BigNumber.from(0) - let outputValue = BigNumber.from(0) if (mainUtxo) { - transaction.addInput( - mainUtxo.transactionHash.reverse().toBuffer(), - mainUtxo.outputIndex + inputCoins.push( + bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), + mainUtxo.outputIndex, + -1 + ) ) - outputValue = outputValue.add(mainUtxo.value) + totalInputValue = totalInputValue.add(mainUtxo.value) } + for (const utxo of utxos) { - transaction.addInput( - utxo.transactionHash.reverse().toBuffer(), - utxo.outputIndex + inputCoins.push( + bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), + utxo.outputIndex, + -1 + ) ) - outputValue = outputValue.add(utxo.value) + totalInputValue = totalInputValue.add(utxo.value) } - outputValue = outputValue.sub(fee) - const outputScript = createOutputScriptFromAddress( - walletAddress, - bitcoinNetwork - ) - transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) + const transaction = new bcoin.MTX() - // Sign the main UTXO input if there is main UTXO. - if (mainUtxo) { - const inputIndex = 0 // Main UTXO is the first input. - const previousOutput = Transaction.fromHex(mainUtxo.transactionHex).outs[ - mainUtxo.outputIndex - ] - - await signMainUtxoInput( - transaction, - inputIndex, - previousOutput, - walletKeyPair - ) - } + transaction.addOutput({ + script: bcoin.Script.fromAddress(walletAddress), + value: totalInputValue.toNumber(), + }) - // Sign the deposit inputs. - for (let depositIndex = 0; depositIndex < deposits.length; depositIndex++) { - // If there is a main UTXO index, we must adjust input index as the first - // input is the main UTXO input. - const inputIndex = mainUtxo ? depositIndex + 1 : depositIndex + await transaction.fund(inputCoins, { + changeAddress: walletAddress, + hardFee: fee.toNumber(), + subtractFee: true, + }) + + if (transaction.outputs.length != 1) { + throw new Error("Deposit sweep transaction must have only one output") + } - const utxo = utxos[depositIndex] - const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ - utxo.outputIndex - ] - const previousOutputValue = previousOutput.value - const previousOutputScript = previousOutput.script + // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any + // order + const utxosWithDeposits: (UnspentTransactionOutput & + RawTransaction & + Deposit)[] = utxos.map((utxo, index) => ({ + ...utxo, + ...deposits[index], + })) + + for (let i = 0; i < transaction.inputs.length; i++) { + const previousOutpoint = transaction.inputs[i].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) + const previousScript = previousOutput.script + + // P2(W)PKH (main UTXO) + if (previousScript.isPubkeyhash() || previousScript.isWitnessPubkeyhash()) { + await signMainUtxoInput(transaction, i, walletKeyRing) + continue + } - const deposit = deposits[depositIndex] + const utxoWithDeposit = utxosWithDeposits.find( + (u) => + u.transactionHash.toString() === previousOutpoint.txid() && + u.outputIndex == previousOutpoint.index + ) + if (!utxoWithDeposit) { + throw new Error("Unknown input") + } - if (isP2SHScript(previousOutputScript)) { + if (previousScript.isScripthash()) { // P2SH (deposit UTXO) - await signP2SHDepositInput( - transaction, - inputIndex, - deposit, - previousOutputValue, - walletKeyPair - ) - } else if (isP2WSHScript(previousOutputScript)) { + await signP2SHDepositInput(transaction, i, utxoWithDeposit, walletKeyRing) + } else if (previousScript.isWitnessScripthash()) { // P2WSH (deposit UTXO) await signP2WSHDepositInput( transaction, - inputIndex, - deposit, - previousOutputValue, - walletKeyPair + i, + utxoWithDeposit, + walletKeyRing ) } else { throw new Error("Unsupported UTXO script type") } } - const transactionHash = TransactionHash.from(transaction.getId()) + const transactionHash = TransactionHash.from(transaction.txid()) return { transactionHash, newMainUtxo: { transactionHash, outputIndex: 0, // There is only one output. - value: BigNumber.from(transaction.outs[0].value), + value: BigNumber.from(transaction.outputs[0].value), }, rawTransaction: { - transactionHex: transaction.toHex(), + transactionHex: transaction.toRaw().toString("hex"), }, } } /** - * Signs the main UTXO transaction input and sets the appropriate script or - * witness data. - * @param transaction - The transaction containing the input to be signed. - * @param inputIndex - Index pointing to the input within the transaction. - * @param previousOutput - The previous output for the main UTXO input. - * @param walletKeyPair - A Signer object with the wallet's public and private - * key pair. - * @param bitcoinNetwork - The Bitcoin network type. - * @returns An empty promise upon successful signing. - * @throws Error if the UTXO doesn't belong to the wallet, or if the script - * format is invalid or unknown. + * Creates script for the transaction input at the given index and signs the + * input. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param walletKeyRing - Key ring created using the wallet's private key. + * @returns Empty promise. */ async function signMainUtxoInput( - transaction: Transaction, + transaction: any, inputIndex: number, - previousOutput: TxOutput, - walletKeyPair: Signer + walletKeyRing: any ) { - if ( - !canSpendOutput(Hex.from(walletKeyPair.publicKey), previousOutput.script) - ) { + const previousOutpoint = transaction.inputs[inputIndex].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) + if (!walletKeyRing.ownOutput(previousOutput)) { throw new Error("UTXO does not belong to the wallet") } - - const sigHashType = Transaction.SIGHASH_ALL - - if (isP2PKHScript(previousOutput.script)) { - // P2PKH - const sigHash = transaction.hashForSignature( - inputIndex, - previousOutput.script, - sigHashType - ) - - const signature = script.signature.encode( - walletKeyPair.sign(sigHash), - sigHashType - ) - - const scriptSig = payments.p2pkh({ - signature: signature, - pubkey: walletKeyPair.publicKey, - }).input! - - transaction.ins[inputIndex].script = scriptSig - } else if (isP2WPKHScript(previousOutput.script)) { - // P2WPKH - const publicKeyHash = payments.p2wpkh({ output: previousOutput.script }) - .hash! - const p2pkhScript = payments.p2pkh({ hash: publicKeyHash }).output! - - const sigHash = transaction.hashForWitnessV0( - inputIndex, - p2pkhScript, - previousOutput.value, - sigHashType - ) - - const signature = script.signature.encode( - walletKeyPair.sign(sigHash), - sigHashType - ) - - transaction.ins[inputIndex].witness = [signature, walletKeyPair.publicKey] - } else { - throw new Error("Unknown type of main UTXO") - } + // Build script and set it as input's witness + transaction.scriptInput(inputIndex, previousOutput, walletKeyRing) + // Build signature and add it in front of script in input's witness + transaction.signInput(inputIndex, previousOutput, walletKeyRing) } /** - * Signs a P2SH deposit transaction input and sets the `scriptSig`. - * @param transaction - The transaction containing the input to be signed. - * @param inputIndex - Index pointing to the input within the transaction. - * @param deposit - Details of the deposit transaction. - * @param previousOutputValue - The value from the previous transaction output. - * @param walletKeyPair - A Signer object with the wallet's public and private - * key pair. - * @returns An empty promise upon successful signing. + * Creates and sets `scriptSig` for the transaction input at the given index by + * combining signature, wallet public key and deposit script. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param deposit - Data of the deposit. + * @param walletKeyRing - Key ring created using the wallet's private key. + * @returns Empty promise. */ async function signP2SHDepositInput( - transaction: Transaction, + transaction: any, inputIndex: number, deposit: Deposit, - previousOutputValue: number, - walletKeyPair: Signer -) { - const depositScript = await prepareDepositScript( - deposit, - previousOutputValue, - walletKeyPair - ) - - const sigHashType = Transaction.SIGHASH_ALL + walletKeyRing: any +): Promise { + const { walletPublicKey, depositScript, previousOutputValue } = + await prepareInputSignData(transaction, inputIndex, deposit, walletKeyRing) - const sigHash = transaction.hashForSignature( + const signature: Buffer = transaction.signature( inputIndex, depositScript, - sigHashType - ) - - const signature = script.signature.encode( - walletKeyPair.sign(sigHash), - sigHashType + previousOutputValue, + walletKeyRing.privateKey, + bcoin.Script.hashType.ALL, + 0 // legacy sighash version ) - - const scriptSig: Stack = [] - scriptSig.push(signature) - scriptSig.push(walletKeyPair.publicKey) - scriptSig.push(depositScript) - - transaction.ins[inputIndex].script = script.compile(scriptSig) + const scriptSig = new bcoin.Script() + scriptSig.clear() + scriptSig.pushData(signature) + scriptSig.pushData(Buffer.from(walletPublicKey, "hex")) + scriptSig.pushData(depositScript.toRaw()) + scriptSig.compile() + + transaction.inputs[inputIndex].script = scriptSig } /** - * Signs a P2WSH deposit transaction input and sets the witness script. - * @param transaction - The transaction containing the input to be signed. - * @param inputIndex - Index pointing to the input within the transaction. - * @param deposit - Details of the deposit transaction. - * @param previousOutputValue - The value from the previous transaction output. - * @param walletKeyPair - A Signer object with the wallet's public and private - * key pair. - * @returns An empty promise upon successful signing. + * Creates and sets witness script for the transaction input at the given index + * by combining signature, wallet public key and deposit script. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param deposit - Data of the deposit. + * @param walletKeyRing - Key ring created using the wallet's private key. + * @returns Empty promise. */ async function signP2WSHDepositInput( - transaction: Transaction, + transaction: any, inputIndex: number, deposit: Deposit, - previousOutputValue: number, - walletKeyPair: Signer -) { - const depositScript = await prepareDepositScript( - deposit, - previousOutputValue, - walletKeyPair - ) - - const sigHashType = Transaction.SIGHASH_ALL + walletKeyRing: any +): Promise { + const { walletPublicKey, depositScript, previousOutputValue } = + await prepareInputSignData(transaction, inputIndex, deposit, walletKeyRing) - const sigHash = transaction.hashForWitnessV0( + const signature: Buffer = transaction.signature( inputIndex, depositScript, previousOutputValue, - sigHashType - ) - - const signature = script.signature.encode( - walletKeyPair.sign(sigHash), - sigHashType + walletKeyRing.privateKey, + bcoin.Script.hashType.ALL, + 1 // segwit sighash version ) - const witness: Buffer[] = [] - witness.push(signature) - witness.push(walletKeyPair.publicKey) - witness.push(depositScript) + const witness = new bcoin.Witness() + witness.clear() + witness.pushData(signature) + witness.pushData(Buffer.from(walletPublicKey, "hex")) + witness.pushData(depositScript.toRaw()) + witness.compile() - transaction.ins[inputIndex].witness = witness + transaction.inputs[inputIndex].witness = witness } /** - * Assembles the deposit script based on the given deposit details. Performs - * validations on values and key formats. - * @param deposit - The deposit details. - * @param previousOutputValue - Value from the previous transaction output. - * @param walletKeyPair - Signer object containing the wallet's key pair. - * @returns A Promise resolving to the assembled deposit script as a Buffer. - * @throws Error if there are discrepancies in values or key formats. + * Creates data needed to sign a deposit input. + * @param transaction - Mutable transaction containing the input. + * @param inputIndex - Index that points to the input. + * @param deposit - Data of the deposit. + * @param walletKeyRing - Key ring created using the wallet's private key. + * @returns Data needed to sign the input. */ -async function prepareDepositScript( +async function prepareInputSignData( + transaction: any, + inputIndex: number, deposit: Deposit, - previousOutputValue: number, - walletKeyPair: Signer -): Promise { - if (previousOutputValue != deposit.amount.toNumber()) { + walletKeyRing: any +): Promise<{ + walletPublicKey: string + depositScript: any + previousOutputValue: number +}> { + const previousOutpoint = transaction.inputs[inputIndex].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) + + if (previousOutput.value != deposit.amount.toNumber()) { throw new Error("Mismatch between amount in deposit and deposit tx") } - const walletPublicKey = walletKeyPair.publicKey.toString("hex") - - if (computeHash160(walletPublicKey) != deposit.walletPublicKeyHash) { + const walletPublicKey = walletKeyRing.getPublicKey("hex") + if ( + computeHash160(walletKeyRing.getPublicKey("hex")) != + deposit.walletPublicKeyHash + ) { throw new Error( "Wallet public key does not correspond to wallet private key" ) @@ -448,12 +374,15 @@ async function prepareDepositScript( // eslint-disable-next-line no-unused-vars const { amount, vault, ...depositScriptParameters } = deposit - const depositScript = Buffer.from( - await assembleDepositScript(depositScriptParameters), - "hex" + const depositScript = bcoin.Script.fromRaw( + Buffer.from(await assembleDepositScript(depositScriptParameters), "hex") ) - return depositScript + return { + walletPublicKey, + depositScript: depositScript, + previousOutputValue: previousOutput.value, + } } /** @@ -491,20 +420,3 @@ export async function submitDepositSweepProof( vault ) } - -/** - * Determines if a UTXO's output script can be spent using the provided public - * key. - * @param publicKey - Public key used to derive the corresponding P2PKH and - * P2WPKH output scripts. - * @param outputScript - The output script of the UTXO in question. - * @returns True if the provided output script matches the P2PKH or P2WPKH - * output scripts derived from the given public key. False otherwise. - */ -function canSpendOutput(publicKey: Hex, outputScript: Buffer): boolean { - const pubkeyBuffer = publicKey.toBuffer() - const p2pkhOutput = payments.p2pkh({ pubkey: pubkeyBuffer }).output! - const p2wpkhOutput = payments.p2wpkh({ pubkey: pubkeyBuffer }).output! - - return outputScript.equals(p2pkhOutput) || outputScript.equals(p2wpkhOutput) -} diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index f897dadbc..1deb84609 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -1,29 +1,20 @@ +import bcoin from "bcoin" import { BigNumber } from "ethers" -import { - Psbt, - Stack, - Transaction, - payments, - script, - opcodes, -} from "bitcoinjs-lib" import { Client as BitcoinClient, - createAddressFromPublicKey, + BitcoinNetwork, + toBcoinNetwork, decomposeRawTransaction, + createKeyRing, RawTransaction, UnspentTransactionOutput, TransactionHash, isPublicKeyHashLength, - computeSha256, - computeHash160, - isP2WPKHScript, -} from "./bitcoin" -import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" +} from "./lib/bitcoin" import { Bridge, Event, Identifier } from "./chain" import { Hex } from "./hex" -import { ECPairFactory } from "ecpair" -import * as tinysecp from "tiny-secp256k1" + +const { opcodes } = bcoin.script.common // TODO: Replace all properties that are expected to be un-prefixed hexadecimal // strings with a Hex type. @@ -129,34 +120,28 @@ export type DepositRevealedEvent = Deposit & { * @param bitcoinClient - Bitcoin client used to interact with the network. * @param witness - If true, a witness (P2WSH) transaction will be created. * Otherwise, a legacy P2SH transaction will be made. - * @param inputUtxos - UTXOs to be used for funding the deposit transaction. So - * far only P2WPKH UTXO inputs are supported. - * @param fee - the value that should be subtracted from the sum of the UTXOs - * values and used as the transaction fee. * @returns The outcome consisting of: * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. - * @dev UTXOs are selected for transaction funding based on their types. UTXOs - * with unsupported types are skipped. The selection process stops once - * the sum of the chosen UTXOs meets the required funding amount. - * Be aware that the function will attempt to broadcast the transaction, - * although successful broadcast is not guaranteed. - * @throws {Error} When the sum of the selected UTXOs is insufficient to cover - * the deposit amount and transaction fee. */ export async function submitDepositTransaction( deposit: Deposit, depositorPrivateKey: string, bitcoinClient: BitcoinClient, - witness: boolean, - inputUtxos: UnspentTransactionOutput[], - fee: BigNumber + witness: boolean ): Promise<{ transactionHash: TransactionHash depositUtxo: UnspentTransactionOutput }> { + const depositorKeyRing = createKeyRing(depositorPrivateKey) + const depositorAddress = depositorKeyRing.getAddress("string") + + const utxos = await bitcoinClient.findAllUnspentTransactionOutputs( + depositorAddress + ) + const utxosWithRaw: (UnspentTransactionOutput & RawTransaction)[] = [] - for (const utxo of inputUtxos) { + for (const utxo of utxos) { const utxoRawTransaction = await bitcoinClient.getRawTransaction( utxo.transactionHash ) @@ -167,21 +152,14 @@ export async function submitDepositTransaction( }) } - const bitcoinNetwork = await bitcoinClient.getNetwork() - const { transactionHash, depositUtxo, rawTransaction } = await assembleDepositTransaction( - bitcoinNetwork, deposit, - depositorPrivateKey, - witness, utxosWithRaw, - fee + depositorPrivateKey, + witness ) - // Note that `broadcast` may fail silently (i.e. no error will be returned, - // even if the transaction is rejected by other nodes and does not enter the - // mempool, for example due to an UTXO being already spent). await bitcoinClient.broadcast(rawTransaction) return { @@ -192,107 +170,57 @@ export async function submitDepositTransaction( /** * Assembles a Bitcoin P2(W)SH deposit transaction. - * @param bitcoinNetwork - The target Bitcoin network. * @param deposit - Details of the deposit. + * @param utxos - UTXOs that should be used as transaction inputs. * @param depositorPrivateKey - Bitcoin private key of the depositor. * @param witness - If true, a witness (P2WSH) transaction will be created. * Otherwise, a legacy P2SH transaction will be made. - * @param inputUtxos - UTXOs to be used for funding the deposit transaction. So - * far only P2WPKH UTXO inputs are supported. - * @param fee - Transaction fee to be subtracted from the sum of the UTXOs' - * values. * @returns The outcome consisting of: * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. * - the deposit transaction in the raw format - * @dev UTXOs are selected for transaction funding based on their types. UTXOs - * with unsupported types are skipped. The selection process stops once - * the sum of the chosen UTXOs meets the required funding amount. - * @throws {Error} When the sum of the selected UTXOs is insufficient to cover - * the deposit amount and transaction fee. */ export async function assembleDepositTransaction( - bitcoinNetwork: BitcoinNetwork, deposit: Deposit, + utxos: (UnspentTransactionOutput & RawTransaction)[], depositorPrivateKey: string, - witness: boolean, - inputUtxos: (UnspentTransactionOutput & RawTransaction)[], - fee: BigNumber + witness: boolean ): Promise<{ transactionHash: TransactionHash depositUtxo: UnspentTransactionOutput rawTransaction: RawTransaction }> { - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - // eslint-disable-next-line new-cap - const depositorKeyPair = ECPairFactory(tinysecp).fromWIF( - depositorPrivateKey, - network + const depositorKeyRing = createKeyRing(depositorPrivateKey) + const depositorAddress = depositorKeyRing.getAddress("string") + + const inputCoins = utxos.map((utxo) => + bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), + utxo.outputIndex, + -1 + ) ) - const psbt = new Psbt({ network }) - psbt.setVersion(1) - - const totalExpenses = deposit.amount.add(fee) - let totalInputValue = BigNumber.from(0) - - for (const utxo of inputUtxos) { - const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ - utxo.outputIndex - ] - const previousOutputValue = previousOutput.value - const previousOutputScript = previousOutput.script - - // TODO: Add support for other utxo types along with unit tests for the - // given type. - if (isP2WPKHScript(previousOutputScript)) { - psbt.addInput({ - hash: utxo.transactionHash.reverse().toBuffer(), - index: utxo.outputIndex, - witnessUtxo: { - script: previousOutputScript, - value: previousOutputValue, - }, - }) - - totalInputValue = totalInputValue.add(utxo.value) - if (totalInputValue.gte(totalExpenses)) { - break - } - } - // Skip UTXO if the type is unsupported. - } + const transaction = new bcoin.MTX() - // Sum of the selected UTXOs must be equal to or greater than the deposit - // amount plus fee. - if (totalInputValue.lt(totalExpenses)) { - throw new Error("Not enough funds in selected UTXOs to fund transaction") - } + const scriptHash = await calculateDepositScriptHash(deposit, witness) - // Add deposit output. - psbt.addOutput({ - address: await calculateDepositAddress(deposit, bitcoinNetwork, witness), + transaction.addOutput({ + script: witness + ? bcoin.Script.fromProgram(0, scriptHash) + : bcoin.Script.fromScripthash(scriptHash), value: deposit.amount.toNumber(), }) - // Add change output if needed. - const changeValue = totalInputValue.sub(totalExpenses) - if (changeValue.gt(0)) { - const depositorAddress = createAddressFromPublicKey( - Hex.from(depositorKeyPair.publicKey), - bitcoinNetwork - ) - psbt.addOutput({ - address: depositorAddress, - value: changeValue.toNumber(), - }) - } + await transaction.fund(inputCoins, { + rate: null, // set null explicitly to always use the default value + changeAddress: depositorAddress, + subtractFee: false, // do not subtract the fee from outputs + }) - psbt.signAllInputs(depositorKeyPair) - psbt.finalizeAllInputs() + transaction.sign(depositorKeyRing) - const transaction = psbt.extractTransaction() - const transactionHash = TransactionHash.from(transaction.getId()) + const transactionHash = TransactionHash.from(transaction.txid()) return { transactionHash, @@ -302,7 +230,7 @@ export async function assembleDepositTransaction( value: deposit.amount, }, rawTransaction: { - transactionHex: transaction.toHex(), + transactionHex: transaction.toRaw().toString("hex"), }, } } @@ -317,31 +245,33 @@ export async function assembleDepositScript( ): Promise { validateDepositScriptParameters(deposit) - const chunks: Stack = [] - - // All HEXes pushed to the script must be un-prefixed - chunks.push(Buffer.from(deposit.depositor.identifierHex, "hex")) - chunks.push(opcodes.OP_DROP) - chunks.push(Buffer.from(deposit.blindingFactor, "hex")) - chunks.push(opcodes.OP_DROP) - chunks.push(opcodes.OP_DUP) - chunks.push(opcodes.OP_HASH160) - chunks.push(Buffer.from(deposit.walletPublicKeyHash, "hex")) - chunks.push(opcodes.OP_EQUAL) - chunks.push(opcodes.OP_IF) - chunks.push(opcodes.OP_CHECKSIG) - chunks.push(opcodes.OP_ELSE) - chunks.push(opcodes.OP_DUP) - chunks.push(opcodes.OP_HASH160) - chunks.push(Buffer.from(deposit.refundPublicKeyHash, "hex")) - chunks.push(opcodes.OP_EQUALVERIFY) - chunks.push(Buffer.from(deposit.refundLocktime, "hex")) - chunks.push(opcodes.OP_CHECKLOCKTIMEVERIFY) - chunks.push(opcodes.OP_DROP) - chunks.push(opcodes.OP_CHECKSIG) - chunks.push(opcodes.OP_ENDIF) - - return script.compile(chunks).toString("hex") + // All HEXes pushed to the script must be un-prefixed. + const script = new bcoin.Script() + script.clear() + script.pushData(Buffer.from(deposit.depositor.identifierHex, "hex")) + script.pushOp(opcodes.OP_DROP) + script.pushData(Buffer.from(deposit.blindingFactor, "hex")) + script.pushOp(opcodes.OP_DROP) + script.pushOp(opcodes.OP_DUP) + script.pushOp(opcodes.OP_HASH160) + script.pushData(Buffer.from(deposit.walletPublicKeyHash, "hex")) + script.pushOp(opcodes.OP_EQUAL) + script.pushOp(opcodes.OP_IF) + script.pushOp(opcodes.OP_CHECKSIG) + script.pushOp(opcodes.OP_ELSE) + script.pushOp(opcodes.OP_DUP) + script.pushOp(opcodes.OP_HASH160) + script.pushData(Buffer.from(deposit.refundPublicKeyHash, "hex")) + script.pushOp(opcodes.OP_EQUALVERIFY) + script.pushData(Buffer.from(deposit.refundLocktime, "hex")) + script.pushOp(opcodes.OP_CHECKLOCKTIMEVERIFY) + script.pushOp(opcodes.OP_DROP) + script.pushOp(opcodes.OP_CHECKSIG) + script.pushOp(opcodes.OP_ENDIF) + script.compile() + + // Return script as HEX string. + return script.toRaw().toString("hex") } // eslint-disable-next-line valid-jsdoc @@ -414,11 +344,11 @@ export async function calculateDepositScriptHash( witness: boolean ): Promise { const script = await assembleDepositScript(deposit) + // Parse the script from HEX string. + const parsedScript = bcoin.Script.fromRaw(Buffer.from(script, "hex")) // If witness script hash should be produced, SHA256 should be used. // Legacy script hash needs HASH160. - return witness - ? computeSha256(Hex.from(script)).toBuffer() - : Buffer.from(computeHash160(script), "hex") + return witness ? parsedScript.sha256() : parsedScript.hash160() } /** @@ -435,28 +365,10 @@ export async function calculateDepositAddress( witness: boolean ): Promise { const scriptHash = await calculateDepositScriptHash(deposit, witness) - const bitcoinNetwork = toBitcoinJsLibNetwork(network) - - if (witness) { - // OP_0 - const p2wshOutput = Buffer.concat([ - Buffer.from([opcodes.OP_0, 0x20]), - scriptHash, - ]) - - return payments.p2wsh({ output: p2wshOutput, network: bitcoinNetwork }) - .address! - } else { - // OP_HASH160 OP_EQUAL - const p2shOutput = Buffer.concat([ - Buffer.from([opcodes.OP_HASH160, 0x14]), - scriptHash, - Buffer.from([opcodes.OP_EQUAL]), - ]) - - return payments.p2sh({ output: p2shOutput, network: bitcoinNetwork }) - .address! - } + const address = witness + ? bcoin.Address.fromWitnessScripthash(scriptHash) + : bcoin.Address.fromScripthash(scriptHash) + return address.toString(toBcoinNetwork(network)) } /** diff --git a/typescript/src/electrum.ts b/typescript/src/electrum.ts index de21961ff..3335f5fc2 100644 --- a/typescript/src/electrum.ts +++ b/typescript/src/electrum.ts @@ -1,8 +1,8 @@ -import { Transaction as Tx, TxInput, TxOutput } from "bitcoinjs-lib" +import bcoin from "bcoin" import pTimeout from "p-timeout" import { Client as BitcoinClient, - computeSha256, + BitcoinNetwork, createOutputScriptFromAddress, RawTransaction, Transaction, @@ -11,8 +11,7 @@ import { TransactionMerkleBranch, TransactionOutput, UnspentTransactionOutput, -} from "./bitcoin" -import { BitcoinNetwork } from "./bitcoin-network" +} from "./lib/bitcoin" import Electrum from "electrum-client-js" import { BigNumber, utils } from "ethers" import { URL } from "url" @@ -233,11 +232,7 @@ export class Client implements BitcoinClient { ): Promise { return this.withElectrum( async (electrum: Electrum) => { - const bitcoinNetwork = await this.getNetwork() - const script = createOutputScriptFromAddress( - address, - bitcoinNetwork - ).toString() + const script = createOutputScriptFromAddress(address).toString() // eslint-disable-next-line camelcase type UnspentOutput = { tx_pos: number; value: number; tx_hash: string } @@ -267,11 +262,7 @@ export class Client implements BitcoinClient { limit?: number ): Promise { return this.withElectrum(async (electrum: Electrum) => { - const bitcoinNetwork = await this.getNetwork() - const script = createOutputScriptFromAddress( - address, - bitcoinNetwork - ).toString() + const script = createOutputScriptFromAddress(address).toString() // eslint-disable-next-line camelcase type HistoryItem = { height: number; tx_hash: string } @@ -338,26 +329,26 @@ export class Client implements BitcoinClient { } // Decode the raw transaction. - const transaction = Tx.fromHex(rawTransaction) + const transaction = bcoin.TX.fromRaw(rawTransaction, "hex") - const inputs = transaction.ins.map( - (input: TxInput): TransactionInput => ({ - transactionHash: TransactionHash.from(input.hash).reverse(), - outputIndex: input.index, - scriptSig: Hex.from(input.script), + const inputs = transaction.inputs.map( + (input: any): TransactionInput => ({ + transactionHash: TransactionHash.from(input.prevout.hash).reverse(), + outputIndex: input.prevout.index, + scriptSig: Hex.from(input.script.toRaw()), }) ) - const outputs = transaction.outs.map( - (output: TxOutput, i: number): TransactionOutput => ({ + const outputs = transaction.outputs.map( + (output: any, i: number): TransactionOutput => ({ outputIndex: i, value: BigNumber.from(output.value), - scriptPubKey: Hex.from(output.script), + scriptPubKey: Hex.from(output.script.toRaw()), }) ) return { - transactionHash: TransactionHash.from(transaction.getId()), + transactionHash: TransactionHash.from(transaction.hash()).reverse(), inputs: inputs, outputs: outputs, } @@ -408,7 +399,7 @@ export class Client implements BitcoinClient { ) // Decode the raw transaction. - const transaction = Tx.fromHex(rawTransaction) + const transaction = bcoin.TX.fromRaw(rawTransaction, "hex") // As a workaround for the problem described in https://github.com/Blockstream/electrs/pull/36 // we need to calculate the number of confirmations based on the latest @@ -426,10 +417,8 @@ export class Client implements BitcoinClient { // If a transaction is unconfirmed (is still in the mempool) the height will // have a value of `0` or `-1`. let txBlockHeight: number = Math.min() - for (const output of transaction.outs) { - const scriptHash: Buffer = computeSha256( - Hex.from(output.script) - ).toBuffer() + for (const output of transaction.outputs) { + const scriptHash: Buffer = output.script.sha256() type HistoryEntry = { // eslint-disable-next-line camelcase diff --git a/typescript/src/ethereum.ts b/typescript/src/ethereum.ts index 6630d8b71..4a7bf48bc 100644 --- a/typescript/src/ethereum.ts +++ b/typescript/src/ethereum.ts @@ -36,7 +36,7 @@ import { readCompactSizeUint, TransactionHash, UnspentTransactionOutput, -} from "./bitcoin" +} from "./lib/bitcoin" import type { OptimisticMintingCancelledEvent, OptimisticMintingFinalizedEvent, diff --git a/typescript/src/index.ts b/typescript/src/index.ts index 7bc6e4922..ed0fdb87e 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -56,9 +56,8 @@ export { Transaction as BitcoinTransaction, TransactionOutput as BitcoinTransactionOutput, locktimeToNumber as BitcoinLocktimeToNumber, -} from "./bitcoin" - -export { BitcoinNetwork } from "./bitcoin-network" + BitcoinNetwork, +} from "./lib/bitcoin" export { Client as ElectrumClient } from "./electrum" diff --git a/typescript/src/lib/bitcoin/address.ts b/typescript/src/lib/bitcoin/address.ts new file mode 100644 index 000000000..42bbbdd76 --- /dev/null +++ b/typescript/src/lib/bitcoin/address.ts @@ -0,0 +1,68 @@ +import bcoin, { Script } from "bcoin" +import { Hex } from "../../hex" +import { BitcoinNetwork, toBcoinNetwork } from "./network" + +/** + * Encodes a public key hash into a P2PKH/P2WPKH address. + * @param publicKeyHash - public key hash that will be encoded. Must be an + * unprefixed hex string (without 0x prefix). + * @param witness - If true, a witness public key hash will be encoded and + * P2WPKH address will be returned. Returns P2PKH address otherwise + * @param network - Network the address should be encoded for. + * @returns P2PKH or P2WPKH address encoded from the given public key hash + * @throws Throws an error if network is not supported. + */ +export function encodeToBitcoinAddress( + publicKeyHash: string, + witness: boolean, + network: BitcoinNetwork +): string { + const buffer = Buffer.from(publicKeyHash, "hex") + const bcoinNetwork = toBcoinNetwork(network) + return witness + ? bcoin.Address.fromWitnessPubkeyhash(buffer).toString(bcoinNetwork) + : bcoin.Address.fromPubkeyhash(buffer).toString(bcoinNetwork) +} + +/** + * Decodes P2PKH or P2WPKH address into a public key hash. Throws if the + * provided address is not PKH-based. + * @param address - P2PKH or P2WPKH address that will be decoded. + * @returns Public key hash decoded from the address. This will be an unprefixed + * hex string (without 0x prefix). + */ +export function decodeBitcoinAddress(address: string): string { + const addressObject = new bcoin.Address(address) + + const isPKH = + addressObject.isPubkeyhash() || addressObject.isWitnessPubkeyhash() + if (!isPKH) { + throw new Error("Address must be P2PKH or P2WPKH") + } + + return addressObject.getHash("hex") +} + +/** + * Creates the output script from the BTC address. + * @param address BTC address. + * @returns The un-prefixed and not prepended with length output script. + */ +export function createOutputScriptFromAddress(address: string): Hex { + return Hex.from(Script.fromAddress(address).toRaw().toString("hex")) +} + +/** + * Creates the Bitcoin address from the output script. + * @param script The unprefixed and not prepended with length output script. + * @param network Bitcoin network. + * @returns The Bitcoin address. + */ +export function createAddressFromOutputScript( + script: Hex, + network: BitcoinNetwork = BitcoinNetwork.Mainnet +): string { + return Script.fromRaw(script.toString(), "hex") + .getAddress() + ?.toString(toBcoinNetwork(network)) +} diff --git a/typescript/src/lib/bitcoin/block.ts b/typescript/src/lib/bitcoin/block.ts new file mode 100644 index 000000000..72b325a4e --- /dev/null +++ b/typescript/src/lib/bitcoin/block.ts @@ -0,0 +1,143 @@ +import { BigNumber } from "ethers" +import { Hex } from "../../hex" + +/** + * BlockHeader represents the header of a Bitcoin block. For reference, see: + * https://developer.bitcoin.org/reference/block_chain.html#block-headers. + */ +export interface BlockHeader { + /** + * The block version number that indicates which set of block validation rules + * to follow. The field is 4-byte long. + */ + version: number + + /** + * The hash of the previous block's header. The field is 32-byte long. + */ + previousBlockHeaderHash: Hex + + /** + * The hash derived from the hashes of all transactions included in this block. + * The field is 32-byte long. + */ + merkleRootHash: Hex + + /** + * The Unix epoch time when the miner started hashing the header. The field is + * 4-byte long. + */ + time: number + + /** + * Bits that determine the target threshold this block's header hash must be + * less than or equal to. The field is 4-byte long. + */ + bits: number + + /** + * An arbitrary number miners change to modify the header hash in order to + * produce a hash less than or equal to the target threshold. The field is + * 4-byte long. + */ + nonce: number +} + +/** + * Serializes a BlockHeader to the raw representation. + * @param blockHeader - block header. + * @returns Serialized block header. + */ +export function serializeBlockHeader(blockHeader: BlockHeader): Hex { + const buffer = Buffer.alloc(80) + buffer.writeUInt32LE(blockHeader.version, 0) + blockHeader.previousBlockHeaderHash.toBuffer().copy(buffer, 4) + blockHeader.merkleRootHash.toBuffer().copy(buffer, 36) + buffer.writeUInt32LE(blockHeader.time, 68) + buffer.writeUInt32LE(blockHeader.bits, 72) + buffer.writeUInt32LE(blockHeader.nonce, 76) + return Hex.from(buffer) +} + +/** + * Deserializes a block header in the raw representation to BlockHeader. + * @param rawBlockHeader - BlockHeader in the raw format. + * @returns Block header as a BlockHeader. + */ +export function deserializeBlockHeader(rawBlockHeader: Hex): BlockHeader { + const buffer = rawBlockHeader.toBuffer() + const version = buffer.readUInt32LE(0) + const previousBlockHeaderHash = buffer.slice(4, 36) + const merkleRootHash = buffer.slice(36, 68) + const time = buffer.readUInt32LE(68) + const bits = buffer.readUInt32LE(72) + const nonce = buffer.readUInt32LE(76) + + return { + version: version, + previousBlockHeaderHash: Hex.from(previousBlockHeaderHash), + merkleRootHash: Hex.from(merkleRootHash), + time: time, + bits: bits, + nonce: nonce, + } +} + +/** + * Converts a block header's bits into target. + * @param bits - bits from block header. + * @returns Target as a BigNumber. + */ +export function bitsToTarget(bits: number): BigNumber { + // A serialized 80-byte block header stores the `bits` value as a 4-byte + // little-endian hexadecimal value in a slot including bytes 73, 74, 75, and + // 76. This function's input argument is expected to be a numerical + // representation of that 4-byte value reverted to the big-endian order. + // For example, if the `bits` little-endian value in the header is + // `0xcb04041b`, it must be reverted to the big-endian form `0x1b0404cb` and + // turned to a decimal number `453248203` in order to be used as this + // function's input. + // + // The `bits` 4-byte big-endian representation is a compact value that works + // like a base-256 version of scientific notation. It encodes the target + // exponent in the first byte and the target mantissa in the last three bytes. + // Referring to the previous example, if `bits = 453248203`, the hexadecimal + // representation is `0x1b0404cb` so the exponent is `0x1b` while the mantissa + // is `0x0404cb`. + // + // To extract the exponent, we need to shift right by 3 bytes (24 bits), + // extract the last byte of the result, and subtract 3 (because of the + // mantissa length): + // - 0x1b0404cb >>> 24 = 0x0000001b + // - 0x0000001b & 0xff = 0x1b + // - 0x1b - 3 = 24 (decimal) + // + // To extract the mantissa, we just need to take the last three bytes: + // - 0x1b0404cb & 0xffffff = 0x0404cb = 263371 (decimal) + // + // The final difficulty can be computed as mantissa * 256^exponent: + // - 263371 * 256^24 = + // 1653206561150525499452195696179626311675293455763937233695932416 (decimal) + // + // Sources: + // - https://developer.bitcoin.org/reference/block_chain.html#target-nbits + // - https://wiki.bitcoinsv.io/index.php/Target + + const exponent = ((bits >>> 24) & 0xff) - 3 + const mantissa = bits & 0xffffff + + const target = BigNumber.from(mantissa).mul(BigNumber.from(256).pow(exponent)) + return target +} + +/** + * Converts difficulty target to difficulty. + * @param target - difficulty target. + * @returns Difficulty as a BigNumber. + */ +export function targetToDifficulty(target: BigNumber): BigNumber { + const DIFF1_TARGET = BigNumber.from( + "0xffff0000000000000000000000000000000000000000000000000000" + ) + return DIFF1_TARGET.div(target) +} diff --git a/typescript/src/lib/bitcoin/client.ts b/typescript/src/lib/bitcoin/client.ts new file mode 100644 index 000000000..0d1e10e99 --- /dev/null +++ b/typescript/src/lib/bitcoin/client.ts @@ -0,0 +1,94 @@ +import { BitcoinNetwork } from "./network" +import { + RawTransaction, + Transaction, + TransactionHash, + UnspentTransactionOutput, +} from "./transaction" +import { TransactionMerkleBranch } from "./proof" + +/** + * Represents a Bitcoin client. + */ +export interface Client { + /** + * Gets the network supported by the server the client connected to. + * @returns Bitcoin network. + */ + getNetwork(): Promise + + /** + * Finds all unspent transaction outputs (UTXOs) for given Bitcoin address. + * @param address - Bitcoin address UTXOs should be determined for. + * @returns List of UTXOs. + */ + findAllUnspentTransactionOutputs( + address: string + ): Promise + + /** + * Gets the history of confirmed transactions for given Bitcoin address. + * Returned transactions are sorted from oldest to newest. The returned + * result does not contain unconfirmed transactions living in the mempool + * at the moment of request. + * @param address - Bitcoin address transaction history should be determined for. + * @param limit - Optional parameter that can limit the resulting list to + * a specific number of last transaction. For example, limit = 5 will + * return only the last 5 transactions for the given address. + */ + getTransactionHistory(address: string, limit?: number): Promise + + /** + * Gets the full transaction object for given transaction hash. + * @param transactionHash - Hash of the transaction. + * @returns Transaction object. + */ + getTransaction(transactionHash: TransactionHash): Promise + + /** + * Gets the raw transaction data for given transaction hash. + * @param transactionHash - Hash of the transaction. + * @returns Raw transaction. + */ + getRawTransaction(transactionHash: TransactionHash): Promise + + /** + * Gets the number of confirmations that a given transaction has accumulated + * so far. + * @param transactionHash - Hash of the transaction. + * @returns The number of confirmations. + */ + getTransactionConfirmations(transactionHash: TransactionHash): Promise + + /** + * Gets height of the latest mined block. + * @return Height of the last mined block. + */ + latestBlockHeight(): Promise + + /** + * Gets concatenated chunk of block headers built on a starting block. + * @param blockHeight - Starting block height. + * @param chainLength - Number of subsequent blocks built on the starting + * block. + * @return Concatenation of block headers in a hexadecimal format. + */ + getHeadersChain(blockHeight: number, chainLength: number): Promise + + /** + * Get Merkle branch for a given transaction. + * @param transactionHash - Hash of a transaction. + * @param blockHeight - Height of the block where transaction was confirmed. + * @return Merkle branch. + */ + getTransactionMerkle( + transactionHash: TransactionHash, + blockHeight: number + ): Promise + + /** + * Broadcasts the given transaction over the network. + * @param transaction - Transaction to broadcast. + */ + broadcast(transaction: RawTransaction): Promise +} diff --git a/typescript/src/lib/bitcoin/csuint.ts b/typescript/src/lib/bitcoin/csuint.ts new file mode 100644 index 000000000..42773d137 --- /dev/null +++ b/typescript/src/lib/bitcoin/csuint.ts @@ -0,0 +1,41 @@ +import { Hex } from "../../hex" + +/** + * Reads the leading compact size uint from the provided variable length data. + * + * WARNING: CURRENTLY, THIS FUNCTION SUPPORTS ONLY 1-BYTE COMPACT SIZE UINTS + * AND WILL THROW ON COMPACT SIZE UINTS OF DIFFERENT BYTE LENGTH. + * + * @param varLenData Variable length data preceded by a compact size uint. + * @returns An object holding the value of the compact size uint along with the + * compact size uint byte length. + */ +export function readCompactSizeUint(varLenData: Hex): { + value: number + byteLength: number +} { + // The varLenData is prefixed with the compact size uint. According to the docs + // (https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers) + // a compact size uint can be 1, 3, 5 or 9 bytes. To determine the exact length, + // we need to look at the discriminant byte which is always the first byte of + // the compact size uint. + const discriminant = varLenData.toString().slice(0, 2) + + switch (discriminant) { + case "ff": + case "fe": + case "fd": { + throw new Error( + "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + ) + } + default: { + // The discriminant tells the compact size uint is 1 byte. That means + // the discriminant represent the value itself. + return { + value: parseInt(discriminant, 16), + byteLength: 1, + } + } + } +} diff --git a/typescript/src/lib/bitcoin/hash.ts b/typescript/src/lib/bitcoin/hash.ts new file mode 100644 index 000000000..34a0da163 --- /dev/null +++ b/typescript/src/lib/bitcoin/hash.ts @@ -0,0 +1,37 @@ +import { BigNumber, utils } from "ethers" +import { Hex } from "../../hex" + +/** + * Computes the HASH160 for the given text. + * @param text - Text the HASH160 is computed for. + * @returns Hash as a 20-byte un-prefixed hex string. + */ +export function computeHash160(text: string): string { + const sha256Hash = utils.sha256( + Hex.from(Buffer.from(text, "hex")).toPrefixedString() + ) + const hash160 = utils.ripemd160(sha256Hash) + + return Hex.from(hash160).toString() +} + +/** + * Computes the double SHA256 for the given text. + * @param text - Text the double SHA256 is computed for. + * @returns Hash as a 32-byte un-prefixed hex string. + */ +export function computeHash256(text: Hex): Hex { + const firstHash = utils.sha256(text.toPrefixedString()) + const secondHash = utils.sha256(firstHash) + + return Hex.from(secondHash) +} + +/** + * Converts a hash in hex string in little endian to a BigNumber. + * @param hash - Hash in hex-string format. + * @returns BigNumber representation of the hash. + */ +export function hashLEToBigNumber(hash: Hex): BigNumber { + return BigNumber.from(hash.reverse().toPrefixedString()) +} diff --git a/typescript/src/lib/bitcoin/index.ts b/typescript/src/lib/bitcoin/index.ts new file mode 100644 index 000000000..2cc43b708 --- /dev/null +++ b/typescript/src/lib/bitcoin/index.ts @@ -0,0 +1,9 @@ +export * from "./address" +export * from "./block" +export * from "./client" +export * from "./csuint" +export * from "./hash" +export * from "./key" +export * from "./network" +export * from "./proof" +export * from "./transaction" diff --git a/typescript/src/lib/bitcoin/key.ts b/typescript/src/lib/bitcoin/key.ts new file mode 100644 index 000000000..110991d81 --- /dev/null +++ b/typescript/src/lib/bitcoin/key.ts @@ -0,0 +1,80 @@ +import bcoin from "bcoin" +import wif from "wif" +import { BigNumber } from "ethers" +import { Hex } from "../../hex" + +/** + * Checks whether given public key is a compressed Bitcoin public key. + * @param publicKey - Public key that should be checked. + * @returns True if the key is a compressed Bitcoin public key, false otherwise. + */ +export function isCompressedPublicKey(publicKey: string): boolean { + // Must have 33 bytes and 02 or 03 prefix. + return ( + publicKey.length == 66 && + (publicKey.substring(0, 2) == "02" || publicKey.substring(0, 2) == "03") + ) +} + +/** + * Compresses the given uncompressed Bitcoin public key. + * @param publicKey Uncompressed 64-byte public key as an unprefixed hex string. + * @returns Compressed 33-byte public key prefixed with 02 or 03. + */ +export function compressPublicKey(publicKey: string | Hex): string { + if (typeof publicKey === "string") { + publicKey = Hex.from(publicKey) + } + + publicKey = publicKey.toString() + + // Must have 64 bytes and no prefix. + if (publicKey.length != 128) { + throw new Error( + "The public key parameter must be 64-byte. Neither 0x nor 04 prefix is allowed" + ) + } + + // The X coordinate is the first 32 bytes. + const publicKeyX = publicKey.substring(0, 64) + // The Y coordinate is the next 32 bytes. + const publicKeyY = publicKey.substring(64) + + let prefix: string + if (BigNumber.from(`0x${publicKeyY}`).mod(2).eq(0)) { + prefix = "02" + } else { + prefix = "03" + } + + return `${prefix}${publicKeyX}` +} + +/** + * Checks if given public key hash has proper length (20-byte) + * @param publicKeyHash - text that will be checked for the correct length + * @returns true if the given string is 20-byte long, false otherwise + */ +export function isPublicKeyHashLength(publicKeyHash: string): boolean { + return publicKeyHash.length === 40 +} + +/** + * Creates a Bitcoin key ring based on the given private key. + * @param privateKey Private key that should be used to create the key ring + * @param witness Flag indicating whether the key ring will create witness + * or non-witness addresses + * @returns Bitcoin key ring. + */ +export function createKeyRing( + privateKey: string, + witness: boolean = true +): any { + const decodedPrivateKey = wif.decode(privateKey) + + return new bcoin.KeyRing({ + witness: witness, + privateKey: decodedPrivateKey.privateKey, + compressed: decodedPrivateKey.compressed, + }) +} diff --git a/typescript/src/bitcoin-network.ts b/typescript/src/lib/bitcoin/network.ts similarity index 70% rename from typescript/src/bitcoin-network.ts rename to typescript/src/lib/bitcoin/network.ts index c54c5da38..ce79fad2c 100644 --- a/typescript/src/bitcoin-network.ts +++ b/typescript/src/lib/bitcoin/network.ts @@ -1,5 +1,4 @@ -import { Hex } from "./hex" -import { networks } from "bitcoinjs-lib" +import { Hex } from "../../hex" /** * Bitcoin networks. @@ -46,21 +45,19 @@ export namespace BitcoinNetwork { } /** - * Converts the provided {@link BitcoinNetwork} enumeration to a format expected - * by the `bitcoinjs-lib` library. - * @param bitcoinNetwork - Specified Bitcoin network. - * @returns Network representation compatible with the `bitcoinjs-lib` library. - * @throws An error if the network is not supported by `bitcoinjs-lib`. + * Converts enumerated {@link BitcoinNetwork} to a string expected by the + * {@link https://github.com/keep-network/bcoin/blob/aba6841e43546e8a485e96dc0019d1e788eab2ee/lib/protocol/networks.js#L33| `bcoin` library} + * @param bitcoinNetwork Bitcoin network. + * @returns String representing the given network in bcoin library. + * @throws An error if the network is not supported by bcoin. */ -export function toBitcoinJsLibNetwork( - bitcoinNetwork: BitcoinNetwork -): networks.Network { +export function toBcoinNetwork(bitcoinNetwork: BitcoinNetwork): string { switch (bitcoinNetwork) { case BitcoinNetwork.Mainnet: { - return networks.bitcoin + return "main" } case BitcoinNetwork.Testnet: { - return networks.testnet + return "testnet" } default: { throw new Error(`network not supported`) diff --git a/typescript/src/lib/bitcoin/proof.ts b/typescript/src/lib/bitcoin/proof.ts new file mode 100644 index 000000000..efbf4f8dd --- /dev/null +++ b/typescript/src/lib/bitcoin/proof.ts @@ -0,0 +1,44 @@ +/** + * Data required to perform a proof that a given transaction was included in + * the Bitcoin blockchain. + */ +export interface Proof { + /** + * The merkle proof of transaction inclusion in a block, as an un-prefixed + * hex string. + */ + merkleProof: string + + /** + * Transaction index in the block (0-indexed). + */ + txIndexInBlock: number + + /** + * Single byte-string of 80-byte block headers, lowest height first, as an + * un-prefixed hex string. + */ + bitcoinHeaders: string +} + +/** + * Information about the merkle branch to a confirmed transaction. + */ +export interface TransactionMerkleBranch { + /** + * The height of the block the transaction was confirmed in. + */ + blockHeight: number + + /** + * A list of transaction hashes the current hash is paired with, recursively, + * in order to trace up to obtain the merkle root of the including block, + * the deepest pairing first. Each hash is an unprefixed hex string. + */ + merkle: string[] + + /** + * The 0-based index of the transaction's position in the block. + */ + position: number +} diff --git a/typescript/src/lib/bitcoin/transaction.ts b/typescript/src/lib/bitcoin/transaction.ts new file mode 100644 index 000000000..00a7a03bd --- /dev/null +++ b/typescript/src/lib/bitcoin/transaction.ts @@ -0,0 +1,195 @@ +import { TX } from "bcoin" +import bufio from "bufio" +import { BigNumber } from "ethers" +import { Hex } from "../../hex" + +/** + * Represents a transaction hash (or transaction ID) as an un-prefixed hex + * string. This hash is supposed to have the same byte order as used by the + * Bitcoin block explorers which is the opposite of the byte order used + * by the Bitcoin protocol internally. That means the hash must be reversed in + * the use cases that expect the Bitcoin internal byte order. + */ +export class TransactionHash extends Hex {} + +/** + * Represents a raw transaction. + */ +export interface RawTransaction { + /** + * The full transaction payload as an un-prefixed hex string. + */ + transactionHex: string +} + +/** + * Data about a transaction. + */ +export interface Transaction { + /** + * The transaction hash (or transaction ID) as an un-prefixed hex string. + */ + transactionHash: TransactionHash + + /** + * The vector of transaction inputs. + */ + inputs: TransactionInput[] + + /** + * The vector of transaction outputs. + */ + outputs: TransactionOutput[] +} + +/** + * Data about a transaction outpoint. + */ +export interface TransactionOutpoint { + /** + * The hash of the transaction the outpoint belongs to. + */ + transactionHash: TransactionHash + + /** + * The zero-based index of the output from the specified transaction. + */ + outputIndex: number +} + +/** + * Data about a transaction input. + */ +export type TransactionInput = TransactionOutpoint & { + /** + * The scriptSig that unlocks the specified outpoint for spending. + */ + scriptSig: Hex +} + +/** + * Data about a transaction output. + */ +export interface TransactionOutput { + /** + * The 0-based index of the output. + */ + outputIndex: number + + /** + * The value of the output in satoshis. + */ + value: BigNumber + + /** + * The receiving scriptPubKey. + */ + scriptPubKey: Hex +} + +/** + * Data about an unspent transaction output. + */ +export type UnspentTransactionOutput = TransactionOutpoint & { + /** + * The unspent value in satoshis. + */ + value: BigNumber +} + +/** + * Represents data of decomposed raw transaction. + */ +export interface DecomposedRawTransaction { + /** + * Transaction version as an un-prefixed hex string. + */ + version: string + + /** + * All transaction's inputs prepended by the number of transaction inputs, + * as an un-prefixed hex string. + */ + inputs: string + + /** + * All transaction's outputs prepended by the number of transaction outputs, + * as an un-prefixed hex string. + */ + outputs: string + + /** + * Transaction locktime as an un-prefixed hex string. + */ + locktime: string +} + +/** + * Decomposes a transaction in the raw representation into version, vector of + * inputs, vector of outputs and locktime. + * @param rawTransaction - Transaction in the raw format. + * @returns Transaction data with fields represented as un-prefixed hex strings. + */ +export function decomposeRawTransaction( + rawTransaction: RawTransaction +): DecomposedRawTransaction { + const toHex = (bufferWriter: any) => { + return bufferWriter.render().toString("hex") + } + + const vectorToRaw = (elements: any[]) => { + const buffer = bufio.write() + buffer.writeVarint(elements.length) + for (const element of elements) { + element.toWriter(buffer) + } + return toHex(buffer) + } + + const getTxInputVector = (tx: any) => { + return vectorToRaw(tx.inputs) + } + + const getTxOutputVector = (tx: any) => { + return vectorToRaw(tx.outputs) + } + + const getTxVersion = (tx: any) => { + const buffer = bufio.write() + buffer.writeU32(tx.version) + return toHex(buffer) + } + + const getTxLocktime = (tx: any) => { + const buffer = bufio.write() + buffer.writeU32(tx.locktime) + return toHex(buffer) + } + + const tx = TX.fromRaw(Buffer.from(rawTransaction.transactionHex, "hex"), null) + + return { + version: getTxVersion(tx), + inputs: getTxInputVector(tx), + outputs: getTxOutputVector(tx), + locktime: getTxLocktime(tx), + } +} + +/** + * Converts Bitcoin specific locktime value to a number. The number represents + * either a block height or an Unix timestamp depending on the value. + * + * If the number is less than 500 000 000 it is a block height. + * If the number is greater or equal 500 000 000 it is a Unix timestamp. + * + * @see {@link https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number Documentation} + * + * @param locktimeLE A 4-byte little-endian locktime as an un-prefixed + * hex string {@link: Deposit#refundLocktime}. + * @returns UNIX timestamp in seconds. + */ +export function locktimeToNumber(locktimeLE: Buffer | string): number { + const locktimeBE: Buffer = Hex.from(locktimeLE).reverse().toBuffer() + return BigNumber.from(locktimeBE).toNumber() +} diff --git a/typescript/src/optimistic-minting.ts b/typescript/src/optimistic-minting.ts index 1d1dfd302..79468366f 100644 --- a/typescript/src/optimistic-minting.ts +++ b/typescript/src/optimistic-minting.ts @@ -1,5 +1,5 @@ import { BigNumber } from "ethers" -import { TransactionHash } from "./bitcoin" +import { TransactionHash } from "./lib/bitcoin" import { Identifier, Event, TBTCVault } from "./chain" import { Hex } from "./hex" diff --git a/typescript/src/wallet.ts b/typescript/src/wallet.ts index 947b95436..4e80905ec 100644 --- a/typescript/src/wallet.ts +++ b/typescript/src/wallet.ts @@ -3,12 +3,12 @@ import { Hex } from "./hex" import { Bridge, Event, Identifier } from "./chain" import { Client as BitcoinClient, + BitcoinNetwork, createOutputScriptFromAddress, encodeToBitcoinAddress, TransactionOutput, UnspentTransactionOutput, -} from "./bitcoin" -import { BitcoinNetwork } from "./bitcoin-network" +} from "./lib/bitcoin" /* eslint-disable no-unused-vars */ export enum WalletState { diff --git a/typescript/test/bitcoin-network.test.ts b/typescript/test/bitcoin-network.test.ts index b283c5441..92c258d53 100644 --- a/typescript/test/bitcoin-network.test.ts +++ b/typescript/test/bitcoin-network.test.ts @@ -1,7 +1,9 @@ import { expect } from "chai" -import { BitcoinNetwork, toBitcoinJsLibNetwork } from "../src/bitcoin-network" -import { TransactionHash } from "../src/bitcoin" -import { networks } from "bitcoinjs-lib" +import { + TransactionHash, + BitcoinNetwork, + toBcoinNetwork, +} from "../src/lib/bitcoin" describe("BitcoinNetwork", () => { const testData = [ @@ -10,7 +12,7 @@ describe("BitcoinNetwork", () => { enumValue: "unknown", // any value that doesn't match other supported networks genesisHash: TransactionHash.from("0x00010203"), - expectedToBitcoinJsLibResult: new Error("network not supported"), + expectedToBcoinResult: new Error("network not supported"), }, { enumKey: BitcoinNetwork.Testnet, @@ -18,7 +20,7 @@ describe("BitcoinNetwork", () => { genesisHash: TransactionHash.from( "0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" ), - expectedToBitcoinJsLibResult: networks.testnet, + expectedToBcoinResult: "testnet", }, { enumKey: BitcoinNetwork.Mainnet, @@ -26,12 +28,12 @@ describe("BitcoinNetwork", () => { genesisHash: TransactionHash.from( "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" ), - expectedToBitcoinJsLibResult: networks.bitcoin, + expectedToBcoinResult: "main", }, ] testData.forEach( - ({ enumKey, enumValue, genesisHash, expectedToBitcoinJsLibResult }) => { + ({ enumKey, enumValue, genesisHash, expectedToBcoinResult }) => { context(enumKey, async () => { describe(`toString`, async () => { it(`should return correct value`, async () => { @@ -47,18 +49,16 @@ describe("BitcoinNetwork", () => { }) }) - describe(`toBitcoinJsLibNetwork`, async () => { - if (expectedToBitcoinJsLibResult instanceof Error) { + describe(`toBcoinNetwork`, async () => { + if (expectedToBcoinResult instanceof Error) { it(`should throw an error`, async () => { - expect(() => toBitcoinJsLibNetwork(enumKey)).to.throw( - expectedToBitcoinJsLibResult.message + expect(() => toBcoinNetwork(enumKey)).to.throw( + expectedToBcoinResult.message ) }) } else { - it(`should return ${expectedToBitcoinJsLibResult}`, async () => { - expect(toBitcoinJsLibNetwork(enumKey)).to.be.equal( - expectedToBitcoinJsLibResult - ) + it(`should return ${expectedToBcoinResult}`, async () => { + expect(toBcoinNetwork(enumKey)).to.be.equal(expectedToBcoinResult) }) } }) diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 03ab74305..0d5e71e38 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -1,5 +1,6 @@ import { expect } from "chai" import { + BitcoinNetwork, compressPublicKey, encodeToBitcoinAddress, decodeBitcoinAddress, @@ -13,23 +14,14 @@ import { targetToDifficulty, createOutputScriptFromAddress, createAddressFromOutputScript, - createAddressFromPublicKey, readCompactSizeUint, computeHash160, - computeSha256, computeHash256, - isP2PKHScript, - isP2WPKHScript, - isP2SHScript, - isP2WSHScript, - decomposeRawTransaction, -} from "../src/bitcoin" +} from "../src/lib/bitcoin" import { calculateDepositRefundLocktime } from "../src/deposit" -import { BitcoinNetwork } from "../src/bitcoin-network" import { Hex } from "../src/hex" import { BigNumber } from "ethers" -import { btcAddresses, btcAddressFromPublicKey } from "./data/bitcoin" -import { depositSweepWithNoMainUtxoAndWitnessOutput } from "./data/deposit-sweep" +import { btcAddresses } from "./data/bitcoin" describe("Bitcoin", () => { describe("compressPublicKey", () => { @@ -101,21 +93,6 @@ describe("Bitcoin", () => { }) }) - describe("computeSha256", () => { - it("should compute hash256 correctly", () => { - const hexValue = Hex.from( - "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" - ) - const expectedSha256 = Hex.from( - "c62e5cb26c97cb52fea7f9965e9ea1f8d41c97773688aa88674e64629fc02901" - ) - - expect(computeSha256(hexValue).toString()).to.be.equal( - expectedSha256.toString() - ) - }) - }) - describe("P2PKH <-> public key hash conversion", () => { const publicKeyHash = "3a38d44d6a0c8d0bb84e0232cc632b7e48c72e0e" const P2WPKHAddress = "bc1q8gudgnt2pjxshwzwqgevccet0eyvwtswt03nuy" @@ -148,10 +125,7 @@ describe("Bitcoin", () => { true, BitcoinNetwork.Mainnet ) - ).to.throw( - 'Expected property "hash" of type Buffer(Length: 20), got ' + - "Buffer(Length: 21)" - ) + ).to.throw("P2WPKH must be 20 bytes") }) }) }) @@ -179,10 +153,7 @@ describe("Bitcoin", () => { false, BitcoinNetwork.Mainnet ) - ).to.throw( - 'Expected property "hash" of type Buffer(Length: 20), got ' + - "Buffer(Length: 21)" - ) + ).to.throw("P2PKH must be 20 bytes") }) }) }) @@ -212,10 +183,7 @@ describe("Bitcoin", () => { true, BitcoinNetwork.Testnet ) - ).to.throw( - 'Expected property "hash" of type Buffer(Length: 20), got ' + - "Buffer(Length: 21)" - ) + ).to.throw("P2WPKH must be 20 bytes") }) }) }) @@ -243,10 +211,7 @@ describe("Bitcoin", () => { false, BitcoinNetwork.Testnet ) - ).to.throw( - 'Expected property "hash" of type Buffer(Length: 20), got ' + - "Buffer(Length: 21)" - ) + ).to.throw("P2PKH must be 20 bytes") }) }) }) @@ -261,21 +226,21 @@ describe("Bitcoin", () => { }) }) - describe("decodeBitcoinAddress", () => { + describe("decodeAddress", () => { context("when network is mainnet", () => { context("when proper P2WPKH address is provided", () => { it("should decode P2WPKH adress correctly", () => { - expect( - decodeBitcoinAddress(P2WPKHAddress, BitcoinNetwork.Mainnet) - ).to.be.equal(publicKeyHash) + expect(decodeBitcoinAddress(P2WPKHAddress)).to.be.equal( + publicKeyHash + ) }) }) context("when proper P2PKH address is provided", () => { it("should decode P2PKH address correctly", () => { - expect( - decodeBitcoinAddress(P2PKHAddress, BitcoinNetwork.Mainnet) - ).to.be.equal(publicKeyHash) + expect(decodeBitcoinAddress(P2PKHAddress)).to.be.equal( + publicKeyHash + ) }) }) @@ -283,10 +248,8 @@ describe("Bitcoin", () => { it("should throw", () => { const bitcoinAddress = "123" + P2PKHAddress - expect(() => - decodeBitcoinAddress(bitcoinAddress, BitcoinNetwork.Mainnet) - ).to.throw( - "Address must be P2PKH or P2WPKH valid for given network" + expect(() => decodeBitcoinAddress(bitcoinAddress)).to.throw( + "Address is too long" ) }) }) @@ -294,13 +257,8 @@ describe("Bitcoin", () => { context("when unsupported P2SH address is provided", () => { it("should throw", () => { expect(() => - decodeBitcoinAddress( - "3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX", - BitcoinNetwork.Mainnet - ) - ).to.throw( - "Address must be P2PKH or P2WPKH valid for given network" - ) + decodeBitcoinAddress("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX") + ).to.throw("Address must be P2PKH or P2WPKH") }) }) @@ -308,25 +266,9 @@ describe("Bitcoin", () => { it("should throw", () => { expect(() => decodeBitcoinAddress( - "bc1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhsdxuv4m", - BitcoinNetwork.Mainnet + "bc1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhsdxuv4m" ) - ).to.throw( - "Address must be P2PKH or P2WPKH valid for given network" - ) - }) - }) - - context("when address from testnet network is provided", () => { - it("should throw", () => { - expect(() => - decodeBitcoinAddress( - "mkpoZkRvtd3SDGWgUDuXK1aEXZfHRM2gKw", - BitcoinNetwork.Mainnet - ) - ).to.throw( - "Address must be P2PKH or P2WPKH valid for given network" - ) + ).to.throw("Address must be P2PKH or P2WPKH") }) }) }) @@ -334,17 +276,17 @@ describe("Bitcoin", () => { context("when network is testnet", () => { context("when proper P2WPKH address is provided", () => { it("should decode P2WPKH adress correctly", () => { - expect( - decodeBitcoinAddress(P2WPKHAddressTestnet, BitcoinNetwork.Testnet) - ).to.be.equal(publicKeyHash) + expect(decodeBitcoinAddress(P2WPKHAddressTestnet)).to.be.equal( + publicKeyHash + ) }) }) context("when proper P2PKH address is provided", () => { it("should decode P2PKH address correctly", () => { - expect( - decodeBitcoinAddress(P2PKHAddressTestnet, BitcoinNetwork.Testnet) - ).to.be.equal(publicKeyHash) + expect(decodeBitcoinAddress(P2PKHAddressTestnet)).to.be.equal( + publicKeyHash + ) }) }) @@ -352,10 +294,8 @@ describe("Bitcoin", () => { it("should throw", () => { const bitcoinAddress = "123" + P2PKHAddressTestnet - expect(() => - decodeBitcoinAddress(bitcoinAddress, BitcoinNetwork.Testnet) - ).to.throw( - "Address must be P2PKH or P2WPKH valid for given network" + expect(() => decodeBitcoinAddress(bitcoinAddress)).to.throw( + "Address is too long" ) }) }) @@ -363,13 +303,8 @@ describe("Bitcoin", () => { context("when unsupported P2SH address is provided", () => { it("should throw", () => { expect(() => - decodeBitcoinAddress( - "2MyxShnGQ5NifGb8CHYrtmzosRySxZ9pZo5", - BitcoinNetwork.Testnet - ) - ).to.throw( - "Address must be P2PKH or P2WPKH valid for given network" - ) + decodeBitcoinAddress("2MyxShnGQ5NifGb8CHYrtmzosRySxZ9pZo5") + ).to.throw("Address must be P2PKH or P2WPKH") }) }) @@ -377,25 +312,9 @@ describe("Bitcoin", () => { it("should throw", () => { expect(() => decodeBitcoinAddress( - "tb1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhs6w2r05", - BitcoinNetwork.Testnet + "tb1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhs6w2r05" ) - ).to.throw( - "Address must be P2PKH or P2WPKH valid for given network" - ) - }) - }) - - context("when address from mainnet network is provided", () => { - it("should throw", () => { - expect(() => - decodeBitcoinAddress( - "bc1q8gudgnt2pjxshwzwqgevccet0eyvwtswt03nuy", - BitcoinNetwork.Testnet - ) - ).to.throw( - "Address must be P2PKH or P2WPKH valid for given network" - ) + ).to.throw("Address must be P2PKH or P2WPKH") }) }) }) @@ -585,11 +504,7 @@ describe("Bitcoin", () => { ).forEach( ([addressType, { address, scriptPubKey: expectedOutputScript }]) => { it(`should create correct output script for ${addressType} address type`, () => { - const network = - bitcoinNetwork === "mainnet" - ? BitcoinNetwork.Mainnet - : BitcoinNetwork.Testnet - const result = createOutputScriptFromAddress(address, network) + const result = createOutputScriptFromAddress(address) expect(result.toString()).to.eq(expectedOutputScript.toString()) }) @@ -599,7 +514,7 @@ describe("Bitcoin", () => { }) }) - describe("createAddressFromOutputScript", () => { + describe("getAddressFromScriptPubKey", () => { Object.keys(btcAddresses).forEach((bitcoinNetwork) => { context(`with ${bitcoinNetwork} addresses`, () => { Object.entries( @@ -620,30 +535,6 @@ describe("Bitcoin", () => { }) }) - describe("createAddressFromPublicKey", () => { - Object.entries(btcAddressFromPublicKey).forEach( - ([bitcoinNetwork, addressData]) => { - context(`with ${bitcoinNetwork} addresses`, () => { - Object.entries(addressData).forEach( - ([addressType, { publicKey, address }]) => { - it(`should return correct ${addressType} address for ${bitcoinNetwork}`, () => { - const witness = addressType === "P2WPKH" - const result = createAddressFromPublicKey( - publicKey, - bitcoinNetwork === "mainnet" - ? BitcoinNetwork.Mainnet - : BitcoinNetwork.Testnet, - witness - ) - expect(result).to.eq(address) - }) - } - ) - }) - } - ) - }) - describe("readCompactSizeUint", () => { context("when the compact size uint is 1-byte", () => { it("should return the the uint value and byte length", () => { @@ -680,82 +571,4 @@ describe("Bitcoin", () => { }) }) }) - - describe("Bitcoin Script Type", () => { - const testData = [ - { - testFunction: isP2PKHScript, - validScript: Buffer.from( - "76a9148db50eb52063ea9d98b3eac91489a90f738986f688ac", - "hex" - ), - name: "P2PKH", - }, - { - testFunction: isP2WPKHScript, - validScript: Buffer.from( - "00148db50eb52063ea9d98b3eac91489a90f738986f6", - "hex" - ), - name: "P2WPKH", - }, - { - testFunction: isP2SHScript, - validScript: Buffer.from( - "a914a9a5f97d5d3c4687a52e90718168270005b369c487", - "hex" - ), - name: "P2SH", - }, - { - testFunction: isP2WSHScript, - validScript: Buffer.from( - "0020b1f83e226979dc9fe74e87f6d303dbb08a27a1c7ce91664033f34c7f2d214cd7", - "hex" - ), - name: "P2WSH", - }, - ] - - testData.forEach(({ testFunction, validScript, name }) => { - describe(`is${name}Script`, () => { - it(`should return true for a valid ${name} script`, () => { - expect(testFunction(validScript)).to.be.true - }) - - it("should return false for other scripts", () => { - testData.forEach((data) => { - if (data.name !== name) { - expect(testFunction(data.validScript)).to.be.false - } - }) - }) - }) - }) - }) -}) - -describe("decomposeRawTransaction", () => { - it("should return correctly decomposed transaction", () => { - const rawTransaction = - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transaction - const decomposedTransaction = decomposeRawTransaction(rawTransaction) - - expect(decomposedTransaction.version).to.be.equal("01000000") - expect(decomposedTransaction.inputs).to.be.equal( - "02bc187be612bc3db8cfcdec56b75e9bc0262ab6eacfe27cc1a699bacd53e3d07400" + - "000000c948304502210089a89aaf3fec97ac9ffa91cdff59829f0cb3ef852a468153" + - "e2c0e2b473466d2e022072902bb923ef016ac52e941ced78f816bf27991c2b73211e" + - "227db27ec200bc0a012103989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f25" + - "64da4cc29dcf8581d94c5c14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508" + - "f9f0c90d000395237576a9148db50eb52063ea9d98b3eac91489a90f738986f68763" + - "ac6776a914e257eccafbc07c381642ce6e7e55120fb077fbed8804e0250162b175ac" + - "68ffffffffdc557e737b6688c5712649b86f7757a722dc3d42786f23b2fa826394df" + - "ec545c0000000000ffffffff" - ) - expect(decomposedTransaction.outputs).to.be.equal( - "01488a0000000000001600148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - expect(decomposedTransaction.locktime).to.be.equal("00000000") - }) }) diff --git a/typescript/test/data/bitcoin.ts b/typescript/test/data/bitcoin.ts index b04baad81..ad0e777d6 100644 --- a/typescript/test/data/bitcoin.ts +++ b/typescript/test/data/bitcoin.ts @@ -1,5 +1,5 @@ -import { BitcoinNetwork } from "../../src/bitcoin-network" -import { Hex } from "../../src/hex" +import { BitcoinNetwork } from "../../src" +import { Hex } from "../../src" export const btcAddresses: Record< Exclude, diff --git a/typescript/test/data/deposit-refund.ts b/typescript/test/data/deposit-refund.ts index d01b99344..880f6a896 100644 --- a/typescript/test/data/deposit-refund.ts +++ b/typescript/test/data/deposit-refund.ts @@ -3,7 +3,7 @@ import { RawTransaction, UnspentTransactionOutput, TransactionHash, -} from "../../src/bitcoin" +} from "../../src/lib/bitcoin" import { Deposit, calculateDepositRefundLocktime } from "../../src/deposit" import { Address } from "../../src/ethereum" diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index 74e001b6b..1992cdb85 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -6,7 +6,7 @@ import { UnspentTransactionOutput, TransactionMerkleBranch, TransactionHash, -} from "../../src/bitcoin" +} from "../../src/lib/bitcoin" import { calculateDepositRefundLocktime, Deposit } from "../../src/deposit" import { BigNumber } from "ethers" import { Address } from "../../src/ethereum" diff --git a/typescript/test/data/deposit.ts b/typescript/test/data/deposit.ts index 61a9e7b46..42371740f 100644 --- a/typescript/test/data/deposit.ts +++ b/typescript/test/data/deposit.ts @@ -2,7 +2,7 @@ import { RawTransaction, TransactionHash, UnspentTransactionOutput, -} from "../../src/bitcoin" +} from "../../src/lib/bitcoin" import { BigNumber } from "ethers" /** diff --git a/typescript/test/data/electrum.ts b/typescript/test/data/electrum.ts index f17708bf4..ddc3f6a06 100644 --- a/typescript/test/data/electrum.ts +++ b/typescript/test/data/electrum.ts @@ -4,7 +4,7 @@ import { UnspentTransactionOutput, TransactionMerkleBranch, TransactionHash, -} from "../../src/bitcoin" +} from "../../src/lib/bitcoin" import { BigNumber } from "ethers" import { Hex } from "../../src" diff --git a/typescript/test/data/proof.ts b/typescript/test/data/proof.ts index a0acdf37c..ab3ae7942 100644 --- a/typescript/test/data/proof.ts +++ b/typescript/test/data/proof.ts @@ -4,7 +4,7 @@ import { Transaction, TransactionHash, TransactionMerkleBranch, -} from "../../src/bitcoin" +} from "../../src/lib/bitcoin" import { BigNumber } from "ethers" import { Hex } from "../../src" diff --git a/typescript/test/data/redemption.ts b/typescript/test/data/redemption.ts index d38780f78..d9e232445 100644 --- a/typescript/test/data/redemption.ts +++ b/typescript/test/data/redemption.ts @@ -8,7 +8,7 @@ import { TransactionMerkleBranch, TransactionHash, createOutputScriptFromAddress, -} from "../../src/bitcoin" +} from "../../src/lib/bitcoin" import { RedemptionRequest } from "../../src/redemption" import { Address } from "../../src/ethereum" import { BitcoinNetwork, BitcoinTransaction, Hex } from "../../src" From 7e6c6197ea7d932579d11127f00556a225c1256f Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 22 Sep 2023 16:46:15 +0200 Subject: [PATCH 157/205] Transform `chain.ts` file to `lib/contracts` shared lib We just moved `bitcoin.ts` to `lib/bitcoin`. Here we do the same transition for `chain.ts`. --- typescript/src/chain.ts | 444 ------------------ typescript/src/deposit-sweep.ts | 2 +- typescript/src/deposit.ts | 2 +- typescript/src/ethereum.ts | 2 +- typescript/src/lib/contracts/bridge.ts | 184 ++++++++ typescript/src/lib/contracts/chain-event.ts | 63 +++ .../src/lib/contracts/chain-identifier.ts | 15 + typescript/src/lib/contracts/index.ts | 6 + typescript/src/lib/contracts/tbtc-token.ts | 43 ++ typescript/src/lib/contracts/tbtc-vault.ts | 114 +++++ .../src/lib/contracts/wallet-registry.ts | 37 ++ typescript/src/optimistic-minting.ts | 2 +- typescript/src/proof.ts | 2 +- typescript/src/redemption.ts | 109 ++--- typescript/src/wallet.ts | 2 +- typescript/test/deposit-refund.test.ts | 2 +- typescript/test/deposit-sweep.test.ts | 149 +++--- typescript/test/deposit.test.ts | 2 +- typescript/test/electrum.test.ts | 2 +- typescript/test/ethereum.test.ts | 2 +- typescript/test/proof.test.ts | 8 +- typescript/test/redemption.test.ts | 105 ++--- typescript/test/wallet.test.ts | 2 +- 23 files changed, 657 insertions(+), 642 deletions(-) delete mode 100644 typescript/src/chain.ts create mode 100644 typescript/src/lib/contracts/bridge.ts create mode 100644 typescript/src/lib/contracts/chain-event.ts create mode 100644 typescript/src/lib/contracts/chain-identifier.ts create mode 100644 typescript/src/lib/contracts/index.ts create mode 100644 typescript/src/lib/contracts/tbtc-token.ts create mode 100644 typescript/src/lib/contracts/tbtc-vault.ts create mode 100644 typescript/src/lib/contracts/wallet-registry.ts diff --git a/typescript/src/chain.ts b/typescript/src/chain.ts deleted file mode 100644 index 0b840dabe..000000000 --- a/typescript/src/chain.ts +++ /dev/null @@ -1,444 +0,0 @@ -import { BigNumber } from "ethers" -import { - Proof, - UnspentTransactionOutput, - DecomposedRawTransaction, - TransactionHash, -} from "./lib/bitcoin" -import { - DepositRevealedEvent, - DepositScriptParameters, - RevealedDeposit, -} from "./deposit" -import { - OptimisticMintingCancelledEvent, - OptimisticMintingFinalizedEvent, - OptimisticMintingRequest, - OptimisticMintingRequestedEvent, -} from "./optimistic-minting" -import { Hex } from "./hex" -import { RedemptionRequest, RedemptionRequestedEvent } from "./redemption" -import { - DkgResultApprovedEvent, - DkgResultChallengedEvent, - DkgResultSubmittedEvent, - NewWalletRegisteredEvent, - Wallet, -} from "./wallet" -import type { ExecutionLoggerFn } from "./backoff" - -/** - * Represents a generic chain identifier. - */ -export interface Identifier { - /** - * Identifier as an un-prefixed hex string. - */ - identifierHex: string - /** - * Checks if two identifiers are equal. - * - * @param identifier Another identifier - */ - equals(identifier: Identifier): boolean -} - -/** - * Represents a generic chain event. - */ -export interface Event { - /** - * Block number of the event emission. - */ - blockNumber: number - /** - * Block hash of the event emission. - */ - blockHash: Hex - /** - * Transaction hash within which the event was emitted. - */ - transactionHash: Hex -} - -export namespace GetEvents { - /** - * Represents generic options used for getting events from the chain. - */ - export interface Options { - /** - * Block number from which events should be queried. - * If not defined a block number of a contract deployment is used. - */ - fromBlock?: number - /** - * Block number to which events should be queried. - * If not defined the latest block number will be used. - */ - toBlock?: number - /** - * Number of retries in case of an error getting the events. - */ - retries?: number - /** - * Number of blocks for interval length in partial events pulls. - */ - batchedQueryBlockInterval?: number - /** - * A logger function to pass execution messages. - */ - logger?: ExecutionLoggerFn - } - - /** - * Represents a generic function to get events emitted on the chain. - */ - export interface Function { - /** - * Get emitted events. - * @param options Options for getting events. - * @param filterArgs Arguments for events filtering. - * @returns Array of found events. - */ - (options?: Options, ...filterArgs: Array): Promise - } -} - -/** - * Interface for communication with the Bridge on-chain contract. - */ -export interface Bridge { - /** - * Get emitted DepositRevealed events. - * @see GetEventsFunction - */ - getDepositRevealedEvents: GetEvents.Function - - /** - * Submits a deposit sweep transaction proof to the on-chain contract. - * @param sweepTx - Sweep transaction data. - * @param sweepProof - Sweep proof data. - * @param mainUtxo - Data of the wallet's main UTXO. - * @param vault - Optional identifier of the vault the swept deposits should - * be routed in. - */ - submitDepositSweepProof( - sweepTx: DecomposedRawTransaction, - sweepProof: Proof, - mainUtxo: UnspentTransactionOutput, - vault?: Identifier - ): Promise - - /** - * Reveals a given deposit to the on-chain contract. - * @param depositTx - Deposit transaction data - * @param depositOutputIndex - Index of the deposit transaction output that - * funds the revealed deposit - * @param deposit - Data of the revealed deposit - * @returns Transaction hash of the reveal deposit transaction as string - */ - revealDeposit( - depositTx: DecomposedRawTransaction, - depositOutputIndex: number, - deposit: DepositScriptParameters, - vault?: Identifier - ): Promise // TODO: Update to Hex - - /** - * Gets a revealed deposit from the on-chain contract. - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @returns Revealed deposit data. - */ - deposits( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise - - /** - * Requests a redemption from the on-chain contract. - * @param walletPublicKey - The Bitcoin public key of the wallet. Must be in the - * compressed form (33 bytes long with 02 or 03 prefix). - * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO - * held by the on-chain contract. - * @param redeemerOutputScript - The output script that the redeemed funds will - * be locked to. Must be un-prefixed and not prepended with length. - * @param amount - The amount to be redeemed in satoshis. - * @returns Empty promise. - */ - requestRedemption( - walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, - redeemerOutputScript: string, - amount: BigNumber - ): Promise - - /** - * Submits a redemption transaction proof to the on-chain contract. - * @param redemptionTx - Redemption transaction data - * @param redemptionProof - Redemption proof data - * @param mainUtxo - Data of the wallet's main UTXO - * @param walletPublicKey - Bitcoin public key of the wallet. Must be in the - * compressed form (33 bytes long with 02 or 03 prefix). - */ - submitRedemptionProof( - redemptionTx: DecomposedRawTransaction, - redemptionProof: Proof, - mainUtxo: UnspentTransactionOutput, - walletPublicKey: string - ): Promise - - /** - * Gets transaction proof difficulty factor from the on-chain contract. - * @dev This number signifies how many confirmations a transaction has to - * accumulate before it can be proven on-chain. - * @returns Proof difficulty factor. - */ - txProofDifficultyFactor(): Promise - - /** - * Gets a pending redemption from the on-chain contract. - * @param walletPublicKey Bitcoin public key of the wallet the request is - * targeted to. Must be in the compressed form (33 bytes long with 02 - * or 03 prefix). - * @param redeemerOutputScript The redeemer output script the redeemed funds - * are supposed to be locked on. Must be un-prefixed and not prepended - * with length. - * @returns Promise with the pending redemption. - */ - pendingRedemptions( - walletPublicKey: string, - redeemerOutputScript: string - ): Promise - - /** - * Gets a timed-out redemption from the on-chain contract. - * @param walletPublicKey Bitcoin public key of the wallet the request is - * targeted to. Must be in the compressed form (33 bytes long with 02 - * or 03 prefix). - * @param redeemerOutputScript The redeemer output script the redeemed funds - * are supposed to be locked on. Must be un-prefixed and not prepended - * with length. - * @returns Promise with the pending redemption. - */ - timedOutRedemptions( - walletPublicKey: string, - redeemerOutputScript: string - ): Promise - - /** - * Gets the public key of the current active wallet. - * @returns Compressed (33 bytes long with 02 or 03 prefix) active wallet's - * public key. If there is no active wallet at the moment, undefined - * is returned. - */ - activeWalletPublicKey(): Promise - - /** - * Get emitted NewWalletRegisteredEvent events. - * @see GetEventsFunction - */ - getNewWalletRegisteredEvents: GetEvents.Function - - /** - * Returns the attached WalletRegistry instance. - */ - walletRegistry(): Promise - - /** - * Gets details about a registered wallet. - * @param walletPublicKeyHash The 20-byte wallet public key hash (computed - * using Bitcoin HASH160 over the compressed ECDSA public key). - * @returns Promise with the wallet details. - */ - wallets(walletPublicKeyHash: Hex): Promise - - /** - * Builds the UTXO hash based on the UTXO components. - * @param utxo UTXO components. - * @returns The hash of the UTXO. - */ - buildUtxoHash(utxo: UnspentTransactionOutput): Hex - - /** - * Get emitted RedemptionRequested events. - * @see GetEventsFunction - */ - getRedemptionRequestedEvents: GetEvents.Function -} - -/** - * Interface for communication with the WalletRegistry on-chain contract. - */ -export interface WalletRegistry { - /** - * Gets the public key for the given wallet. - * @param walletID ID of the wallet. - * @returns Uncompressed public key without the 04 prefix. - */ - getWalletPublicKey(walletID: Hex): Promise - - /** - * Get emitted DkgResultSubmittedEvent events. - * @see GetEventsFunction - */ - getDkgResultSubmittedEvents: GetEvents.Function - - /** - * Get emitted DkgResultApprovedEvent events. - * @see GetEventsFunction - */ - getDkgResultApprovedEvents: GetEvents.Function - - /** - * Get emitted DkgResultChallengedEvent events. - * @see GetEventsFunction - */ - getDkgResultChallengedEvents: GetEvents.Function -} - -/** - * Interface for communication with the TBTCVault on-chain contract. - */ -export interface TBTCVault { - /** - * Gets optimistic minting delay. - * - * The time that needs to pass between the moment the optimistic minting is - * requested and the moment optimistic minting is finalized with minting TBTC. - * @returns Optimistic Minting Delay in seconds. - */ - optimisticMintingDelay(): Promise - - /** - * Gets currently registered minters. - * - * @returns Array containing identifiers of all currently registered minters. - */ - getMinters(): Promise - - /** - * Checks if given identifier is registered as minter. - * - * @param identifier Chain identifier to check. - */ - isMinter(identifier: Identifier): Promise - - /** - * Checks if given identifier is registered as guardian. - * - * @param identifier Chain identifier to check. - */ - isGuardian(identifier: Identifier): Promise - - /** - * Requests optimistic minting for a deposit in an on-chain contract. - * - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @returns Transaction hash of the optimistic mint request transaction. - */ - requestOptimisticMint( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise - - /** - * Cancels optimistic minting for a deposit in an on-chain contract. - * - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @returns Transaction hash of the optimistic mint cancel transaction. - */ - cancelOptimisticMint( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise - - /** - * Finalizes optimistic minting for a deposit in an on-chain contract. - * - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @returns Transaction hash of the optimistic mint finalize transaction. - */ - finalizeOptimisticMint( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise - - /** - * Gets optimistic minting request for a deposit. - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @param tbtcVault Handle to the TBTCVault on-chain contract - * @returns Optimistic minting request. - */ - optimisticMintingRequests( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise - - /** - * Get emitted OptimisticMintingRequested events. - * @see GetEventsFunction - */ - getOptimisticMintingRequestedEvents: GetEvents.Function - - /** - * Get emitted OptimisticMintingCancelled events. - * @see GetEventsFunction - */ - getOptimisticMintingCancelledEvents: GetEvents.Function - - /** - * Get emitted OptimisticMintingFinalized events. - * @see GetEventsFunction - */ - getOptimisticMintingFinalizedEvents: GetEvents.Function -} - -/** - * Interface for communication with the TBTC v2 token on-chain contract. - */ -export interface TBTCToken { - /** - * Gets the total supply of the TBTC v2 token. The returned value is in - * ERC 1e18 precision, it has to be converted before using as Bitcoin value - * with 1e8 precision in satoshi. - * @param blockNumber Optional parameter determining the block the total - * supply should be fetched for. If this parameter is not set, the - * total supply is taken for the latest block. - */ - // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 - // precision to Bitcoin in 1e8 precision (satoshi). - totalSupply(blockNumber?: number): Promise - - /** - * Requests redemption in one transacion using the `approveAndCall` function - * from the tBTC on-chain token contract. Then the tBTC token contract calls - * the `receiveApproval` function from the `TBTCVault` contract which burns - * tBTC tokens and requests redemption. - * @param walletPublicKey - The Bitcoin public key of the wallet. Must be in - * the compressed form (33 bytes long with 02 or 03 prefix). - * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO - * held by the on-chain Bridge contract. - * @param redeemerOutputScript - The output script that the redeemed funds - * will be locked to. Must be un-prefixed and not prepended with - * length. - * @param amount - The amount to be redeemed with the precision of the tBTC - * on-chain token contract. - * @returns Transaction hash of the approve and call transaction. - */ - requestRedemption( - walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, - redeemerOutputScript: string, - amount: BigNumber - ): Promise -} diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 9a1e00f7c..5f8e922be 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -11,7 +11,7 @@ import { computeHash160, } from "./lib/bitcoin" import { assembleDepositScript, Deposit } from "./deposit" -import { Bridge, Identifier } from "./chain" +import { Bridge, Identifier } from "./lib/contracts" import { assembleTransactionProof } from "./proof" /** diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 1deb84609..cf838bb34 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -11,7 +11,7 @@ import { TransactionHash, isPublicKeyHashLength, } from "./lib/bitcoin" -import { Bridge, Event, Identifier } from "./chain" +import { Bridge, Event, Identifier } from "./lib/contracts" import { Hex } from "./hex" const { opcodes } = bcoin.script.common diff --git a/typescript/src/ethereum.ts b/typescript/src/ethereum.ts index 4a7bf48bc..1f05152bd 100644 --- a/typescript/src/ethereum.ts +++ b/typescript/src/ethereum.ts @@ -5,7 +5,7 @@ import { TBTCToken as ChainTBTCToken, Identifier as ChainIdentifier, GetEvents, -} from "./chain" +} from "./lib/contracts" import { BigNumber, constants, diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts new file mode 100644 index 000000000..7452a69d4 --- /dev/null +++ b/typescript/src/lib/contracts/bridge.ts @@ -0,0 +1,184 @@ +import { BigNumber } from "ethers" +import { + Proof, + UnspentTransactionOutput, + DecomposedRawTransaction, + TransactionHash, +} from "../bitcoin" +import { + DepositRevealedEvent, + DepositScriptParameters, + RevealedDeposit, +} from "../../deposit" +import { Hex } from "../../hex" +import { RedemptionRequest, RedemptionRequestedEvent } from "../../redemption" +import { NewWalletRegisteredEvent, Wallet } from "../../wallet" +import { GetEvents } from "./chain-event" +import { Identifier } from "./chain-identifier" +import { WalletRegistry } from "./wallet-registry" + +/** + * Interface for communication with the Bridge on-chain contract. + */ +export interface Bridge { + /** + * Get emitted DepositRevealed events. + * @see GetEventsFunction + */ + getDepositRevealedEvents: GetEvents.Function + + /** + * Submits a deposit sweep transaction proof to the on-chain contract. + * @param sweepTx - Sweep transaction data. + * @param sweepProof - Sweep proof data. + * @param mainUtxo - Data of the wallet's main UTXO. + * @param vault - Optional identifier of the vault the swept deposits should + * be routed in. + */ + submitDepositSweepProof( + sweepTx: DecomposedRawTransaction, + sweepProof: Proof, + mainUtxo: UnspentTransactionOutput, + vault?: Identifier + ): Promise + + /** + * Reveals a given deposit to the on-chain contract. + * @param depositTx - Deposit transaction data + * @param depositOutputIndex - Index of the deposit transaction output that + * funds the revealed deposit + * @param deposit - Data of the revealed deposit + * @param vault - Optional parameter denoting the vault the given deposit + * should be routed to + * @returns Transaction hash of the reveal deposit transaction as string + */ + revealDeposit( + depositTx: DecomposedRawTransaction, + depositOutputIndex: number, + deposit: DepositScriptParameters, + vault?: Identifier + ): Promise // TODO: Update to Hex + + /** + * Gets a revealed deposit from the on-chain contract. + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Revealed deposit data. + */ + deposits( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise + + /** + * Requests a redemption from the on-chain contract. + * @param walletPublicKey - The Bitcoin public key of the wallet. Must be in the + * compressed form (33 bytes long with 02 or 03 prefix). + * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO + * held by the on-chain contract. + * @param redeemerOutputScript - The output script that the redeemed funds will + * be locked to. Must be un-prefixed and not prepended with length. + * @param amount - The amount to be redeemed in satoshis. + * @returns Empty promise. + */ + requestRedemption( + walletPublicKey: string, + mainUtxo: UnspentTransactionOutput, + redeemerOutputScript: string, + amount: BigNumber + ): Promise + + /** + * Submits a redemption transaction proof to the on-chain contract. + * @param redemptionTx - Redemption transaction data + * @param redemptionProof - Redemption proof data + * @param mainUtxo - Data of the wallet's main UTXO + * @param walletPublicKey - Bitcoin public key of the wallet. Must be in the + * compressed form (33 bytes long with 02 or 03 prefix). + */ + submitRedemptionProof( + redemptionTx: DecomposedRawTransaction, + redemptionProof: Proof, + mainUtxo: UnspentTransactionOutput, + walletPublicKey: string + ): Promise + + /** + * Gets transaction proof difficulty factor from the on-chain contract. + * @dev This number signifies how many confirmations a transaction has to + * accumulate before it can be proven on-chain. + * @returns Proof difficulty factor. + */ + txProofDifficultyFactor(): Promise + + /** + * Gets a pending redemption from the on-chain contract. + * @param walletPublicKey Bitcoin public key of the wallet the request is + * targeted to. Must be in the compressed form (33 bytes long with 02 + * or 03 prefix). + * @param redeemerOutputScript The redeemer output script the redeemed funds + * are supposed to be locked on. Must be un-prefixed and not prepended + * with length. + * @returns Promise with the pending redemption. + */ + pendingRedemptions( + walletPublicKey: string, + redeemerOutputScript: string + ): Promise + + /** + * Gets a timed-out redemption from the on-chain contract. + * @param walletPublicKey Bitcoin public key of the wallet the request is + * targeted to. Must be in the compressed form (33 bytes long with 02 + * or 03 prefix). + * @param redeemerOutputScript The redeemer output script the redeemed funds + * are supposed to be locked on. Must be un-prefixed and not prepended + * with length. + * @returns Promise with the pending redemption. + */ + timedOutRedemptions( + walletPublicKey: string, + redeemerOutputScript: string + ): Promise + + /** + * Gets the public key of the current active wallet. + * @returns Compressed (33 bytes long with 02 or 03 prefix) active wallet's + * public key. If there is no active wallet at the moment, undefined + * is returned. + */ + activeWalletPublicKey(): Promise + + /** + * Get emitted NewWalletRegisteredEvent events. + * @see GetEventsFunction + */ + getNewWalletRegisteredEvents: GetEvents.Function + + /** + * Returns the attached WalletRegistry instance. + */ + walletRegistry(): Promise + + /** + * Gets details about a registered wallet. + * @param walletPublicKeyHash The 20-byte wallet public key hash (computed + * using Bitcoin HASH160 over the compressed ECDSA public key). + * @returns Promise with the wallet details. + */ + wallets(walletPublicKeyHash: Hex): Promise + + /** + * Builds the UTXO hash based on the UTXO components. + * @param utxo UTXO components. + * @returns The hash of the UTXO. + */ + buildUtxoHash(utxo: UnspentTransactionOutput): Hex + + /** + * Get emitted RedemptionRequested events. + * @see GetEventsFunction + */ + getRedemptionRequestedEvents: GetEvents.Function +} diff --git a/typescript/src/lib/contracts/chain-event.ts b/typescript/src/lib/contracts/chain-event.ts new file mode 100644 index 000000000..09f5cb022 --- /dev/null +++ b/typescript/src/lib/contracts/chain-event.ts @@ -0,0 +1,63 @@ +import { Hex } from "../../hex" +import { ExecutionLoggerFn } from "../../backoff" + +/** + * Represents a generic chain event. + */ +export interface Event { + /** + * Block number of the event emission. + */ + blockNumber: number + /** + * Block hash of the event emission. + */ + blockHash: Hex + /** + * Transaction hash within which the event was emitted. + */ + transactionHash: Hex +} + +export namespace GetEvents { + /** + * Represents generic options used for getting events from the chain. + */ + export interface Options { + /** + * Block number from which events should be queried. + * If not defined a block number of a contract deployment is used. + */ + fromBlock?: number + /** + * Block number to which events should be queried. + * If not defined the latest block number will be used. + */ + toBlock?: number + /** + * Number of retries in case of an error getting the events. + */ + retries?: number + /** + * Number of blocks for interval length in partial events pulls. + */ + batchedQueryBlockInterval?: number + /** + * A logger function to pass execution messages. + */ + logger?: ExecutionLoggerFn + } + + /** + * Represents a generic function to get events emitted on the chain. + */ + export interface Function { + /** + * Get emitted events. + * @param options Options for getting events. + * @param filterArgs Arguments for events filtering. + * @returns Array of found events. + */ + (options?: Options, ...filterArgs: Array): Promise + } +} diff --git a/typescript/src/lib/contracts/chain-identifier.ts b/typescript/src/lib/contracts/chain-identifier.ts new file mode 100644 index 000000000..3591f7bd1 --- /dev/null +++ b/typescript/src/lib/contracts/chain-identifier.ts @@ -0,0 +1,15 @@ +/** + * Represents a generic chain identifier. + */ +export interface Identifier { + /** + * Identifier as an un-prefixed hex string. + */ + identifierHex: string + /** + * Checks if two identifiers are equal. + * + * @param identifier Another identifier + */ + equals(identifier: Identifier): boolean +} diff --git a/typescript/src/lib/contracts/index.ts b/typescript/src/lib/contracts/index.ts new file mode 100644 index 000000000..58f2565df --- /dev/null +++ b/typescript/src/lib/contracts/index.ts @@ -0,0 +1,6 @@ +export * from "./bridge" +export * from "./chain-event" +export * from "./chain-identifier" +export * from "./tbtc-token" +export * from "./tbtc-vault" +export * from "./wallet-registry" diff --git a/typescript/src/lib/contracts/tbtc-token.ts b/typescript/src/lib/contracts/tbtc-token.ts new file mode 100644 index 000000000..6133bb01d --- /dev/null +++ b/typescript/src/lib/contracts/tbtc-token.ts @@ -0,0 +1,43 @@ +import { BigNumber } from "ethers" +import { UnspentTransactionOutput } from "../bitcoin" +import { Hex } from "../../hex" + +/** + * Interface for communication with the TBTC v2 token on-chain contract. + */ +export interface TBTCToken { + /** + * Gets the total supply of the TBTC v2 token. The returned value is in + * ERC 1e18 precision, it has to be converted before using as Bitcoin value + * with 1e8 precision in satoshi. + * @param blockNumber Optional parameter determining the block the total + * supply should be fetched for. If this parameter is not set, the + * total supply is taken for the latest block. + */ + // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 + // precision to Bitcoin in 1e8 precision (satoshi). + totalSupply(blockNumber?: number): Promise + + /** + * Requests redemption in one transacion using the `approveAndCall` function + * from the tBTC on-chain token contract. Then the tBTC token contract calls + * the `receiveApproval` function from the `TBTCVault` contract which burns + * tBTC tokens and requests redemption. + * @param walletPublicKey - The Bitcoin public key of the wallet. Must be in + * the compressed form (33 bytes long with 02 or 03 prefix). + * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO + * held by the on-chain Bridge contract. + * @param redeemerOutputScript - The output script that the redeemed funds + * will be locked to. Must be un-prefixed and not prepended with + * length. + * @param amount - The amount to be redeemed with the precision of the tBTC + * on-chain token contract. + * @returns Transaction hash of the approve and call transaction. + */ + requestRedemption( + walletPublicKey: string, + mainUtxo: UnspentTransactionOutput, + redeemerOutputScript: string, + amount: BigNumber + ): Promise +} diff --git a/typescript/src/lib/contracts/tbtc-vault.ts b/typescript/src/lib/contracts/tbtc-vault.ts new file mode 100644 index 000000000..0ce82041f --- /dev/null +++ b/typescript/src/lib/contracts/tbtc-vault.ts @@ -0,0 +1,114 @@ +import { TransactionHash } from "../bitcoin" +import { Hex } from "../../hex" +import { + OptimisticMintingCancelledEvent, + OptimisticMintingFinalizedEvent, + OptimisticMintingRequest, + OptimisticMintingRequestedEvent, +} from "../../optimistic-minting" +import { Identifier } from "./chain-identifier" +import { GetEvents } from "./chain-event" + +/** + * Interface for communication with the TBTCVault on-chain contract. + */ +export interface TBTCVault { + /** + * Gets optimistic minting delay. + * + * The time that needs to pass between the moment the optimistic minting is + * requested and the moment optimistic minting is finalized with minting TBTC. + * @returns Optimistic Minting Delay in seconds. + */ + optimisticMintingDelay(): Promise + + /** + * Gets currently registered minters. + * + * @returns Array containing identifiers of all currently registered minters. + */ + getMinters(): Promise + + /** + * Checks if given identifier is registered as minter. + * + * @param identifier Chain identifier to check. + */ + isMinter(identifier: Identifier): Promise + + /** + * Checks if given identifier is registered as guardian. + * + * @param identifier Chain identifier to check. + */ + isGuardian(identifier: Identifier): Promise + + /** + * Requests optimistic minting for a deposit in an on-chain contract. + * + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Transaction hash of the optimistic mint request transaction. + */ + requestOptimisticMint( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise + + /** + * Cancels optimistic minting for a deposit in an on-chain contract. + * + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Transaction hash of the optimistic mint cancel transaction. + */ + cancelOptimisticMint( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise + + /** + * Finalizes optimistic minting for a deposit in an on-chain contract. + * + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Transaction hash of the optimistic mint finalize transaction. + */ + finalizeOptimisticMint( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise + + /** + * Gets optimistic minting request for a deposit. + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Optimistic minting request. + */ + optimisticMintingRequests( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise + + /** + * Get emitted OptimisticMintingRequested events. + * @see GetEventsFunction + */ + getOptimisticMintingRequestedEvents: GetEvents.Function + + /** + * Get emitted OptimisticMintingCancelled events. + * @see GetEventsFunction + */ + getOptimisticMintingCancelledEvents: GetEvents.Function + + /** + * Get emitted OptimisticMintingFinalized events. + * @see GetEventsFunction + */ + getOptimisticMintingFinalizedEvents: GetEvents.Function +} diff --git a/typescript/src/lib/contracts/wallet-registry.ts b/typescript/src/lib/contracts/wallet-registry.ts new file mode 100644 index 000000000..ef0e1711b --- /dev/null +++ b/typescript/src/lib/contracts/wallet-registry.ts @@ -0,0 +1,37 @@ +import { Hex } from "../../hex" +import { + DkgResultApprovedEvent, + DkgResultChallengedEvent, + DkgResultSubmittedEvent, +} from "../../wallet" +import { GetEvents } from "./chain-event" + +/** + * Interface for communication with the WalletRegistry on-chain contract. + */ +export interface WalletRegistry { + /** + * Gets the public key for the given wallet. + * @param walletID ID of the wallet. + * @returns Uncompressed public key without the 04 prefix. + */ + getWalletPublicKey(walletID: Hex): Promise + + /** + * Get emitted DkgResultSubmittedEvent events. + * @see GetEventsFunction + */ + getDkgResultSubmittedEvents: GetEvents.Function + + /** + * Get emitted DkgResultApprovedEvent events. + * @see GetEventsFunction + */ + getDkgResultApprovedEvents: GetEvents.Function + + /** + * Get emitted DkgResultChallengedEvent events. + * @see GetEventsFunction + */ + getDkgResultChallengedEvents: GetEvents.Function +} diff --git a/typescript/src/optimistic-minting.ts b/typescript/src/optimistic-minting.ts index 79468366f..04506cebf 100644 --- a/typescript/src/optimistic-minting.ts +++ b/typescript/src/optimistic-minting.ts @@ -1,6 +1,6 @@ import { BigNumber } from "ethers" import { TransactionHash } from "./lib/bitcoin" -import { Identifier, Event, TBTCVault } from "./chain" +import { Identifier, Event, TBTCVault } from "./lib/contracts" import { Hex } from "./hex" /** diff --git a/typescript/src/proof.ts b/typescript/src/proof.ts index f07cf8161..7d7f739b7 100644 --- a/typescript/src/proof.ts +++ b/typescript/src/proof.ts @@ -11,7 +11,7 @@ import { hashLEToBigNumber, serializeBlockHeader, BlockHeader, -} from "./bitcoin" +} from "./lib/bitcoin" import { BigNumber } from "ethers" import { Hex } from "./hex" diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index 7e99a85ea..c5e9045d6 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -1,21 +1,17 @@ +import bcoin from "bcoin" import { BigNumber } from "ethers" import { - createAddressFromPublicKey, + BitcoinNetwork, + createKeyRing, decomposeRawTransaction, RawTransaction, UnspentTransactionOutput, Client as BitcoinClient, TransactionHash, - isP2PKHScript, - isP2WPKHScript, -} from "./bitcoin" -import { Bridge, Event, Identifier, TBTCToken } from "./chain" +} from "./lib/bitcoin" +import { Bridge, Event, Identifier, TBTCToken } from "./lib/contracts" import { assembleTransactionProof } from "./proof" import { determineWalletMainUtxo, WalletState } from "./wallet" -import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./bitcoin-network" -import { Psbt, Transaction } from "bitcoinjs-lib" -import { ECPairFactory } from "ecpair" -import * as tinysecp from "tiny-secp256k1" import { Hex } from "./hex" /** @@ -144,25 +140,15 @@ export async function submitRedemptionTransaction( transactionHex: mainUtxoRawTransaction.transactionHex, } - const bitcoinNetwork = await bitcoinClient.getNetwork() - - // eslint-disable-next-line new-cap - const walletKeyPair = ECPairFactory(tinysecp).fromWIF( - walletPrivateKey, - toBitcoinJsLibNetwork(bitcoinNetwork) - ) - const walletPublicKey = walletKeyPair.publicKey.toString("hex") - const redemptionRequests = await getWalletRedemptionRequests( bridge, - walletPublicKey, + createKeyRing(walletPrivateKey).getPublicKey().toString("hex"), redeemerOutputScripts, "pending" ) const { transactionHash, newMainUtxo, rawTransaction } = await assembleRedemptionTransaction( - bitcoinNetwork, walletPrivateKey, mainUtxoWithRaw, redemptionRequests, @@ -256,7 +242,6 @@ async function getWalletRedemptionRequests( * - there is at least one redemption * - the `requestedAmount` in each redemption request is greater than * the sum of its `txFee` and `treasuryFee` - * @param bitcoinNetwork - The target Bitcoin network. * @param walletPrivateKey - The private key of the wallet in the WIF format * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO held * by the on-chain Bridge contract @@ -269,7 +254,6 @@ async function getWalletRedemptionRequests( * - the redemption transaction in the raw format */ export async function assembleRedemptionTransaction( - bitcoinNetwork: BitcoinNetwork, walletPrivateKey: string, mainUtxo: UnspentTransactionOutput & RawTransaction, redemptionRequests: RedemptionRequest[], @@ -283,46 +267,19 @@ export async function assembleRedemptionTransaction( throw new Error("There must be at least one request to redeem") } - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - // eslint-disable-next-line new-cap - const walletKeyPair = ECPairFactory(tinysecp).fromWIF( - walletPrivateKey, - network - ) - const walletAddress = createAddressFromPublicKey( - Hex.from(walletKeyPair.publicKey), - bitcoinNetwork, - witness - ) + const walletKeyRing = createKeyRing(walletPrivateKey, witness) + const walletAddress = walletKeyRing.getAddress("string") - const psbt = new Psbt({ network }) - psbt.setVersion(1) - - // Add input (current main UTXO). - const previousOutput = Transaction.fromHex(mainUtxo.transactionHex).outs[ - mainUtxo.outputIndex + // Use the main UTXO as the single transaction input + const inputCoins = [ + bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), + mainUtxo.outputIndex, + -1 + ), ] - const previousOutputScript = previousOutput.script - const previousOutputValue = previousOutput.value - - if (isP2PKHScript(previousOutputScript)) { - psbt.addInput({ - hash: mainUtxo.transactionHash.reverse().toBuffer(), - index: mainUtxo.outputIndex, - nonWitnessUtxo: Buffer.from(mainUtxo.transactionHex, "hex"), - }) - } else if (isP2WPKHScript(previousOutputScript)) { - psbt.addInput({ - hash: mainUtxo.transactionHash.reverse().toBuffer(), - index: mainUtxo.outputIndex, - witnessUtxo: { - script: previousOutputScript, - value: previousOutputValue, - }, - }) - } else { - throw new Error("Unexpected main UTXO type") - } + + const transaction = new bcoin.MTX() let txTotalFee = BigNumber.from(0) let totalOutputsValue = BigNumber.from(0) @@ -346,34 +303,44 @@ export async function assembleRedemptionTransaction( // use the proposed fee and add the difference to outputs proportionally. txTotalFee = txTotalFee.add(request.txMaxFee) - psbt.addOutput({ - script: Buffer.from(request.redeemerOutputScript, "hex"), + transaction.addOutput({ + script: bcoin.Script.fromRaw( + Buffer.from(request.redeemerOutputScript, "hex") + ), value: outputValue.toNumber(), }) } - // If there is a change output, add it to the transaction. + // If there is a change output, add it explicitly to the transaction. + // If we did not add this output explicitly, the bcoin library would add it + // anyway during funding, but if the value of the change output was very low, + // the library would consider it "dust" and add it to the fee rather than + // create a new output. const changeOutputValue = mainUtxo.value .sub(totalOutputsValue) .sub(txTotalFee) if (changeOutputValue.gt(0)) { - psbt.addOutput({ - address: walletAddress, + transaction.addOutput({ + script: bcoin.Script.fromAddress(walletAddress), value: changeOutputValue.toNumber(), }) } - psbt.signAllInputs(walletKeyPair) - psbt.finalizeAllInputs() + await transaction.fund(inputCoins, { + changeAddress: walletAddress, + hardFee: txTotalFee.toNumber(), + subtractFee: false, + }) + + transaction.sign(walletKeyRing) - const transaction = psbt.extractTransaction() - const transactionHash = TransactionHash.from(transaction.getId()) + const transactionHash = TransactionHash.from(transaction.txid()) // If there is a change output, it will be the new wallet's main UTXO. const newMainUtxo = changeOutputValue.gt(0) ? { transactionHash, // It was the last output added to the transaction. - outputIndex: transaction.outs.length - 1, + outputIndex: transaction.outputs.length - 1, value: changeOutputValue, } : undefined @@ -382,7 +349,7 @@ export async function assembleRedemptionTransaction( transactionHash, newMainUtxo, rawTransaction: { - transactionHex: transaction.toHex(), + transactionHex: transaction.toRaw().toString("hex"), }, } } diff --git a/typescript/src/wallet.ts b/typescript/src/wallet.ts index 4e80905ec..a292b0574 100644 --- a/typescript/src/wallet.ts +++ b/typescript/src/wallet.ts @@ -1,6 +1,6 @@ import { BigNumber } from "ethers" import { Hex } from "./hex" -import { Bridge, Event, Identifier } from "./chain" +import { Bridge, Event, Identifier } from "./lib/contracts" import { Client as BitcoinClient, BitcoinNetwork, diff --git a/typescript/test/deposit-refund.test.ts b/typescript/test/deposit-refund.test.ts index 04111e4c5..a6e30ccf3 100644 --- a/typescript/test/deposit-refund.test.ts +++ b/typescript/test/deposit-refund.test.ts @@ -5,7 +5,7 @@ import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) import { expect } from "chai" import { submitDepositRefundTransaction } from "../src/deposit-refund" -import { TransactionHash, RawTransaction } from "./bitcoin" +import { TransactionHash, RawTransaction } from "./lib/bitcoin" import { refunderPrivateKey, depositRefundOfWitnessDepositAndWitnessRefunderAddress, diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index f37a961c6..e7727de85 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -4,8 +4,13 @@ import { TransactionHash, UnspentTransactionOutput, Transaction, -} from "../src/bitcoin" -import { testnetWalletAddress, testnetWalletPrivateKey } from "./data/deposit" +} from "../src/lib/bitcoin" +import { + testnetDepositScripthashAddress, + testnetDepositWitnessScripthashAddress, + testnetWalletAddress, + testnetWalletPrivateKey, +} from "./data/deposit" import { depositSweepWithWitnessMainUtxoAndWitnessOutput, depositSweepWithNoMainUtxoAndWitnessOutput, @@ -16,7 +21,7 @@ import { } from "./data/deposit-sweep" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { MockBridge } from "./utils/mock-bridge" -import { txToJSON } from "./utils/helpers" +import bcoin from "bcoin" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) @@ -26,7 +31,6 @@ import { submitDepositSweepProof, submitDepositSweepTransaction, } from "../src/deposit-sweep" -import { BitcoinNetwork } from "../src/bitcoin-network" describe("Sweep", () => { const fee = BigNumber.from(1600) @@ -35,6 +39,8 @@ describe("Sweep", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { + bcoin.set("testnet") + bitcoinClient = new MockBitcoinClient() }) @@ -373,7 +379,6 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -389,10 +394,8 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() @@ -403,23 +406,26 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(2) const p2shInput = txJSON.inputs[0] - expect(p2shInput.hash).to.be.equal( + expect(p2shInput.prevout.hash).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2shInput.index).to.be.equal( + expect(p2shInput.prevout.index).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.empty + expect(p2shInput.witness).to.be.equal("00") expect(p2shInput.script.length).to.be.greaterThan(0) + // Input's address should be set to the address generated from deposit + // script hash + expect(p2shInput.address).to.be.equal(testnetDepositScripthashAddress) const p2wshInput = txJSON.inputs[1] - expect(p2wshInput.hash).to.be.equal( + expect(p2wshInput.prevout.hash).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() ) - expect(p2wshInput.index).to.be.equal( + expect(p2wshInput.prevout.index).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo .outputIndex ) @@ -427,6 +433,11 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wshInput.witness.length).to.be.greaterThan(0) expect(p2wshInput.script.length).to.be.equal(0) + // Input's address should be set to the address generated from deposit + // witness script hash + expect(p2wshInput.address).to.be.equal( + testnetDepositWitnessScripthashAddress + ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -497,7 +508,6 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -515,10 +525,8 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() @@ -529,10 +537,10 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(3) const p2wkhInput = txJSON.inputs[0] - expect(p2wkhInput.hash).to.be.equal( + expect(p2wkhInput.prevout.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() ) - expect(p2wkhInput.index).to.be.equal( + expect(p2wkhInput.prevout.index).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo .outputIndex ) @@ -540,25 +548,33 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wkhInput.witness.length).to.be.greaterThan(0) expect(p2wkhInput.script.length).to.be.equal(0) + // The input comes from the main UTXO so the input should be the + // wallet's address + expect(p2wkhInput.address).to.be.equal(testnetWalletAddress) const p2shInput = txJSON.inputs[1] - expect(p2shInput.hash).to.be.equal( + expect(p2shInput.prevout.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2shInput.index).to.be.equal( + expect(p2shInput.prevout.index).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.empty + expect(p2shInput.witness).to.be.equal("00") expect(p2shInput.script.length).to.be.greaterThan(0) + // Input's address should be set to the address generated from deposit + // script hash + expect(p2shInput.address).to.be.equal( + testnetDepositScripthashAddress + ) const p2wshInput = txJSON.inputs[2] - expect(p2wshInput.hash).to.be.equal( + expect(p2wshInput.prevout.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() ) - expect(p2wshInput.index).to.be.equal( + expect(p2wshInput.prevout.index).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo .outputIndex ) @@ -566,6 +582,11 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wshInput.witness.length).to.be.greaterThan(0) expect(p2wshInput.script.length).to.be.equal(0) + // Input's address should be set to the address generated from deposit + // witness script hash + expect(p2wshInput.address).to.be.equal( + testnetDepositWitnessScripthashAddress + ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -637,7 +658,6 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -655,10 +675,8 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() @@ -668,24 +686,11 @@ describe("Sweep", () => { // Validate inputs. expect(txJSON.inputs.length).to.be.equal(2) - const p2pkhInput = txJSON.inputs[0] // main UTXO - expect(p2pkhInput.hash).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() - ) - expect(p2pkhInput.index).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo - .outputIndex - ) - // Transaction should be signed. As it's not SegWit input, the `witness` - // field should be empty, while the `script` field should be filled. - expect(p2pkhInput.witness).to.be.empty - expect(p2pkhInput.script.length).to.be.greaterThan(0) - - const p2wshInput = txJSON.inputs[1] - expect(p2wshInput.hash).to.be.equal( + const p2wshInput = txJSON.inputs[0] + expect(p2wshInput.prevout.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2wshInput.index).to.be.equal( + expect(p2wshInput.prevout.index).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0] .utxo.outputIndex ) @@ -693,6 +698,29 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wshInput.witness.length).to.be.greaterThan(0) expect(p2wshInput.script.length).to.be.equal(0) + // Input's address should be set to the address generated from deposit + // script hash + expect(p2wshInput.address).to.be.equal( + "tb1qk8urugnf08wfle6wslmdxq7mkz9z0gw8e6gkvspn7dx87tfpfntshdm7qr" + ) + + const p2pkhInput = txJSON.inputs[1] // main UTXO + expect(p2pkhInput.prevout.hash).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() + ) + expect(p2pkhInput.prevout.index).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo + .outputIndex + ) + // Transaction should be signed. As it's not SegWit input, the `witness` + // field should be empty, while the `script` field should be filled. + expect(p2pkhInput.witness).to.be.equal("00") + expect(p2pkhInput.script.length).to.be.greaterThan(0) + // The input comes from the main UTXO so the input should be the + // wallet's address + expect(p2pkhInput.address).to.be.equal( + "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" + ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -763,7 +791,6 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -780,10 +807,9 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + expect(txJSON.hash).to.be.equal( depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep.transactionHash.toString() ) @@ -793,17 +819,22 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(1) const p2shInput = txJSON.inputs[0] - expect(p2shInput.hash).to.be.equal( + expect(p2shInput.prevout.hash).to.be.equal( depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2shInput.index).to.be.equal( + expect(p2shInput.prevout.index).to.be.equal( depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.empty + expect(p2shInput.witness).to.be.equal("00") expect(p2shInput.script.length).to.be.greaterThan(0) + // Input's address should be set to the address generated from deposit + // script hash + expect(p2shInput.address).to.be.equal( + "2N8iF1pRndihBzgLDna9MfRhmqktwTdHejA" + ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -847,7 +878,6 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, true, @@ -876,7 +906,6 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, witness, @@ -902,7 +931,6 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, true, @@ -942,7 +970,6 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, true, @@ -967,7 +994,6 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, anotherPrivateKey, true, @@ -1001,7 +1027,6 @@ describe("Sweep", () => { it("should revert", async () => { await expect( assembleDepositSweepTransaction( - BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, true, @@ -1018,6 +1043,8 @@ describe("Sweep", () => { let bridge: MockBridge beforeEach(async () => { + bcoin.set("testnet") + bitcoinClient = new MockBitcoinClient() bridge = new MockBridge() diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index a1b2c705b..fd94c1f04 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -12,7 +12,7 @@ import { RawTransaction, TransactionHash, UnspentTransactionOutput, -} from "../src/bitcoin" +} from "../src/lib/bitcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { assembleDepositScript, diff --git a/typescript/test/electrum.test.ts b/typescript/test/electrum.test.ts index e0ad8909b..51d7bb788 100644 --- a/typescript/test/electrum.test.ts +++ b/typescript/test/electrum.test.ts @@ -3,7 +3,7 @@ import { Client as ElectrumClient, computeScriptHash, } from "../src/electrum" -import { BitcoinNetwork } from "../src/bitcoin-network" +import { BitcoinNetwork } from "../src/lib/bitcoin" import { testnetAddress, testnetHeadersChain, diff --git a/typescript/test/ethereum.test.ts b/typescript/test/ethereum.test.ts index 780180ffa..98215fc04 100644 --- a/typescript/test/ethereum.test.ts +++ b/typescript/test/ethereum.test.ts @@ -10,7 +10,7 @@ import { abi as TBTCTokenABI } from "@keep-network/tbtc-v2/artifacts/TBTC.json" import { abi as WalletRegistryABI } from "@keep-network/ecdsa/artifacts/WalletRegistry.json" import { MockProvider } from "@ethereum-waffle/provider" import { waffleChai } from "@ethereum-waffle/chai" -import { TransactionHash, computeHash160 } from "../src/bitcoin" +import { TransactionHash, computeHash160 } from "../src/lib/bitcoin" import { Hex } from "../src/hex" chai.use(waffleChai) diff --git a/typescript/test/proof.test.ts b/typescript/test/proof.test.ts index 68cef604e..ead678177 100644 --- a/typescript/test/proof.test.ts +++ b/typescript/test/proof.test.ts @@ -1,5 +1,10 @@ import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import { serializeBlockHeader, Transaction, BlockHeader } from "../src/bitcoin" +import { + serializeBlockHeader, + Transaction, + BlockHeader, + Proof, +} from "../src/lib/bitcoin" import { Hex } from "../src/hex" import { singleInputProofTestData, @@ -15,7 +20,6 @@ import { validateTransactionProof, splitHeaders, } from "../src/proof" -import { Proof } from "./bitcoin" import { expect } from "chai" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index 802942f7b..b83ad3161 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -1,9 +1,11 @@ import { + BitcoinNetwork, Transaction, RawTransaction, TransactionHash, UnspentTransactionOutput, -} from "../src/bitcoin" +} from "../src/lib/bitcoin" +import bcoin from "bcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { walletPrivateKey, @@ -30,13 +32,11 @@ import { submitRedemptionProof, submitRedemptionTransaction, } from "../src/redemption" -import { txToJSON } from "./utils/helpers" import { MockBridge } from "./utils/mock-bridge" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" import { expect } from "chai" import { BigNumberish, BigNumber } from "ethers" -import { BitcoinNetwork } from "../src/bitcoin-network" import { Wallet } from "../src/wallet" import { MockTBTCToken } from "./utils/mock-tbtc-token" import { BitcoinTransaction } from "../src" @@ -53,6 +53,8 @@ describe("Redemption", () => { const token: MockTBTCToken = new MockTBTCToken() beforeEach(async () => { + bcoin.set("testnet") + await requestRedemption( walletPublicKey, mainUtxo, @@ -80,6 +82,7 @@ describe("Redemption", () => { let bridge: MockBridge beforeEach(async () => { + bcoin.set("testnet") bitcoinClient = new MockBitcoinClient() bridge = new MockBridge() }) @@ -495,7 +498,6 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await assembleRedemptionTransaction( - BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -510,10 +512,8 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -525,14 +525,17 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.hash).to.be.equal( + expect(input.prevout.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.prevout.index).to.be.equal( + data.mainUtxo.outputIndex + ) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -608,7 +611,6 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await assembleRedemptionTransaction( - BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -623,10 +625,8 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -638,14 +638,17 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.hash).to.be.equal( + expect(input.prevout.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.prevout.index).to.be.equal( + data.mainUtxo.outputIndex + ) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -720,7 +723,6 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await assembleRedemptionTransaction( - BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -735,10 +737,8 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -750,14 +750,17 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.hash).to.be.equal( + expect(input.prevout.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.prevout.index).to.be.equal( + data.mainUtxo.outputIndex + ) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -832,7 +835,6 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await assembleRedemptionTransaction( - BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -847,10 +849,8 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -862,14 +862,17 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.hash).to.be.equal( + expect(input.prevout.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.prevout.index).to.be.equal( + data.mainUtxo.outputIndex + ) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -943,7 +946,6 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await assembleRedemptionTransaction( - BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -956,10 +958,8 @@ describe("Redemption", () => { expect(transaction).to.be.eql(data.expectedRedemption.transaction) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -971,14 +971,15 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.hash).to.be.equal( + expect(input.prevout.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.prevout.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(5) @@ -1102,7 +1103,6 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await assembleRedemptionTransaction( - BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -1115,10 +1115,8 @@ describe("Redemption", () => { expect(transaction).to.be.eql(data.expectedRedemption.transaction) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -1130,14 +1128,15 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.hash).to.be.equal( + expect(input.prevout.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.prevout.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -1210,7 +1209,6 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await assembleRedemptionTransaction( - BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests, @@ -1223,10 +1221,9 @@ describe("Redemption", () => { expect(transaction).to.be.eql(data.expectedRedemption.transaction) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() ) @@ -1237,14 +1234,15 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.hash).to.be.equal( + expect(input.prevout.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.prevout.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -1300,7 +1298,6 @@ describe("Redemption", () => { it("should revert", async () => { await expect( assembleRedemptionTransaction( - BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, [], // empty list of redemption requests @@ -1324,6 +1321,8 @@ describe("Redemption", () => { let bridge: MockBridge beforeEach(async () => { + bcoin.set("testnet") + bitcoinClient = new MockBitcoinClient() bridge = new MockBridge() diff --git a/typescript/test/wallet.test.ts b/typescript/test/wallet.test.ts index 277b07e5a..678c396c4 100644 --- a/typescript/test/wallet.test.ts +++ b/typescript/test/wallet.test.ts @@ -3,7 +3,7 @@ import { MockBridge } from "./utils/mock-bridge" import { BitcoinNetwork, BitcoinTransaction, Hex } from "../src" import { determineWalletMainUtxo, Wallet } from "../src/wallet" import { expect } from "chai" -import { encodeToBitcoinAddress } from "../src/bitcoin" +import { encodeToBitcoinAddress } from "../src/lib/bitcoin" import { BigNumber } from "ethers" describe("Wallet", () => { From 97cfb7e9e86cb546150d60302cf7e87f452862fa Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 22 Sep 2023 16:58:26 +0200 Subject: [PATCH 158/205] Transform `electrum.ts` file to `lib/electrum` shared lib --- typescript/src/index.ts | 2 +- typescript/src/{electrum.ts => lib/electrum/client.ts} | 6 +++--- typescript/src/lib/electrum/index.ts | 1 + typescript/test/electrum.test.ts | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) rename typescript/src/{electrum.ts => lib/electrum/client.ts} (99%) create mode 100644 typescript/src/lib/electrum/index.ts diff --git a/typescript/src/index.ts b/typescript/src/index.ts index ed0fdb87e..a130de012 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -59,7 +59,7 @@ export { BitcoinNetwork, } from "./lib/bitcoin" -export { Client as ElectrumClient } from "./electrum" +export { Client as ElectrumClient } from "./lib/electrum" export { Bridge as EthereumBridge, diff --git a/typescript/src/electrum.ts b/typescript/src/lib/electrum/client.ts similarity index 99% rename from typescript/src/electrum.ts rename to typescript/src/lib/electrum/client.ts index 3335f5fc2..f3d69cd7a 100644 --- a/typescript/src/electrum.ts +++ b/typescript/src/lib/electrum/client.ts @@ -11,12 +11,12 @@ import { TransactionMerkleBranch, TransactionOutput, UnspentTransactionOutput, -} from "./lib/bitcoin" +} from "../bitcoin" import Electrum from "electrum-client-js" import { BigNumber, utils } from "ethers" import { URL } from "url" -import { Hex } from "./hex" -import { backoffRetrier, RetrierFn } from "./backoff" +import { Hex } from "../../hex" +import { backoffRetrier, RetrierFn } from "../../backoff" /** * Represents a set of credentials required to establish an Electrum connection. diff --git a/typescript/src/lib/electrum/index.ts b/typescript/src/lib/electrum/index.ts new file mode 100644 index 000000000..a5017494f --- /dev/null +++ b/typescript/src/lib/electrum/index.ts @@ -0,0 +1 @@ +export * from "./client" diff --git a/typescript/test/electrum.test.ts b/typescript/test/electrum.test.ts index 51d7bb788..8d643309e 100644 --- a/typescript/test/electrum.test.ts +++ b/typescript/test/electrum.test.ts @@ -2,7 +2,7 @@ import { Credentials as ElectrumCredentials, Client as ElectrumClient, computeScriptHash, -} from "../src/electrum" +} from "../src/lib/electrum" import { BitcoinNetwork } from "../src/lib/bitcoin" import { testnetAddress, From c09233fcbf8e8678b36b0b110c3f65ab8b71cf69 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 22 Sep 2023 17:40:31 +0200 Subject: [PATCH 159/205] Transform `ethereum.ts` file to `lib/ethereum` shared lib --- typescript/src/ethereum.ts | 1308 ----------------- typescript/src/index.ts | 2 +- typescript/src/lib/ethereum/address.ts | 32 + typescript/src/lib/ethereum/bridge.ts | 618 ++++++++ .../ethereum/contract-handle.ts} | 142 +- typescript/src/lib/ethereum/index.ts | 10 + typescript/src/lib/ethereum/tbtc-token.ts | 129 ++ typescript/src/lib/ethereum/tbtc-vault.ts | 286 ++++ .../src/lib/ethereum/wallet-registry.ts | 136 ++ typescript/test/data/deposit-refund.ts | 2 +- typescript/test/data/deposit-sweep.ts | 2 +- typescript/test/data/redemption.ts | 10 +- typescript/test/deposit.test.ts | 77 +- typescript/test/ethereum.test.ts | 2 +- typescript/test/utils/mock-bitcoin-client.ts | 4 +- typescript/test/utils/mock-bridge.ts | 14 +- typescript/test/utils/mock-tbtc-token.ts | 4 +- 17 files changed, 1404 insertions(+), 1374 deletions(-) delete mode 100644 typescript/src/ethereum.ts create mode 100644 typescript/src/lib/ethereum/address.ts create mode 100644 typescript/src/lib/ethereum/bridge.ts rename typescript/src/{ethereum-helpers.ts => lib/ethereum/contract-handle.ts} (56%) create mode 100644 typescript/src/lib/ethereum/index.ts create mode 100644 typescript/src/lib/ethereum/tbtc-token.ts create mode 100644 typescript/src/lib/ethereum/tbtc-vault.ts create mode 100644 typescript/src/lib/ethereum/wallet-registry.ts diff --git a/typescript/src/ethereum.ts b/typescript/src/ethereum.ts deleted file mode 100644 index 1f05152bd..000000000 --- a/typescript/src/ethereum.ts +++ /dev/null @@ -1,1308 +0,0 @@ -import { - Bridge as ChainBridge, - WalletRegistry as ChainWalletRegistry, - TBTCVault as ChainTBTCVault, - TBTCToken as ChainTBTCToken, - Identifier as ChainIdentifier, - GetEvents, -} from "./lib/contracts" -import { - BigNumber, - constants, - Contract as EthersContract, - ContractTransaction, - Event as EthersEvent, - providers, - Signer, - utils, -} from "ethers" -import BridgeDeployment from "@keep-network/tbtc-v2/artifacts/Bridge.json" -import WalletRegistryDeployment from "@keep-network/ecdsa/artifacts/WalletRegistry.json" -import TBTCVaultDeployment from "@keep-network/tbtc-v2/artifacts/TBTCVault.json" -import TBTCDeployment from "@keep-network/tbtc-v2/artifacts/TBTC.json" -import { backoffRetrier } from "./backoff" -import { - DepositScriptParameters, - RevealedDeposit, - DepositRevealedEvent, -} from "./deposit" -import { getEvents, sendWithRetry } from "./ethereum-helpers" -import { RedemptionRequest, RedemptionRequestedEvent } from "./redemption" -import { - compressPublicKey, - computeHash160, - DecomposedRawTransaction, - Proof, - readCompactSizeUint, - TransactionHash, - UnspentTransactionOutput, -} from "./lib/bitcoin" -import type { - OptimisticMintingCancelledEvent, - OptimisticMintingFinalizedEvent, - OptimisticMintingRequest, - OptimisticMintingRequestedEvent, -} from "./optimistic-minting" - -import type { - Bridge as ContractBridge, - Deposit as ContractDeposit, - Redemption as ContractRedemption, - Wallets, -} from "../typechain/Bridge" -import type { WalletRegistry as ContractWalletRegistry } from "../typechain/WalletRegistry" -import type { TBTCVault as ContractTBTCVault } from "../typechain/TBTCVault" -import type { TBTC as ContractTBTC } from "../typechain/TBTC" -import { Hex } from "./hex" -import { - DkgResultApprovedEvent, - DkgResultChallengedEvent, - DkgResultSubmittedEvent, - NewWalletRegisteredEvent, - Wallet, - WalletState, -} from "./wallet" - -type ContractDepositRequest = ContractDeposit.DepositRequestStructOutput - -type ContractRedemptionRequest = - ContractRedemption.RedemptionRequestStructOutput - -type ContractOptimisticMintingRequest = { - requestedAt: BigNumber - finalizedAt: BigNumber -} - -/** - * Contract deployment artifact. - * @see [hardhat-deploy#Deployment](https://github.com/wighawag/hardhat-deploy/blob/0c969e9a27b4eeff9f5ccac7e19721ef2329eed2/types.ts#L358)} - */ -export interface Deployment { - /** - * Address of the deployed contract. - */ - address: string - /** - * Contract's ABI. - */ - abi: any[] - /** - * Deployment transaction receipt. - */ - receipt: { - /** - * Number of block in which the contract was deployed. - */ - blockNumber: number - } -} - -/** - * Represents an Ethereum address. - */ -// TODO: Make Address extends Hex -export class Address implements ChainIdentifier { - readonly identifierHex: string - - // TODO: Make constructor private - constructor(address: string) { - let validAddress: string - - try { - validAddress = utils.getAddress(address) - } catch (e) { - throw new Error(`Invalid Ethereum address`) - } - - this.identifierHex = validAddress.substring(2).toLowerCase() - } - - static from(address: string): Address { - return new Address(address) - } - - // TODO: Remove once extends Hex - equals(otherValue: Address): boolean { - return this.identifierHex === otherValue.identifierHex - } -} - -/** - * Represents a config set required to connect an Ethereum contract. - */ -export interface ContractConfig { - /** - * Address of the Ethereum contract as a 0x-prefixed hex string. - * Optional parameter, if not provided the value will be resolved from the - * contract artifact. - */ - address?: string - /** - * Signer - will return a Contract which will act on behalf of that signer. The signer will sign all contract transactions. - * Provider - will return a downgraded Contract which only has read-only access (i.e. constant calls) - */ - signerOrProvider: Signer | providers.Provider - /** - * Number of a block in which the contract was deployed. - * Optional parameter, if not provided the value will be resolved from the - * contract artifact. - */ - deployedAtBlockNumber?: number -} - -/** - * Deployed Ethereum contract - */ -class EthereumContract { - /** - * Ethers instance of the deployed contract. - */ - protected readonly _instance: T - /** - * Number of a block within which the contract was deployed. Value is read from - * the contract deployment artifact. It can be overwritten by setting a - * {@link ContractConfig.deployedAtBlockNumber} property. - */ - protected readonly _deployedAtBlockNumber: number - /** - * Number of retries for ethereum requests. - */ - protected readonly _totalRetryAttempts: number - - /** - * @param config Configuration for contract instance initialization. - * @param deployment Contract Deployment artifact. - * @param totalRetryAttempts Number of retries for ethereum requests. - */ - constructor( - config: ContractConfig, - deployment: Deployment, - totalRetryAttempts = 3 - ) { - this._instance = new EthersContract( - config.address ?? utils.getAddress(deployment.address), - `${JSON.stringify(deployment.abi)}`, - config.signerOrProvider - ) as T - - this._deployedAtBlockNumber = - config.deployedAtBlockNumber ?? deployment.receipt.blockNumber - - this._totalRetryAttempts = totalRetryAttempts - } - - /** - * Get address of the contract instance. - * @returns Address of this contract instance. - */ - getAddress(): Address { - return Address.from(this._instance.address) - } - - /** - * Get events emitted by the Ethereum contract. - * It starts searching from provided block number. If the {@link GetEvents.Options#fromBlock} - * option is missing it looks for a contract's defined property - * {@link _deployedAtBlockNumber}. If the property is missing starts searching - * from block `0`. - * @param eventName Name of the event. - * @param options Options for events fetching. - * @param filterArgs Arguments for events filtering. - * @returns Array of found events. - */ - async getEvents( - eventName: string, - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - // TODO: Test if we need a workaround for querying events from big range in chunks, - // see: https://github.com/keep-network/tbtc-monitoring/blob/e169357d7b8c638d4eaf73d52aa8f53ee4aebc1d/src/lib/ethereum-helper.js#L44-L73 - return backoffRetrier( - options?.retries ?? this._totalRetryAttempts - )(async () => { - return await getEvents( - this._instance, - this._instance.filters[eventName](...filterArgs), - options?.fromBlock ?? this._deployedAtBlockNumber, - options?.toBlock, - options?.batchedQueryBlockInterval, - options?.logger - ) - }) - } -} - -// TODO: Refactor code structure as discussed in https://github.com/keep-network/tbtc-v2/pull/460#discussion_r1063383624. - -/** - * Implementation of the Ethereum Bridge handle. - * @see {ChainBridge} for reference. - */ -export class Bridge - extends EthereumContract - implements ChainBridge -{ - constructor(config: ContractConfig) { - super(config, BridgeDeployment) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#getDepositRevealedEvents} - */ - async getDepositRevealedEvents( - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - const events: EthersEvent[] = await this.getEvents( - "DepositRevealed", - options, - ...filterArgs - ) - - return events.map((event) => { - return { - blockNumber: BigNumber.from(event.blockNumber).toNumber(), - blockHash: Hex.from(event.blockHash), - transactionHash: Hex.from(event.transactionHash), - fundingTxHash: TransactionHash.from( - event.args!.fundingTxHash - ).reverse(), - fundingOutputIndex: BigNumber.from( - event.args!.fundingOutputIndex - ).toNumber(), - depositor: new Address(event.args!.depositor), - amount: BigNumber.from(event.args!.amount), - blindingFactor: Hex.from(event.args!.blindingFactor).toString(), - walletPublicKeyHash: Hex.from(event.args!.walletPubKeyHash).toString(), - refundPublicKeyHash: Hex.from(event.args!.refundPubKeyHash).toString(), - refundLocktime: Hex.from(event.args!.refundLocktime).toString(), - vault: - event.args!.vault === constants.AddressZero - ? undefined - : new Address(event.args!.vault), - } - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#pendingRedemptions} - */ - async pendingRedemptions( - walletPublicKey: string, - redeemerOutputScript: string - ): Promise { - const redemptionKey = Bridge.buildRedemptionKey( - computeHash160(walletPublicKey), - redeemerOutputScript - ) - - const request: ContractRedemptionRequest = - await backoffRetrier(this._totalRetryAttempts)( - async () => { - return await this._instance.pendingRedemptions(redemptionKey) - } - ) - - return this.parseRedemptionRequest(request, redeemerOutputScript) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#timedOutRedemptions} - */ - async timedOutRedemptions( - walletPublicKey: string, - redeemerOutputScript: string - ): Promise { - const redemptionKey = Bridge.buildRedemptionKey( - computeHash160(walletPublicKey), - redeemerOutputScript - ) - - const request: ContractRedemptionRequest = - await backoffRetrier(this._totalRetryAttempts)( - async () => { - return await this._instance.timedOutRedemptions(redemptionKey) - } - ) - - return this.parseRedemptionRequest(request, redeemerOutputScript) - } - - /** - * Builds a redemption key required to refer a redemption request. - * @param walletPublicKeyHash The wallet public key hash that identifies the - * pending redemption (along with the redeemer output script). Must be - * unprefixed. - * @param redeemerOutputScript The redeemer output script that identifies the - * pending redemption (along with the wallet public key hash). Must be - * un-prefixed and not prepended with length. - * @returns The redemption key. - */ - static buildRedemptionKey( - walletPublicKeyHash: string, - redeemerOutputScript: string - ): string { - // Convert the output script to raw bytes buffer. - const rawRedeemerOutputScript = Buffer.from(redeemerOutputScript, "hex") - // Prefix the output script bytes buffer with 0x and its own length. - const prefixedRawRedeemerOutputScript = `0x${Buffer.concat([ - Buffer.from([rawRedeemerOutputScript.length]), - rawRedeemerOutputScript, - ]).toString("hex")}` - // Build the redemption key by using the 0x-prefixed wallet PKH and - // prefixed output script. - return utils.solidityKeccak256( - ["bytes32", "bytes20"], - [ - utils.solidityKeccak256(["bytes"], [prefixedRawRedeemerOutputScript]), - `0x${walletPublicKeyHash}`, - ] - ) - } - - /** - * Parses a redemption request using data fetched from the on-chain contract. - * @param request Data of the request. - * @param redeemerOutputScript The redeemer output script that identifies the - * pending redemption (along with the wallet public key hash). Must be - * un-prefixed and not prepended with length. - * @returns Parsed redemption request. - */ - private parseRedemptionRequest( - request: ContractRedemptionRequest, - redeemerOutputScript: string - ): RedemptionRequest { - return { - redeemer: new Address(request.redeemer), - redeemerOutputScript: redeemerOutputScript, - requestedAmount: BigNumber.from(request.requestedAmount), - treasuryFee: BigNumber.from(request.treasuryFee), - txMaxFee: BigNumber.from(request.txMaxFee), - requestedAt: BigNumber.from(request.requestedAt).toNumber(), - } - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#revealDeposit} - */ - async revealDeposit( - depositTx: DecomposedRawTransaction, - depositOutputIndex: number, - deposit: DepositScriptParameters, - vault?: ChainIdentifier - ): Promise { - const depositTxParam = { - version: `0x${depositTx.version}`, - inputVector: `0x${depositTx.inputs}`, - outputVector: `0x${depositTx.outputs}`, - locktime: `0x${depositTx.locktime}`, - } - - const revealParam = { - fundingOutputIndex: depositOutputIndex, - blindingFactor: `0x${deposit.blindingFactor}`, - walletPubKeyHash: `0x${deposit.walletPublicKeyHash}`, - refundPubKeyHash: `0x${deposit.refundPublicKeyHash}`, - refundLocktime: `0x${deposit.refundLocktime}`, - vault: vault ? `0x${vault.identifierHex}` : constants.AddressZero, - } - - const tx = await sendWithRetry( - async () => { - return await this._instance.revealDeposit(depositTxParam, revealParam) - }, - this._totalRetryAttempts, - undefined, - ["Deposit already revealed"] - ) - - return tx.hash - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#submitDepositSweepProof} - */ - async submitDepositSweepProof( - sweepTx: DecomposedRawTransaction, - sweepProof: Proof, - mainUtxo: UnspentTransactionOutput, - vault?: ChainIdentifier - ): Promise { - const sweepTxParam = { - version: `0x${sweepTx.version}`, - inputVector: `0x${sweepTx.inputs}`, - outputVector: `0x${sweepTx.outputs}`, - locktime: `0x${sweepTx.locktime}`, - } - - const sweepProofParam = { - merkleProof: `0x${sweepProof.merkleProof}`, - txIndexInBlock: sweepProof.txIndexInBlock, - bitcoinHeaders: `0x${sweepProof.bitcoinHeaders}`, - } - - const mainUtxoParam = { - // The Ethereum Bridge expects this hash to be in the Bitcoin internal - // byte order. - txHash: mainUtxo.transactionHash.reverse().toPrefixedString(), - txOutputIndex: mainUtxo.outputIndex, - txOutputValue: mainUtxo.value, - } - - const vaultParam = vault - ? `0x${vault.identifierHex}` - : constants.AddressZero - - await sendWithRetry(async () => { - return await this._instance.submitDepositSweepProof( - sweepTxParam, - sweepProofParam, - mainUtxoParam, - vaultParam - ) - }, this._totalRetryAttempts) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#txProofDifficultyFactor} - */ - async txProofDifficultyFactor(): Promise { - const txProofDifficultyFactor: BigNumber = await backoffRetrier( - this._totalRetryAttempts - )(async () => { - return await this._instance.txProofDifficultyFactor() - }) - - return txProofDifficultyFactor.toNumber() - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#requestRedemption} - */ - async requestRedemption( - walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, - redeemerOutputScript: string, - amount: BigNumber - ): Promise { - const walletPublicKeyHash = `0x${computeHash160(walletPublicKey)}` - - const mainUtxoParam = { - // The Ethereum Bridge expects this hash to be in the Bitcoin internal - // byte order. - txHash: mainUtxo.transactionHash.reverse().toPrefixedString(), - txOutputIndex: mainUtxo.outputIndex, - txOutputValue: mainUtxo.value, - } - - // Convert the output script to raw bytes buffer. - const rawRedeemerOutputScript = Buffer.from(redeemerOutputScript, "hex") - // Prefix the output script bytes buffer with 0x and its own length. - const prefixedRawRedeemerOutputScript = `0x${Buffer.concat([ - Buffer.from([rawRedeemerOutputScript.length]), - rawRedeemerOutputScript, - ]).toString("hex")}` - - await sendWithRetry(async () => { - return await this._instance.requestRedemption( - walletPublicKeyHash, - mainUtxoParam, - prefixedRawRedeemerOutputScript, - amount - ) - }, this._totalRetryAttempts) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#submitRedemptionProof} - */ - async submitRedemptionProof( - redemptionTx: DecomposedRawTransaction, - redemptionProof: Proof, - mainUtxo: UnspentTransactionOutput, - walletPublicKey: string - ): Promise { - const redemptionTxParam = { - version: `0x${redemptionTx.version}`, - inputVector: `0x${redemptionTx.inputs}`, - outputVector: `0x${redemptionTx.outputs}`, - locktime: `0x${redemptionTx.locktime}`, - } - - const redemptionProofParam = { - merkleProof: `0x${redemptionProof.merkleProof}`, - txIndexInBlock: redemptionProof.txIndexInBlock, - bitcoinHeaders: `0x${redemptionProof.bitcoinHeaders}`, - } - - const mainUtxoParam = { - // The Ethereum Bridge expects this hash to be in the Bitcoin internal - // byte order. - txHash: mainUtxo.transactionHash.reverse().toPrefixedString(), - txOutputIndex: mainUtxo.outputIndex, - txOutputValue: mainUtxo.value, - } - - const walletPublicKeyHash = `0x${computeHash160(walletPublicKey)}` - - await sendWithRetry(async () => { - return await this._instance.submitRedemptionProof( - redemptionTxParam, - redemptionProofParam, - mainUtxoParam, - walletPublicKeyHash - ) - }, this._totalRetryAttempts) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#deposits} - */ - async deposits( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise { - const depositKey = Bridge.buildDepositKey(depositTxHash, depositOutputIndex) - - const deposit: ContractDepositRequest = - await backoffRetrier(this._totalRetryAttempts)( - async () => { - return await this._instance.deposits(depositKey) - } - ) - - return this.parseRevealedDeposit(deposit) - } - - /** - * Builds the deposit key required to refer a revealed deposit. - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @returns Deposit key. - */ - static buildDepositKey( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): string { - const prefixedReversedDepositTxHash = depositTxHash - .reverse() - .toPrefixedString() - - return utils.solidityKeccak256( - ["bytes32", "uint32"], - [prefixedReversedDepositTxHash, depositOutputIndex] - ) - } - - /** - * Parses a revealed deposit using data fetched from the on-chain contract. - * @param deposit Data of the revealed deposit. - * @returns Parsed revealed deposit. - */ - private parseRevealedDeposit( - deposit: ContractDepositRequest - ): RevealedDeposit { - return { - depositor: new Address(deposit.depositor), - amount: BigNumber.from(deposit.amount), - vault: - deposit.vault === constants.AddressZero - ? undefined - : new Address(deposit.vault), - revealedAt: BigNumber.from(deposit.revealedAt).toNumber(), - sweptAt: BigNumber.from(deposit.sweptAt).toNumber(), - treasuryFee: BigNumber.from(deposit.treasuryFee), - } - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#activeWalletPublicKey} - */ - async activeWalletPublicKey(): Promise { - const activeWalletPublicKeyHash: string = await backoffRetrier( - this._totalRetryAttempts - )(async () => { - return await this._instance.activeWalletPubKeyHash() - }) - - if ( - activeWalletPublicKeyHash === "0x0000000000000000000000000000000000000000" - ) { - // If there is no active wallet currently, return undefined. - return undefined - } - - const { walletPublicKey } = await this.wallets( - Hex.from(activeWalletPublicKeyHash) - ) - - return walletPublicKey.toString() - } - - private async getWalletCompressedPublicKey(ecdsaWalletID: Hex): Promise { - const walletRegistry = await this.walletRegistry() - const uncompressedPublicKey = await walletRegistry.getWalletPublicKey( - ecdsaWalletID - ) - - return Hex.from(compressPublicKey(uncompressedPublicKey)) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#getNewWalletRegisteredEvents} - */ - async getNewWalletRegisteredEvents( - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - const events: EthersEvent[] = await this.getEvents( - "NewWalletRegistered", - options, - ...filterArgs - ) - - return events.map((event) => { - return { - blockNumber: BigNumber.from(event.blockNumber).toNumber(), - blockHash: Hex.from(event.blockHash), - transactionHash: Hex.from(event.transactionHash), - ecdsaWalletID: Hex.from(event.args!.ecdsaWalletID), - walletPublicKeyHash: Hex.from(event.args!.walletPubKeyHash), - } - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#walletRegistry} - */ - async walletRegistry(): Promise { - const { ecdsaWalletRegistry } = await backoffRetrier<{ - ecdsaWalletRegistry: string - }>(this._totalRetryAttempts)(async () => { - return await this._instance.contractReferences() - }) - - return new WalletRegistry({ - address: ecdsaWalletRegistry, - signerOrProvider: this._instance.signer || this._instance.provider, - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#wallets} - */ - async wallets(walletPublicKeyHash: Hex): Promise { - const wallet = await backoffRetrier( - this._totalRetryAttempts - )(async () => { - return await this._instance.wallets( - walletPublicKeyHash.toPrefixedString() - ) - }) - - return this.parseWalletDetails(wallet) - } - - /** - * Parses a wallet data using data fetched from the on-chain contract. - * @param wallet Data of the wallet. - * @returns Parsed wallet data. - */ - private async parseWalletDetails( - wallet: Wallets.WalletStructOutput - ): Promise { - const ecdsaWalletID = Hex.from(wallet.ecdsaWalletID) - - return { - ecdsaWalletID, - walletPublicKey: await this.getWalletCompressedPublicKey(ecdsaWalletID), - mainUtxoHash: Hex.from(wallet.mainUtxoHash), - pendingRedemptionsValue: wallet.pendingRedemptionsValue, - createdAt: wallet.createdAt, - movingFundsRequestedAt: wallet.movingFundsRequestedAt, - closingStartedAt: wallet.closingStartedAt, - pendingMovedFundsSweepRequestsCount: - wallet.pendingMovedFundsSweepRequestsCount, - state: WalletState.parse(wallet.state), - movingFundsTargetWalletsCommitmentHash: Hex.from( - wallet.movingFundsTargetWalletsCommitmentHash - ), - } - } - - // eslint-disable-next-line valid-jsdoc - /** - * Builds the UTXO hash based on the UTXO components. UTXO hash is computed as - * `keccak256(txHash | txOutputIndex | txOutputValue)`. - * - * @see {ChainBridge#buildUtxoHash} - */ - buildUtxoHash(utxo: UnspentTransactionOutput): Hex { - return Hex.from( - utils.solidityKeccak256( - ["bytes32", "uint32", "uint64"], - [ - utxo.transactionHash.reverse().toPrefixedString(), - utxo.outputIndex, - utxo.value, - ] - ) - ) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#getDepositRevealedEvents} - */ - async getRedemptionRequestedEvents( - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - // FIXME: Filtering by indexed walletPubKeyHash field may not work - // until https://github.com/ethers-io/ethers.js/pull/4244 is - // included in the currently used version of ethers.js. - // Ultimately, we should upgrade ethers.js to include that fix. - // Short-term, we can workaround the problem as presented in: - // https://github.com/threshold-network/token-dashboard/blob/main/src/threshold-ts/tbtc/index.ts#L1041C1-L1093C1 - const events: EthersEvent[] = await this.getEvents( - "RedemptionRequested", - options, - ...filterArgs - ) - - return events.map((event) => { - const prefixedRedeemerOutputScript = Hex.from( - event.args!.redeemerOutputScript - ) - const redeemerOutputScript = prefixedRedeemerOutputScript - .toString() - .slice(readCompactSizeUint(prefixedRedeemerOutputScript).byteLength * 2) - - return { - blockNumber: BigNumber.from(event.blockNumber).toNumber(), - blockHash: Hex.from(event.blockHash), - transactionHash: Hex.from(event.transactionHash), - walletPublicKeyHash: Hex.from(event.args!.walletPubKeyHash).toString(), - redeemer: new Address(event.args!.redeemer), - redeemerOutputScript: redeemerOutputScript, - requestedAmount: BigNumber.from(event.args!.requestedAmount), - treasuryFee: BigNumber.from(event.args!.treasuryFee), - txMaxFee: BigNumber.from(event.args!.txMaxFee), - } - }) - } -} - -/** - * Implementation of the Ethereum WalletRegistry handle. - * @see {ChainWalletRegistry} for reference. - */ -export class WalletRegistry - extends EthereumContract - implements ChainWalletRegistry -{ - constructor(config: ContractConfig) { - super(config, WalletRegistryDeployment) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainWalletRegistry#getWalletPublicKey} - */ - async getWalletPublicKey(walletID: Hex): Promise { - const publicKey = await backoffRetrier(this._totalRetryAttempts)( - async () => { - return await this._instance.getWalletPublicKey( - walletID.toPrefixedString() - ) - } - ) - return Hex.from(publicKey.substring(2)) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainWalletRegistry#getDkgResultSubmittedEvents} - */ - async getDkgResultSubmittedEvents( - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - const events: EthersEvent[] = await this.getEvents( - "DkgResultSubmitted", - options, - ...filterArgs - ) - - return events.map((event) => { - return { - blockNumber: BigNumber.from(event.blockNumber).toNumber(), - blockHash: Hex.from(event.blockHash), - transactionHash: Hex.from(event.transactionHash), - resultHash: Hex.from(event.args!.resultHash), - seed: Hex.from(BigNumber.from(event.args!.seed).toHexString()), - result: { - submitterMemberIndex: BigNumber.from( - event.args!.result.submitterMemberIndex - ), - groupPubKey: Hex.from(event.args!.result.groupPubKey), - misbehavedMembersIndices: - event.args!.result.misbehavedMembersIndices.map((mmi: unknown) => - BigNumber.from(mmi).toNumber() - ), - signatures: Hex.from(event.args!.result.signatures), - signingMembersIndices: event.args!.result.signingMembersIndices.map( - BigNumber.from - ), - members: event.args!.result.members.map((m: unknown) => - BigNumber.from(m).toNumber() - ), - membersHash: Hex.from(event.args!.result.membersHash), - }, - } - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainWalletRegistry#getDkgResultApprovedEvents} - */ - async getDkgResultApprovedEvents( - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - const events: EthersEvent[] = await this.getEvents( - "DkgResultApproved", - options, - ...filterArgs - ) - - return events.map((event) => { - return { - blockNumber: BigNumber.from(event.blockNumber).toNumber(), - blockHash: Hex.from(event.blockHash), - transactionHash: Hex.from(event.transactionHash), - resultHash: Hex.from(event.args!.resultHash), - approver: Address.from(event.args!.approver), - } - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainWalletRegistry#getDkgResultChallengedEvents} - */ - async getDkgResultChallengedEvents( - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - const events: EthersEvent[] = await this.getEvents( - "DkgResultChallenged", - options, - ...filterArgs - ) - - return events.map((event) => { - return { - blockNumber: BigNumber.from(event.blockNumber).toNumber(), - blockHash: Hex.from(event.blockHash), - transactionHash: Hex.from(event.transactionHash), - resultHash: Hex.from(event.args!.resultHash), - challenger: Address.from(event.args!.challenger), - reason: event.args!.reason, - } - }) - } -} - -/** - * Implementation of the Ethereum TBTCVault handle. - */ -export class TBTCVault - extends EthereumContract - implements ChainTBTCVault -{ - constructor(config: ContractConfig) { - super(config, TBTCVaultDeployment) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCVault#optimisticMintingDelay} - */ - async optimisticMintingDelay(): Promise { - const delaySeconds = await backoffRetrier(this._totalRetryAttempts)( - async () => { - return await this._instance.optimisticMintingDelay() - } - ) - - return BigNumber.from(delaySeconds).toNumber() - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCVault#getMinters} - */ - async getMinters(): Promise { - const minters: string[] = await backoffRetrier( - this._totalRetryAttempts - )(async () => { - return await this._instance.getMinters() - }) - - return minters.map(Address.from) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCVault#isMinter} - */ - async isMinter(address: Address): Promise { - return await backoffRetrier(this._totalRetryAttempts)(async () => { - return await this._instance.isMinter(`0x${address.identifierHex}`) - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCVault#isGuardian} - */ - async isGuardian(address: Address): Promise { - return await backoffRetrier(this._totalRetryAttempts)(async () => { - return await this._instance.isGuardian(`0x${address.identifierHex}`) - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCVault#requestOptimisticMint} - */ - async requestOptimisticMint( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise { - const tx = await sendWithRetry( - async () => { - return await this._instance.requestOptimisticMint( - depositTxHash.reverse().toPrefixedString(), - depositOutputIndex - ) - }, - this._totalRetryAttempts, - undefined, - [ - "Optimistic minting already requested for the deposit", - "The deposit is already swept", - ] - ) - - return Hex.from(tx.hash) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCVault#cancelOptimisticMint} - */ - async cancelOptimisticMint( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise { - const tx = await sendWithRetry( - async () => { - return await this._instance.cancelOptimisticMint( - depositTxHash.reverse().toPrefixedString(), - depositOutputIndex - ) - }, - this._totalRetryAttempts, - undefined, - ["Optimistic minting already finalized for the deposit"] - ) - - return Hex.from(tx.hash) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCVault#finalizeOptimisticMint} - */ - async finalizeOptimisticMint( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise { - const tx = await sendWithRetry( - async () => { - return await this._instance.finalizeOptimisticMint( - depositTxHash.reverse().toPrefixedString(), - depositOutputIndex - ) - }, - this._totalRetryAttempts, - undefined, - [ - "Optimistic minting already finalized for the deposit", - "The deposit is already swept", - ] - ) - - return Hex.from(tx.hash) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCVault#optimisticMintingRequests} - */ - async optimisticMintingRequests( - depositTxHash: TransactionHash, - depositOutputIndex: number - ): Promise { - const depositKey = Bridge.buildDepositKey(depositTxHash, depositOutputIndex) - - const request: ContractOptimisticMintingRequest = - await backoffRetrier( - this._totalRetryAttempts - )(async () => { - return await this._instance.optimisticMintingRequests(depositKey) - }) - return this.parseOptimisticMintingRequest(request) - } - - /** - * Parses a optimistic minting request using data fetched from the on-chain contract. - * @param request Data of the optimistic minting request. - * @returns Parsed optimistic minting request. - */ - private parseOptimisticMintingRequest( - request: ContractOptimisticMintingRequest - ): OptimisticMintingRequest { - return { - requestedAt: BigNumber.from(request.requestedAt).toNumber(), - finalizedAt: BigNumber.from(request.finalizedAt).toNumber(), - } - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#getOptimisticMintingRequestedEvents} - */ - async getOptimisticMintingRequestedEvents( - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - const events = await this.getEvents( - "OptimisticMintingRequested", - options, - ...filterArgs - ) - - return events.map((event) => { - return { - blockNumber: BigNumber.from(event.blockNumber).toNumber(), - blockHash: Hex.from(event.blockHash), - transactionHash: Hex.from(event.transactionHash), - minter: new Address(event.args!.minter), - depositKey: Hex.from( - BigNumber.from(event.args!.depositKey).toHexString() - ), - depositor: new Address(event.args!.depositor), - amount: BigNumber.from(event.args!.amount), - fundingTxHash: TransactionHash.from( - event.args!.fundingTxHash - ).reverse(), - fundingOutputIndex: BigNumber.from( - event.args!.fundingOutputIndex - ).toNumber(), - } - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#getOptimisticMintingCancelledEvents} - */ - async getOptimisticMintingCancelledEvents( - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - const events = await this.getEvents( - "OptimisticMintingCancelled", - options, - ...filterArgs - ) - - return events.map((event) => { - return { - blockNumber: BigNumber.from(event.blockNumber).toNumber(), - blockHash: Hex.from(event.blockHash), - transactionHash: Hex.from(event.transactionHash), - guardian: new Address(event.args!.guardian), - depositKey: Hex.from( - BigNumber.from(event.args!.depositKey).toHexString() - ), - } - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainBridge#getOptimisticMintingFinalizedEvents} - */ - async getOptimisticMintingFinalizedEvents( - options?: GetEvents.Options, - ...filterArgs: Array - ): Promise { - const events = await this.getEvents( - "OptimisticMintingFinalized", - options, - ...filterArgs - ) - - return events.map((event) => { - return { - blockNumber: BigNumber.from(event.blockNumber).toNumber(), - blockHash: Hex.from(event.blockHash), - transactionHash: Hex.from(event.transactionHash), - minter: new Address(event.args!.minter), - depositKey: Hex.from( - BigNumber.from(event.args!.depositKey).toHexString() - ), - depositor: new Address(event.args!.depositor), - optimisticMintingDebt: BigNumber.from( - event.args!.optimisticMintingDebt - ), - } - }) - } -} - -/** - * Implementation of the Ethereum TBTC v2 token handle. - */ -export class TBTCToken - extends EthereumContract - implements ChainTBTCToken -{ - constructor(config: ContractConfig) { - super(config, TBTCDeployment) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCToken#totalSupply} - */ - async totalSupply(blockNumber?: number): Promise { - return this._instance.totalSupply({ - blockTag: blockNumber ?? "latest", - }) - } - - // eslint-disable-next-line valid-jsdoc - /** - * @see {ChainTBTCToken#requestRedemption} - */ - async requestRedemption( - walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, - redeemerOutputScript: string, - amount: BigNumber - ): Promise { - const redeemer = await this._instance?.signer?.getAddress() - if (!redeemer) { - throw new Error("Signer not provided") - } - - const vault = await this._instance.owner() - const extraData = this.buildRequestRedemptionData( - Address.from(redeemer), - walletPublicKey, - mainUtxo, - redeemerOutputScript - ) - - const tx = await sendWithRetry(async () => { - return await this._instance.approveAndCall( - vault, - amount, - extraData.toPrefixedString() - ) - }, this._totalRetryAttempts) - - return Hex.from(tx.hash) - } - - private buildRequestRedemptionData( - redeemer: Address, - walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, - redeemerOutputScript: string - ): Hex { - const { - walletPublicKeyHash, - prefixedRawRedeemerOutputScript, - mainUtxo: _mainUtxo, - } = this.buildBridgeRequestRedemptionData( - walletPublicKey, - mainUtxo, - redeemerOutputScript - ) - - return Hex.from( - utils.defaultAbiCoder.encode( - ["address", "bytes20", "bytes32", "uint32", "uint64", "bytes"], - [ - redeemer.identifierHex, - walletPublicKeyHash, - _mainUtxo.txHash, - _mainUtxo.txOutputIndex, - _mainUtxo.txOutputValue, - prefixedRawRedeemerOutputScript, - ] - ) - ) - } - - private buildBridgeRequestRedemptionData( - walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, - redeemerOutputScript: string - ) { - const walletPublicKeyHash = `0x${computeHash160(walletPublicKey)}` - - const mainUtxoParam = { - // The Ethereum Bridge expects this hash to be in the Bitcoin internal - // byte order. - txHash: mainUtxo.transactionHash.reverse().toPrefixedString(), - txOutputIndex: mainUtxo.outputIndex, - txOutputValue: mainUtxo.value, - } - - // Convert the output script to raw bytes buffer. - const rawRedeemerOutputScript = Buffer.from(redeemerOutputScript, "hex") - // Prefix the output script bytes buffer with 0x and its own length. - const prefixedRawRedeemerOutputScript = `0x${Buffer.concat([ - Buffer.from([rawRedeemerOutputScript.length]), - rawRedeemerOutputScript, - ]).toString("hex")}` - - return { - walletPublicKeyHash, - mainUtxo: mainUtxoParam, - prefixedRawRedeemerOutputScript, - } - } -} diff --git a/typescript/src/index.ts b/typescript/src/index.ts index a130de012..8fc6cb953 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -67,7 +67,7 @@ export { Address as EthereumAddress, TBTCVault as EthereumTBTCVault, TBTCToken as EthereumTBTCToken, -} from "./ethereum" +} from "./lib/ethereum" export { Hex } from "./hex" diff --git a/typescript/src/lib/ethereum/address.ts b/typescript/src/lib/ethereum/address.ts new file mode 100644 index 000000000..cd9f1a054 --- /dev/null +++ b/typescript/src/lib/ethereum/address.ts @@ -0,0 +1,32 @@ +import { Identifier as ChainIdentifier } from "../contracts" +import { utils } from "ethers" + +/** + * Represents an Ethereum address. + */ +// TODO: Make Address extends Hex +export class Address implements ChainIdentifier { + readonly identifierHex: string + + // TODO: Make constructor private + constructor(address: string) { + let validAddress: string + + try { + validAddress = utils.getAddress(address) + } catch (e) { + throw new Error(`Invalid Ethereum address`) + } + + this.identifierHex = validAddress.substring(2).toLowerCase() + } + + static from(address: string): Address { + return new Address(address) + } + + // TODO: Remove once extends Hex + equals(otherValue: Address): boolean { + return this.identifierHex === otherValue.identifierHex + } +} diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts new file mode 100644 index 000000000..3f444c7c7 --- /dev/null +++ b/typescript/src/lib/ethereum/bridge.ts @@ -0,0 +1,618 @@ +import { + Bridge as ContractBridge, + Deposit as ContractDeposit, + Redemption as ContractRedemption, + Wallets, +} from "../../../typechain/Bridge" +import { + Bridge as ChainBridge, + GetEvents, + Identifier as ChainIdentifier, + WalletRegistry as ChainWalletRegistry, +} from "../contracts" +import { + DepositRevealedEvent, + DepositScriptParameters, + RevealedDeposit, +} from "../../deposit" +import { Event as EthersEvent } from "@ethersproject/contracts" +import { BigNumber, constants, ContractTransaction, utils } from "ethers" +import { Hex } from "../../hex" +import { + compressPublicKey, + computeHash160, + DecomposedRawTransaction, + Proof, + readCompactSizeUint, + TransactionHash, + UnspentTransactionOutput, +} from "../bitcoin" +import { RedemptionRequest, RedemptionRequestedEvent } from "../../redemption" +import { backoffRetrier } from "../../backoff" +import { NewWalletRegisteredEvent, Wallet, WalletState } from "../../wallet" +import { + ContractConfig, + EthereumContract, + sendWithRetry, +} from "./contract-handle" +import BridgeDeployment from "@keep-network/tbtc-v2/artifacts/Bridge.json" +import { Address } from "./address" +import { WalletRegistry } from "./wallet-registry" + +type ContractDepositRequest = ContractDeposit.DepositRequestStructOutput + +type ContractRedemptionRequest = + ContractRedemption.RedemptionRequestStructOutput + +/** + * Implementation of the Ethereum Bridge handle. + * @see {ChainBridge} for reference. + */ +export class Bridge + extends EthereumContract + implements ChainBridge +{ + constructor(config: ContractConfig) { + super(config, BridgeDeployment) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#getDepositRevealedEvents} + */ + async getDepositRevealedEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + const events: EthersEvent[] = await this.getEvents( + "DepositRevealed", + options, + ...filterArgs + ) + + return events.map((event) => { + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + fundingTxHash: TransactionHash.from( + event.args!.fundingTxHash + ).reverse(), + fundingOutputIndex: BigNumber.from( + event.args!.fundingOutputIndex + ).toNumber(), + depositor: new Address(event.args!.depositor), + amount: BigNumber.from(event.args!.amount), + blindingFactor: Hex.from(event.args!.blindingFactor).toString(), + walletPublicKeyHash: Hex.from(event.args!.walletPubKeyHash).toString(), + refundPublicKeyHash: Hex.from(event.args!.refundPubKeyHash).toString(), + refundLocktime: Hex.from(event.args!.refundLocktime).toString(), + vault: + event.args!.vault === constants.AddressZero + ? undefined + : new Address(event.args!.vault), + } + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#pendingRedemptions} + */ + async pendingRedemptions( + walletPublicKey: string, + redeemerOutputScript: string + ): Promise { + const redemptionKey = Bridge.buildRedemptionKey( + computeHash160(walletPublicKey), + redeemerOutputScript + ) + + const request: ContractRedemptionRequest = + await backoffRetrier(this._totalRetryAttempts)( + async () => { + return await this._instance.pendingRedemptions(redemptionKey) + } + ) + + return this.parseRedemptionRequest(request, redeemerOutputScript) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#timedOutRedemptions} + */ + async timedOutRedemptions( + walletPublicKey: string, + redeemerOutputScript: string + ): Promise { + const redemptionKey = Bridge.buildRedemptionKey( + computeHash160(walletPublicKey), + redeemerOutputScript + ) + + const request: ContractRedemptionRequest = + await backoffRetrier(this._totalRetryAttempts)( + async () => { + return await this._instance.timedOutRedemptions(redemptionKey) + } + ) + + return this.parseRedemptionRequest(request, redeemerOutputScript) + } + + /** + * Builds a redemption key required to refer a redemption request. + * @param walletPublicKeyHash The wallet public key hash that identifies the + * pending redemption (along with the redeemer output script). Must be + * unprefixed. + * @param redeemerOutputScript The redeemer output script that identifies the + * pending redemption (along with the wallet public key hash). Must be + * un-prefixed and not prepended with length. + * @returns The redemption key. + */ + static buildRedemptionKey( + walletPublicKeyHash: string, + redeemerOutputScript: string + ): string { + // Convert the output script to raw bytes buffer. + const rawRedeemerOutputScript = Buffer.from(redeemerOutputScript, "hex") + // Prefix the output script bytes buffer with 0x and its own length. + const prefixedRawRedeemerOutputScript = `0x${Buffer.concat([ + Buffer.from([rawRedeemerOutputScript.length]), + rawRedeemerOutputScript, + ]).toString("hex")}` + // Build the redemption key by using the 0x-prefixed wallet PKH and + // prefixed output script. + return utils.solidityKeccak256( + ["bytes32", "bytes20"], + [ + utils.solidityKeccak256(["bytes"], [prefixedRawRedeemerOutputScript]), + `0x${walletPublicKeyHash}`, + ] + ) + } + + /** + * Parses a redemption request using data fetched from the on-chain contract. + * @param request Data of the request. + * @param redeemerOutputScript The redeemer output script that identifies the + * pending redemption (along with the wallet public key hash). Must be + * un-prefixed and not prepended with length. + * @returns Parsed redemption request. + */ + private parseRedemptionRequest( + request: ContractRedemptionRequest, + redeemerOutputScript: string + ): RedemptionRequest { + return { + redeemer: new Address(request.redeemer), + redeemerOutputScript: redeemerOutputScript, + requestedAmount: BigNumber.from(request.requestedAmount), + treasuryFee: BigNumber.from(request.treasuryFee), + txMaxFee: BigNumber.from(request.txMaxFee), + requestedAt: BigNumber.from(request.requestedAt).toNumber(), + } + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#revealDeposit} + */ + async revealDeposit( + depositTx: DecomposedRawTransaction, + depositOutputIndex: number, + deposit: DepositScriptParameters, + vault?: ChainIdentifier + ): Promise { + const depositTxParam = { + version: `0x${depositTx.version}`, + inputVector: `0x${depositTx.inputs}`, + outputVector: `0x${depositTx.outputs}`, + locktime: `0x${depositTx.locktime}`, + } + + const revealParam = { + fundingOutputIndex: depositOutputIndex, + blindingFactor: `0x${deposit.blindingFactor}`, + walletPubKeyHash: `0x${deposit.walletPublicKeyHash}`, + refundPubKeyHash: `0x${deposit.refundPublicKeyHash}`, + refundLocktime: `0x${deposit.refundLocktime}`, + vault: vault ? `0x${vault.identifierHex}` : constants.AddressZero, + } + + const tx = await sendWithRetry( + async () => { + return await this._instance.revealDeposit(depositTxParam, revealParam) + }, + this._totalRetryAttempts, + undefined, + ["Deposit already revealed"] + ) + + return tx.hash + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#submitDepositSweepProof} + */ + async submitDepositSweepProof( + sweepTx: DecomposedRawTransaction, + sweepProof: Proof, + mainUtxo: UnspentTransactionOutput, + vault?: ChainIdentifier + ): Promise { + const sweepTxParam = { + version: `0x${sweepTx.version}`, + inputVector: `0x${sweepTx.inputs}`, + outputVector: `0x${sweepTx.outputs}`, + locktime: `0x${sweepTx.locktime}`, + } + + const sweepProofParam = { + merkleProof: `0x${sweepProof.merkleProof}`, + txIndexInBlock: sweepProof.txIndexInBlock, + bitcoinHeaders: `0x${sweepProof.bitcoinHeaders}`, + } + + const mainUtxoParam = { + // The Ethereum Bridge expects this hash to be in the Bitcoin internal + // byte order. + txHash: mainUtxo.transactionHash.reverse().toPrefixedString(), + txOutputIndex: mainUtxo.outputIndex, + txOutputValue: mainUtxo.value, + } + + const vaultParam = vault + ? `0x${vault.identifierHex}` + : constants.AddressZero + + await sendWithRetry(async () => { + return await this._instance.submitDepositSweepProof( + sweepTxParam, + sweepProofParam, + mainUtxoParam, + vaultParam + ) + }, this._totalRetryAttempts) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#txProofDifficultyFactor} + */ + async txProofDifficultyFactor(): Promise { + const txProofDifficultyFactor: BigNumber = await backoffRetrier( + this._totalRetryAttempts + )(async () => { + return await this._instance.txProofDifficultyFactor() + }) + + return txProofDifficultyFactor.toNumber() + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#requestRedemption} + */ + async requestRedemption( + walletPublicKey: string, + mainUtxo: UnspentTransactionOutput, + redeemerOutputScript: string, + amount: BigNumber + ): Promise { + const walletPublicKeyHash = `0x${computeHash160(walletPublicKey)}` + + const mainUtxoParam = { + // The Ethereum Bridge expects this hash to be in the Bitcoin internal + // byte order. + txHash: mainUtxo.transactionHash.reverse().toPrefixedString(), + txOutputIndex: mainUtxo.outputIndex, + txOutputValue: mainUtxo.value, + } + + // Convert the output script to raw bytes buffer. + const rawRedeemerOutputScript = Buffer.from(redeemerOutputScript, "hex") + // Prefix the output script bytes buffer with 0x and its own length. + const prefixedRawRedeemerOutputScript = `0x${Buffer.concat([ + Buffer.from([rawRedeemerOutputScript.length]), + rawRedeemerOutputScript, + ]).toString("hex")}` + + await sendWithRetry(async () => { + return await this._instance.requestRedemption( + walletPublicKeyHash, + mainUtxoParam, + prefixedRawRedeemerOutputScript, + amount + ) + }, this._totalRetryAttempts) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#submitRedemptionProof} + */ + async submitRedemptionProof( + redemptionTx: DecomposedRawTransaction, + redemptionProof: Proof, + mainUtxo: UnspentTransactionOutput, + walletPublicKey: string + ): Promise { + const redemptionTxParam = { + version: `0x${redemptionTx.version}`, + inputVector: `0x${redemptionTx.inputs}`, + outputVector: `0x${redemptionTx.outputs}`, + locktime: `0x${redemptionTx.locktime}`, + } + + const redemptionProofParam = { + merkleProof: `0x${redemptionProof.merkleProof}`, + txIndexInBlock: redemptionProof.txIndexInBlock, + bitcoinHeaders: `0x${redemptionProof.bitcoinHeaders}`, + } + + const mainUtxoParam = { + // The Ethereum Bridge expects this hash to be in the Bitcoin internal + // byte order. + txHash: mainUtxo.transactionHash.reverse().toPrefixedString(), + txOutputIndex: mainUtxo.outputIndex, + txOutputValue: mainUtxo.value, + } + + const walletPublicKeyHash = `0x${computeHash160(walletPublicKey)}` + + await sendWithRetry(async () => { + return await this._instance.submitRedemptionProof( + redemptionTxParam, + redemptionProofParam, + mainUtxoParam, + walletPublicKeyHash + ) + }, this._totalRetryAttempts) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#deposits} + */ + async deposits( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise { + const depositKey = Bridge.buildDepositKey(depositTxHash, depositOutputIndex) + + const deposit: ContractDepositRequest = + await backoffRetrier(this._totalRetryAttempts)( + async () => { + return await this._instance.deposits(depositKey) + } + ) + + return this.parseRevealedDeposit(deposit) + } + + /** + * Builds the deposit key required to refer a revealed deposit. + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Deposit key. + */ + static buildDepositKey( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): string { + const prefixedReversedDepositTxHash = depositTxHash + .reverse() + .toPrefixedString() + + return utils.solidityKeccak256( + ["bytes32", "uint32"], + [prefixedReversedDepositTxHash, depositOutputIndex] + ) + } + + /** + * Parses a revealed deposit using data fetched from the on-chain contract. + * @param deposit Data of the revealed deposit. + * @returns Parsed revealed deposit. + */ + private parseRevealedDeposit( + deposit: ContractDepositRequest + ): RevealedDeposit { + return { + depositor: new Address(deposit.depositor), + amount: BigNumber.from(deposit.amount), + vault: + deposit.vault === constants.AddressZero + ? undefined + : new Address(deposit.vault), + revealedAt: BigNumber.from(deposit.revealedAt).toNumber(), + sweptAt: BigNumber.from(deposit.sweptAt).toNumber(), + treasuryFee: BigNumber.from(deposit.treasuryFee), + } + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#activeWalletPublicKey} + */ + async activeWalletPublicKey(): Promise { + const activeWalletPublicKeyHash: string = await backoffRetrier( + this._totalRetryAttempts + )(async () => { + return await this._instance.activeWalletPubKeyHash() + }) + + if ( + activeWalletPublicKeyHash === "0x0000000000000000000000000000000000000000" + ) { + // If there is no active wallet currently, return undefined. + return undefined + } + + const { walletPublicKey } = await this.wallets( + Hex.from(activeWalletPublicKeyHash) + ) + + return walletPublicKey.toString() + } + + private async getWalletCompressedPublicKey(ecdsaWalletID: Hex): Promise { + const walletRegistry = await this.walletRegistry() + const uncompressedPublicKey = await walletRegistry.getWalletPublicKey( + ecdsaWalletID + ) + + return Hex.from(compressPublicKey(uncompressedPublicKey)) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#getNewWalletRegisteredEvents} + */ + async getNewWalletRegisteredEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + const events: EthersEvent[] = await this.getEvents( + "NewWalletRegistered", + options, + ...filterArgs + ) + + return events.map((event) => { + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + ecdsaWalletID: Hex.from(event.args!.ecdsaWalletID), + walletPublicKeyHash: Hex.from(event.args!.walletPubKeyHash), + } + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#walletRegistry} + */ + async walletRegistry(): Promise { + const { ecdsaWalletRegistry } = await backoffRetrier<{ + ecdsaWalletRegistry: string + }>(this._totalRetryAttempts)(async () => { + return await this._instance.contractReferences() + }) + + return new WalletRegistry({ + address: ecdsaWalletRegistry, + signerOrProvider: this._instance.signer || this._instance.provider, + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#wallets} + */ + async wallets(walletPublicKeyHash: Hex): Promise { + const wallet = await backoffRetrier( + this._totalRetryAttempts + )(async () => { + return await this._instance.wallets( + walletPublicKeyHash.toPrefixedString() + ) + }) + + return this.parseWalletDetails(wallet) + } + + /** + * Parses a wallet data using data fetched from the on-chain contract. + * @param wallet Data of the wallet. + * @returns Parsed wallet data. + */ + private async parseWalletDetails( + wallet: Wallets.WalletStructOutput + ): Promise { + const ecdsaWalletID = Hex.from(wallet.ecdsaWalletID) + + return { + ecdsaWalletID, + walletPublicKey: await this.getWalletCompressedPublicKey(ecdsaWalletID), + mainUtxoHash: Hex.from(wallet.mainUtxoHash), + pendingRedemptionsValue: wallet.pendingRedemptionsValue, + createdAt: wallet.createdAt, + movingFundsRequestedAt: wallet.movingFundsRequestedAt, + closingStartedAt: wallet.closingStartedAt, + pendingMovedFundsSweepRequestsCount: + wallet.pendingMovedFundsSweepRequestsCount, + state: WalletState.parse(wallet.state), + movingFundsTargetWalletsCommitmentHash: Hex.from( + wallet.movingFundsTargetWalletsCommitmentHash + ), + } + } + + // eslint-disable-next-line valid-jsdoc + /** + * Builds the UTXO hash based on the UTXO components. UTXO hash is computed as + * `keccak256(txHash | txOutputIndex | txOutputValue)`. + * + * @see {ChainBridge#buildUtxoHash} + */ + buildUtxoHash(utxo: UnspentTransactionOutput): Hex { + return Hex.from( + utils.solidityKeccak256( + ["bytes32", "uint32", "uint64"], + [ + utxo.transactionHash.reverse().toPrefixedString(), + utxo.outputIndex, + utxo.value, + ] + ) + ) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#getDepositRevealedEvents} + */ + async getRedemptionRequestedEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + // FIXME: Filtering by indexed walletPubKeyHash field may not work + // until https://github.com/ethers-io/ethers.js/pull/4244 is + // included in the currently used version of ethers.js. + // Ultimately, we should upgrade ethers.js to include that fix. + // Short-term, we can workaround the problem as presented in: + // https://github.com/threshold-network/token-dashboard/blob/main/src/threshold-ts/tbtc/index.ts#L1041C1-L1093C1 + const events: EthersEvent[] = await this.getEvents( + "RedemptionRequested", + options, + ...filterArgs + ) + + return events.map((event) => { + const prefixedRedeemerOutputScript = Hex.from( + event.args!.redeemerOutputScript + ) + const redeemerOutputScript = prefixedRedeemerOutputScript + .toString() + .slice(readCompactSizeUint(prefixedRedeemerOutputScript).byteLength * 2) + + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + walletPublicKeyHash: Hex.from(event.args!.walletPubKeyHash).toString(), + redeemer: new Address(event.args!.redeemer), + redeemerOutputScript: redeemerOutputScript, + requestedAmount: BigNumber.from(event.args!.requestedAmount), + treasuryFee: BigNumber.from(event.args!.treasuryFee), + txMaxFee: BigNumber.from(event.args!.txMaxFee), + } + }) + } +} diff --git a/typescript/src/ethereum-helpers.ts b/typescript/src/lib/ethereum/contract-handle.ts similarity index 56% rename from typescript/src/ethereum-helpers.ts rename to typescript/src/lib/ethereum/contract-handle.ts index 456016476..c5ba09813 100644 --- a/typescript/src/ethereum-helpers.ts +++ b/typescript/src/lib/ethereum/contract-handle.ts @@ -1,15 +1,145 @@ +import { providers, Signer, utils } from "ethers" import { Contract as EthersContract, Event as EthersEvent, EventFilter as EthersEventFilter, -} from "ethers" +} from "@ethersproject/contracts" +import { GetEvents } from "../contracts" import { backoffRetrier, - skipRetryWhenMatched, ExecutionLoggerFn, -} from "./backoff" + skipRetryWhenMatched, +} from "../../backoff" +import { Address } from "./address" -const GET_EVENTS_BLOCK_INTERVAL = 10_000 +/** + * Contract deployment artifact. + * @see [hardhat-deploy#Deployment](https://github.com/wighawag/hardhat-deploy/blob/0c969e9a27b4eeff9f5ccac7e19721ef2329eed2/types.ts#L358)} + */ +export interface Deployment { + /** + * Address of the deployed contract. + */ + address: string + /** + * Contract's ABI. + */ + abi: any[] + /** + * Deployment transaction receipt. + */ + receipt: { + /** + * Number of block in which the contract was deployed. + */ + blockNumber: number + } +} + +/** + * Represents a config set required to connect an Ethereum contract. + */ +export interface ContractConfig { + /** + * Address of the Ethereum contract as a 0x-prefixed hex string. + * Optional parameter, if not provided the value will be resolved from the + * contract artifact. + */ + address?: string + /** + * Signer - will return a Contract which will act on behalf of that signer. The signer will sign all contract transactions. + * Provider - will return a downgraded Contract which only has read-only access (i.e. constant calls) + */ + signerOrProvider: Signer | providers.Provider + /** + * Number of a block in which the contract was deployed. + * Optional parameter, if not provided the value will be resolved from the + * contract artifact. + */ + deployedAtBlockNumber?: number +} + +/** + * Deployed Ethereum contract + */ +export class EthereumContract { + /** + * Ethers instance of the deployed contract. + */ + protected readonly _instance: T + /** + * Number of a block within which the contract was deployed. Value is read from + * the contract deployment artifact. It can be overwritten by setting a + * {@link ContractConfig.deployedAtBlockNumber} property. + */ + protected readonly _deployedAtBlockNumber: number + /** + * Number of retries for ethereum requests. + */ + protected readonly _totalRetryAttempts: number + + /** + * @param config Configuration for contract instance initialization. + * @param deployment Contract Deployment artifact. + * @param totalRetryAttempts Number of retries for ethereum requests. + */ + constructor( + config: ContractConfig, + deployment: Deployment, + totalRetryAttempts = 3 + ) { + this._instance = new EthersContract( + config.address ?? utils.getAddress(deployment.address), + `${JSON.stringify(deployment.abi)}`, + config.signerOrProvider + ) as T + + this._deployedAtBlockNumber = + config.deployedAtBlockNumber ?? deployment.receipt.blockNumber + + this._totalRetryAttempts = totalRetryAttempts + } + + /** + * Get address of the contract instance. + * @returns Address of this contract instance. + */ + getAddress(): Address { + return Address.from(this._instance.address) + } + + /** + * Get events emitted by the Ethereum contract. + * It starts searching from provided block number. If the {@link GetEvents.Options#fromBlock} + * option is missing it looks for a contract's defined property + * {@link _deployedAtBlockNumber}. If the property is missing starts searching + * from block `0`. + * @param eventName Name of the event. + * @param options Options for events fetching. + * @param filterArgs Arguments for events filtering. + * @returns Array of found events. + */ + async getEvents( + eventName: string, + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + // TODO: Test if we need a workaround for querying events from big range in chunks, + // see: https://github.com/keep-network/tbtc-monitoring/blob/e169357d7b8c638d4eaf73d52aa8f53ee4aebc1d/src/lib/ethereum-helper.js#L44-L73 + return backoffRetrier( + options?.retries ?? this._totalRetryAttempts + )(async () => { + return await getEvents( + this._instance, + this._instance.filters[eventName](...filterArgs), + options?.fromBlock ?? this._deployedAtBlockNumber, + options?.toBlock, + options?.batchedQueryBlockInterval, + options?.logger + ) + }) + } +} /** * Sends ethereum transaction with retries. @@ -80,6 +210,8 @@ function resolveEthersError(err: unknown): unknown { return err } +const GET_EVENTS_BLOCK_INTERVAL = 10_000 + /** * Looks up all existing events defined by the {@link event} filter on * {@link sourceContract}, searching past blocks and then returning them. @@ -97,7 +229,7 @@ function resolveEthersError(err: unknown): unknown { * @returns A promise that will be fulfilled by the list of event objects once * they are found. */ -export async function getEvents( +async function getEvents( sourceContract: EthersContract, event: EthersEventFilter, fromBlock: number = 0, diff --git a/typescript/src/lib/ethereum/index.ts b/typescript/src/lib/ethereum/index.ts new file mode 100644 index 000000000..e6ac22fcf --- /dev/null +++ b/typescript/src/lib/ethereum/index.ts @@ -0,0 +1,10 @@ +export * from "./address" +export * from "./bridge" +export * from "./tbtc-token" +export * from "./tbtc-vault" +export * from "./wallet-registry" + +// The `contract-handle` module should not be re-exported directly as it +// contains low-level contract integration code. Re-export only components +// that are relevant for `lib/ethereum` clients. +export { ContractConfig } from "./contract-handle" diff --git a/typescript/src/lib/ethereum/tbtc-token.ts b/typescript/src/lib/ethereum/tbtc-token.ts new file mode 100644 index 000000000..37b63df31 --- /dev/null +++ b/typescript/src/lib/ethereum/tbtc-token.ts @@ -0,0 +1,129 @@ +import { TBTC as ContractTBTC } from "../../../typechain/TBTC" +import { TBTCToken as ChainTBTCToken } from "../contracts" +import { BigNumber, ContractTransaction, utils } from "ethers" +import { computeHash160, UnspentTransactionOutput } from "../bitcoin" +import { Hex } from "../../hex" +import { + ContractConfig, + EthereumContract, + sendWithRetry, +} from "./contract-handle" +import TBTCDeployment from "@keep-network/tbtc-v2/artifacts/TBTC.json" +import { Address } from "./address" + +/** + * Implementation of the Ethereum TBTC v2 token handle. + */ +export class TBTCToken + extends EthereumContract + implements ChainTBTCToken +{ + constructor(config: ContractConfig) { + super(config, TBTCDeployment) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCToken#totalSupply} + */ + async totalSupply(blockNumber?: number): Promise { + return this._instance.totalSupply({ + blockTag: blockNumber ?? "latest", + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCToken#requestRedemption} + */ + async requestRedemption( + walletPublicKey: string, + mainUtxo: UnspentTransactionOutput, + redeemerOutputScript: string, + amount: BigNumber + ): Promise { + const redeemer = await this._instance?.signer?.getAddress() + if (!redeemer) { + throw new Error("Signer not provided") + } + + const vault = await this._instance.owner() + const extraData = this.buildRequestRedemptionData( + Address.from(redeemer), + walletPublicKey, + mainUtxo, + redeemerOutputScript + ) + + const tx = await sendWithRetry(async () => { + return await this._instance.approveAndCall( + vault, + amount, + extraData.toPrefixedString() + ) + }, this._totalRetryAttempts) + + return Hex.from(tx.hash) + } + + private buildRequestRedemptionData( + redeemer: Address, + walletPublicKey: string, + mainUtxo: UnspentTransactionOutput, + redeemerOutputScript: string + ): Hex { + const { + walletPublicKeyHash, + prefixedRawRedeemerOutputScript, + mainUtxo: _mainUtxo, + } = this.buildBridgeRequestRedemptionData( + walletPublicKey, + mainUtxo, + redeemerOutputScript + ) + + return Hex.from( + utils.defaultAbiCoder.encode( + ["address", "bytes20", "bytes32", "uint32", "uint64", "bytes"], + [ + redeemer.identifierHex, + walletPublicKeyHash, + _mainUtxo.txHash, + _mainUtxo.txOutputIndex, + _mainUtxo.txOutputValue, + prefixedRawRedeemerOutputScript, + ] + ) + ) + } + + private buildBridgeRequestRedemptionData( + walletPublicKey: string, + mainUtxo: UnspentTransactionOutput, + redeemerOutputScript: string + ) { + const walletPublicKeyHash = `0x${computeHash160(walletPublicKey)}` + + const mainUtxoParam = { + // The Ethereum Bridge expects this hash to be in the Bitcoin internal + // byte order. + txHash: mainUtxo.transactionHash.reverse().toPrefixedString(), + txOutputIndex: mainUtxo.outputIndex, + txOutputValue: mainUtxo.value, + } + + // Convert the output script to raw bytes buffer. + const rawRedeemerOutputScript = Buffer.from(redeemerOutputScript, "hex") + // Prefix the output script bytes buffer with 0x and its own length. + const prefixedRawRedeemerOutputScript = `0x${Buffer.concat([ + Buffer.from([rawRedeemerOutputScript.length]), + rawRedeemerOutputScript, + ]).toString("hex")}` + + return { + walletPublicKeyHash, + mainUtxo: mainUtxoParam, + prefixedRawRedeemerOutputScript, + } + } +} diff --git a/typescript/src/lib/ethereum/tbtc-vault.ts b/typescript/src/lib/ethereum/tbtc-vault.ts new file mode 100644 index 000000000..bf5f8c5d5 --- /dev/null +++ b/typescript/src/lib/ethereum/tbtc-vault.ts @@ -0,0 +1,286 @@ +import { TBTCVault as ContractTBTCVault } from "../../../typechain/TBTCVault" +import { GetEvents, TBTCVault as ChainTBTCVault } from "../contracts" +import { backoffRetrier } from "../../backoff" +import { BigNumber, ContractTransaction } from "ethers" +import { TransactionHash } from "../bitcoin" +import { Hex } from "../../hex" +import { + OptimisticMintingCancelledEvent, + OptimisticMintingFinalizedEvent, + OptimisticMintingRequest, + OptimisticMintingRequestedEvent, +} from "../../optimistic-minting" +import TBTCVaultDeployment from "@keep-network/tbtc-v2/artifacts/TBTCVault.json" +import { + ContractConfig, + EthereumContract, + sendWithRetry, +} from "./contract-handle" +import { Address } from "./address" +import { Bridge } from "./bridge" + +type ContractOptimisticMintingRequest = { + requestedAt: BigNumber + finalizedAt: BigNumber +} + +/** + * Implementation of the Ethereum TBTCVault handle. + */ +export class TBTCVault + extends EthereumContract + implements ChainTBTCVault +{ + constructor(config: ContractConfig) { + super(config, TBTCVaultDeployment) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCVault#optimisticMintingDelay} + */ + async optimisticMintingDelay(): Promise { + const delaySeconds = await backoffRetrier(this._totalRetryAttempts)( + async () => { + return await this._instance.optimisticMintingDelay() + } + ) + + return BigNumber.from(delaySeconds).toNumber() + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCVault#getMinters} + */ + async getMinters(): Promise { + const minters: string[] = await backoffRetrier( + this._totalRetryAttempts + )(async () => { + return await this._instance.getMinters() + }) + + return minters.map(Address.from) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCVault#isMinter} + */ + async isMinter(address: Address): Promise { + return await backoffRetrier(this._totalRetryAttempts)(async () => { + return await this._instance.isMinter(`0x${address.identifierHex}`) + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCVault#isGuardian} + */ + async isGuardian(address: Address): Promise { + return await backoffRetrier(this._totalRetryAttempts)(async () => { + return await this._instance.isGuardian(`0x${address.identifierHex}`) + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCVault#requestOptimisticMint} + */ + async requestOptimisticMint( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise { + const tx = await sendWithRetry( + async () => { + return await this._instance.requestOptimisticMint( + depositTxHash.reverse().toPrefixedString(), + depositOutputIndex + ) + }, + this._totalRetryAttempts, + undefined, + [ + "Optimistic minting already requested for the deposit", + "The deposit is already swept", + ] + ) + + return Hex.from(tx.hash) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCVault#cancelOptimisticMint} + */ + async cancelOptimisticMint( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise { + const tx = await sendWithRetry( + async () => { + return await this._instance.cancelOptimisticMint( + depositTxHash.reverse().toPrefixedString(), + depositOutputIndex + ) + }, + this._totalRetryAttempts, + undefined, + ["Optimistic minting already finalized for the deposit"] + ) + + return Hex.from(tx.hash) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCVault#finalizeOptimisticMint} + */ + async finalizeOptimisticMint( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise { + const tx = await sendWithRetry( + async () => { + return await this._instance.finalizeOptimisticMint( + depositTxHash.reverse().toPrefixedString(), + depositOutputIndex + ) + }, + this._totalRetryAttempts, + undefined, + [ + "Optimistic minting already finalized for the deposit", + "The deposit is already swept", + ] + ) + + return Hex.from(tx.hash) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainTBTCVault#optimisticMintingRequests} + */ + async optimisticMintingRequests( + depositTxHash: TransactionHash, + depositOutputIndex: number + ): Promise { + const depositKey = Bridge.buildDepositKey(depositTxHash, depositOutputIndex) + + const request: ContractOptimisticMintingRequest = + await backoffRetrier( + this._totalRetryAttempts + )(async () => { + return await this._instance.optimisticMintingRequests(depositKey) + }) + return this.parseOptimisticMintingRequest(request) + } + + /** + * Parses a optimistic minting request using data fetched from the on-chain contract. + * @param request Data of the optimistic minting request. + * @returns Parsed optimistic minting request. + */ + private parseOptimisticMintingRequest( + request: ContractOptimisticMintingRequest + ): OptimisticMintingRequest { + return { + requestedAt: BigNumber.from(request.requestedAt).toNumber(), + finalizedAt: BigNumber.from(request.finalizedAt).toNumber(), + } + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#getOptimisticMintingRequestedEvents} + */ + async getOptimisticMintingRequestedEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + const events = await this.getEvents( + "OptimisticMintingRequested", + options, + ...filterArgs + ) + + return events.map((event) => { + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + minter: new Address(event.args!.minter), + depositKey: Hex.from( + BigNumber.from(event.args!.depositKey).toHexString() + ), + depositor: new Address(event.args!.depositor), + amount: BigNumber.from(event.args!.amount), + fundingTxHash: TransactionHash.from( + event.args!.fundingTxHash + ).reverse(), + fundingOutputIndex: BigNumber.from( + event.args!.fundingOutputIndex + ).toNumber(), + } + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#getOptimisticMintingCancelledEvents} + */ + async getOptimisticMintingCancelledEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + const events = await this.getEvents( + "OptimisticMintingCancelled", + options, + ...filterArgs + ) + + return events.map((event) => { + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + guardian: new Address(event.args!.guardian), + depositKey: Hex.from( + BigNumber.from(event.args!.depositKey).toHexString() + ), + } + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainBridge#getOptimisticMintingFinalizedEvents} + */ + async getOptimisticMintingFinalizedEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + const events = await this.getEvents( + "OptimisticMintingFinalized", + options, + ...filterArgs + ) + + return events.map((event) => { + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + minter: new Address(event.args!.minter), + depositKey: Hex.from( + BigNumber.from(event.args!.depositKey).toHexString() + ), + depositor: new Address(event.args!.depositor), + optimisticMintingDebt: BigNumber.from( + event.args!.optimisticMintingDebt + ), + } + }) + } +} diff --git a/typescript/src/lib/ethereum/wallet-registry.ts b/typescript/src/lib/ethereum/wallet-registry.ts new file mode 100644 index 000000000..92502fb18 --- /dev/null +++ b/typescript/src/lib/ethereum/wallet-registry.ts @@ -0,0 +1,136 @@ +import { WalletRegistry as ContractWalletRegistry } from "../../../typechain/WalletRegistry" +import { GetEvents, WalletRegistry as ChainWalletRegistry } from "../contracts" +import { Hex } from "../../hex" +import { backoffRetrier } from "../../backoff" +import { + DkgResultApprovedEvent, + DkgResultChallengedEvent, + DkgResultSubmittedEvent, +} from "../../wallet" +import { Event as EthersEvent } from "@ethersproject/contracts" +import { BigNumber } from "ethers" +import WalletRegistryDeployment from "@keep-network/ecdsa/artifacts/WalletRegistry.json" +import { ContractConfig, EthereumContract } from "./contract-handle" +import { Address } from "./address" + +/** + * Implementation of the Ethereum WalletRegistry handle. + * @see {ChainWalletRegistry} for reference. + */ +export class WalletRegistry + extends EthereumContract + implements ChainWalletRegistry +{ + constructor(config: ContractConfig) { + super(config, WalletRegistryDeployment) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainWalletRegistry#getWalletPublicKey} + */ + async getWalletPublicKey(walletID: Hex): Promise { + const publicKey = await backoffRetrier(this._totalRetryAttempts)( + async () => { + return await this._instance.getWalletPublicKey( + walletID.toPrefixedString() + ) + } + ) + return Hex.from(publicKey.substring(2)) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainWalletRegistry#getDkgResultSubmittedEvents} + */ + async getDkgResultSubmittedEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + const events: EthersEvent[] = await this.getEvents( + "DkgResultSubmitted", + options, + ...filterArgs + ) + + return events.map((event) => { + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + resultHash: Hex.from(event.args!.resultHash), + seed: Hex.from(BigNumber.from(event.args!.seed).toHexString()), + result: { + submitterMemberIndex: BigNumber.from( + event.args!.result.submitterMemberIndex + ), + groupPubKey: Hex.from(event.args!.result.groupPubKey), + misbehavedMembersIndices: + event.args!.result.misbehavedMembersIndices.map((mmi: unknown) => + BigNumber.from(mmi).toNumber() + ), + signatures: Hex.from(event.args!.result.signatures), + signingMembersIndices: event.args!.result.signingMembersIndices.map( + BigNumber.from + ), + members: event.args!.result.members.map((m: unknown) => + BigNumber.from(m).toNumber() + ), + membersHash: Hex.from(event.args!.result.membersHash), + }, + } + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainWalletRegistry#getDkgResultApprovedEvents} + */ + async getDkgResultApprovedEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + const events: EthersEvent[] = await this.getEvents( + "DkgResultApproved", + options, + ...filterArgs + ) + + return events.map((event) => { + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + resultHash: Hex.from(event.args!.resultHash), + approver: Address.from(event.args!.approver), + } + }) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {ChainWalletRegistry#getDkgResultChallengedEvents} + */ + async getDkgResultChallengedEvents( + options?: GetEvents.Options, + ...filterArgs: Array + ): Promise { + const events: EthersEvent[] = await this.getEvents( + "DkgResultChallenged", + options, + ...filterArgs + ) + + return events.map((event) => { + return { + blockNumber: BigNumber.from(event.blockNumber).toNumber(), + blockHash: Hex.from(event.blockHash), + transactionHash: Hex.from(event.transactionHash), + resultHash: Hex.from(event.args!.resultHash), + challenger: Address.from(event.args!.challenger), + reason: event.args!.reason, + } + }) + } +} diff --git a/typescript/test/data/deposit-refund.ts b/typescript/test/data/deposit-refund.ts index 880f6a896..ebb835187 100644 --- a/typescript/test/data/deposit-refund.ts +++ b/typescript/test/data/deposit-refund.ts @@ -5,7 +5,7 @@ import { TransactionHash, } from "../../src/lib/bitcoin" import { Deposit, calculateDepositRefundLocktime } from "../../src/deposit" -import { Address } from "../../src/ethereum" +import { Address } from "../../src/lib/ethereum" /** * Testnet private key that can be used to refund the deposits used in tests. diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index 1992cdb85..e567dce0f 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -9,7 +9,7 @@ import { } from "../../src/lib/bitcoin" import { calculateDepositRefundLocktime, Deposit } from "../../src/deposit" import { BigNumber } from "ethers" -import { Address } from "../../src/ethereum" +import { Address } from "../../src/lib/ethereum" import { Hex } from "../../src" export const NO_MAIN_UTXO = { diff --git a/typescript/test/data/redemption.ts b/typescript/test/data/redemption.ts index d9e232445..46c695c9b 100644 --- a/typescript/test/data/redemption.ts +++ b/typescript/test/data/redemption.ts @@ -10,8 +10,8 @@ import { createOutputScriptFromAddress, } from "../../src/lib/bitcoin" import { RedemptionRequest } from "../../src/redemption" -import { Address } from "../../src/ethereum" -import { BitcoinNetwork, BitcoinTransaction, Hex } from "../../src" +import { Address } from "../../src/lib/ethereum" +import { BitcoinTransaction, Hex } from "../../src" import { WalletState } from "../../src/wallet" /** @@ -723,8 +723,7 @@ export const findWalletForRedemptionData: { outputIndex: 0, value: BigNumber.from("791613461"), scriptPubKey: createOutputScriptFromAddress( - "tb1qqwm566yn44rdlhgph8sw8vecta8uutg79afuja", - BitcoinNetwork.Testnet + "tb1qqwm566yn44rdlhgph8sw8vecta8uutg79afuja" ), }, ], @@ -849,8 +848,7 @@ export const findWalletForRedemptionData: { outputIndex: 0, value: BigNumber.from("3370000"), // 0.0337 BTC scriptPubKey: createOutputScriptFromAddress( - "tb1qx2xejtjltdcau5dpks8ucszkhxdg3fj88404lh", - BitcoinNetwork.Testnet + "tb1qx2xejtjltdcau5dpks8ucszkhxdg3fj88404lh" ), }, ], diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index fd94c1f04..bab39a487 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -14,6 +14,7 @@ import { UnspentTransactionOutput, } from "../src/lib/bitcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" +import bcoin from "bcoin" import { assembleDepositScript, assembleDepositTransaction, @@ -29,8 +30,7 @@ import { suggestDepositWallet, } from "../src/deposit" import { MockBridge } from "./utils/mock-bridge" -import { txToJSON } from "./utils/helpers" -import { Address } from "../src/ethereum" +import { Address } from "../src/lib/ethereum" import { BitcoinNetwork } from "../src" describe("Deposit", () => { @@ -224,8 +224,16 @@ describe("Deposit", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { + bcoin.set("testnet") + bitcoinClient = new MockBitcoinClient() + // Tie used testnetAddress with testnetUTXO to use it during deposit + // creation. + const utxos = new Map() + utxos.set(testnetAddress, [testnetUTXO]) + bitcoinClient.unspentTransactionOutputs = utxos + // Tie testnetTransaction to testnetUTXO. This is needed since // submitDepositTransaction attach transaction data to each UTXO. const rawTransactions = new Map() @@ -238,14 +246,11 @@ describe("Deposit", () => { let depositUtxo: UnspentTransactionOutput beforeEach(async () => { - const fee = BigNumber.from(1520) ;({ transactionHash, depositUtxo } = await submitDepositTransaction( deposit, testnetPrivateKey, bitcoinClient, - true, - [testnetUTXO], - fee + true )) }) @@ -278,15 +283,11 @@ describe("Deposit", () => { let depositUtxo: UnspentTransactionOutput beforeEach(async () => { - const fee = BigNumber.from(1410) - ;({ transactionHash, depositUtxo } = await submitDepositTransaction( deposit, testnetPrivateKey, bitcoinClient, - false, - [testnetUTXO], - fee + false )) }) @@ -322,18 +323,15 @@ describe("Deposit", () => { let transaction: RawTransaction beforeEach(async () => { - const fee = BigNumber.from(1520) ;({ transactionHash, depositUtxo, rawTransaction: transaction, } = await assembleDepositTransaction( - BitcoinNetwork.Testnet, deposit, - testnetPrivateKey, - true, [testnetUTXO], - fee + testnetPrivateKey, + true )) }) @@ -342,10 +340,8 @@ describe("Deposit", () => { expect(transaction).to.be.eql(expectedP2WSHDeposit.transaction) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( expectedP2WSHDeposit.transactionHash.toString() @@ -357,12 +353,15 @@ describe("Deposit", () => { const input = txJSON.inputs[0] - expect(input.hash).to.be.equal(testnetUTXO.transactionHash.toString()) - expect(input.index).to.be.equal(testnetUTXO.outputIndex) + expect(input.prevout.hash).to.be.equal( + testnetUTXO.transactionHash.toString() + ) + expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(testnetAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -421,18 +420,15 @@ describe("Deposit", () => { let transaction: RawTransaction beforeEach(async () => { - const fee = BigNumber.from(1410) ;({ transactionHash, depositUtxo, rawTransaction: transaction, } = await assembleDepositTransaction( - BitcoinNetwork.Testnet, deposit, - testnetPrivateKey, - false, [testnetUTXO], - fee + testnetPrivateKey, + false )) }) @@ -441,10 +437,8 @@ describe("Deposit", () => { expect(transaction).to.be.eql(expectedP2SHDeposit.transaction) // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( expectedP2SHDeposit.transactionHash.toString() @@ -456,12 +450,15 @@ describe("Deposit", () => { const input = txJSON.inputs[0] - expect(input.hash).to.be.equal(testnetUTXO.transactionHash.toString()) - expect(input.index).to.be.equal(testnetUTXO.outputIndex) + expect(input.prevout.hash).to.be.equal( + testnetUTXO.transactionHash.toString() + ) + expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(testnetAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -701,14 +698,11 @@ describe("Deposit", () => { beforeEach(async () => { // Create a deposit transaction. - const fee = BigNumber.from(1520) const result = await assembleDepositTransaction( - BitcoinNetwork.Testnet, deposit, - testnetPrivateKey, - true, [testnetUTXO], - fee + testnetPrivateKey, + true ) transaction = result.rawTransaction @@ -746,14 +740,11 @@ describe("Deposit", () => { beforeEach(async () => { // Create a deposit transaction. - const fee = BigNumber.from(1520) ;({ depositUtxo } = await assembleDepositTransaction( - BitcoinNetwork.Testnet, deposit, - testnetPrivateKey, - true, [testnetUTXO], - fee + testnetPrivateKey, + true )) revealedDeposit = { diff --git a/typescript/test/ethereum.test.ts b/typescript/test/ethereum.test.ts index 98215fc04..682ffd2a7 100644 --- a/typescript/test/ethereum.test.ts +++ b/typescript/test/ethereum.test.ts @@ -1,4 +1,4 @@ -import { Address, Bridge, TBTCToken } from "../src/ethereum" +import { Address, Bridge, TBTCToken } from "../src/lib/ethereum" import { deployMockContract, MockContract, diff --git a/typescript/test/utils/mock-bitcoin-client.ts b/typescript/test/utils/mock-bitcoin-client.ts index b37dd7820..fdb0e17fb 100644 --- a/typescript/test/utils/mock-bitcoin-client.ts +++ b/typescript/test/utils/mock-bitcoin-client.ts @@ -1,12 +1,12 @@ -import { BitcoinNetwork } from "../../src/bitcoin-network" import { + BitcoinNetwork, Client, UnspentTransactionOutput, TransactionMerkleBranch, RawTransaction, Transaction, TransactionHash, -} from "../../src/bitcoin" +} from "../../src/lib/bitcoin" /** * Mock Bitcoin client used for test purposes. diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index c18c0909f..213bf4d44 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -1,9 +1,16 @@ -import { Bridge, WalletRegistry, GetEvents, Identifier } from "../../src/chain" +import { + Bridge, + WalletRegistry, + GetEvents, + Identifier, +} from "../../src/lib/contracts" import { DecomposedRawTransaction, Proof, UnspentTransactionOutput, -} from "../../src/bitcoin" + computeHash160, + TransactionHash, +} from "../../src/lib/bitcoin" import { BigNumberish, BigNumber, utils, constants } from "ethers" import { RedemptionRequest, RedemptionRequestedEvent } from "../redemption" import { @@ -11,9 +18,8 @@ import { DepositRevealedEvent, RevealedDeposit, } from "../../src/deposit" -import { computeHash160, TransactionHash } from "../../src/bitcoin" import { depositSweepWithNoMainUtxoAndWitnessOutput } from "../data/deposit-sweep" -import { Address } from "../../src/ethereum" +import { Address } from "../../src/lib/ethereum" import { Hex } from "../../src/hex" import { NewWalletRegisteredEvent, Wallet } from "../../src/wallet" diff --git a/typescript/test/utils/mock-tbtc-token.ts b/typescript/test/utils/mock-tbtc-token.ts index 2e37d3e68..5c4246085 100644 --- a/typescript/test/utils/mock-tbtc-token.ts +++ b/typescript/test/utils/mock-tbtc-token.ts @@ -1,7 +1,7 @@ -import { TBTCToken } from "../../src/chain" +import { TBTCToken } from "../../src/lib/contracts" import { Hex } from "../../src/hex" import { BigNumber } from "ethers" -import { UnspentTransactionOutput } from "../../src/bitcoin" +import { UnspentTransactionOutput } from "../../src/lib/bitcoin" interface RequestRedemptionLog { walletPublicKey: string From b3e99a10d8a5c678c333e420fde5525839ad1c84 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 25 Sep 2023 10:44:17 +0200 Subject: [PATCH 160/205] Transform `backoff.ts` and `hex.ts` files to `lib/utils` shared lib --- typescript/src/deposit.ts | 2 +- typescript/src/index.ts | 2 +- typescript/src/lib/bitcoin/address.ts | 2 +- typescript/src/lib/bitcoin/block.ts | 2 +- typescript/src/lib/bitcoin/csuint.ts | 2 +- typescript/src/lib/bitcoin/hash.ts | 2 +- typescript/src/lib/bitcoin/key.ts | 2 +- typescript/src/lib/bitcoin/network.ts | 2 +- typescript/src/lib/bitcoin/transaction.ts | 2 +- typescript/src/lib/contracts/bridge.ts | 2 +- typescript/src/lib/contracts/chain-event.ts | 3 +-- typescript/src/lib/contracts/tbtc-token.ts | 2 +- typescript/src/lib/contracts/tbtc-vault.ts | 2 +- typescript/src/lib/contracts/wallet-registry.ts | 2 +- typescript/src/lib/electrum/client.ts | 3 +-- typescript/src/lib/ethereum/bridge.ts | 3 +-- typescript/src/lib/ethereum/contract-handle.ts | 2 +- typescript/src/lib/ethereum/tbtc-token.ts | 2 +- typescript/src/lib/ethereum/tbtc-vault.ts | 3 +-- typescript/src/lib/ethereum/wallet-registry.ts | 3 +-- typescript/src/{ => lib/utils}/backoff.ts | 0 typescript/src/{ => lib/utils}/hex.ts | 0 typescript/src/lib/utils/index.ts | 2 ++ typescript/src/optimistic-minting.ts | 2 +- typescript/src/proof.ts | 2 +- typescript/src/redemption.ts | 2 +- typescript/src/wallet.ts | 2 +- typescript/test/bitcoin.test.ts | 2 +- typescript/test/hex.test.ts | 2 +- typescript/test/proof.test.ts | 2 +- typescript/test/utils/mock-bridge.ts | 2 +- typescript/test/utils/mock-tbtc-token.ts | 2 +- 32 files changed, 31 insertions(+), 34 deletions(-) rename typescript/src/{ => lib/utils}/backoff.ts (100%) rename typescript/src/{ => lib/utils}/hex.ts (100%) create mode 100644 typescript/src/lib/utils/index.ts diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index cf838bb34..59ba5b0f4 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -12,7 +12,7 @@ import { isPublicKeyHashLength, } from "./lib/bitcoin" import { Bridge, Event, Identifier } from "./lib/contracts" -import { Hex } from "./hex" +import { Hex } from "./lib/utils" const { opcodes } = bcoin.script.common diff --git a/typescript/src/index.ts b/typescript/src/index.ts index 8fc6cb953..c340f622a 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -69,7 +69,7 @@ export { TBTCToken as EthereumTBTCToken, } from "./lib/ethereum" -export { Hex } from "./hex" +export { Hex } from "./lib/utils" export { OptimisticMintingRequest, diff --git a/typescript/src/lib/bitcoin/address.ts b/typescript/src/lib/bitcoin/address.ts index 42bbbdd76..354cb3db7 100644 --- a/typescript/src/lib/bitcoin/address.ts +++ b/typescript/src/lib/bitcoin/address.ts @@ -1,5 +1,5 @@ import bcoin, { Script } from "bcoin" -import { Hex } from "../../hex" +import { Hex } from "../utils" import { BitcoinNetwork, toBcoinNetwork } from "./network" /** diff --git a/typescript/src/lib/bitcoin/block.ts b/typescript/src/lib/bitcoin/block.ts index 72b325a4e..6fc235d53 100644 --- a/typescript/src/lib/bitcoin/block.ts +++ b/typescript/src/lib/bitcoin/block.ts @@ -1,5 +1,5 @@ import { BigNumber } from "ethers" -import { Hex } from "../../hex" +import { Hex } from "../utils" /** * BlockHeader represents the header of a Bitcoin block. For reference, see: diff --git a/typescript/src/lib/bitcoin/csuint.ts b/typescript/src/lib/bitcoin/csuint.ts index 42773d137..613736103 100644 --- a/typescript/src/lib/bitcoin/csuint.ts +++ b/typescript/src/lib/bitcoin/csuint.ts @@ -1,4 +1,4 @@ -import { Hex } from "../../hex" +import { Hex } from "../utils" /** * Reads the leading compact size uint from the provided variable length data. diff --git a/typescript/src/lib/bitcoin/hash.ts b/typescript/src/lib/bitcoin/hash.ts index 34a0da163..bef166140 100644 --- a/typescript/src/lib/bitcoin/hash.ts +++ b/typescript/src/lib/bitcoin/hash.ts @@ -1,5 +1,5 @@ import { BigNumber, utils } from "ethers" -import { Hex } from "../../hex" +import { Hex } from "../utils" /** * Computes the HASH160 for the given text. diff --git a/typescript/src/lib/bitcoin/key.ts b/typescript/src/lib/bitcoin/key.ts index 110991d81..968bd2bed 100644 --- a/typescript/src/lib/bitcoin/key.ts +++ b/typescript/src/lib/bitcoin/key.ts @@ -1,7 +1,7 @@ import bcoin from "bcoin" import wif from "wif" import { BigNumber } from "ethers" -import { Hex } from "../../hex" +import { Hex } from "../utils" /** * Checks whether given public key is a compressed Bitcoin public key. diff --git a/typescript/src/lib/bitcoin/network.ts b/typescript/src/lib/bitcoin/network.ts index ce79fad2c..bdb810e44 100644 --- a/typescript/src/lib/bitcoin/network.ts +++ b/typescript/src/lib/bitcoin/network.ts @@ -1,4 +1,4 @@ -import { Hex } from "../../hex" +import { Hex } from "../utils" /** * Bitcoin networks. diff --git a/typescript/src/lib/bitcoin/transaction.ts b/typescript/src/lib/bitcoin/transaction.ts index 00a7a03bd..7d9b69670 100644 --- a/typescript/src/lib/bitcoin/transaction.ts +++ b/typescript/src/lib/bitcoin/transaction.ts @@ -1,7 +1,7 @@ import { TX } from "bcoin" import bufio from "bufio" import { BigNumber } from "ethers" -import { Hex } from "../../hex" +import { Hex } from "../utils" /** * Represents a transaction hash (or transaction ID) as an un-prefixed hex diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index 7452a69d4..67b95eba7 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -10,7 +10,7 @@ import { DepositScriptParameters, RevealedDeposit, } from "../../deposit" -import { Hex } from "../../hex" +import { Hex } from "../utils" import { RedemptionRequest, RedemptionRequestedEvent } from "../../redemption" import { NewWalletRegisteredEvent, Wallet } from "../../wallet" import { GetEvents } from "./chain-event" diff --git a/typescript/src/lib/contracts/chain-event.ts b/typescript/src/lib/contracts/chain-event.ts index 09f5cb022..2d58b9ddd 100644 --- a/typescript/src/lib/contracts/chain-event.ts +++ b/typescript/src/lib/contracts/chain-event.ts @@ -1,5 +1,4 @@ -import { Hex } from "../../hex" -import { ExecutionLoggerFn } from "../../backoff" +import { ExecutionLoggerFn, Hex } from "../utils" /** * Represents a generic chain event. diff --git a/typescript/src/lib/contracts/tbtc-token.ts b/typescript/src/lib/contracts/tbtc-token.ts index 6133bb01d..dcfdd484a 100644 --- a/typescript/src/lib/contracts/tbtc-token.ts +++ b/typescript/src/lib/contracts/tbtc-token.ts @@ -1,6 +1,6 @@ import { BigNumber } from "ethers" import { UnspentTransactionOutput } from "../bitcoin" -import { Hex } from "../../hex" +import { Hex } from "../utils" /** * Interface for communication with the TBTC v2 token on-chain contract. diff --git a/typescript/src/lib/contracts/tbtc-vault.ts b/typescript/src/lib/contracts/tbtc-vault.ts index 0ce82041f..0102225d5 100644 --- a/typescript/src/lib/contracts/tbtc-vault.ts +++ b/typescript/src/lib/contracts/tbtc-vault.ts @@ -1,5 +1,5 @@ import { TransactionHash } from "../bitcoin" -import { Hex } from "../../hex" +import { Hex } from "../utils" import { OptimisticMintingCancelledEvent, OptimisticMintingFinalizedEvent, diff --git a/typescript/src/lib/contracts/wallet-registry.ts b/typescript/src/lib/contracts/wallet-registry.ts index ef0e1711b..d9a0626e7 100644 --- a/typescript/src/lib/contracts/wallet-registry.ts +++ b/typescript/src/lib/contracts/wallet-registry.ts @@ -1,4 +1,4 @@ -import { Hex } from "../../hex" +import { Hex } from "../utils" import { DkgResultApprovedEvent, DkgResultChallengedEvent, diff --git a/typescript/src/lib/electrum/client.ts b/typescript/src/lib/electrum/client.ts index f3d69cd7a..0142e8037 100644 --- a/typescript/src/lib/electrum/client.ts +++ b/typescript/src/lib/electrum/client.ts @@ -15,8 +15,7 @@ import { import Electrum from "electrum-client-js" import { BigNumber, utils } from "ethers" import { URL } from "url" -import { Hex } from "../../hex" -import { backoffRetrier, RetrierFn } from "../../backoff" +import { backoffRetrier, Hex, RetrierFn } from "../utils" /** * Represents a set of credentials required to establish an Electrum connection. diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index 3f444c7c7..8415234eb 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -17,7 +17,7 @@ import { } from "../../deposit" import { Event as EthersEvent } from "@ethersproject/contracts" import { BigNumber, constants, ContractTransaction, utils } from "ethers" -import { Hex } from "../../hex" +import { backoffRetrier, Hex } from "../utils" import { compressPublicKey, computeHash160, @@ -28,7 +28,6 @@ import { UnspentTransactionOutput, } from "../bitcoin" import { RedemptionRequest, RedemptionRequestedEvent } from "../../redemption" -import { backoffRetrier } from "../../backoff" import { NewWalletRegisteredEvent, Wallet, WalletState } from "../../wallet" import { ContractConfig, diff --git a/typescript/src/lib/ethereum/contract-handle.ts b/typescript/src/lib/ethereum/contract-handle.ts index c5ba09813..12ad04230 100644 --- a/typescript/src/lib/ethereum/contract-handle.ts +++ b/typescript/src/lib/ethereum/contract-handle.ts @@ -9,7 +9,7 @@ import { backoffRetrier, ExecutionLoggerFn, skipRetryWhenMatched, -} from "../../backoff" +} from "../utils" import { Address } from "./address" /** diff --git a/typescript/src/lib/ethereum/tbtc-token.ts b/typescript/src/lib/ethereum/tbtc-token.ts index 37b63df31..51f1aa480 100644 --- a/typescript/src/lib/ethereum/tbtc-token.ts +++ b/typescript/src/lib/ethereum/tbtc-token.ts @@ -2,7 +2,7 @@ import { TBTC as ContractTBTC } from "../../../typechain/TBTC" import { TBTCToken as ChainTBTCToken } from "../contracts" import { BigNumber, ContractTransaction, utils } from "ethers" import { computeHash160, UnspentTransactionOutput } from "../bitcoin" -import { Hex } from "../../hex" +import { Hex } from "../utils" import { ContractConfig, EthereumContract, diff --git a/typescript/src/lib/ethereum/tbtc-vault.ts b/typescript/src/lib/ethereum/tbtc-vault.ts index bf5f8c5d5..c06b96217 100644 --- a/typescript/src/lib/ethereum/tbtc-vault.ts +++ b/typescript/src/lib/ethereum/tbtc-vault.ts @@ -1,9 +1,8 @@ import { TBTCVault as ContractTBTCVault } from "../../../typechain/TBTCVault" import { GetEvents, TBTCVault as ChainTBTCVault } from "../contracts" -import { backoffRetrier } from "../../backoff" import { BigNumber, ContractTransaction } from "ethers" import { TransactionHash } from "../bitcoin" -import { Hex } from "../../hex" +import { backoffRetrier, Hex } from "../utils" import { OptimisticMintingCancelledEvent, OptimisticMintingFinalizedEvent, diff --git a/typescript/src/lib/ethereum/wallet-registry.ts b/typescript/src/lib/ethereum/wallet-registry.ts index 92502fb18..0e6d8e3cb 100644 --- a/typescript/src/lib/ethereum/wallet-registry.ts +++ b/typescript/src/lib/ethereum/wallet-registry.ts @@ -1,7 +1,6 @@ import { WalletRegistry as ContractWalletRegistry } from "../../../typechain/WalletRegistry" import { GetEvents, WalletRegistry as ChainWalletRegistry } from "../contracts" -import { Hex } from "../../hex" -import { backoffRetrier } from "../../backoff" +import { backoffRetrier, Hex } from "../utils" import { DkgResultApprovedEvent, DkgResultChallengedEvent, diff --git a/typescript/src/backoff.ts b/typescript/src/lib/utils/backoff.ts similarity index 100% rename from typescript/src/backoff.ts rename to typescript/src/lib/utils/backoff.ts diff --git a/typescript/src/hex.ts b/typescript/src/lib/utils/hex.ts similarity index 100% rename from typescript/src/hex.ts rename to typescript/src/lib/utils/hex.ts diff --git a/typescript/src/lib/utils/index.ts b/typescript/src/lib/utils/index.ts new file mode 100644 index 000000000..d3e639c60 --- /dev/null +++ b/typescript/src/lib/utils/index.ts @@ -0,0 +1,2 @@ +export * from "./backoff" +export * from "./hex" diff --git a/typescript/src/optimistic-minting.ts b/typescript/src/optimistic-minting.ts index 04506cebf..b08141b86 100644 --- a/typescript/src/optimistic-minting.ts +++ b/typescript/src/optimistic-minting.ts @@ -1,7 +1,7 @@ import { BigNumber } from "ethers" import { TransactionHash } from "./lib/bitcoin" import { Identifier, Event, TBTCVault } from "./lib/contracts" -import { Hex } from "./hex" +import { Hex } from "./lib/utils" /** * Represents an event that is emitted when a new optimistic minting is requested diff --git a/typescript/src/proof.ts b/typescript/src/proof.ts index 7d7f739b7..5cddfcba0 100644 --- a/typescript/src/proof.ts +++ b/typescript/src/proof.ts @@ -13,7 +13,7 @@ import { BlockHeader, } from "./lib/bitcoin" import { BigNumber } from "ethers" -import { Hex } from "./hex" +import { Hex } from "./lib/utils" /** * Assembles a proof that a given transaction was included in the blockchain and diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index c5e9045d6..f22c5f718 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -12,7 +12,7 @@ import { import { Bridge, Event, Identifier, TBTCToken } from "./lib/contracts" import { assembleTransactionProof } from "./proof" import { determineWalletMainUtxo, WalletState } from "./wallet" -import { Hex } from "./hex" +import { Hex } from "./lib/utils" /** * Represents a redemption request. diff --git a/typescript/src/wallet.ts b/typescript/src/wallet.ts index a292b0574..cf0c5ae39 100644 --- a/typescript/src/wallet.ts +++ b/typescript/src/wallet.ts @@ -1,5 +1,5 @@ import { BigNumber } from "ethers" -import { Hex } from "./hex" +import { Hex } from "./lib/utils" import { Bridge, Event, Identifier } from "./lib/contracts" import { Client as BitcoinClient, diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 0d5e71e38..dcaf31853 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -19,7 +19,7 @@ import { computeHash256, } from "../src/lib/bitcoin" import { calculateDepositRefundLocktime } from "../src/deposit" -import { Hex } from "../src/hex" +import { Hex } from "../src/lib/utils" import { BigNumber } from "ethers" import { btcAddresses } from "./data/bitcoin" diff --git a/typescript/test/hex.test.ts b/typescript/test/hex.test.ts index 08fdbfebb..1f8e538e3 100644 --- a/typescript/test/hex.test.ts +++ b/typescript/test/hex.test.ts @@ -1,5 +1,5 @@ import { assert } from "chai" -import { Hex } from "../src/hex" +import { Hex } from "../src/lib/utils" describe("Hex", () => { const stringUnprefixed = diff --git a/typescript/test/proof.test.ts b/typescript/test/proof.test.ts index ead678177..bfe846ac0 100644 --- a/typescript/test/proof.test.ts +++ b/typescript/test/proof.test.ts @@ -5,7 +5,7 @@ import { BlockHeader, Proof, } from "../src/lib/bitcoin" -import { Hex } from "../src/hex" +import { Hex } from "../src/lib/utils" import { singleInputProofTestData, multipleInputsProofTestData, diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index 213bf4d44..f1362f2a0 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -20,7 +20,7 @@ import { } from "../../src/deposit" import { depositSweepWithNoMainUtxoAndWitnessOutput } from "../data/deposit-sweep" import { Address } from "../../src/lib/ethereum" -import { Hex } from "../../src/hex" +import { Hex } from "../../src/lib/utils" import { NewWalletRegisteredEvent, Wallet } from "../../src/wallet" interface DepositSweepProofLogEntry { diff --git a/typescript/test/utils/mock-tbtc-token.ts b/typescript/test/utils/mock-tbtc-token.ts index 5c4246085..588615404 100644 --- a/typescript/test/utils/mock-tbtc-token.ts +++ b/typescript/test/utils/mock-tbtc-token.ts @@ -1,5 +1,5 @@ import { TBTCToken } from "../../src/lib/contracts" -import { Hex } from "../../src/hex" +import { Hex } from "../../src/lib/utils" import { BigNumber } from "ethers" import { UnspentTransactionOutput } from "../../src/lib/bitcoin" From 0052915041d41c3cdca6b981cfa55393542c7c14 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 25 Sep 2023 11:42:04 +0200 Subject: [PATCH 161/205] Move chain types from `wallet.ts` to `lib/contracts` Those types are purely chain-related and should be placed next to the respective contracts interfaces. --- typescript/src/lib/contracts/bridge.ts | 116 +++++++++- .../src/lib/contracts/wallet-registry.ts | 104 ++++++++- typescript/src/lib/ethereum/bridge.ts | 4 +- .../src/lib/ethereum/wallet-registry.ts | 7 +- typescript/src/redemption.ts | 10 +- typescript/src/wallet.ts | 211 +----------------- typescript/test/utils/mock-bridge.ts | 3 +- typescript/test/wallet.test.ts | 3 +- 8 files changed, 232 insertions(+), 226 deletions(-) diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index 67b95eba7..0aef22d6c 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -12,8 +12,7 @@ import { } from "../../deposit" import { Hex } from "../utils" import { RedemptionRequest, RedemptionRequestedEvent } from "../../redemption" -import { NewWalletRegisteredEvent, Wallet } from "../../wallet" -import { GetEvents } from "./chain-event" +import { Event, GetEvents } from "./chain-event" import { Identifier } from "./chain-identifier" import { WalletRegistry } from "./wallet-registry" @@ -182,3 +181,116 @@ export interface Bridge { */ getRedemptionRequestedEvents: GetEvents.Function } + +/* eslint-disable no-unused-vars */ +export enum WalletState { + /** + * The wallet is unknown to the Bridge. + */ + Unknown = 0, + /** + * The wallet can sweep deposits and accept redemption requests. + */ + Live = 1, + /** + * The wallet was deemed unhealthy and is expected to move their outstanding + * funds to another wallet. The wallet can still fulfill their pending redemption + * requests although new redemption requests and new deposit reveals are not + * accepted. + */ + MovingFunds = 2, + /** + * The wallet moved or redeemed all their funds and is in the + * losing period where it is still a subject of fraud challenges + * and must defend against them. + * */ + Closing = 3, + /** + * The wallet finalized the closing period successfully and can no longer perform + * any action in the Bridge. + * */ + Closed = 4, + /** + * The wallet committed a fraud that was reported, did not move funds to + * another wallet before a timeout, or did not sweep funds moved to if from + * another wallet before a timeout. The wallet is blocked and can not perform + * any actions in the Bridge. + */ + Terminated = 5, +} +/* eslint-enable no-unused-vars */ + +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace WalletState { + export function parse(val: number): WalletState { + return ( + (WalletState)[ + Object.keys(WalletState)[ + Object.values(WalletState).indexOf(val as WalletState) + ] + ] ?? WalletState.Unknown + ) + } +} + +/** + * Represents a deposit. + */ +export interface Wallet { + /** + * Identifier of a ECDSA Wallet registered in the ECDSA Wallet Registry. + */ + ecdsaWalletID: Hex + /** + * Compressed public key of the ECDSA Wallet. + */ + walletPublicKey: Hex + /** + * Latest wallet's main UTXO hash. + */ + mainUtxoHash: Hex + /** + * The total redeemable value of pending redemption requests targeting that wallet. + */ + pendingRedemptionsValue: BigNumber + /** + * UNIX timestamp the wallet was created at. + */ + createdAt: number + /** + * UNIX timestamp indicating the moment the wallet was requested to move their + * funds. + */ + movingFundsRequestedAt: number + /** + * UNIX timestamp indicating the moment the wallet's closing period started. + */ + closingStartedAt: number + /** + * Total count of pending moved funds sweep requests targeting this wallet. + */ + pendingMovedFundsSweepRequestsCount: number + /** + * Current state of the wallet. + */ + state: WalletState + /** + * Moving funds target wallet commitment submitted by the wallet. + */ + movingFundsTargetWalletsCommitmentHash: Hex +} + +/** + * Represents an event emitted when new wallet is registered on the on-chain bridge. + */ +export type NewWalletRegisteredEvent = { + /** + * Identifier of a ECDSA Wallet registered in the ECDSA Wallet Registry. + */ + ecdsaWalletID: Hex + /** + * 20-byte public key hash of the ECDSA Wallet. It is computed by applying + * hash160 on the compressed public key of the ECDSA Wallet. + */ + walletPublicKeyHash: Hex +} & Event diff --git a/typescript/src/lib/contracts/wallet-registry.ts b/typescript/src/lib/contracts/wallet-registry.ts index d9a0626e7..969756a88 100644 --- a/typescript/src/lib/contracts/wallet-registry.ts +++ b/typescript/src/lib/contracts/wallet-registry.ts @@ -1,10 +1,7 @@ import { Hex } from "../utils" -import { - DkgResultApprovedEvent, - DkgResultChallengedEvent, - DkgResultSubmittedEvent, -} from "../../wallet" -import { GetEvents } from "./chain-event" +import { Event, GetEvents } from "./chain-event" +import { BigNumber } from "ethers" +import { Identifier } from "./chain-identifier" /** * Interface for communication with the WalletRegistry on-chain contract. @@ -35,3 +32,98 @@ export interface WalletRegistry { */ getDkgResultChallengedEvents: GetEvents.Function } + +/** + * Represents an event emitted when a DKG result is submitted to the on-chain + * wallet registry. + */ +export type DkgResultSubmittedEvent = { + /** + * 32-byte hash of the submitted DKG result. + */ + resultHash: Hex + /** + * 32-byte seed of the current DKG execution. + */ + seed: Hex + /** + * DKG result object. + */ + result: DkgResult +} & Event + +/** + * Represents an event emitted when a DKG result is approved on the on-chain + * wallet registry. + */ +export type DkgResultApprovedEvent = { + /** + * 32-byte hash of the submitted DKG result. + */ + resultHash: Hex + /** + * Approver's chain identifier. + */ + approver: Identifier +} & Event + +/** + * Represents an event emitted when a DKG result is challenged on the on-chain + * wallet registry. + */ +export type DkgResultChallengedEvent = { + /** + * 32-byte hash of the submitted DKG result. + */ + resultHash: Hex + /** + * Challenger's chain identifier. + */ + challenger: Identifier + /** + * Reason of the challenge. + */ + reason: string +} & Event + +/** + * Represents a DKG on-chain result. + */ +type DkgResult = { + /** + * Claimed submitter candidate group member index. Is in range [1, groupSize]. + */ + submitterMemberIndex: BigNumber + /** + * Generated group public key. + */ + groupPubKey: Hex + /** + * Array of misbehaved members indices (disqualified or inactive). Indices + * are in range [1, groupSize], unique, and sorted in ascending order. + */ + misbehavedMembersIndices: number[] + /** + * Concatenation of signatures from members supporting the result. + * The message to be signed by each member is keccak256 hash of the + * calculated group public key, misbehaved members indices and DKG + * start block. The calculated hash is also prefixed with + * `\x19Ethereum signed message:\n` before signing. + */ + signatures: Hex + /** + * Indices of members corresponding to each signature. Indices are + * in range [1, groupSize], unique, and sorted in ascending order. + */ + signingMembersIndices: BigNumber[] + /** + * Identifiers of candidate group members as outputted by the group + * selection protocol. + */ + members: number[] + /** + * Keccak256 hash of group members identifiers that actively took part + * in DKG (excluding IA/DQ members). + */ + membersHash: Hex +} diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index 8415234eb..bd380a82e 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -9,6 +9,9 @@ import { GetEvents, Identifier as ChainIdentifier, WalletRegistry as ChainWalletRegistry, + NewWalletRegisteredEvent, + Wallet, + WalletState, } from "../contracts" import { DepositRevealedEvent, @@ -28,7 +31,6 @@ import { UnspentTransactionOutput, } from "../bitcoin" import { RedemptionRequest, RedemptionRequestedEvent } from "../../redemption" -import { NewWalletRegisteredEvent, Wallet, WalletState } from "../../wallet" import { ContractConfig, EthereumContract, diff --git a/typescript/src/lib/ethereum/wallet-registry.ts b/typescript/src/lib/ethereum/wallet-registry.ts index 0e6d8e3cb..859a01661 100644 --- a/typescript/src/lib/ethereum/wallet-registry.ts +++ b/typescript/src/lib/ethereum/wallet-registry.ts @@ -1,11 +1,12 @@ import { WalletRegistry as ContractWalletRegistry } from "../../../typechain/WalletRegistry" -import { GetEvents, WalletRegistry as ChainWalletRegistry } from "../contracts" -import { backoffRetrier, Hex } from "../utils" import { + GetEvents, + WalletRegistry as ChainWalletRegistry, DkgResultApprovedEvent, DkgResultChallengedEvent, DkgResultSubmittedEvent, -} from "../../wallet" +} from "../contracts" +import { backoffRetrier, Hex } from "../utils" import { Event as EthersEvent } from "@ethersproject/contracts" import { BigNumber } from "ethers" import WalletRegistryDeployment from "@keep-network/ecdsa/artifacts/WalletRegistry.json" diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index f22c5f718..f1c66d189 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -9,9 +9,15 @@ import { Client as BitcoinClient, TransactionHash, } from "./lib/bitcoin" -import { Bridge, Event, Identifier, TBTCToken } from "./lib/contracts" +import { + Bridge, + Event, + Identifier, + TBTCToken, + WalletState, +} from "./lib/contracts" import { assembleTransactionProof } from "./proof" -import { determineWalletMainUtxo, WalletState } from "./wallet" +import { determineWalletMainUtxo } from "./wallet" import { Hex } from "./lib/utils" /** diff --git a/typescript/src/wallet.ts b/typescript/src/wallet.ts index cf0c5ae39..6903042ff 100644 --- a/typescript/src/wallet.ts +++ b/typescript/src/wallet.ts @@ -1,6 +1,5 @@ -import { BigNumber } from "ethers" import { Hex } from "./lib/utils" -import { Bridge, Event, Identifier } from "./lib/contracts" +import { Bridge } from "./lib/contracts" import { Client as BitcoinClient, BitcoinNetwork, @@ -10,214 +9,6 @@ import { UnspentTransactionOutput, } from "./lib/bitcoin" -/* eslint-disable no-unused-vars */ -export enum WalletState { - /** - * The wallet is unknown to the Bridge. - */ - Unknown = 0, - /** - * The wallet can sweep deposits and accept redemption requests. - */ - Live = 1, - /** - * The wallet was deemed unhealthy and is expected to move their outstanding - * funds to another wallet. The wallet can still fulfill their pending redemption - * requests although new redemption requests and new deposit reveals are not - * accepted. - */ - MovingFunds = 2, - /** - * The wallet moved or redeemed all their funds and is in the - * losing period where it is still a subject of fraud challenges - * and must defend against them. - * */ - Closing = 3, - /** - * The wallet finalized the closing period successfully and can no longer perform - * any action in the Bridge. - * */ - Closed = 4, - /** - * The wallet committed a fraud that was reported, did not move funds to - * another wallet before a timeout, or did not sweep funds moved to if from - * another wallet before a timeout. The wallet is blocked and can not perform - * any actions in the Bridge. - */ - Terminated = 5, -} -/* eslint-enable no-unused-vars */ - -// eslint-disable-next-line @typescript-eslint/no-namespace -export namespace WalletState { - export function parse(val: number): WalletState { - return ( - (WalletState)[ - Object.keys(WalletState)[ - Object.values(WalletState).indexOf(val as WalletState) - ] - ] ?? WalletState.Unknown - ) - } -} - -/** - * Represents a deposit. - */ -export interface Wallet { - /** - * Identifier of a ECDSA Wallet registered in the ECDSA Wallet Registry. - */ - ecdsaWalletID: Hex - /** - * Compressed public key of the ECDSA Wallet. - */ - walletPublicKey: Hex - /** - * Latest wallet's main UTXO hash. - */ - mainUtxoHash: Hex - /** - * The total redeemable value of pending redemption requests targeting that wallet. - */ - pendingRedemptionsValue: BigNumber - /** - * UNIX timestamp the wallet was created at. - */ - createdAt: number - /** - * UNIX timestamp indicating the moment the wallet was requested to move their - * funds. - */ - movingFundsRequestedAt: number - /** - * UNIX timestamp indicating the moment the wallet's closing period started. - */ - closingStartedAt: number - /** - * Total count of pending moved funds sweep requests targeting this wallet. - */ - pendingMovedFundsSweepRequestsCount: number - /** - * Current state of the wallet. - */ - state: WalletState - /** - * Moving funds target wallet commitment submitted by the wallet. - */ - movingFundsTargetWalletsCommitmentHash: Hex -} - -/** - * Represents an event emitted when new wallet is registered on the on-chain bridge. - */ -export type NewWalletRegisteredEvent = { - /** - * Identifier of a ECDSA Wallet registered in the ECDSA Wallet Registry. - */ - ecdsaWalletID: Hex - /** - * 20-byte public key hash of the ECDSA Wallet. It is computed by applying - * hash160 on the compressed public key of the ECDSA Wallet. - */ - walletPublicKeyHash: Hex -} & Event - -/** - * Represents an event emitted when a DKG result is submitted to the on-chain - * wallet registry. - */ -export type DkgResultSubmittedEvent = { - /** - * 32-byte hash of the submitted DKG result. - */ - resultHash: Hex - /** - * 32-byte seed of the current DKG execution. - */ - seed: Hex - /** - * DKG result object. - */ - result: DkgResult -} & Event - -/** - * Represents an event emitted when a DKG result is approved on the on-chain - * wallet registry. - */ -export type DkgResultApprovedEvent = { - /** - * 32-byte hash of the submitted DKG result. - */ - resultHash: Hex - /** - * Approver's chain identifier. - */ - approver: Identifier -} & Event - -/** - * Represents an event emitted when a DKG result is challenged on the on-chain - * wallet registry. - */ -export type DkgResultChallengedEvent = { - /** - * 32-byte hash of the submitted DKG result. - */ - resultHash: Hex - /** - * Challenger's chain identifier. - */ - challenger: Identifier - /** - * Reason of the challenge. - */ - reason: string -} & Event - -/** - * Represents a DKG on-chain result. - */ -type DkgResult = { - /** - * Claimed submitter candidate group member index. Is in range [1, groupSize]. - */ - submitterMemberIndex: BigNumber - /** - * Generated group public key. - */ - groupPubKey: Hex - /** - * Array of misbehaved members indices (disqualified or inactive). Indices - * are in range [1, groupSize], unique, and sorted in ascending order. - */ - misbehavedMembersIndices: number[] - /** - * Concatenation of signatures from members supporting the result. - * The message to be signed by each member is keccak256 hash of the - * calculated group public key, misbehaved members indices and DKG - * start block. The calculated hash is also prefixed with - * `\x19Ethereum signed message:\n` before signing. - */ - signatures: Hex - /** - * Indices of members corresponding to each signature. Indices are - * in range [1, groupSize], unique, and sorted in ascending order. - */ - signingMembersIndices: BigNumber[] - /** - * Identifiers of candidate group members as outputted by the group - * selection protocol. - */ - members: number[] - /** - * Keccak256 hash of group members identifiers that actively took part - * in DKG (excluding IA/DQ members). - */ - membersHash: Hex -} - /** * Determines the plain-text wallet main UTXO currently registered in the * Bridge on-chain contract. The returned main UTXO can be undefined if the diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index f1362f2a0..7f2551676 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -3,6 +3,8 @@ import { WalletRegistry, GetEvents, Identifier, + NewWalletRegisteredEvent, + Wallet, } from "../../src/lib/contracts" import { DecomposedRawTransaction, @@ -21,7 +23,6 @@ import { import { depositSweepWithNoMainUtxoAndWitnessOutput } from "../data/deposit-sweep" import { Address } from "../../src/lib/ethereum" import { Hex } from "../../src/lib/utils" -import { NewWalletRegisteredEvent, Wallet } from "../../src/wallet" interface DepositSweepProofLogEntry { sweepTx: DecomposedRawTransaction diff --git a/typescript/test/wallet.test.ts b/typescript/test/wallet.test.ts index 678c396c4..5e5f83997 100644 --- a/typescript/test/wallet.test.ts +++ b/typescript/test/wallet.test.ts @@ -1,9 +1,10 @@ import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { MockBridge } from "./utils/mock-bridge" import { BitcoinNetwork, BitcoinTransaction, Hex } from "../src" -import { determineWalletMainUtxo, Wallet } from "../src/wallet" +import { determineWalletMainUtxo } from "../src/wallet" import { expect } from "chai" import { encodeToBitcoinAddress } from "../src/lib/bitcoin" +import { Wallet } from "../src/lib/contracts" import { BigNumber } from "ethers" describe("Wallet", () => { From 3a1a92c77e646936fedf01dd977ff1c52f39b086 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 25 Sep 2023 11:51:51 +0200 Subject: [PATCH 162/205] Move chain types from `redemption.ts` to `lib/contracts` Those types are purely chain-related and should be placed next to the respective contracts interfaces. --- typescript/src/lib/contracts/bridge.ts | 57 ++++++++++++++++++++++++- typescript/src/lib/ethereum/bridge.ts | 3 +- typescript/src/redemption.ts | 59 +------------------------- typescript/test/data/redemption.ts | 3 +- typescript/test/ethereum.test.ts | 2 +- typescript/test/redemption.test.ts | 3 +- typescript/test/utils/mock-bridge.ts | 3 +- 7 files changed, 64 insertions(+), 66 deletions(-) diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index 0aef22d6c..53a3a0fea 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -11,7 +11,6 @@ import { RevealedDeposit, } from "../../deposit" import { Hex } from "../utils" -import { RedemptionRequest, RedemptionRequestedEvent } from "../../redemption" import { Event, GetEvents } from "./chain-event" import { Identifier } from "./chain-identifier" import { WalletRegistry } from "./wallet-registry" @@ -182,6 +181,62 @@ export interface Bridge { getRedemptionRequestedEvents: GetEvents.Function } +/** + * Represents a redemption request. + */ +export interface RedemptionRequest { + /** + * On-chain identifier of the redeemer. + */ + redeemer: Identifier + + /** + * The output script the redeemed Bitcoin funds are locked to. It is un-prefixed + * and is not prepended with length. + */ + redeemerOutputScript: string + + /** + * The amount of Bitcoins in satoshis that is requested to be redeemed. + * The actual value of the output in the Bitcoin transaction will be decreased + * by the sum of the fee share and the treasury fee for this particular output. + */ + requestedAmount: BigNumber + + /** + * The amount of Bitcoins in satoshis that is subtracted from the amount of + * the redemption request and used to pay the treasury fee. + * The value should be exactly equal to the value of treasury fee in the Bridge + * on-chain contract at the time the redemption request was made. + */ + treasuryFee: BigNumber + + /** + * The maximum amount of Bitcoins in satoshis that can be subtracted from the + * redemption's `requestedAmount` to pay the transaction network fee. + */ + txMaxFee: BigNumber + + /** + * UNIX timestamp the request was created at. + */ + requestedAt: number +} + +/** + * Represents an event emitted on redemption request. + */ +export type RedemptionRequestedEvent = Omit< + RedemptionRequest, + "requestedAt" +> & { + /** + * Public key hash of the wallet that is meant to handle the redemption. Must + * be an unprefixed hex string (without 0x prefix). + */ + walletPublicKeyHash: string +} & Event + /* eslint-disable no-unused-vars */ export enum WalletState { /** diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index bd380a82e..0dc461d44 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -12,6 +12,8 @@ import { NewWalletRegisteredEvent, Wallet, WalletState, + RedemptionRequest, + RedemptionRequestedEvent, } from "../contracts" import { DepositRevealedEvent, @@ -30,7 +32,6 @@ import { TransactionHash, UnspentTransactionOutput, } from "../bitcoin" -import { RedemptionRequest, RedemptionRequestedEvent } from "../../redemption" import { ContractConfig, EthereumContract, diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index f1c66d189..e1a3f0528 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -11,8 +11,7 @@ import { } from "./lib/bitcoin" import { Bridge, - Event, - Identifier, + RedemptionRequest, TBTCToken, WalletState, } from "./lib/contracts" @@ -20,62 +19,6 @@ import { assembleTransactionProof } from "./proof" import { determineWalletMainUtxo } from "./wallet" import { Hex } from "./lib/utils" -/** - * Represents a redemption request. - */ -export interface RedemptionRequest { - /** - * On-chain identifier of the redeemer. - */ - redeemer: Identifier - - /** - * The output script the redeemed Bitcoin funds are locked to. It is un-prefixed - * and is not prepended with length. - */ - redeemerOutputScript: string - - /** - * The amount of Bitcoins in satoshis that is requested to be redeemed. - * The actual value of the output in the Bitcoin transaction will be decreased - * by the sum of the fee share and the treasury fee for this particular output. - */ - requestedAmount: BigNumber - - /** - * The amount of Bitcoins in satoshis that is subtracted from the amount of - * the redemption request and used to pay the treasury fee. - * The value should be exactly equal to the value of treasury fee in the Bridge - * on-chain contract at the time the redemption request was made. - */ - treasuryFee: BigNumber - - /** - * The maximum amount of Bitcoins in satoshis that can be subtracted from the - * redemption's `requestedAmount` to pay the transaction network fee. - */ - txMaxFee: BigNumber - - /** - * UNIX timestamp the request was created at. - */ - requestedAt: number -} - -/** - * Represents an event emitted on redemption request. - */ -export type RedemptionRequestedEvent = Omit< - RedemptionRequest, - "requestedAt" -> & { - /** - * Public key hash of the wallet that is meant to handle the redemption. Must - * be an unprefixed hex string (without 0x prefix). - */ - walletPublicKeyHash: string -} & Event - /** * Requests a redemption of tBTC into BTC. * @param walletPublicKey - The Bitcoin public key of the wallet. Must be in the diff --git a/typescript/test/data/redemption.ts b/typescript/test/data/redemption.ts index 46c695c9b..3ba8b0b57 100644 --- a/typescript/test/data/redemption.ts +++ b/typescript/test/data/redemption.ts @@ -9,10 +9,9 @@ import { TransactionHash, createOutputScriptFromAddress, } from "../../src/lib/bitcoin" -import { RedemptionRequest } from "../../src/redemption" +import { RedemptionRequest, WalletState } from "../../src/lib/contracts" import { Address } from "../../src/lib/ethereum" import { BitcoinTransaction, Hex } from "../../src" -import { WalletState } from "../../src/wallet" /** * Private key (testnet) of the wallet. diff --git a/typescript/test/ethereum.test.ts b/typescript/test/ethereum.test.ts index 682ffd2a7..ae98d3f9a 100644 --- a/typescript/test/ethereum.test.ts +++ b/typescript/test/ethereum.test.ts @@ -11,7 +11,7 @@ import { abi as WalletRegistryABI } from "@keep-network/ecdsa/artifacts/WalletRe import { MockProvider } from "@ethereum-waffle/provider" import { waffleChai } from "@ethereum-waffle/chai" import { TransactionHash, computeHash160 } from "../src/lib/bitcoin" -import { Hex } from "../src/hex" +import { Hex } from "../src/lib/utils" chai.use(waffleChai) diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index b83ad3161..ee59f3b48 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -23,11 +23,11 @@ import { RedemptionTestData, findWalletForRedemptionData, } from "./data/redemption" +import { RedemptionRequest, Wallet } from "../src/lib/contracts" import { assembleRedemptionTransaction, findWalletForRedemption, getRedemptionRequest, - RedemptionRequest, requestRedemption, submitRedemptionProof, submitRedemptionTransaction, @@ -37,7 +37,6 @@ import * as chai from "chai" import chaiAsPromised from "chai-as-promised" import { expect } from "chai" import { BigNumberish, BigNumber } from "ethers" -import { Wallet } from "../src/wallet" import { MockTBTCToken } from "./utils/mock-tbtc-token" import { BitcoinTransaction } from "../src" diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index 7f2551676..30ee58aff 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -5,6 +5,8 @@ import { Identifier, NewWalletRegisteredEvent, Wallet, + RedemptionRequest, + RedemptionRequestedEvent, } from "../../src/lib/contracts" import { DecomposedRawTransaction, @@ -14,7 +16,6 @@ import { TransactionHash, } from "../../src/lib/bitcoin" import { BigNumberish, BigNumber, utils, constants } from "ethers" -import { RedemptionRequest, RedemptionRequestedEvent } from "../redemption" import { Deposit, DepositRevealedEvent, From b3390d8c7ebe07dcc48bdcce0fac5c82ebccbf68 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 25 Sep 2023 11:57:48 +0200 Subject: [PATCH 163/205] Move chain types from `optimistic-minting.ts` to `lib/contracts` Those types are purely chain-related and should be placed next to the respective contracts interfaces. --- typescript/src/index.ts | 2 +- typescript/src/lib/contracts/tbtc-vault.ts | 105 +++++++++++++++++++-- typescript/src/lib/ethereum/tbtc-vault.ts | 11 ++- typescript/src/optimistic-minting.ts | 99 +------------------ 4 files changed, 106 insertions(+), 111 deletions(-) diff --git a/typescript/src/index.ts b/typescript/src/index.ts index c340f622a..66c92731e 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -74,4 +74,4 @@ export { Hex } from "./lib/utils" export { OptimisticMintingRequest, OptimisticMintingRequestedEvent, -} from "./optimistic-minting" +} from "./lib/contracts" diff --git a/typescript/src/lib/contracts/tbtc-vault.ts b/typescript/src/lib/contracts/tbtc-vault.ts index 0102225d5..732251000 100644 --- a/typescript/src/lib/contracts/tbtc-vault.ts +++ b/typescript/src/lib/contracts/tbtc-vault.ts @@ -1,13 +1,8 @@ import { TransactionHash } from "../bitcoin" import { Hex } from "../utils" -import { - OptimisticMintingCancelledEvent, - OptimisticMintingFinalizedEvent, - OptimisticMintingRequest, - OptimisticMintingRequestedEvent, -} from "../../optimistic-minting" import { Identifier } from "./chain-identifier" -import { GetEvents } from "./chain-event" +import { Event, GetEvents } from "./chain-event" +import { BigNumber } from "ethers" /** * Interface for communication with the TBTCVault on-chain contract. @@ -112,3 +107,99 @@ export interface TBTCVault { */ getOptimisticMintingFinalizedEvents: GetEvents.Function } + +/** + * Represents optimistic minting request for the given deposit revealed to the + * Bridge. + */ +export type OptimisticMintingRequest = { + /** + * UNIX timestamp at which the optimistic minting was requested. + */ + requestedAt: number + /** + * UNIX timestamp at which the optimistic minting was finalized. + * 0 if not yet finalized. + */ + finalizedAt: number +} + +/** + * Represents an event that is emitted when a new optimistic minting is requested + * on chain. + */ +export type OptimisticMintingRequestedEvent = { + /** + * Minter's chain identifier. + */ + minter: Identifier + /** + * Unique deposit identifier. + * @see Bridge.buildDepositKey + */ + depositKey: Hex + /** + * Depositor's chain identifier. + */ + depositor: Identifier + /** + * Amount of tokens requested to mint. + * This value is in ERC 1e18 precision, it has to be converted before using + * as Bitcoin value with 1e8 precision in satoshi. + */ + // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 + // precision to Bitcoin in 1e8 precision (satoshi). + amount: BigNumber + /** + * Hash of a Bitcoin transaction made to fund the deposit. + */ + fundingTxHash: TransactionHash + /** + * Index of an output in the funding transaction made to fund the deposit. + */ + fundingOutputIndex: number +} & Event + +/** + * Represents an event that is emitted when an optimistic minting request + * is cancelled on chain. + */ +export type OptimisticMintingCancelledEvent = { + /** + * Guardian's chain identifier. + */ + guardian: Identifier + /** + * Unique deposit identifier. + * @see Bridge.buildDepositKey + */ + depositKey: Hex +} & Event + +/** + * Represents an event that is emitted when an optimistic minting request + * is finalized on chain. + */ +export type OptimisticMintingFinalizedEvent = { + /** + * Minter's chain identifier. + */ + minter: Identifier + /** + * Unique deposit identifier. + * @see Bridge.buildDepositKey + */ + depositKey: Hex + /** + * Depositor's chain identifier. + */ + depositor: Identifier + /** + * Value of the new optimistic minting debt of the depositor. + * This value is in ERC 1e18 precision, it has to be converted before using + * as Bitcoin value with 1e8 precision in satoshi. + */ + // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 + // precision to Bitcoin in 1e8 precision (satoshi). + optimisticMintingDebt: BigNumber +} & Event diff --git a/typescript/src/lib/ethereum/tbtc-vault.ts b/typescript/src/lib/ethereum/tbtc-vault.ts index c06b96217..d381c2973 100644 --- a/typescript/src/lib/ethereum/tbtc-vault.ts +++ b/typescript/src/lib/ethereum/tbtc-vault.ts @@ -1,14 +1,15 @@ import { TBTCVault as ContractTBTCVault } from "../../../typechain/TBTCVault" -import { GetEvents, TBTCVault as ChainTBTCVault } from "../contracts" -import { BigNumber, ContractTransaction } from "ethers" -import { TransactionHash } from "../bitcoin" -import { backoffRetrier, Hex } from "../utils" import { + GetEvents, + TBTCVault as ChainTBTCVault, OptimisticMintingCancelledEvent, OptimisticMintingFinalizedEvent, OptimisticMintingRequest, OptimisticMintingRequestedEvent, -} from "../../optimistic-minting" +} from "../contracts" +import { BigNumber, ContractTransaction } from "ethers" +import { TransactionHash } from "../bitcoin" +import { backoffRetrier, Hex } from "../utils" import TBTCVaultDeployment from "@keep-network/tbtc-v2/artifacts/TBTCVault.json" import { ContractConfig, diff --git a/typescript/src/optimistic-minting.ts b/typescript/src/optimistic-minting.ts index b08141b86..d856b7b0e 100644 --- a/typescript/src/optimistic-minting.ts +++ b/typescript/src/optimistic-minting.ts @@ -1,104 +1,7 @@ -import { BigNumber } from "ethers" import { TransactionHash } from "./lib/bitcoin" -import { Identifier, Event, TBTCVault } from "./lib/contracts" +import { TBTCVault, OptimisticMintingRequest } from "./lib/contracts" import { Hex } from "./lib/utils" -/** - * Represents an event that is emitted when a new optimistic minting is requested - * on chain. - */ -export type OptimisticMintingRequestedEvent = { - /** - * Minter's chain identifier. - */ - minter: Identifier - /** - * Unique deposit identifier. - * @see Bridge.buildDepositKey - */ - depositKey: Hex - /** - * Depositor's chain identifier. - */ - depositor: Identifier - /** - * Amount of tokens requested to mint. - * This value is in ERC 1e18 precision, it has to be converted before using - * as Bitcoin value with 1e8 precision in satoshi. - */ - // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 - // precision to Bitcoin in 1e8 precision (satoshi). - amount: BigNumber - /** - * Hash of a Bitcoin transaction made to fund the deposit. - */ - fundingTxHash: TransactionHash - /** - * Index of an output in the funding transaction made to fund the deposit. - */ - fundingOutputIndex: number -} & Event - -/** - * Represents an event that is emitted when an optimistic minting request - * is cancelled on chain. - */ -export type OptimisticMintingCancelledEvent = { - /** - * Guardian's chain identifier. - */ - guardian: Identifier - /** - * Unique deposit identifier. - * @see Bridge.buildDepositKey - */ - depositKey: Hex -} & Event - -/** - * Represents an event that is emitted when an optimistic minting request - * is finalized on chain. - */ -export type OptimisticMintingFinalizedEvent = { - /** - * Minter's chain identifier. - */ - minter: Identifier - /** - * Unique deposit identifier. - * @see Bridge.buildDepositKey - */ - depositKey: Hex - /** - * Depositor's chain identifier. - */ - depositor: Identifier - /** - * Value of the new optimistic minting debt of the depositor. - * This value is in ERC 1e18 precision, it has to be converted before using - * as Bitcoin value with 1e8 precision in satoshi. - */ - // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 - // precision to Bitcoin in 1e8 precision (satoshi). - optimisticMintingDebt: BigNumber -} & Event - -/** - * Represents optimistic minting request for the given deposit revealed to the - * Bridge. - */ -export type OptimisticMintingRequest = { - /** - * UNIX timestamp at which the optimistic minting was requested. - */ - requestedAt: number - /** - * UNIX timestamp at which the optimistic minting was finalized. - * 0 if not yet finalized. - */ - finalizedAt: number -} - /** * Requests optimistic minting for a deposit on chain. * @param depositTxHash The revealed deposit transaction's hash. From dcba2dfded84d028a6ce8e1e6807b4d32799fb72 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 25 Sep 2023 12:38:44 +0200 Subject: [PATCH 164/205] Move chain types from `deposit.ts` to `lib/contracts` Those types are purely chain-related and should be placed next to the respective contracts interfaces. --- typescript/src/deposit-refund.ts | 2 +- typescript/src/deposit-sweep.ts | 4 +- typescript/src/deposit.ts | 104 ++----------------------- typescript/src/lib/contracts/bridge.ts | 101 ++++++++++++++++++++++-- typescript/src/lib/ethereum/bridge.ts | 4 +- typescript/test/data/deposit-refund.ts | 3 +- typescript/test/data/deposit-sweep.ts | 3 +- typescript/test/deposit.test.ts | 8 +- typescript/test/utils/mock-bridge.ts | 8 +- 9 files changed, 119 insertions(+), 118 deletions(-) diff --git a/typescript/src/deposit-refund.ts b/typescript/src/deposit-refund.ts index ec34038a1..16fa8448d 100644 --- a/typescript/src/deposit-refund.ts +++ b/typescript/src/deposit-refund.ts @@ -9,9 +9,9 @@ import { computeHash160, isCompressedPublicKey, } from "./lib/bitcoin" +import { Deposit } from "./lib/contracts" import { assembleDepositScript, - Deposit, validateDepositScriptParameters, } from "./deposit" diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 5f8e922be..6b8b2344d 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -10,8 +10,8 @@ import { TransactionHash, computeHash160, } from "./lib/bitcoin" -import { assembleDepositScript, Deposit } from "./deposit" -import { Bridge, Identifier } from "./lib/contracts" +import { assembleDepositScript } from "./deposit" +import { Bridge, Identifier, Deposit } from "./lib/contracts" import { assembleTransactionProof } from "./proof" /** diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 59ba5b0f4..7d66bc7e8 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -11,107 +11,17 @@ import { TransactionHash, isPublicKeyHashLength, } from "./lib/bitcoin" -import { Bridge, Event, Identifier } from "./lib/contracts" +import { + Bridge, + Identifier, + Deposit, + DepositScriptParameters, + RevealedDeposit, +} from "./lib/contracts" import { Hex } from "./lib/utils" const { opcodes } = bcoin.script.common -// TODO: Replace all properties that are expected to be un-prefixed hexadecimal -// strings with a Hex type. - -/** - * Represents a deposit. - */ -export interface Deposit { - /** - * Depositor's chain identifier. - */ - depositor: Identifier - - /** - * Deposit amount in satoshis. - */ - amount: BigNumber - - /** - * An 8-byte blinding factor as an un-prefixed hex string. Must be unique - * for the given depositor, wallet public key and refund public key. - */ - blindingFactor: string - - /** - * Public key hash of the wallet that is meant to receive the deposit. Must - * be an unprefixed hex string (without 0x prefix). - * - * You can use `computeHash160` function to get the hash from a plain text public key. - */ - walletPublicKeyHash: string - - /** - * Public key hash that is meant to be used during deposit refund after the - * locktime passes. Must be an unprefixed hex string (without 0x prefix). - * - * You can use `computeHash160` function to get the hash from a plain text public key. - */ - refundPublicKeyHash: string - - /** - * A 4-byte little-endian refund locktime as an un-prefixed hex string. - */ - refundLocktime: string - - /** - * Optional identifier of the vault the deposit should be routed in. - */ - vault?: Identifier -} - -/** - * Helper type that groups deposit's fields required to assemble a deposit - * script. - */ -export type DepositScriptParameters = Pick< - Deposit, - | "depositor" - | "blindingFactor" - | "refundLocktime" - | "walletPublicKeyHash" - | "refundPublicKeyHash" -> & {} - -/** - * Represents a deposit revealed to the on-chain bridge. This type emphasizes - * the on-chain state of the revealed deposit and omits the deposit script - * parameters as they are not relevant in this context. - */ -export type RevealedDeposit = Pick< - Deposit, - "depositor" | "amount" | "vault" -> & { - /** - * UNIX timestamp the deposit was revealed at. - */ - revealedAt: number - /** - * UNIX timestamp the request was swept at. If not swept yet, this parameter - * should have zero as value. - */ - sweptAt: number - /** - * Value of the treasury fee calculated for this revealed deposit. - * Denominated in satoshi. - */ - treasuryFee: BigNumber -} - -/** - * Represents an event emitted on deposit reveal to the on-chain bridge. - */ -export type DepositRevealedEvent = Deposit & { - fundingTxHash: TransactionHash - fundingOutputIndex: number -} & Event - /** * Submits a deposit by creating and broadcasting a Bitcoin P2(W)SH * deposit transaction. diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index 53a3a0fea..c663dc527 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -5,11 +5,6 @@ import { DecomposedRawTransaction, TransactionHash, } from "../bitcoin" -import { - DepositRevealedEvent, - DepositScriptParameters, - RevealedDeposit, -} from "../../deposit" import { Hex } from "../utils" import { Event, GetEvents } from "./chain-event" import { Identifier } from "./chain-identifier" @@ -181,6 +176,102 @@ export interface Bridge { getRedemptionRequestedEvents: GetEvents.Function } +// TODO: Replace all properties that are expected to be un-prefixed hexadecimal +// strings with a Hex type. + +/** + * Represents a deposit. + */ +export interface Deposit { + /** + * Depositor's chain identifier. + */ + depositor: Identifier + + /** + * Deposit amount in satoshis. + */ + amount: BigNumber + + /** + * An 8-byte blinding factor as an un-prefixed hex string. Must be unique + * for the given depositor, wallet public key and refund public key. + */ + blindingFactor: string + + /** + * Public key hash of the wallet that is meant to receive the deposit. Must + * be an unprefixed hex string (without 0x prefix). + * + * You can use `computeHash160` function to get the hash from a plain text public key. + */ + walletPublicKeyHash: string + + /** + * Public key hash that is meant to be used during deposit refund after the + * locktime passes. Must be an unprefixed hex string (without 0x prefix). + * + * You can use `computeHash160` function to get the hash from a plain text public key. + */ + refundPublicKeyHash: string + + /** + * A 4-byte little-endian refund locktime as an un-prefixed hex string. + */ + refundLocktime: string + + /** + * Optional identifier of the vault the deposit should be routed in. + */ + vault?: Identifier +} + +/** + * Helper type that groups deposit's fields required to assemble a deposit + * script. + */ +export type DepositScriptParameters = Pick< + Deposit, + | "depositor" + | "blindingFactor" + | "refundLocktime" + | "walletPublicKeyHash" + | "refundPublicKeyHash" +> & {} + +/** + * Represents a deposit revealed to the on-chain bridge. This type emphasizes + * the on-chain state of the revealed deposit and omits the deposit script + * parameters as they are not relevant in this context. + */ +export type RevealedDeposit = Pick< + Deposit, + "depositor" | "amount" | "vault" +> & { + /** + * UNIX timestamp the deposit was revealed at. + */ + revealedAt: number + /** + * UNIX timestamp the request was swept at. If not swept yet, this parameter + * should have zero as value. + */ + sweptAt: number + /** + * Value of the treasury fee calculated for this revealed deposit. + * Denominated in satoshi. + */ + treasuryFee: BigNumber +} + +/** + * Represents an event emitted on deposit reveal to the on-chain bridge. + */ +export type DepositRevealedEvent = Deposit & { + fundingTxHash: TransactionHash + fundingOutputIndex: number +} & Event + /** * Represents a redemption request. */ diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index 0dc461d44..824a8c286 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -14,12 +14,10 @@ import { WalletState, RedemptionRequest, RedemptionRequestedEvent, -} from "../contracts" -import { DepositRevealedEvent, DepositScriptParameters, RevealedDeposit, -} from "../../deposit" +} from "../contracts" import { Event as EthersEvent } from "@ethersproject/contracts" import { BigNumber, constants, ContractTransaction, utils } from "ethers" import { backoffRetrier, Hex } from "../utils" diff --git a/typescript/test/data/deposit-refund.ts b/typescript/test/data/deposit-refund.ts index ebb835187..d5763354b 100644 --- a/typescript/test/data/deposit-refund.ts +++ b/typescript/test/data/deposit-refund.ts @@ -4,7 +4,8 @@ import { UnspentTransactionOutput, TransactionHash, } from "../../src/lib/bitcoin" -import { Deposit, calculateDepositRefundLocktime } from "../../src/deposit" +import { Deposit } from "../../src/lib/contracts" +import { calculateDepositRefundLocktime } from "../../src/deposit" import { Address } from "../../src/lib/ethereum" /** diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index e567dce0f..ba394fc4d 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -7,7 +7,8 @@ import { TransactionMerkleBranch, TransactionHash, } from "../../src/lib/bitcoin" -import { calculateDepositRefundLocktime, Deposit } from "../../src/deposit" +import { Deposit } from "../../src/lib/contracts" +import { calculateDepositRefundLocktime } from "../../src/deposit" import { BigNumber } from "ethers" import { Address } from "../../src/lib/ethereum" import { Hex } from "../../src" diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index bab39a487..7e34edd9c 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -13,6 +13,11 @@ import { TransactionHash, UnspentTransactionOutput, } from "../src/lib/bitcoin" +import { + Deposit, + DepositScriptParameters, + RevealedDeposit, +} from "../src/lib/contracts" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import bcoin from "bcoin" import { @@ -21,11 +26,8 @@ import { calculateDepositAddress, calculateDepositRefundLocktime, calculateDepositScriptHash, - Deposit, - DepositScriptParameters, getRevealedDeposit, revealDeposit, - RevealedDeposit, submitDepositTransaction, suggestDepositWallet, } from "../src/deposit" diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index 30ee58aff..bdbca6683 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -7,6 +7,9 @@ import { Wallet, RedemptionRequest, RedemptionRequestedEvent, + Deposit, + DepositRevealedEvent, + RevealedDeposit, } from "../../src/lib/contracts" import { DecomposedRawTransaction, @@ -16,11 +19,6 @@ import { TransactionHash, } from "../../src/lib/bitcoin" import { BigNumberish, BigNumber, utils, constants } from "ethers" -import { - Deposit, - DepositRevealedEvent, - RevealedDeposit, -} from "../../src/deposit" import { depositSweepWithNoMainUtxoAndWitnessOutput } from "../data/deposit-sweep" import { Address } from "../../src/lib/ethereum" import { Hex } from "../../src/lib/utils" From a4160bdb55cf2189a37c84ed1adcd49dc58e117b Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 25 Sep 2023 12:59:53 +0200 Subject: [PATCH 165/205] Move `proof.ts` to `lib/bitcoin` This content of the `proof.ts` file actually belongs to `lib/bitcoin/proof.ts`. Part of this code related to blocks, should live in `lib/bitcoin/block.ts`. --- typescript/src/deposit-sweep.ts | 2 +- typescript/src/index.ts | 4 +- typescript/src/lib/bitcoin/block.ts | 106 ++++++++ typescript/src/lib/bitcoin/proof.ts | 291 ++++++++++++++++++++ typescript/src/proof.ts | 399 ---------------------------- typescript/src/redemption.ts | 2 +- typescript/test/proof.test.ts | 12 +- 7 files changed, 406 insertions(+), 410 deletions(-) delete mode 100644 typescript/src/proof.ts diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 6b8b2344d..4a80b1cdc 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,6 +1,7 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" import { + assembleTransactionProof, RawTransaction, UnspentTransactionOutput, Client as BitcoinClient, @@ -12,7 +13,6 @@ import { } from "./lib/bitcoin" import { assembleDepositScript } from "./deposit" import { Bridge, Identifier, Deposit } from "./lib/contracts" -import { assembleTransactionProof } from "./proof" /** * Submits a deposit sweep by combining all the provided P2(W)SH UTXOs and diff --git a/typescript/src/index.ts b/typescript/src/index.ts index 66c92731e..8d2666446 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -1,5 +1,7 @@ // TODO: Consider exports refactoring as per discussion https://github.com/keep-network/tbtc-v2/pull/460#discussion_r1084530007 +import { validateTransactionProof } from "./lib/bitcoin" + import { calculateDepositAddress, getRevealedDeposit, @@ -23,8 +25,6 @@ import { getOptimisticMintingRequest, } from "./optimistic-minting" -import { validateTransactionProof } from "./proof" - export const TBTC = { calculateDepositAddress, suggestDepositWallet, diff --git a/typescript/src/lib/bitcoin/block.ts b/typescript/src/lib/bitcoin/block.ts index 6fc235d53..185ffa619 100644 --- a/typescript/src/lib/bitcoin/block.ts +++ b/typescript/src/lib/bitcoin/block.ts @@ -1,5 +1,6 @@ import { BigNumber } from "ethers" import { Hex } from "../utils" +import { computeHash256, hashLEToBigNumber } from "./hash" /** * BlockHeader represents the header of a Bitcoin block. For reference, see: @@ -141,3 +142,108 @@ export function targetToDifficulty(target: BigNumber): BigNumber { ) return DIFF1_TARGET.div(target) } + +/** + * Validates a chain of consecutive block headers by checking each header's + * difficulty, hash, and continuity with the previous header. This function can + * be used to validate a series of Bitcoin block headers for their validity. + * @param blockHeaders An array of block headers that form the chain to be + * validated. + * @param previousEpochDifficulty The difficulty of the previous Bitcoin epoch. + * @param currentEpochDifficulty The difficulty of the current Bitcoin epoch. + * @dev The block headers must come from Bitcoin epochs with difficulties marked + * by the previous and current difficulties. If a Bitcoin difficulty relay + * is used to provide these values and the relay is up-to-date, only the + * recent block headers will pass validation. Block headers older than the + * current and previous Bitcoin epochs will fail. + * @throws {Error} If any of the block headers are invalid, or if the block + * header chain is not continuous. + * @returns An empty return value. + */ +export function validateBlockHeadersChain( + blockHeaders: BlockHeader[], + previousEpochDifficulty: BigNumber, + currentEpochDifficulty: BigNumber +) { + let requireCurrentDifficulty: boolean = false + let previousBlockHeaderHash: Hex = Hex.from("00") + + for (let index = 0; index < blockHeaders.length; index++) { + const currentHeader = blockHeaders[index] + + // Check if the current block header stores the hash of the previously + // processed block header. Skip the check for the first header. + if (index !== 0) { + if ( + !previousBlockHeaderHash.equals(currentHeader.previousBlockHeaderHash) + ) { + throw new Error("Invalid headers chain") + } + } + + const difficultyTarget = bitsToTarget(currentHeader.bits) + + const currentBlockHeaderHash = computeHash256( + serializeBlockHeader(currentHeader) + ) + + // Ensure the header has sufficient work. + if (hashLEToBigNumber(currentBlockHeaderHash).gt(difficultyTarget)) { + throw new Error("Insufficient work in the header") + } + + // Save the current block header hash to compare it with the next block + // header's previous block header hash. + previousBlockHeaderHash = currentBlockHeaderHash + + // Check if the stored block difficulty is equal to previous or current + // difficulties. + const difficulty = targetToDifficulty(difficultyTarget) + + if (previousEpochDifficulty.eq(1) && currentEpochDifficulty.eq(1)) { + // Special case for Bitcoin Testnet. Do not check block's difficulty + // due to required difficulty falling to `1` for Testnet. + continue + } + + if ( + !difficulty.eq(previousEpochDifficulty) && + !difficulty.eq(currentEpochDifficulty) + ) { + throw new Error( + "Header difficulty not at current or previous Bitcoin difficulty" + ) + } + + // Additionally, require the header to be at current difficulty if some + // headers at current difficulty have already been seen. This ensures + // there is at most one switch from previous to current difficulties. + if (requireCurrentDifficulty && !difficulty.eq(currentEpochDifficulty)) { + throw new Error("Header must be at current Bitcoin difficulty") + } + + // If the header is at current difficulty, require the subsequent headers to + // be at current difficulty as well. + requireCurrentDifficulty = difficulty.eq(currentEpochDifficulty) + } +} + +/** + * Splits Bitcoin block headers in the raw format into an array of BlockHeaders. + * @param blockHeaders - string that contains block headers in the raw format. + * @returns Array of BlockHeader objects. + */ +export function splitBlockHeadersChain(blockHeaders: string): BlockHeader[] { + if (blockHeaders.length % 160 !== 0) { + throw new Error("Incorrect length of Bitcoin headers") + } + + const result: BlockHeader[] = [] + for (let i = 0; i < blockHeaders.length; i += 160) { + result.push( + deserializeBlockHeader(Hex.from(blockHeaders.substring(i, i + 160))) + ) + } + + return result +} diff --git a/typescript/src/lib/bitcoin/proof.ts b/typescript/src/lib/bitcoin/proof.ts index efbf4f8dd..60ce9128d 100644 --- a/typescript/src/lib/bitcoin/proof.ts +++ b/typescript/src/lib/bitcoin/proof.ts @@ -1,3 +1,14 @@ +import { Transaction, TransactionHash } from "./transaction" +import { Client } from "./client" +import { BigNumber } from "ethers" +import { + BlockHeader, + splitBlockHeadersChain, + validateBlockHeadersChain, +} from "./block" +import { Hex } from "../utils" +import { computeHash256 } from "./hash" + /** * Data required to perform a proof that a given transaction was included in * the Bitcoin blockchain. @@ -42,3 +53,283 @@ export interface TransactionMerkleBranch { */ position: number } + +/** + * Assembles a proof that a given transaction was included in the blockchain and + * has accumulated the required number of confirmations. + * @param transactionHash - Hash of the transaction being proven. + * @param requiredConfirmations - Required number of confirmations. + * @param bitcoinClient - Bitcoin client used to interact with the network. + * @returns Bitcoin transaction along with the inclusion proof. + */ +export async function assembleTransactionProof( + transactionHash: TransactionHash, + requiredConfirmations: number, + bitcoinClient: Client +): Promise { + const transaction = await bitcoinClient.getTransaction(transactionHash) + const confirmations = await bitcoinClient.getTransactionConfirmations( + transactionHash + ) + + if (confirmations < requiredConfirmations) { + throw new Error( + "Transaction confirmations number[" + + confirmations + + "] is not enough, required [" + + requiredConfirmations + + "]" + ) + } + + const latestBlockHeight = await bitcoinClient.latestBlockHeight() + const txBlockHeight = latestBlockHeight - confirmations + 1 + + // We subtract `1` from `requiredConfirmations` because the header at + // `txBlockHeight` is already included in the headers chain and is considered + // the first confirmation. So we only need to retrieve `requiredConfirmations - 1` + // subsequent block headers to reach the desired number of confirmations for + // the transaction. + const headersChain = await bitcoinClient.getHeadersChain( + txBlockHeight, + requiredConfirmations - 1 + ) + + const merkleBranch = await bitcoinClient.getTransactionMerkle( + transactionHash, + txBlockHeight + ) + + const merkleProof = createMerkleProof(merkleBranch) + + const proof = { + merkleProof: merkleProof, + txIndexInBlock: merkleBranch.position, + bitcoinHeaders: headersChain, + } + + return { ...transaction, ...proof } +} + +/** + * Create a proof of transaction inclusion in the block by concatenating + * 32-byte-long hash values. The values are converted to little endian form. + * @param txMerkleBranch - Branch of a Merkle tree leading to a transaction. + * @returns Transaction inclusion proof in hexadecimal form. + */ +function createMerkleProof(txMerkleBranch: TransactionMerkleBranch): string { + let proof = Buffer.from("") + txMerkleBranch.merkle.forEach(function (item) { + proof = Buffer.concat([proof, Buffer.from(item, "hex").reverse()]) + }) + return proof.toString("hex") +} + +/** + * Proves that a transaction with the given hash is included in the Bitcoin + * blockchain by validating the transaction's inclusion in the Merkle tree and + * verifying that the block containing the transaction has enough confirmations. + * @param transactionHash The hash of the transaction to be validated. + * @param requiredConfirmations The number of confirmations required for the + * transaction to be considered valid. The transaction has 1 confirmation + * when it is in the block at the current blockchain tip. Every subsequent + * block added to the blockchain is one additional confirmation. + * @param previousDifficulty The difficulty of the previous Bitcoin epoch. + * @param currentDifficulty The difficulty of the current Bitcoin epoch. + * @param bitcoinClient The client for interacting with the Bitcoin blockchain. + * @throws {Error} If the transaction is not included in the Bitcoin blockchain + * or if the block containing the transaction does not have enough + * confirmations. + * @dev The function should be used within a try-catch block. + * @returns An empty return value. + */ +export async function validateTransactionProof( + transactionHash: TransactionHash, + requiredConfirmations: number, + previousDifficulty: BigNumber, + currentDifficulty: BigNumber, + bitcoinClient: Client +) { + if (requiredConfirmations < 1) { + throw new Error("The number of required confirmations but at least 1") + } + + const proof = await assembleTransactionProof( + transactionHash, + requiredConfirmations, + bitcoinClient + ) + + const bitcoinHeaders: BlockHeader[] = splitBlockHeadersChain( + proof.bitcoinHeaders + ) + if (bitcoinHeaders.length != requiredConfirmations) { + throw new Error("Wrong number of confirmations") + } + + const merkleRootHash: Hex = bitcoinHeaders[0].merkleRootHash + const intermediateNodeHashes: Hex[] = splitMerkleProof(proof.merkleProof) + + validateMerkleTree( + transactionHash, + merkleRootHash, + intermediateNodeHashes, + proof.txIndexInBlock + ) + + validateBlockHeadersChain( + bitcoinHeaders, + previousDifficulty, + currentDifficulty + ) +} + +/** + * Validates the Merkle tree by checking if the provided transaction hash, + * Merkle root hash, intermediate node hashes, and transaction index parameters + * produce a valid Merkle proof. + * @param transactionHash The hash of the transaction being validated. + * @param merkleRootHash The Merkle root hash that the intermediate node hashes + * should compute to. + * @param intermediateNodeHashes The Merkle tree intermediate node hashes. + * This is a list of hashes the transaction being validated is paired + * with in the Merkle tree. + * @param transactionIndex The index of the transaction being validated within + * the block, used to determine the path to traverse in the Merkle tree. + * @throws {Error} If the Merkle tree is not valid. + * @returns An empty return value. + */ +function validateMerkleTree( + transactionHash: TransactionHash, + merkleRootHash: Hex, + intermediateNodeHashes: Hex[], + transactionIndex: number +) { + // Shortcut for a block that contains only a single transaction (coinbase). + if ( + transactionHash.reverse().equals(merkleRootHash) && + transactionIndex == 0 && + intermediateNodeHashes.length == 0 + ) { + return + } + + validateMerkleTreeHashes( + transactionHash, + merkleRootHash, + intermediateNodeHashes, + transactionIndex + ) +} + +/** + * Validates the transaction's Merkle proof by traversing the Merkle tree + * starting from the provided transaction hash and using the intermediate node + * hashes to compute the root hash. If the computed root hash does not match the + * merkle root hash, an error is thrown. + * @param transactionHash The hash of the transaction being validated. + * @param merkleRootHash The Merkle root hash that the intermediate nodes should + * compute to. + * @param intermediateNodeHashes The Merkle tree intermediate node hashes. + * This is a list of hashes the transaction being validated is paired + * with in the Merkle tree. + * @param transactionIndex The index of the transaction in the block, used + * to determine the path to traverse in the Merkle tree. + * @throws {Error} If the intermediate nodes are of an invalid length or if the + * computed root hash does not match the merkle root hash parameter. + * @returns An empty return value. + */ +function validateMerkleTreeHashes( + transactionHash: TransactionHash, + merkleRootHash: Hex, + intermediateNodeHashes: Hex[], + transactionIndex: number +) { + // To prove the transaction inclusion in a block we only need the hashes that + // form a path from the transaction being validated to the Merkle root hash. + // If the Merkle tree looks like this: + // + // h_01234567 + // / \ + // h_0123 h_4567 + // / \ / \ + // h_01 h_23 h_45 h_67 + // / \ / \ / \ / \ + // h_0 h_1 h_2 h_3 h_4 h_5 h_6 h_7 + // + // and the transaction hash to be validated is h_5 the following data + // will be used: + // - `transactionHash`: h_5 + // - `merkleRootHash`: h_01234567 + // - `intermediateNodeHashes`: [h_4, h_67, h_0123] + // - `transactionIndex`: 5 + // + // The following calculations will be performed: + // - h_4 and h_5 will be hashed to obtain h_45 + // - h_45 and h_67 will be hashed to obtain h_4567 + // - h_0123 will be hashed with h_4567 to obtain h_1234567 (Merkle root hash). + + // Note that when we move up the Merkle tree calculating parent hashes we need + // to join children hashes. The information which child hash should go first + // is obtained from `transactionIndex`. When `transactionIndex` is odd the + // hash taken from `intermediateNodeHashes` must go first. If it is even the + // hash from previous calculation must go first. The `transactionIndex` is + // divided by `2` after every hash calculation. + + if (intermediateNodeHashes.length === 0) { + throw new Error("Invalid merkle tree") + } + + let idx = transactionIndex + let currentHash = transactionHash.reverse() + + // Move up the Merkle tree hashing current hash value with hashes taken + // from `intermediateNodeHashes`. Use `idx` to determine the order of joining + // children hashes. + for (let i = 0; i < intermediateNodeHashes.length; i++) { + if (idx % 2 === 1) { + // If the current value of idx is odd the hash taken from + // `intermediateNodeHashes` goes before the current hash. + currentHash = computeHash256( + Hex.from(intermediateNodeHashes[i].toString() + currentHash.toString()) + ) + } else { + // If the current value of idx is even the hash taken from the current + // hash goes before the hash taken from `intermediateNodeHashes`. + currentHash = computeHash256( + Hex.from(currentHash.toString() + intermediateNodeHashes[i].toString()) + ) + } + + // Divide the value of `idx` by `2` when we move one level up the Merkle + // tree. + idx = idx >> 1 + } + + // Verify we arrived at the same value of Merkle root hash as the one stored + // in the block header. + if (!currentHash.equals(merkleRootHash)) { + throw new Error( + "Transaction Merkle proof is not valid for provided header and transaction hash" + ) + } +} + +/** + * Splits a given Merkle proof string into an array of intermediate node hashes. + * @param merkleProof A string representation of the Merkle proof. + * @returns An array of intermediate node hashes. + * @throws {Error} If the length of the Merkle proof is not a multiple of 64. + */ +function splitMerkleProof(merkleProof: string): Hex[] { + if (merkleProof.length % 64 != 0) { + throw new Error("Incorrect length of Merkle proof") + } + + const intermediateNodeHashes: Hex[] = [] + for (let i = 0; i < merkleProof.length; i += 64) { + intermediateNodeHashes.push(Hex.from(merkleProof.slice(i, i + 64))) + } + + return intermediateNodeHashes +} diff --git a/typescript/src/proof.ts b/typescript/src/proof.ts deleted file mode 100644 index 5cddfcba0..000000000 --- a/typescript/src/proof.ts +++ /dev/null @@ -1,399 +0,0 @@ -import { - Transaction, - Proof, - TransactionMerkleBranch, - Client as BitcoinClient, - TransactionHash, - computeHash256, - deserializeBlockHeader, - bitsToTarget, - targetToDifficulty, - hashLEToBigNumber, - serializeBlockHeader, - BlockHeader, -} from "./lib/bitcoin" -import { BigNumber } from "ethers" -import { Hex } from "./lib/utils" - -/** - * Assembles a proof that a given transaction was included in the blockchain and - * has accumulated the required number of confirmations. - * @param transactionHash - Hash of the transaction being proven. - * @param requiredConfirmations - Required number of confirmations. - * @param bitcoinClient - Bitcoin client used to interact with the network. - * @returns Bitcoin transaction along with the inclusion proof. - */ -export async function assembleTransactionProof( - transactionHash: TransactionHash, - requiredConfirmations: number, - bitcoinClient: BitcoinClient -): Promise { - const transaction = await bitcoinClient.getTransaction(transactionHash) - const confirmations = await bitcoinClient.getTransactionConfirmations( - transactionHash - ) - - if (confirmations < requiredConfirmations) { - throw new Error( - "Transaction confirmations number[" + - confirmations + - "] is not enough, required [" + - requiredConfirmations + - "]" - ) - } - - const latestBlockHeight = await bitcoinClient.latestBlockHeight() - const txBlockHeight = latestBlockHeight - confirmations + 1 - - // We subtract `1` from `requiredConfirmations` because the header at - // `txBlockHeight` is already included in the headers chain and is considered - // the first confirmation. So we only need to retrieve `requiredConfirmations - 1` - // subsequent block headers to reach the desired number of confirmations for - // the transaction. - const headersChain = await bitcoinClient.getHeadersChain( - txBlockHeight, - requiredConfirmations - 1 - ) - - const merkleBranch = await bitcoinClient.getTransactionMerkle( - transactionHash, - txBlockHeight - ) - - const merkleProof = createMerkleProof(merkleBranch) - - const proof = { - merkleProof: merkleProof, - txIndexInBlock: merkleBranch.position, - bitcoinHeaders: headersChain, - } - - return { ...transaction, ...proof } -} - -/** - * Create a proof of transaction inclusion in the block by concatenating - * 32-byte-long hash values. The values are converted to little endian form. - * @param txMerkleBranch - Branch of a Merkle tree leading to a transaction. - * @returns Transaction inclusion proof in hexadecimal form. - */ -function createMerkleProof(txMerkleBranch: TransactionMerkleBranch): string { - let proof = Buffer.from("") - txMerkleBranch.merkle.forEach(function (item) { - proof = Buffer.concat([proof, Buffer.from(item, "hex").reverse()]) - }) - return proof.toString("hex") -} - -/** - * Proves that a transaction with the given hash is included in the Bitcoin - * blockchain by validating the transaction's inclusion in the Merkle tree and - * verifying that the block containing the transaction has enough confirmations. - * @param transactionHash The hash of the transaction to be validated. - * @param requiredConfirmations The number of confirmations required for the - * transaction to be considered valid. The transaction has 1 confirmation - * when it is in the block at the current blockchain tip. Every subsequent - * block added to the blockchain is one additional confirmation. - * @param previousDifficulty The difficulty of the previous Bitcoin epoch. - * @param currentDifficulty The difficulty of the current Bitcoin epoch. - * @param bitcoinClient The client for interacting with the Bitcoin blockchain. - * @throws {Error} If the transaction is not included in the Bitcoin blockchain - * or if the block containing the transaction does not have enough - * confirmations. - * @dev The function should be used within a try-catch block. - * @returns An empty return value. - */ -export async function validateTransactionProof( - transactionHash: TransactionHash, - requiredConfirmations: number, - previousDifficulty: BigNumber, - currentDifficulty: BigNumber, - bitcoinClient: BitcoinClient -) { - if (requiredConfirmations < 1) { - throw new Error("The number of required confirmations but at least 1") - } - - const proof = await assembleTransactionProof( - transactionHash, - requiredConfirmations, - bitcoinClient - ) - - const bitcoinHeaders: BlockHeader[] = splitHeaders(proof.bitcoinHeaders) - if (bitcoinHeaders.length != requiredConfirmations) { - throw new Error("Wrong number of confirmations") - } - - const merkleRootHash: Hex = bitcoinHeaders[0].merkleRootHash - const intermediateNodeHashes: Hex[] = splitMerkleProof(proof.merkleProof) - - validateMerkleTree( - transactionHash, - merkleRootHash, - intermediateNodeHashes, - proof.txIndexInBlock - ) - - validateBlockHeadersChain( - bitcoinHeaders, - previousDifficulty, - currentDifficulty - ) -} - -/** - * Validates the Merkle tree by checking if the provided transaction hash, - * Merkle root hash, intermediate node hashes, and transaction index parameters - * produce a valid Merkle proof. - * @param transactionHash The hash of the transaction being validated. - * @param merkleRootHash The Merkle root hash that the intermediate node hashes - * should compute to. - * @param intermediateNodeHashes The Merkle tree intermediate node hashes. - * This is a list of hashes the transaction being validated is paired - * with in the Merkle tree. - * @param transactionIndex The index of the transaction being validated within - * the block, used to determine the path to traverse in the Merkle tree. - * @throws {Error} If the Merkle tree is not valid. - * @returns An empty return value. - */ -function validateMerkleTree( - transactionHash: TransactionHash, - merkleRootHash: Hex, - intermediateNodeHashes: Hex[], - transactionIndex: number -) { - // Shortcut for a block that contains only a single transaction (coinbase). - if ( - transactionHash.reverse().equals(merkleRootHash) && - transactionIndex == 0 && - intermediateNodeHashes.length == 0 - ) { - return - } - - validateMerkleTreeHashes( - transactionHash, - merkleRootHash, - intermediateNodeHashes, - transactionIndex - ) -} - -/** - * Validates the transaction's Merkle proof by traversing the Merkle tree - * starting from the provided transaction hash and using the intermediate node - * hashes to compute the root hash. If the computed root hash does not match the - * merkle root hash, an error is thrown. - * @param transactionHash The hash of the transaction being validated. - * @param merkleRootHash The Merkle root hash that the intermediate nodes should - * compute to. - * @param intermediateNodeHashes The Merkle tree intermediate node hashes. - * This is a list of hashes the transaction being validated is paired - * with in the Merkle tree. - * @param transactionIndex The index of the transaction in the block, used - * to determine the path to traverse in the Merkle tree. - * @throws {Error} If the intermediate nodes are of an invalid length or if the - * computed root hash does not match the merkle root hash parameter. - * @returns An empty return value. - */ -function validateMerkleTreeHashes( - transactionHash: TransactionHash, - merkleRootHash: Hex, - intermediateNodeHashes: Hex[], - transactionIndex: number -) { - // To prove the transaction inclusion in a block we only need the hashes that - // form a path from the transaction being validated to the Merkle root hash. - // If the Merkle tree looks like this: - // - // h_01234567 - // / \ - // h_0123 h_4567 - // / \ / \ - // h_01 h_23 h_45 h_67 - // / \ / \ / \ / \ - // h_0 h_1 h_2 h_3 h_4 h_5 h_6 h_7 - // - // and the transaction hash to be validated is h_5 the following data - // will be used: - // - `transactionHash`: h_5 - // - `merkleRootHash`: h_01234567 - // - `intermediateNodeHashes`: [h_4, h_67, h_0123] - // - `transactionIndex`: 5 - // - // The following calculations will be performed: - // - h_4 and h_5 will be hashed to obtain h_45 - // - h_45 and h_67 will be hashed to obtain h_4567 - // - h_0123 will be hashed with h_4567 to obtain h_1234567 (Merkle root hash). - - // Note that when we move up the Merkle tree calculating parent hashes we need - // to join children hashes. The information which child hash should go first - // is obtained from `transactionIndex`. When `transactionIndex` is odd the - // hash taken from `intermediateNodeHashes` must go first. If it is even the - // hash from previous calculation must go first. The `transactionIndex` is - // divided by `2` after every hash calculation. - - if (intermediateNodeHashes.length === 0) { - throw new Error("Invalid merkle tree") - } - - let idx = transactionIndex - let currentHash = transactionHash.reverse() - - // Move up the Merkle tree hashing current hash value with hashes taken - // from `intermediateNodeHashes`. Use `idx` to determine the order of joining - // children hashes. - for (let i = 0; i < intermediateNodeHashes.length; i++) { - if (idx % 2 === 1) { - // If the current value of idx is odd the hash taken from - // `intermediateNodeHashes` goes before the current hash. - currentHash = computeHash256( - Hex.from(intermediateNodeHashes[i].toString() + currentHash.toString()) - ) - } else { - // If the current value of idx is even the hash taken from the current - // hash goes before the hash taken from `intermediateNodeHashes`. - currentHash = computeHash256( - Hex.from(currentHash.toString() + intermediateNodeHashes[i].toString()) - ) - } - - // Divide the value of `idx` by `2` when we move one level up the Merkle - // tree. - idx = idx >> 1 - } - - // Verify we arrived at the same value of Merkle root hash as the one stored - // in the block header. - if (!currentHash.equals(merkleRootHash)) { - throw new Error( - "Transaction Merkle proof is not valid for provided header and transaction hash" - ) - } -} - -/** - * Validates a chain of consecutive block headers by checking each header's - * difficulty, hash, and continuity with the previous header. This function can - * be used to validate a series of Bitcoin block headers for their validity. - * @param blockHeaders An array of block headers that form the chain to be - * validated. - * @param previousEpochDifficulty The difficulty of the previous Bitcoin epoch. - * @param currentEpochDifficulty The difficulty of the current Bitcoin epoch. - * @dev The block headers must come from Bitcoin epochs with difficulties marked - * by the previous and current difficulties. If a Bitcoin difficulty relay - * is used to provide these values and the relay is up-to-date, only the - * recent block headers will pass validation. Block headers older than the - * current and previous Bitcoin epochs will fail. - * @throws {Error} If any of the block headers are invalid, or if the block - * header chain is not continuous. - * @returns An empty return value. - */ -function validateBlockHeadersChain( - blockHeaders: BlockHeader[], - previousEpochDifficulty: BigNumber, - currentEpochDifficulty: BigNumber -) { - let requireCurrentDifficulty: boolean = false - let previousBlockHeaderHash: Hex = Hex.from("00") - - for (let index = 0; index < blockHeaders.length; index++) { - const currentHeader = blockHeaders[index] - - // Check if the current block header stores the hash of the previously - // processed block header. Skip the check for the first header. - if (index !== 0) { - if ( - !previousBlockHeaderHash.equals(currentHeader.previousBlockHeaderHash) - ) { - throw new Error("Invalid headers chain") - } - } - - const difficultyTarget = bitsToTarget(currentHeader.bits) - - const currentBlockHeaderHash = computeHash256( - serializeBlockHeader(currentHeader) - ) - - // Ensure the header has sufficient work. - if (hashLEToBigNumber(currentBlockHeaderHash).gt(difficultyTarget)) { - throw new Error("Insufficient work in the header") - } - - // Save the current block header hash to compare it with the next block - // header's previous block header hash. - previousBlockHeaderHash = currentBlockHeaderHash - - // Check if the stored block difficulty is equal to previous or current - // difficulties. - const difficulty = targetToDifficulty(difficultyTarget) - - if (previousEpochDifficulty.eq(1) && currentEpochDifficulty.eq(1)) { - // Special case for Bitcoin Testnet. Do not check block's difficulty - // due to required difficulty falling to `1` for Testnet. - continue - } - - if ( - !difficulty.eq(previousEpochDifficulty) && - !difficulty.eq(currentEpochDifficulty) - ) { - throw new Error( - "Header difficulty not at current or previous Bitcoin difficulty" - ) - } - - // Additionally, require the header to be at current difficulty if some - // headers at current difficulty have already been seen. This ensures - // there is at most one switch from previous to current difficulties. - if (requireCurrentDifficulty && !difficulty.eq(currentEpochDifficulty)) { - throw new Error("Header must be at current Bitcoin difficulty") - } - - // If the header is at current difficulty, require the subsequent headers to - // be at current difficulty as well. - requireCurrentDifficulty = difficulty.eq(currentEpochDifficulty) - } -} - -/** - * Splits a given Merkle proof string into an array of intermediate node hashes. - * @param merkleProof A string representation of the Merkle proof. - * @returns An array of intermediate node hashes. - * @throws {Error} If the length of the Merkle proof is not a multiple of 64. - */ -export function splitMerkleProof(merkleProof: string): Hex[] { - if (merkleProof.length % 64 != 0) { - throw new Error("Incorrect length of Merkle proof") - } - - const intermediateNodeHashes: Hex[] = [] - for (let i = 0; i < merkleProof.length; i += 64) { - intermediateNodeHashes.push(Hex.from(merkleProof.slice(i, i + 64))) - } - - return intermediateNodeHashes -} - -/** - * Splits Bitcoin block headers in the raw format into an array of BlockHeaders. - * @param blockHeaders - string that contains block headers in the raw format. - * @returns Array of BlockHeader objects. - */ -export function splitHeaders(blockHeaders: string): BlockHeader[] { - if (blockHeaders.length % 160 !== 0) { - throw new Error("Incorrect length of Bitcoin headers") - } - - const result: BlockHeader[] = [] - for (let i = 0; i < blockHeaders.length; i += 160) { - result.push( - deserializeBlockHeader(Hex.from(blockHeaders.substring(i, i + 160))) - ) - } - - return result -} diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index e1a3f0528..8db6dd296 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -1,6 +1,7 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" import { + assembleTransactionProof, BitcoinNetwork, createKeyRing, decomposeRawTransaction, @@ -15,7 +16,6 @@ import { TBTCToken, WalletState, } from "./lib/contracts" -import { assembleTransactionProof } from "./proof" import { determineWalletMainUtxo } from "./wallet" import { Hex } from "./lib/utils" diff --git a/typescript/test/proof.test.ts b/typescript/test/proof.test.ts index bfe846ac0..37c47ea8d 100644 --- a/typescript/test/proof.test.ts +++ b/typescript/test/proof.test.ts @@ -4,6 +4,9 @@ import { Transaction, BlockHeader, Proof, + assembleTransactionProof, + validateTransactionProof, + splitBlockHeadersChain, } from "../src/lib/bitcoin" import { Hex } from "../src/lib/utils" import { @@ -15,11 +18,6 @@ import { ProofTestData, TransactionProofData, } from "./data/proof" -import { - assembleTransactionProof, - validateTransactionProof, - splitHeaders, -} from "../src/proof" import { expect } from "chai" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" @@ -285,7 +283,7 @@ describe("Proof", () => { it("should throw", async () => { // Corrupt data by modifying previous block header hash of one of the // headers. - const headers: BlockHeader[] = splitHeaders( + const headers: BlockHeader[] = splitBlockHeadersChain( transactionConfirmationsInOneEpochData.bitcoinChainData.headersChain ) headers[headers.length - 1].previousBlockHeaderHash = Hex.from( @@ -313,7 +311,7 @@ describe("Proof", () => { it("should throw", async () => { // Corrupt data by modifying the nonce of one of the headers, so that // the resulting hash will be above the required difficulty target. - const headers: BlockHeader[] = splitHeaders( + const headers: BlockHeader[] = splitBlockHeadersChain( transactionConfirmationsInOneEpochData.bitcoinChainData.headersChain ) headers[headers.length - 1].nonce++ From 6c637d1eb5377bcfb4c09644aa39851ea5498978 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 26 Sep 2023 10:19:49 +0200 Subject: [PATCH 166/205] Final iteration on `lib/bitcoin` Here we make a final rework of the `lib/bitcoin` module. The main work is focused on introducing a consistent naming system that doesn't cause name clashes outside and group related functions into separate components. --- typescript/src/deposit-refund.ts | 38 +- typescript/src/deposit-sweep.ts | 71 ++- typescript/src/deposit.ts | 46 +- typescript/src/index.ts | 12 +- typescript/src/lib/bitcoin/address.ts | 26 +- typescript/src/lib/bitcoin/client.ts | 29 +- typescript/src/lib/bitcoin/csuint.ts | 9 +- .../src/lib/bitcoin/{key.ts => ecdsa-key.ts} | 25 +- typescript/src/lib/bitcoin/hash.ts | 15 +- .../src/lib/bitcoin/{block.ts => header.ts} | 199 +++--- typescript/src/lib/bitcoin/index.ts | 8 +- .../src/lib/bitcoin/{proof.ts => spv.ts} | 51 +- .../src/lib/bitcoin/{transaction.ts => tx.ts} | 55 +- typescript/src/lib/contracts/bridge.ts | 30 +- typescript/src/lib/contracts/tbtc-token.ts | 4 +- typescript/src/lib/contracts/tbtc-vault.ts | 12 +- typescript/src/lib/electrum/client.ts | 101 ++- typescript/src/lib/ethereum/bridge.ts | 61 +- typescript/src/lib/ethereum/tbtc-token.ts | 12 +- typescript/src/lib/ethereum/tbtc-vault.ts | 14 +- typescript/src/optimistic-minting.ts | 10 +- typescript/src/redemption.ts | 57 +- typescript/src/wallet.ts | 25 +- typescript/test/bitcoin-network.test.ts | 8 +- typescript/test/bitcoin.test.ts | 588 +++++++++--------- typescript/test/data/deposit-refund.ts | 24 +- typescript/test/data/deposit-sweep.ts | 99 +-- typescript/test/data/deposit.ts | 12 +- typescript/test/data/electrum.ts | 22 +- typescript/test/data/proof.ts | 62 +- typescript/test/data/redemption.ts | 78 +-- typescript/test/deposit-refund.test.ts | 14 +- typescript/test/deposit-sweep.test.ts | 70 +-- typescript/test/deposit.test.ts | 46 +- typescript/test/ethereum.test.ts | 18 +- typescript/test/proof.test.ts | 47 +- typescript/test/redemption.test.ts | 100 ++- typescript/test/utils/mock-bitcoin-client.ts | 88 ++- typescript/test/utils/mock-bridge.ts | 50 +- typescript/test/utils/mock-tbtc-token.ts | 6 +- typescript/test/wallet.test.ts | 41 +- 41 files changed, 1163 insertions(+), 1120 deletions(-) rename typescript/src/lib/bitcoin/{key.ts => ecdsa-key.ts} (77%) rename typescript/src/lib/bitcoin/{block.ts => header.ts} (75%) rename typescript/src/lib/bitcoin/{proof.ts => spv.ts} (91%) rename typescript/src/lib/bitcoin/{transaction.ts => tx.ts} (76%) diff --git a/typescript/src/deposit-refund.ts b/typescript/src/deposit-refund.ts index 16fa8448d..d2fe47da8 100644 --- a/typescript/src/deposit-refund.ts +++ b/typescript/src/deposit-refund.ts @@ -1,13 +1,13 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" import { - createKeyRing, - RawTransaction, - Client as BitcoinClient, - TransactionHash, - UnspentTransactionOutput, - computeHash160, - isCompressedPublicKey, + BitcoinPrivateKeyUtils, + BitcoinRawTx, + BitcoinClient, + BitcoinTxHash, + BitcoinUtxo, + BitcoinHashUtils, + BitcoinPublicKeyUtils, } from "./lib/bitcoin" import { Deposit } from "./lib/contracts" import { @@ -38,11 +38,11 @@ import { export async function submitDepositRefundTransaction( bitcoinClient: BitcoinClient, fee: BigNumber, - utxo: UnspentTransactionOutput, + utxo: BitcoinUtxo, deposit: Deposit, refunderAddress: string, refunderPrivateKey: string -): Promise<{ transactionHash: TransactionHash }> { +): Promise<{ transactionHash: BitcoinTxHash }> { const utxoRawTransaction = await bitcoinClient.getRawTransaction( utxo.transactionHash ) @@ -86,17 +86,18 @@ export async function submitDepositRefundTransaction( */ export async function assembleDepositRefundTransaction( fee: BigNumber, - utxo: UnspentTransactionOutput & RawTransaction, + utxo: BitcoinUtxo & BitcoinRawTx, deposit: Deposit, refunderAddress: string, refunderPrivateKey: string ): Promise<{ - transactionHash: TransactionHash - rawTransaction: RawTransaction + transactionHash: BitcoinTxHash + rawTransaction: BitcoinRawTx }> { validateInputParameters(deposit, utxo) - const refunderKeyRing = createKeyRing(refunderPrivateKey) + const refunderKeyRing = + BitcoinPrivateKeyUtils.createKeyRing(refunderPrivateKey) const transaction = new bcoin.MTX() @@ -149,7 +150,7 @@ export async function assembleDepositRefundTransaction( throw new Error("Transaction verification failure") } - const transactionHash = TransactionHash.from(transaction.txid()) + const transactionHash = BitcoinTxHash.from(transaction.txid()) return { transactionHash, @@ -186,7 +187,7 @@ async function prepareInputSignData( const refunderPublicKey = refunderKeyRing.getPublicKey("hex") if ( - computeHash160(refunderKeyRing.getPublicKey("hex")) != + BitcoinHashUtils.computeHash160(refunderKeyRing.getPublicKey("hex")) != deposit.refundPublicKeyHash ) { throw new Error( @@ -194,7 +195,7 @@ async function prepareInputSignData( ) } - if (!isCompressedPublicKey(refunderPublicKey)) { + if (!BitcoinPublicKeyUtils.isCompressedPublicKey(refunderPublicKey)) { throw new Error("Refunder public key must be compressed") } @@ -315,10 +316,7 @@ function locktimeToUnixTimestamp(locktime: string): number { * @param utxo - UTXO that was created during depositing that needs be refunded. * @returns Empty return. */ -function validateInputParameters( - deposit: Deposit, - utxo: UnspentTransactionOutput -) { +function validateInputParameters(deposit: Deposit, utxo: BitcoinUtxo) { validateDepositScriptParameters(deposit) if (!deposit.amount.eq(utxo.value)) { diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 4a80b1cdc..6b20c142f 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -1,15 +1,15 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" import { - assembleTransactionProof, - RawTransaction, - UnspentTransactionOutput, - Client as BitcoinClient, - decomposeRawTransaction, - isCompressedPublicKey, - createKeyRing, - TransactionHash, - computeHash160, + assembleBitcoinSpvProof, + BitcoinRawTx, + BitcoinUtxo, + BitcoinClient, + extractBitcoinRawTxVectors, + BitcoinPublicKeyUtils, + BitcoinPrivateKeyUtils, + BitcoinTxHash, + BitcoinHashUtils, } from "./lib/bitcoin" import { assembleDepositScript } from "./deposit" import { Bridge, Identifier, Deposit } from "./lib/contracts" @@ -41,14 +41,14 @@ export async function submitDepositSweepTransaction( fee: BigNumber, walletPrivateKey: string, witness: boolean, - utxos: UnspentTransactionOutput[], + utxos: BitcoinUtxo[], deposits: Deposit[], - mainUtxo?: UnspentTransactionOutput + mainUtxo?: BitcoinUtxo ): Promise<{ - transactionHash: TransactionHash - newMainUtxo: UnspentTransactionOutput + transactionHash: BitcoinTxHash + newMainUtxo: BitcoinUtxo }> { - const utxosWithRaw: (UnspentTransactionOutput & RawTransaction)[] = [] + const utxosWithRaw: (BitcoinUtxo & BitcoinRawTx)[] = [] for (const utxo of utxos) { const utxoRawTransaction = await bitcoinClient.getRawTransaction( utxo.transactionHash @@ -114,13 +114,13 @@ export async function assembleDepositSweepTransaction( fee: BigNumber, walletPrivateKey: string, witness: boolean, - utxos: (UnspentTransactionOutput & RawTransaction)[], + utxos: (BitcoinUtxo & BitcoinRawTx)[], deposits: Deposit[], - mainUtxo?: UnspentTransactionOutput & RawTransaction + mainUtxo?: BitcoinUtxo & BitcoinRawTx ): Promise<{ - transactionHash: TransactionHash - newMainUtxo: UnspentTransactionOutput - rawTransaction: RawTransaction + transactionHash: BitcoinTxHash + newMainUtxo: BitcoinUtxo + rawTransaction: BitcoinRawTx }> { if (utxos.length < 1) { throw new Error("There must be at least one deposit UTXO to sweep") @@ -130,7 +130,10 @@ export async function assembleDepositSweepTransaction( throw new Error("Number of UTXOs must equal the number of deposit elements") } - const walletKeyRing = createKeyRing(walletPrivateKey, witness) + const walletKeyRing = BitcoinPrivateKeyUtils.createKeyRing( + walletPrivateKey, + witness + ) const walletAddress = walletKeyRing.getAddress("string") const inputCoins = [] @@ -177,12 +180,12 @@ export async function assembleDepositSweepTransaction( // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any // order - const utxosWithDeposits: (UnspentTransactionOutput & - RawTransaction & - Deposit)[] = utxos.map((utxo, index) => ({ - ...utxo, - ...deposits[index], - })) + const utxosWithDeposits: (BitcoinUtxo & BitcoinRawTx & Deposit)[] = utxos.map( + (utxo, index) => ({ + ...utxo, + ...deposits[index], + }) + ) for (let i = 0; i < transaction.inputs.length; i++) { const previousOutpoint = transaction.inputs[i].prevout @@ -220,7 +223,7 @@ export async function assembleDepositSweepTransaction( } } - const transactionHash = TransactionHash.from(transaction.txid()) + const transactionHash = BitcoinTxHash.from(transaction.txid()) return { transactionHash, @@ -359,7 +362,7 @@ async function prepareInputSignData( const walletPublicKey = walletKeyRing.getPublicKey("hex") if ( - computeHash160(walletKeyRing.getPublicKey("hex")) != + BitcoinHashUtils.computeHash160(walletKeyRing.getPublicKey("hex")) != deposit.walletPublicKeyHash ) { throw new Error( @@ -367,7 +370,7 @@ async function prepareInputSignData( ) } - if (!isCompressedPublicKey(walletPublicKey)) { + if (!BitcoinPublicKeyUtils.isCompressedPublicKey(walletPublicKey)) { throw new Error("Wallet public key must be compressed") } @@ -396,14 +399,14 @@ async function prepareInputSignData( * @returns Empty promise. */ export async function submitDepositSweepProof( - transactionHash: TransactionHash, - mainUtxo: UnspentTransactionOutput, + transactionHash: BitcoinTxHash, + mainUtxo: BitcoinUtxo, bridge: Bridge, bitcoinClient: BitcoinClient, vault?: Identifier ): Promise { const confirmations = await bridge.txProofDifficultyFactor() - const proof = await assembleTransactionProof( + const proof = await assembleBitcoinSpvProof( transactionHash, confirmations, bitcoinClient @@ -412,9 +415,9 @@ export async function submitDepositSweepProof( // proof to the decomposed transaction data (version, inputs, outputs, locktime). // Use raw transaction data for now. const rawTransaction = await bitcoinClient.getRawTransaction(transactionHash) - const decomposedRawTransaction = decomposeRawTransaction(rawTransaction) + const rawTransactionVectors = extractBitcoinRawTxVectors(rawTransaction) await bridge.submitDepositSweepProof( - decomposedRawTransaction, + rawTransactionVectors, proof, mainUtxo, vault diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 7d66bc7e8..78b2b8fcc 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -1,15 +1,14 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" import { - Client as BitcoinClient, + BitcoinClient, BitcoinNetwork, toBcoinNetwork, - decomposeRawTransaction, - createKeyRing, - RawTransaction, - UnspentTransactionOutput, - TransactionHash, - isPublicKeyHashLength, + extractBitcoinRawTxVectors, + BitcoinPrivateKeyUtils, + BitcoinRawTx, + BitcoinUtxo, + BitcoinTxHash, } from "./lib/bitcoin" import { Bridge, @@ -40,17 +39,18 @@ export async function submitDepositTransaction( bitcoinClient: BitcoinClient, witness: boolean ): Promise<{ - transactionHash: TransactionHash - depositUtxo: UnspentTransactionOutput + transactionHash: BitcoinTxHash + depositUtxo: BitcoinUtxo }> { - const depositorKeyRing = createKeyRing(depositorPrivateKey) + const depositorKeyRing = + BitcoinPrivateKeyUtils.createKeyRing(depositorPrivateKey) const depositorAddress = depositorKeyRing.getAddress("string") const utxos = await bitcoinClient.findAllUnspentTransactionOutputs( depositorAddress ) - const utxosWithRaw: (UnspentTransactionOutput & RawTransaction)[] = [] + const utxosWithRaw: (BitcoinUtxo & BitcoinRawTx)[] = [] for (const utxo of utxos) { const utxoRawTransaction = await bitcoinClient.getRawTransaction( utxo.transactionHash @@ -92,15 +92,16 @@ export async function submitDepositTransaction( */ export async function assembleDepositTransaction( deposit: Deposit, - utxos: (UnspentTransactionOutput & RawTransaction)[], + utxos: (BitcoinUtxo & BitcoinRawTx)[], depositorPrivateKey: string, witness: boolean ): Promise<{ - transactionHash: TransactionHash - depositUtxo: UnspentTransactionOutput - rawTransaction: RawTransaction + transactionHash: BitcoinTxHash + depositUtxo: BitcoinUtxo + rawTransaction: BitcoinRawTx }> { - const depositorKeyRing = createKeyRing(depositorPrivateKey) + const depositorKeyRing = + BitcoinPrivateKeyUtils.createKeyRing(depositorPrivateKey) const depositorAddress = depositorKeyRing.getAddress("string") const inputCoins = utxos.map((utxo) => @@ -130,7 +131,7 @@ export async function assembleDepositTransaction( transaction.sign(depositorKeyRing) - const transactionHash = TransactionHash.from(transaction.txid()) + const transactionHash = BitcoinTxHash.from(transaction.txid()) return { transactionHash, @@ -198,12 +199,11 @@ export function validateDepositScriptParameters( if (deposit.blindingFactor.length != 16) { throw new Error("Blinding factor must be an 8-byte number") } - - if (!isPublicKeyHashLength(deposit.walletPublicKeyHash)) { + if (deposit.walletPublicKeyHash.length != 40) { throw new Error("Invalid wallet public key hash") } - if (!isPublicKeyHashLength(deposit.refundPublicKeyHash)) { + if (deposit.refundPublicKeyHash.length != 40) { throw new Error("Invalid refund public key hash") } @@ -294,13 +294,13 @@ export async function calculateDepositAddress( * that matches the given deposit data. */ export async function revealDeposit( - utxo: UnspentTransactionOutput, + utxo: BitcoinUtxo, deposit: DepositScriptParameters, bitcoinClient: BitcoinClient, bridge: Bridge, vault?: Identifier ): Promise { - const depositTx = decomposeRawTransaction( + const depositTx = extractBitcoinRawTxVectors( await bitcoinClient.getRawTransaction(utxo.transactionHash) ) @@ -314,7 +314,7 @@ export async function revealDeposit( * @returns Revealed deposit data. */ export async function getRevealedDeposit( - utxo: UnspentTransactionOutput, + utxo: BitcoinUtxo, bridge: Bridge ): Promise { return bridge.deposits(utxo.transactionHash, utxo.outputIndex) diff --git a/typescript/src/index.ts b/typescript/src/index.ts index 8d2666446..c522694f8 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -1,6 +1,6 @@ // TODO: Consider exports refactoring as per discussion https://github.com/keep-network/tbtc-v2/pull/460#discussion_r1084530007 -import { validateTransactionProof } from "./lib/bitcoin" +import { validateBitcoinSpvProof } from "./lib/bitcoin" import { calculateDepositAddress, @@ -48,14 +48,14 @@ export const OptimisticMinting = { } export const Bitcoin = { - validateTransactionProof, + validateBitcoinSpvProof, } export { - TransactionHash as BitcoinTransactionHash, - Transaction as BitcoinTransaction, - TransactionOutput as BitcoinTransactionOutput, - locktimeToNumber as BitcoinLocktimeToNumber, + BitcoinTxHash, + BitcoinTx, + BitcoinTxOutput, + BitcoinLocktimeUtils, BitcoinNetwork, } from "./lib/bitcoin" diff --git a/typescript/src/lib/bitcoin/address.ts b/typescript/src/lib/bitcoin/address.ts index 354cb3db7..874d995ab 100644 --- a/typescript/src/lib/bitcoin/address.ts +++ b/typescript/src/lib/bitcoin/address.ts @@ -3,7 +3,7 @@ import { Hex } from "../utils" import { BitcoinNetwork, toBcoinNetwork } from "./network" /** - * Encodes a public key hash into a P2PKH/P2WPKH address. + * Converts a public key hash into a P2PKH/P2WPKH address. * @param publicKeyHash - public key hash that will be encoded. Must be an * unprefixed hex string (without 0x prefix). * @param witness - If true, a witness public key hash will be encoded and @@ -12,7 +12,7 @@ import { BitcoinNetwork, toBcoinNetwork } from "./network" * @returns P2PKH or P2WPKH address encoded from the given public key hash * @throws Throws an error if network is not supported. */ -export function encodeToBitcoinAddress( +function publicKeyHashToAddress( publicKeyHash: string, witness: boolean, network: BitcoinNetwork @@ -25,13 +25,13 @@ export function encodeToBitcoinAddress( } /** - * Decodes P2PKH or P2WPKH address into a public key hash. Throws if the + * Converts a P2PKH or P2WPKH address into a public key hash. Throws if the * provided address is not PKH-based. * @param address - P2PKH or P2WPKH address that will be decoded. * @returns Public key hash decoded from the address. This will be an unprefixed * hex string (without 0x prefix). */ -export function decodeBitcoinAddress(address: string): string { +function addressToPublicKeyHash(address: string): string { const addressObject = new bcoin.Address(address) const isPKH = @@ -44,21 +44,21 @@ export function decodeBitcoinAddress(address: string): string { } /** - * Creates the output script from the BTC address. + * Converts an address to the respective output script. * @param address BTC address. * @returns The un-prefixed and not prepended with length output script. */ -export function createOutputScriptFromAddress(address: string): Hex { +function addressToOutputScript(address: string): Hex { return Hex.from(Script.fromAddress(address).toRaw().toString("hex")) } /** - * Creates the Bitcoin address from the output script. + * Converts an output script to the respective network-specific address. * @param script The unprefixed and not prepended with length output script. * @param network Bitcoin network. * @returns The Bitcoin address. */ -export function createAddressFromOutputScript( +function outputScriptToAddress( script: Hex, network: BitcoinNetwork = BitcoinNetwork.Mainnet ): string { @@ -66,3 +66,13 @@ export function createAddressFromOutputScript( .getAddress() ?.toString(toBcoinNetwork(network)) } + +/** + * Utility functions allowing to perform Bitcoin address conversions. + */ +export const BitcoinAddressConverter = { + publicKeyHashToAddress, + addressToPublicKeyHash, + addressToOutputScript, + outputScriptToAddress, +} diff --git a/typescript/src/lib/bitcoin/client.ts b/typescript/src/lib/bitcoin/client.ts index 0d1e10e99..6e3d512fe 100644 --- a/typescript/src/lib/bitcoin/client.ts +++ b/typescript/src/lib/bitcoin/client.ts @@ -1,16 +1,11 @@ import { BitcoinNetwork } from "./network" -import { - RawTransaction, - Transaction, - TransactionHash, - UnspentTransactionOutput, -} from "./transaction" -import { TransactionMerkleBranch } from "./proof" +import { BitcoinRawTx, BitcoinTx, BitcoinTxHash, BitcoinUtxo } from "./tx" +import { BitcoinTxMerkleBranch } from "./spv" /** * Represents a Bitcoin client. */ -export interface Client { +export interface BitcoinClient { /** * Gets the network supported by the server the client connected to. * @returns Bitcoin network. @@ -22,9 +17,7 @@ export interface Client { * @param address - Bitcoin address UTXOs should be determined for. * @returns List of UTXOs. */ - findAllUnspentTransactionOutputs( - address: string - ): Promise + findAllUnspentTransactionOutputs(address: string): Promise /** * Gets the history of confirmed transactions for given Bitcoin address. @@ -36,21 +29,21 @@ export interface Client { * a specific number of last transaction. For example, limit = 5 will * return only the last 5 transactions for the given address. */ - getTransactionHistory(address: string, limit?: number): Promise + getTransactionHistory(address: string, limit?: number): Promise /** * Gets the full transaction object for given transaction hash. * @param transactionHash - Hash of the transaction. * @returns Transaction object. */ - getTransaction(transactionHash: TransactionHash): Promise + getTransaction(transactionHash: BitcoinTxHash): Promise /** * Gets the raw transaction data for given transaction hash. * @param transactionHash - Hash of the transaction. * @returns Raw transaction. */ - getRawTransaction(transactionHash: TransactionHash): Promise + getRawTransaction(transactionHash: BitcoinTxHash): Promise /** * Gets the number of confirmations that a given transaction has accumulated @@ -58,7 +51,7 @@ export interface Client { * @param transactionHash - Hash of the transaction. * @returns The number of confirmations. */ - getTransactionConfirmations(transactionHash: TransactionHash): Promise + getTransactionConfirmations(transactionHash: BitcoinTxHash): Promise /** * Gets height of the latest mined block. @@ -82,13 +75,13 @@ export interface Client { * @return Merkle branch. */ getTransactionMerkle( - transactionHash: TransactionHash, + transactionHash: BitcoinTxHash, blockHeight: number - ): Promise + ): Promise /** * Broadcasts the given transaction over the network. * @param transaction - Transaction to broadcast. */ - broadcast(transaction: RawTransaction): Promise + broadcast(transaction: BitcoinRawTx): Promise } diff --git a/typescript/src/lib/bitcoin/csuint.ts b/typescript/src/lib/bitcoin/csuint.ts index 613736103..e0576e176 100644 --- a/typescript/src/lib/bitcoin/csuint.ts +++ b/typescript/src/lib/bitcoin/csuint.ts @@ -10,7 +10,7 @@ import { Hex } from "../utils" * @returns An object holding the value of the compact size uint along with the * compact size uint byte length. */ -export function readCompactSizeUint(varLenData: Hex): { +function read(varLenData: Hex): { value: number byteLength: number } { @@ -39,3 +39,10 @@ export function readCompactSizeUint(varLenData: Hex): { } } } + +/** + * Utility functions allowing to deal with Bitcoin compact size uints. + */ +export const BitcoinCompactSizeUint = { + read, +} diff --git a/typescript/src/lib/bitcoin/key.ts b/typescript/src/lib/bitcoin/ecdsa-key.ts similarity index 77% rename from typescript/src/lib/bitcoin/key.ts rename to typescript/src/lib/bitcoin/ecdsa-key.ts index 968bd2bed..16a6b1ec7 100644 --- a/typescript/src/lib/bitcoin/key.ts +++ b/typescript/src/lib/bitcoin/ecdsa-key.ts @@ -8,7 +8,7 @@ import { Hex } from "../utils" * @param publicKey - Public key that should be checked. * @returns True if the key is a compressed Bitcoin public key, false otherwise. */ -export function isCompressedPublicKey(publicKey: string): boolean { +function isCompressedPublicKey(publicKey: string): boolean { // Must have 33 bytes and 02 or 03 prefix. return ( publicKey.length == 66 && @@ -21,7 +21,7 @@ export function isCompressedPublicKey(publicKey: string): boolean { * @param publicKey Uncompressed 64-byte public key as an unprefixed hex string. * @returns Compressed 33-byte public key prefixed with 02 or 03. */ -export function compressPublicKey(publicKey: string | Hex): string { +function compressPublicKey(publicKey: string | Hex): string { if (typeof publicKey === "string") { publicKey = Hex.from(publicKey) } @@ -51,12 +51,11 @@ export function compressPublicKey(publicKey: string | Hex): string { } /** - * Checks if given public key hash has proper length (20-byte) - * @param publicKeyHash - text that will be checked for the correct length - * @returns true if the given string is 20-byte long, false otherwise + * Utility functions allowing to perform Bitcoin ECDSA public keys. */ -export function isPublicKeyHashLength(publicKeyHash: string): boolean { - return publicKeyHash.length === 40 +export const BitcoinPublicKeyUtils = { + isCompressedPublicKey, + compressPublicKey, } /** @@ -66,10 +65,7 @@ export function isPublicKeyHashLength(publicKeyHash: string): boolean { * or non-witness addresses * @returns Bitcoin key ring. */ -export function createKeyRing( - privateKey: string, - witness: boolean = true -): any { +function createKeyRing(privateKey: string, witness: boolean = true): any { const decodedPrivateKey = wif.decode(privateKey) return new bcoin.KeyRing({ @@ -78,3 +74,10 @@ export function createKeyRing( compressed: decodedPrivateKey.compressed, }) } + +/** + * Utility functions allowing to perform Bitcoin ECDSA public keys. + */ +export const BitcoinPrivateKeyUtils = { + createKeyRing, +} diff --git a/typescript/src/lib/bitcoin/hash.ts b/typescript/src/lib/bitcoin/hash.ts index bef166140..31426edf9 100644 --- a/typescript/src/lib/bitcoin/hash.ts +++ b/typescript/src/lib/bitcoin/hash.ts @@ -6,7 +6,7 @@ import { Hex } from "../utils" * @param text - Text the HASH160 is computed for. * @returns Hash as a 20-byte un-prefixed hex string. */ -export function computeHash160(text: string): string { +function computeHash160(text: string): string { const sha256Hash = utils.sha256( Hex.from(Buffer.from(text, "hex")).toPrefixedString() ) @@ -20,7 +20,7 @@ export function computeHash160(text: string): string { * @param text - Text the double SHA256 is computed for. * @returns Hash as a 32-byte un-prefixed hex string. */ -export function computeHash256(text: Hex): Hex { +function computeHash256(text: Hex): Hex { const firstHash = utils.sha256(text.toPrefixedString()) const secondHash = utils.sha256(firstHash) @@ -32,6 +32,15 @@ export function computeHash256(text: Hex): Hex { * @param hash - Hash in hex-string format. * @returns BigNumber representation of the hash. */ -export function hashLEToBigNumber(hash: Hex): BigNumber { +function hashLEToBigNumber(hash: Hex): BigNumber { return BigNumber.from(hash.reverse().toPrefixedString()) } + +/** + * Utility functions allowing to deal with Bitcoin hashes. + */ +export const BitcoinHashUtils = { + computeHash160, + computeHash256, + hashLEToBigNumber, +} diff --git a/typescript/src/lib/bitcoin/block.ts b/typescript/src/lib/bitcoin/header.ts similarity index 75% rename from typescript/src/lib/bitcoin/block.ts rename to typescript/src/lib/bitcoin/header.ts index 185ffa619..06531d933 100644 --- a/typescript/src/lib/bitcoin/block.ts +++ b/typescript/src/lib/bitcoin/header.ts @@ -1,12 +1,12 @@ import { BigNumber } from "ethers" import { Hex } from "../utils" -import { computeHash256, hashLEToBigNumber } from "./hash" +import { BitcoinHashUtils } from "./hash" /** - * BlockHeader represents the header of a Bitcoin block. For reference, see: + * BitcoinHeader represents the header of a Bitcoin block. For reference, see: * https://developer.bitcoin.org/reference/block_chain.html#block-headers. */ -export interface BlockHeader { +export interface BitcoinHeader { /** * The block version number that indicates which set of block validation rules * to follow. The field is 4-byte long. @@ -45,28 +45,28 @@ export interface BlockHeader { } /** - * Serializes a BlockHeader to the raw representation. - * @param blockHeader - block header. - * @returns Serialized block header. + * Serializes a Bitcoin block header to the raw representation. + * @param header - Bitcoin block header. + * @returns Serialized Bitcoin block header. */ -export function serializeBlockHeader(blockHeader: BlockHeader): Hex { +function serializeHeader(header: BitcoinHeader): Hex { const buffer = Buffer.alloc(80) - buffer.writeUInt32LE(blockHeader.version, 0) - blockHeader.previousBlockHeaderHash.toBuffer().copy(buffer, 4) - blockHeader.merkleRootHash.toBuffer().copy(buffer, 36) - buffer.writeUInt32LE(blockHeader.time, 68) - buffer.writeUInt32LE(blockHeader.bits, 72) - buffer.writeUInt32LE(blockHeader.nonce, 76) + buffer.writeUInt32LE(header.version, 0) + header.previousBlockHeaderHash.toBuffer().copy(buffer, 4) + header.merkleRootHash.toBuffer().copy(buffer, 36) + buffer.writeUInt32LE(header.time, 68) + buffer.writeUInt32LE(header.bits, 72) + buffer.writeUInt32LE(header.nonce, 76) return Hex.from(buffer) } /** - * Deserializes a block header in the raw representation to BlockHeader. - * @param rawBlockHeader - BlockHeader in the raw format. - * @returns Block header as a BlockHeader. + * Deserializes a raw representation of a Bitcoin block header. + * @param rawHeader - Raw Bitcoin block header. + * @returns Deserialized Bitcoin block header. */ -export function deserializeBlockHeader(rawBlockHeader: Hex): BlockHeader { - const buffer = rawBlockHeader.toBuffer() +function deserializeHeader(rawHeader: Hex): BitcoinHeader { + const buffer = rawHeader.toBuffer() const version = buffer.readUInt32LE(0) const previousBlockHeaderHash = buffer.slice(4, 36) const merkleRootHash = buffer.slice(36, 68) @@ -85,69 +85,39 @@ export function deserializeBlockHeader(rawBlockHeader: Hex): BlockHeader { } /** - * Converts a block header's bits into target. - * @param bits - bits from block header. - * @returns Target as a BigNumber. + * Deserializes a raw representation of a Bitcoin block headers chain. + * @param rawHeadersChain - Raw Bitcoin block headers chain. + * @returns Deserialized Bitcoin block headers. */ -export function bitsToTarget(bits: number): BigNumber { - // A serialized 80-byte block header stores the `bits` value as a 4-byte - // little-endian hexadecimal value in a slot including bytes 73, 74, 75, and - // 76. This function's input argument is expected to be a numerical - // representation of that 4-byte value reverted to the big-endian order. - // For example, if the `bits` little-endian value in the header is - // `0xcb04041b`, it must be reverted to the big-endian form `0x1b0404cb` and - // turned to a decimal number `453248203` in order to be used as this - // function's input. - // - // The `bits` 4-byte big-endian representation is a compact value that works - // like a base-256 version of scientific notation. It encodes the target - // exponent in the first byte and the target mantissa in the last three bytes. - // Referring to the previous example, if `bits = 453248203`, the hexadecimal - // representation is `0x1b0404cb` so the exponent is `0x1b` while the mantissa - // is `0x0404cb`. - // - // To extract the exponent, we need to shift right by 3 bytes (24 bits), - // extract the last byte of the result, and subtract 3 (because of the - // mantissa length): - // - 0x1b0404cb >>> 24 = 0x0000001b - // - 0x0000001b & 0xff = 0x1b - // - 0x1b - 3 = 24 (decimal) - // - // To extract the mantissa, we just need to take the last three bytes: - // - 0x1b0404cb & 0xffffff = 0x0404cb = 263371 (decimal) - // - // The final difficulty can be computed as mantissa * 256^exponent: - // - 263371 * 256^24 = - // 1653206561150525499452195696179626311675293455763937233695932416 (decimal) - // - // Sources: - // - https://developer.bitcoin.org/reference/block_chain.html#target-nbits - // - https://wiki.bitcoinsv.io/index.php/Target +function deserializeHeadersChain(rawHeadersChain: string): BitcoinHeader[] { + if (rawHeadersChain.length % 160 !== 0) { + throw new Error("Incorrect length of Bitcoin headers") + } - const exponent = ((bits >>> 24) & 0xff) - 3 - const mantissa = bits & 0xffffff + const result: BitcoinHeader[] = [] + for (let i = 0; i < rawHeadersChain.length; i += 160) { + result.push( + deserializeHeader(Hex.from(rawHeadersChain.substring(i, i + 160))) + ) + } - const target = BigNumber.from(mantissa).mul(BigNumber.from(256).pow(exponent)) - return target + return result } /** - * Converts difficulty target to difficulty. - * @param target - difficulty target. - * @returns Difficulty as a BigNumber. + * Utility functions allowing to serialize and deserialize Bitcoin block headers. */ -export function targetToDifficulty(target: BigNumber): BigNumber { - const DIFF1_TARGET = BigNumber.from( - "0xffff0000000000000000000000000000000000000000000000000000" - ) - return DIFF1_TARGET.div(target) +export const BitcoinHeaderSerializer = { + serializeHeader, + deserializeHeader, + deserializeHeadersChain, } /** * Validates a chain of consecutive block headers by checking each header's * difficulty, hash, and continuity with the previous header. This function can * be used to validate a series of Bitcoin block headers for their validity. - * @param blockHeaders An array of block headers that form the chain to be + * @param headers An array of block headers that form the chain to be * validated. * @param previousEpochDifficulty The difficulty of the previous Bitcoin epoch. * @param currentEpochDifficulty The difficulty of the current Bitcoin epoch. @@ -160,16 +130,16 @@ export function targetToDifficulty(target: BigNumber): BigNumber { * header chain is not continuous. * @returns An empty return value. */ -export function validateBlockHeadersChain( - blockHeaders: BlockHeader[], +export function validateBitcoinHeadersChain( + headers: BitcoinHeader[], previousEpochDifficulty: BigNumber, currentEpochDifficulty: BigNumber ) { let requireCurrentDifficulty: boolean = false let previousBlockHeaderHash: Hex = Hex.from("00") - for (let index = 0; index < blockHeaders.length; index++) { - const currentHeader = blockHeaders[index] + for (let index = 0; index < headers.length; index++) { + const currentHeader = headers[index] // Check if the current block header stores the hash of the previously // processed block header. Skip the check for the first header. @@ -183,12 +153,16 @@ export function validateBlockHeadersChain( const difficultyTarget = bitsToTarget(currentHeader.bits) - const currentBlockHeaderHash = computeHash256( - serializeBlockHeader(currentHeader) + const currentBlockHeaderHash = BitcoinHashUtils.computeHash256( + serializeHeader(currentHeader) ) // Ensure the header has sufficient work. - if (hashLEToBigNumber(currentBlockHeaderHash).gt(difficultyTarget)) { + if ( + BitcoinHashUtils.hashLEToBigNumber(currentBlockHeaderHash).gt( + difficultyTarget + ) + ) { throw new Error("Insufficient work in the header") } @@ -229,21 +203,68 @@ export function validateBlockHeadersChain( } /** - * Splits Bitcoin block headers in the raw format into an array of BlockHeaders. - * @param blockHeaders - string that contains block headers in the raw format. - * @returns Array of BlockHeader objects. + * Converts a block header's bits into target. + * @param bits - bits from block header. + * @returns Target as a BigNumber. */ -export function splitBlockHeadersChain(blockHeaders: string): BlockHeader[] { - if (blockHeaders.length % 160 !== 0) { - throw new Error("Incorrect length of Bitcoin headers") - } +function bitsToTarget(bits: number): BigNumber { + // A serialized 80-byte block header stores the `bits` value as a 4-byte + // little-endian hexadecimal value in a slot including bytes 73, 74, 75, and + // 76. This function's input argument is expected to be a numerical + // representation of that 4-byte value reverted to the big-endian order. + // For example, if the `bits` little-endian value in the header is + // `0xcb04041b`, it must be reverted to the big-endian form `0x1b0404cb` and + // turned to a decimal number `453248203` in order to be used as this + // function's input. + // + // The `bits` 4-byte big-endian representation is a compact value that works + // like a base-256 version of scientific notation. It encodes the target + // exponent in the first byte and the target mantissa in the last three bytes. + // Referring to the previous example, if `bits = 453248203`, the hexadecimal + // representation is `0x1b0404cb` so the exponent is `0x1b` while the mantissa + // is `0x0404cb`. + // + // To extract the exponent, we need to shift right by 3 bytes (24 bits), + // extract the last byte of the result, and subtract 3 (because of the + // mantissa length): + // - 0x1b0404cb >>> 24 = 0x0000001b + // - 0x0000001b & 0xff = 0x1b + // - 0x1b - 3 = 24 (decimal) + // + // To extract the mantissa, we just need to take the last three bytes: + // - 0x1b0404cb & 0xffffff = 0x0404cb = 263371 (decimal) + // + // The final difficulty can be computed as mantissa * 256^exponent: + // - 263371 * 256^24 = + // 1653206561150525499452195696179626311675293455763937233695932416 (decimal) + // + // Sources: + // - https://developer.bitcoin.org/reference/block_chain.html#target-nbits + // - https://wiki.bitcoinsv.io/index.php/Target - const result: BlockHeader[] = [] - for (let i = 0; i < blockHeaders.length; i += 160) { - result.push( - deserializeBlockHeader(Hex.from(blockHeaders.substring(i, i + 160))) - ) - } + const exponent = ((bits >>> 24) & 0xff) - 3 + const mantissa = bits & 0xffffff - return result + const target = BigNumber.from(mantissa).mul(BigNumber.from(256).pow(exponent)) + return target +} + +/** + * Converts difficulty target to difficulty. + * @param target - difficulty target. + * @returns Difficulty as a BigNumber. + */ +function targetToDifficulty(target: BigNumber): BigNumber { + const DIFF1_TARGET = BigNumber.from( + "0xffff0000000000000000000000000000000000000000000000000000" + ) + return DIFF1_TARGET.div(target) +} + +/** + * Utility functions allowing to perform Bitcoin target conversions. + */ +export const BitcoinTargetConverter = { + bitsToTarget, + targetToDifficulty, } diff --git a/typescript/src/lib/bitcoin/index.ts b/typescript/src/lib/bitcoin/index.ts index 2cc43b708..52028bc46 100644 --- a/typescript/src/lib/bitcoin/index.ts +++ b/typescript/src/lib/bitcoin/index.ts @@ -1,9 +1,9 @@ export * from "./address" -export * from "./block" export * from "./client" export * from "./csuint" +export * from "./ecdsa-key" export * from "./hash" -export * from "./key" +export * from "./header" export * from "./network" -export * from "./proof" -export * from "./transaction" +export * from "./spv" +export * from "./tx" diff --git a/typescript/src/lib/bitcoin/proof.ts b/typescript/src/lib/bitcoin/spv.ts similarity index 91% rename from typescript/src/lib/bitcoin/proof.ts rename to typescript/src/lib/bitcoin/spv.ts index 60ce9128d..4deb1cec4 100644 --- a/typescript/src/lib/bitcoin/proof.ts +++ b/typescript/src/lib/bitcoin/spv.ts @@ -1,19 +1,19 @@ -import { Transaction, TransactionHash } from "./transaction" -import { Client } from "./client" +import { BitcoinTx, BitcoinTxHash } from "./tx" +import { BitcoinClient } from "./client" import { BigNumber } from "ethers" import { - BlockHeader, - splitBlockHeadersChain, - validateBlockHeadersChain, -} from "./block" + BitcoinHeader, + BitcoinHeaderSerializer, + validateBitcoinHeadersChain, +} from "./header" import { Hex } from "../utils" -import { computeHash256 } from "./hash" +import { BitcoinHashUtils } from "./hash" /** * Data required to perform a proof that a given transaction was included in * the Bitcoin blockchain. */ -export interface Proof { +export interface BitcoinSpvProof { /** * The merkle proof of transaction inclusion in a block, as an un-prefixed * hex string. @@ -35,7 +35,7 @@ export interface Proof { /** * Information about the merkle branch to a confirmed transaction. */ -export interface TransactionMerkleBranch { +export interface BitcoinTxMerkleBranch { /** * The height of the block the transaction was confirmed in. */ @@ -62,11 +62,11 @@ export interface TransactionMerkleBranch { * @param bitcoinClient - Bitcoin client used to interact with the network. * @returns Bitcoin transaction along with the inclusion proof. */ -export async function assembleTransactionProof( - transactionHash: TransactionHash, +export async function assembleBitcoinSpvProof( + transactionHash: BitcoinTxHash, requiredConfirmations: number, - bitcoinClient: Client -): Promise { + bitcoinClient: BitcoinClient +): Promise { const transaction = await bitcoinClient.getTransaction(transactionHash) const confirmations = await bitcoinClient.getTransactionConfirmations( transactionHash @@ -117,7 +117,7 @@ export async function assembleTransactionProof( * @param txMerkleBranch - Branch of a Merkle tree leading to a transaction. * @returns Transaction inclusion proof in hexadecimal form. */ -function createMerkleProof(txMerkleBranch: TransactionMerkleBranch): string { +function createMerkleProof(txMerkleBranch: BitcoinTxMerkleBranch): string { let proof = Buffer.from("") txMerkleBranch.merkle.forEach(function (item) { proof = Buffer.concat([proof, Buffer.from(item, "hex").reverse()]) @@ -143,26 +143,25 @@ function createMerkleProof(txMerkleBranch: TransactionMerkleBranch): string { * @dev The function should be used within a try-catch block. * @returns An empty return value. */ -export async function validateTransactionProof( - transactionHash: TransactionHash, +export async function validateBitcoinSpvProof( + transactionHash: BitcoinTxHash, requiredConfirmations: number, previousDifficulty: BigNumber, currentDifficulty: BigNumber, - bitcoinClient: Client + bitcoinClient: BitcoinClient ) { if (requiredConfirmations < 1) { throw new Error("The number of required confirmations but at least 1") } - const proof = await assembleTransactionProof( + const proof = await assembleBitcoinSpvProof( transactionHash, requiredConfirmations, bitcoinClient ) - const bitcoinHeaders: BlockHeader[] = splitBlockHeadersChain( - proof.bitcoinHeaders - ) + const bitcoinHeaders: BitcoinHeader[] = + BitcoinHeaderSerializer.deserializeHeadersChain(proof.bitcoinHeaders) if (bitcoinHeaders.length != requiredConfirmations) { throw new Error("Wrong number of confirmations") } @@ -177,7 +176,7 @@ export async function validateTransactionProof( proof.txIndexInBlock ) - validateBlockHeadersChain( + validateBitcoinHeadersChain( bitcoinHeaders, previousDifficulty, currentDifficulty @@ -200,7 +199,7 @@ export async function validateTransactionProof( * @returns An empty return value. */ function validateMerkleTree( - transactionHash: TransactionHash, + transactionHash: BitcoinTxHash, merkleRootHash: Hex, intermediateNodeHashes: Hex[], transactionIndex: number @@ -240,7 +239,7 @@ function validateMerkleTree( * @returns An empty return value. */ function validateMerkleTreeHashes( - transactionHash: TransactionHash, + transactionHash: BitcoinTxHash, merkleRootHash: Hex, intermediateNodeHashes: Hex[], transactionIndex: number @@ -290,13 +289,13 @@ function validateMerkleTreeHashes( if (idx % 2 === 1) { // If the current value of idx is odd the hash taken from // `intermediateNodeHashes` goes before the current hash. - currentHash = computeHash256( + currentHash = BitcoinHashUtils.computeHash256( Hex.from(intermediateNodeHashes[i].toString() + currentHash.toString()) ) } else { // If the current value of idx is even the hash taken from the current // hash goes before the hash taken from `intermediateNodeHashes`. - currentHash = computeHash256( + currentHash = BitcoinHashUtils.computeHash256( Hex.from(currentHash.toString() + intermediateNodeHashes[i].toString()) ) } diff --git a/typescript/src/lib/bitcoin/transaction.ts b/typescript/src/lib/bitcoin/tx.ts similarity index 76% rename from typescript/src/lib/bitcoin/transaction.ts rename to typescript/src/lib/bitcoin/tx.ts index 7d9b69670..e51532dc1 100644 --- a/typescript/src/lib/bitcoin/transaction.ts +++ b/typescript/src/lib/bitcoin/tx.ts @@ -4,18 +4,18 @@ import { BigNumber } from "ethers" import { Hex } from "../utils" /** - * Represents a transaction hash (or transaction ID) as an un-prefixed hex + * Represents a Bitcoin transaction hash (or transaction ID) as an un-prefixed hex * string. This hash is supposed to have the same byte order as used by the * Bitcoin block explorers which is the opposite of the byte order used * by the Bitcoin protocol internally. That means the hash must be reversed in * the use cases that expect the Bitcoin internal byte order. */ -export class TransactionHash extends Hex {} +export class BitcoinTxHash extends Hex {} /** - * Represents a raw transaction. + * Represents a raw Bitcoin transaction. */ -export interface RawTransaction { +export interface BitcoinRawTx { /** * The full transaction payload as an un-prefixed hex string. */ @@ -23,33 +23,33 @@ export interface RawTransaction { } /** - * Data about a transaction. + * Data about a Bitcoin transaction. */ -export interface Transaction { +export interface BitcoinTx { /** * The transaction hash (or transaction ID) as an un-prefixed hex string. */ - transactionHash: TransactionHash + transactionHash: BitcoinTxHash /** * The vector of transaction inputs. */ - inputs: TransactionInput[] + inputs: BitcoinTxInput[] /** * The vector of transaction outputs. */ - outputs: TransactionOutput[] + outputs: BitcoinTxOutput[] } /** - * Data about a transaction outpoint. + * Data about a Bitcoin transaction outpoint. */ -export interface TransactionOutpoint { +export interface BitcoinTxOutpoint { /** * The hash of the transaction the outpoint belongs to. */ - transactionHash: TransactionHash + transactionHash: BitcoinTxHash /** * The zero-based index of the output from the specified transaction. @@ -58,9 +58,9 @@ export interface TransactionOutpoint { } /** - * Data about a transaction input. + * Data about a Bitcoin transaction input. */ -export type TransactionInput = TransactionOutpoint & { +export type BitcoinTxInput = BitcoinTxOutpoint & { /** * The scriptSig that unlocks the specified outpoint for spending. */ @@ -68,9 +68,9 @@ export type TransactionInput = TransactionOutpoint & { } /** - * Data about a transaction output. + * Data about a Bitcoin transaction output. */ -export interface TransactionOutput { +export interface BitcoinTxOutput { /** * The 0-based index of the output. */ @@ -88,9 +88,9 @@ export interface TransactionOutput { } /** - * Data about an unspent transaction output. + * Data about a Bitcoin unspent transaction output. */ -export type UnspentTransactionOutput = TransactionOutpoint & { +export type BitcoinUtxo = BitcoinTxOutpoint & { /** * The unspent value in satoshis. */ @@ -98,9 +98,9 @@ export type UnspentTransactionOutput = TransactionOutpoint & { } /** - * Represents data of decomposed raw transaction. + * Represents a raw Bitcoin transaction decomposed into specific vectors. */ -export interface DecomposedRawTransaction { +export interface BitcoinRawTxVectors { /** * Transaction version as an un-prefixed hex string. */ @@ -130,9 +130,9 @@ export interface DecomposedRawTransaction { * @param rawTransaction - Transaction in the raw format. * @returns Transaction data with fields represented as un-prefixed hex strings. */ -export function decomposeRawTransaction( - rawTransaction: RawTransaction -): DecomposedRawTransaction { +export function extractBitcoinRawTxVectors( + rawTransaction: BitcoinRawTx +): BitcoinRawTxVectors { const toHex = (bufferWriter: any) => { return bufferWriter.render().toString("hex") } @@ -189,7 +189,14 @@ export function decomposeRawTransaction( * hex string {@link: Deposit#refundLocktime}. * @returns UNIX timestamp in seconds. */ -export function locktimeToNumber(locktimeLE: Buffer | string): number { +function locktimeToNumber(locktimeLE: Buffer | string): number { const locktimeBE: Buffer = Hex.from(locktimeLE).reverse().toBuffer() return BigNumber.from(locktimeBE).toNumber() } + +/** + * Utility functions allowing to deal with Bitcoin locktime. + */ +export const BitcoinLocktimeUtils = { + locktimeToNumber, +} diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index c663dc527..b92d54911 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -1,9 +1,9 @@ import { BigNumber } from "ethers" import { - Proof, - UnspentTransactionOutput, - DecomposedRawTransaction, - TransactionHash, + BitcoinSpvProof, + BitcoinUtxo, + BitcoinRawTxVectors, + BitcoinTxHash, } from "../bitcoin" import { Hex } from "../utils" import { Event, GetEvents } from "./chain-event" @@ -29,9 +29,9 @@ export interface Bridge { * be routed in. */ submitDepositSweepProof( - sweepTx: DecomposedRawTransaction, - sweepProof: Proof, - mainUtxo: UnspentTransactionOutput, + sweepTx: BitcoinRawTxVectors, + sweepProof: BitcoinSpvProof, + mainUtxo: BitcoinUtxo, vault?: Identifier ): Promise @@ -46,7 +46,7 @@ export interface Bridge { * @returns Transaction hash of the reveal deposit transaction as string */ revealDeposit( - depositTx: DecomposedRawTransaction, + depositTx: BitcoinRawTxVectors, depositOutputIndex: number, deposit: DepositScriptParameters, vault?: Identifier @@ -60,7 +60,7 @@ export interface Bridge { * @returns Revealed deposit data. */ deposits( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise @@ -77,7 +77,7 @@ export interface Bridge { */ requestRedemption( walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScript: string, amount: BigNumber ): Promise @@ -91,9 +91,9 @@ export interface Bridge { * compressed form (33 bytes long with 02 or 03 prefix). */ submitRedemptionProof( - redemptionTx: DecomposedRawTransaction, - redemptionProof: Proof, - mainUtxo: UnspentTransactionOutput, + redemptionTx: BitcoinRawTxVectors, + redemptionProof: BitcoinSpvProof, + mainUtxo: BitcoinUtxo, walletPublicKey: string ): Promise @@ -167,7 +167,7 @@ export interface Bridge { * @param utxo UTXO components. * @returns The hash of the UTXO. */ - buildUtxoHash(utxo: UnspentTransactionOutput): Hex + buildUtxoHash(utxo: BitcoinUtxo): Hex /** * Get emitted RedemptionRequested events. @@ -268,7 +268,7 @@ export type RevealedDeposit = Pick< * Represents an event emitted on deposit reveal to the on-chain bridge. */ export type DepositRevealedEvent = Deposit & { - fundingTxHash: TransactionHash + fundingTxHash: BitcoinTxHash fundingOutputIndex: number } & Event diff --git a/typescript/src/lib/contracts/tbtc-token.ts b/typescript/src/lib/contracts/tbtc-token.ts index dcfdd484a..9e32a4801 100644 --- a/typescript/src/lib/contracts/tbtc-token.ts +++ b/typescript/src/lib/contracts/tbtc-token.ts @@ -1,5 +1,5 @@ import { BigNumber } from "ethers" -import { UnspentTransactionOutput } from "../bitcoin" +import { BitcoinUtxo } from "../bitcoin" import { Hex } from "../utils" /** @@ -36,7 +36,7 @@ export interface TBTCToken { */ requestRedemption( walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScript: string, amount: BigNumber ): Promise diff --git a/typescript/src/lib/contracts/tbtc-vault.ts b/typescript/src/lib/contracts/tbtc-vault.ts index 732251000..8a61c5f8e 100644 --- a/typescript/src/lib/contracts/tbtc-vault.ts +++ b/typescript/src/lib/contracts/tbtc-vault.ts @@ -1,4 +1,4 @@ -import { TransactionHash } from "../bitcoin" +import { BitcoinTxHash } from "../bitcoin" import { Hex } from "../utils" import { Identifier } from "./chain-identifier" import { Event, GetEvents } from "./chain-event" @@ -47,7 +47,7 @@ export interface TBTCVault { * @returns Transaction hash of the optimistic mint request transaction. */ requestOptimisticMint( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise @@ -60,7 +60,7 @@ export interface TBTCVault { * @returns Transaction hash of the optimistic mint cancel transaction. */ cancelOptimisticMint( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise @@ -73,7 +73,7 @@ export interface TBTCVault { * @returns Transaction hash of the optimistic mint finalize transaction. */ finalizeOptimisticMint( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise @@ -85,7 +85,7 @@ export interface TBTCVault { * @returns Optimistic minting request. */ optimisticMintingRequests( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise @@ -153,7 +153,7 @@ export type OptimisticMintingRequestedEvent = { /** * Hash of a Bitcoin transaction made to fund the deposit. */ - fundingTxHash: TransactionHash + fundingTxHash: BitcoinTxHash /** * Index of an output in the funding transaction made to fund the deposit. */ diff --git a/typescript/src/lib/electrum/client.ts b/typescript/src/lib/electrum/client.ts index 0142e8037..cf12baca5 100644 --- a/typescript/src/lib/electrum/client.ts +++ b/typescript/src/lib/electrum/client.ts @@ -1,16 +1,16 @@ import bcoin from "bcoin" import pTimeout from "p-timeout" import { - Client as BitcoinClient, + BitcoinClient, BitcoinNetwork, - createOutputScriptFromAddress, - RawTransaction, - Transaction, - TransactionHash, - TransactionInput, - TransactionMerkleBranch, - TransactionOutput, - UnspentTransactionOutput, + BitcoinAddressConverter, + BitcoinRawTx, + BitcoinTx, + BitcoinTxHash, + BitcoinTxInput, + BitcoinTxMerkleBranch, + BitcoinTxOutput, + BitcoinUtxo, } from "../bitcoin" import Electrum from "electrum-client-js" import { BigNumber, utils } from "ethers" @@ -226,42 +226,37 @@ export class Client implements BitcoinClient { /** * @see {BitcoinClient#findAllUnspentTransactionOutputs} */ - findAllUnspentTransactionOutputs( - address: string - ): Promise { - return this.withElectrum( - async (electrum: Electrum) => { - const script = createOutputScriptFromAddress(address).toString() + findAllUnspentTransactionOutputs(address: string): Promise { + return this.withElectrum(async (electrum: Electrum) => { + const script = + BitcoinAddressConverter.addressToOutputScript(address).toString() - // eslint-disable-next-line camelcase - type UnspentOutput = { tx_pos: number; value: number; tx_hash: string } - - const unspentTransactions: UnspentOutput[] = - await this.withBackoffRetrier()(async () => { - return await electrum.blockchain_scripthash_listunspent( - computeScriptHash(script) - ) - }) - - return unspentTransactions.reverse().map((tx: UnspentOutput) => ({ - transactionHash: TransactionHash.from(tx.tx_hash), - outputIndex: tx.tx_pos, - value: BigNumber.from(tx.value), - })) - } - ) + // eslint-disable-next-line camelcase + type UnspentOutput = { tx_pos: number; value: number; tx_hash: string } + + const unspentTransactions: UnspentOutput[] = + await this.withBackoffRetrier()(async () => { + return await electrum.blockchain_scripthash_listunspent( + computeScriptHash(script) + ) + }) + + return unspentTransactions.reverse().map((tx: UnspentOutput) => ({ + transactionHash: BitcoinTxHash.from(tx.tx_hash), + outputIndex: tx.tx_pos, + value: BigNumber.from(tx.value), + })) + }) } // eslint-disable-next-line valid-jsdoc /** * @see {BitcoinClient#getTransactionHistory} */ - getTransactionHistory( - address: string, - limit?: number - ): Promise { - return this.withElectrum(async (electrum: Electrum) => { - const script = createOutputScriptFromAddress(address).toString() + getTransactionHistory(address: string, limit?: number): Promise { + return this.withElectrum(async (electrum: Electrum) => { + const script = + BitcoinAddressConverter.addressToOutputScript(address).toString() // eslint-disable-next-line camelcase type HistoryItem = { height: number; tx_hash: string } @@ -297,7 +292,7 @@ export class Client implements BitcoinClient { } const transactions = historyItems.map((item) => - this.getTransaction(TransactionHash.from(item.tx_hash)) + this.getTransaction(BitcoinTxHash.from(item.tx_hash)) ) return Promise.all(transactions) @@ -308,8 +303,8 @@ export class Client implements BitcoinClient { /** * @see {BitcoinClient#getTransaction} */ - getTransaction(transactionHash: TransactionHash): Promise { - return this.withElectrum(async (electrum: Electrum) => { + getTransaction(transactionHash: BitcoinTxHash): Promise { + return this.withElectrum(async (electrum: Electrum) => { // We cannot use `blockchain_transaction_get` with `verbose = true` argument // to get the the transaction details as Esplora/Electrs doesn't support verbose // transactions. @@ -331,15 +326,15 @@ export class Client implements BitcoinClient { const transaction = bcoin.TX.fromRaw(rawTransaction, "hex") const inputs = transaction.inputs.map( - (input: any): TransactionInput => ({ - transactionHash: TransactionHash.from(input.prevout.hash).reverse(), + (input: any): BitcoinTxInput => ({ + transactionHash: BitcoinTxHash.from(input.prevout.hash).reverse(), outputIndex: input.prevout.index, scriptSig: Hex.from(input.script.toRaw()), }) ) const outputs = transaction.outputs.map( - (output: any, i: number): TransactionOutput => ({ + (output: any, i: number): BitcoinTxOutput => ({ outputIndex: i, value: BigNumber.from(output.value), scriptPubKey: Hex.from(output.script.toRaw()), @@ -347,7 +342,7 @@ export class Client implements BitcoinClient { ) return { - transactionHash: TransactionHash.from(transaction.hash()).reverse(), + transactionHash: BitcoinTxHash.from(transaction.hash()).reverse(), inputs: inputs, outputs: outputs, } @@ -358,8 +353,8 @@ export class Client implements BitcoinClient { /** * @see {BitcoinClient#getRawTransaction} */ - getRawTransaction(transactionHash: TransactionHash): Promise { - return this.withElectrum(async (electrum: Electrum) => { + getRawTransaction(transactionHash: BitcoinTxHash): Promise { + return this.withElectrum(async (electrum: Electrum) => { const transaction: string = await this.withBackoffRetrier()( async () => { return await electrum.blockchain_transaction_get( @@ -379,9 +374,7 @@ export class Client implements BitcoinClient { /** * @see {BitcoinClient#getTransactionConfirmations} */ - getTransactionConfirmations( - transactionHash: TransactionHash - ): Promise { + getTransactionConfirmations(transactionHash: BitcoinTxHash): Promise { // We cannot use `blockchain_transaction_get` with `verbose = true` argument // to get the the transaction details as Esplora/Electrs doesn't support verbose // transactions. @@ -507,10 +500,10 @@ export class Client implements BitcoinClient { * @see {BitcoinClient#getTransactionMerkle} */ getTransactionMerkle( - transactionHash: TransactionHash, + transactionHash: BitcoinTxHash, blockHeight: number - ): Promise { - return this.withElectrum( + ): Promise { + return this.withElectrum( async (electrum: Electrum) => { const merkle = await this.withBackoffRetrier<{ // eslint-disable-next-line camelcase @@ -537,7 +530,7 @@ export class Client implements BitcoinClient { /** * @see {BitcoinClient#broadcast} */ - broadcast(transaction: RawTransaction): Promise { + broadcast(transaction: BitcoinRawTx): Promise { return this.withElectrum(async (electrum: Electrum) => { await this.withBackoffRetrier()(async () => { return await electrum.blockchain_transaction_broadcast( diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index 824a8c286..03da23321 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -22,13 +22,13 @@ import { Event as EthersEvent } from "@ethersproject/contracts" import { BigNumber, constants, ContractTransaction, utils } from "ethers" import { backoffRetrier, Hex } from "../utils" import { - compressPublicKey, - computeHash160, - DecomposedRawTransaction, - Proof, - readCompactSizeUint, - TransactionHash, - UnspentTransactionOutput, + BitcoinPublicKeyUtils, + BitcoinHashUtils, + BitcoinRawTxVectors, + BitcoinSpvProof, + BitcoinCompactSizeUint, + BitcoinTxHash, + BitcoinUtxo, } from "../bitcoin" import { ContractConfig, @@ -75,9 +75,7 @@ export class Bridge blockNumber: BigNumber.from(event.blockNumber).toNumber(), blockHash: Hex.from(event.blockHash), transactionHash: Hex.from(event.transactionHash), - fundingTxHash: TransactionHash.from( - event.args!.fundingTxHash - ).reverse(), + fundingTxHash: BitcoinTxHash.from(event.args!.fundingTxHash).reverse(), fundingOutputIndex: BigNumber.from( event.args!.fundingOutputIndex ).toNumber(), @@ -104,7 +102,7 @@ export class Bridge redeemerOutputScript: string ): Promise { const redemptionKey = Bridge.buildRedemptionKey( - computeHash160(walletPublicKey), + BitcoinHashUtils.computeHash160(walletPublicKey), redeemerOutputScript ) @@ -127,7 +125,7 @@ export class Bridge redeemerOutputScript: string ): Promise { const redemptionKey = Bridge.buildRedemptionKey( - computeHash160(walletPublicKey), + BitcoinHashUtils.computeHash160(walletPublicKey), redeemerOutputScript ) @@ -200,7 +198,7 @@ export class Bridge * @see {ChainBridge#revealDeposit} */ async revealDeposit( - depositTx: DecomposedRawTransaction, + depositTx: BitcoinRawTxVectors, depositOutputIndex: number, deposit: DepositScriptParameters, vault?: ChainIdentifier @@ -238,9 +236,9 @@ export class Bridge * @see {ChainBridge#submitDepositSweepProof} */ async submitDepositSweepProof( - sweepTx: DecomposedRawTransaction, - sweepProof: Proof, - mainUtxo: UnspentTransactionOutput, + sweepTx: BitcoinRawTxVectors, + sweepProof: BitcoinSpvProof, + mainUtxo: BitcoinUtxo, vault?: ChainIdentifier ): Promise { const sweepTxParam = { @@ -298,11 +296,13 @@ export class Bridge */ async requestRedemption( walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScript: string, amount: BigNumber ): Promise { - const walletPublicKeyHash = `0x${computeHash160(walletPublicKey)}` + const walletPublicKeyHash = `0x${BitcoinHashUtils.computeHash160( + walletPublicKey + )}` const mainUtxoParam = { // The Ethereum Bridge expects this hash to be in the Bitcoin internal @@ -335,9 +335,9 @@ export class Bridge * @see {ChainBridge#submitRedemptionProof} */ async submitRedemptionProof( - redemptionTx: DecomposedRawTransaction, - redemptionProof: Proof, - mainUtxo: UnspentTransactionOutput, + redemptionTx: BitcoinRawTxVectors, + redemptionProof: BitcoinSpvProof, + mainUtxo: BitcoinUtxo, walletPublicKey: string ): Promise { const redemptionTxParam = { @@ -361,7 +361,9 @@ export class Bridge txOutputValue: mainUtxo.value, } - const walletPublicKeyHash = `0x${computeHash160(walletPublicKey)}` + const walletPublicKeyHash = `0x${BitcoinHashUtils.computeHash160( + walletPublicKey + )}` await sendWithRetry(async () => { return await this._instance.submitRedemptionProof( @@ -378,7 +380,7 @@ export class Bridge * @see {ChainBridge#deposits} */ async deposits( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { const depositKey = Bridge.buildDepositKey(depositTxHash, depositOutputIndex) @@ -401,7 +403,7 @@ export class Bridge * @returns Deposit key. */ static buildDepositKey( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): string { const prefixedReversedDepositTxHash = depositTxHash @@ -466,7 +468,9 @@ export class Bridge ecdsaWalletID ) - return Hex.from(compressPublicKey(uncompressedPublicKey)) + return Hex.from( + BitcoinPublicKeyUtils.compressPublicKey(uncompressedPublicKey) + ) } // eslint-disable-next-line valid-jsdoc @@ -561,7 +565,7 @@ export class Bridge * * @see {ChainBridge#buildUtxoHash} */ - buildUtxoHash(utxo: UnspentTransactionOutput): Hex { + buildUtxoHash(utxo: BitcoinUtxo): Hex { return Hex.from( utils.solidityKeccak256( ["bytes32", "uint32", "uint64"], @@ -600,7 +604,10 @@ export class Bridge ) const redeemerOutputScript = prefixedRedeemerOutputScript .toString() - .slice(readCompactSizeUint(prefixedRedeemerOutputScript).byteLength * 2) + .slice( + BitcoinCompactSizeUint.read(prefixedRedeemerOutputScript).byteLength * + 2 + ) return { blockNumber: BigNumber.from(event.blockNumber).toNumber(), diff --git a/typescript/src/lib/ethereum/tbtc-token.ts b/typescript/src/lib/ethereum/tbtc-token.ts index 51f1aa480..825a8c920 100644 --- a/typescript/src/lib/ethereum/tbtc-token.ts +++ b/typescript/src/lib/ethereum/tbtc-token.ts @@ -1,7 +1,7 @@ import { TBTC as ContractTBTC } from "../../../typechain/TBTC" import { TBTCToken as ChainTBTCToken } from "../contracts" import { BigNumber, ContractTransaction, utils } from "ethers" -import { computeHash160, UnspentTransactionOutput } from "../bitcoin" +import { BitcoinHashUtils, BitcoinUtxo } from "../bitcoin" import { Hex } from "../utils" import { ContractConfig, @@ -38,7 +38,7 @@ export class TBTCToken */ async requestRedemption( walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScript: string, amount: BigNumber ): Promise { @@ -69,7 +69,7 @@ export class TBTCToken private buildRequestRedemptionData( redeemer: Address, walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScript: string ): Hex { const { @@ -99,10 +99,12 @@ export class TBTCToken private buildBridgeRequestRedemptionData( walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScript: string ) { - const walletPublicKeyHash = `0x${computeHash160(walletPublicKey)}` + const walletPublicKeyHash = `0x${BitcoinHashUtils.computeHash160( + walletPublicKey + )}` const mainUtxoParam = { // The Ethereum Bridge expects this hash to be in the Bitcoin internal diff --git a/typescript/src/lib/ethereum/tbtc-vault.ts b/typescript/src/lib/ethereum/tbtc-vault.ts index d381c2973..30c7eccec 100644 --- a/typescript/src/lib/ethereum/tbtc-vault.ts +++ b/typescript/src/lib/ethereum/tbtc-vault.ts @@ -8,7 +8,7 @@ import { OptimisticMintingRequestedEvent, } from "../contracts" import { BigNumber, ContractTransaction } from "ethers" -import { TransactionHash } from "../bitcoin" +import { BitcoinTxHash } from "../bitcoin" import { backoffRetrier, Hex } from "../utils" import TBTCVaultDeployment from "@keep-network/tbtc-v2/artifacts/TBTCVault.json" import { @@ -88,7 +88,7 @@ export class TBTCVault * @see {ChainTBTCVault#requestOptimisticMint} */ async requestOptimisticMint( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { const tx = await sendWithRetry( @@ -114,7 +114,7 @@ export class TBTCVault * @see {ChainTBTCVault#cancelOptimisticMint} */ async cancelOptimisticMint( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { const tx = await sendWithRetry( @@ -137,7 +137,7 @@ export class TBTCVault * @see {ChainTBTCVault#finalizeOptimisticMint} */ async finalizeOptimisticMint( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { const tx = await sendWithRetry( @@ -163,7 +163,7 @@ export class TBTCVault * @see {ChainTBTCVault#optimisticMintingRequests} */ async optimisticMintingRequests( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { const depositKey = Bridge.buildDepositKey(depositTxHash, depositOutputIndex) @@ -216,9 +216,7 @@ export class TBTCVault ), depositor: new Address(event.args!.depositor), amount: BigNumber.from(event.args!.amount), - fundingTxHash: TransactionHash.from( - event.args!.fundingTxHash - ).reverse(), + fundingTxHash: BitcoinTxHash.from(event.args!.fundingTxHash).reverse(), fundingOutputIndex: BigNumber.from( event.args!.fundingOutputIndex ).toNumber(), diff --git a/typescript/src/optimistic-minting.ts b/typescript/src/optimistic-minting.ts index d856b7b0e..3f884e8ab 100644 --- a/typescript/src/optimistic-minting.ts +++ b/typescript/src/optimistic-minting.ts @@ -1,4 +1,4 @@ -import { TransactionHash } from "./lib/bitcoin" +import { BitcoinTxHash } from "./lib/bitcoin" import { TBTCVault, OptimisticMintingRequest } from "./lib/contracts" import { Hex } from "./lib/utils" @@ -11,7 +11,7 @@ import { Hex } from "./lib/utils" * @returns Transaction hash of the optimistic mint request transaction. */ export async function requestOptimisticMint( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number, tbtcVault: TBTCVault ): Promise { @@ -30,7 +30,7 @@ export async function requestOptimisticMint( * @returns Transaction hash of the optimistic mint cancel transaction. */ export async function cancelOptimisticMint( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number, tbtcVault: TBTCVault ): Promise { @@ -46,7 +46,7 @@ export async function cancelOptimisticMint( * @returns Transaction hash of the optimistic mint finalize transaction. */ export async function finalizeOptimisticMint( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number, tbtcVault: TBTCVault ): Promise { @@ -65,7 +65,7 @@ export async function finalizeOptimisticMint( * @returns Optimistic minting request. */ export async function getOptimisticMintingRequest( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number, tbtcVault: TBTCVault ): Promise { diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index 8db6dd296..cda5658f2 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -1,14 +1,14 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" import { - assembleTransactionProof, + assembleBitcoinSpvProof, BitcoinNetwork, - createKeyRing, - decomposeRawTransaction, - RawTransaction, - UnspentTransactionOutput, - Client as BitcoinClient, - TransactionHash, + BitcoinPrivateKeyUtils, + extractBitcoinRawTxVectors, + BitcoinRawTx, + BitcoinUtxo, + BitcoinClient, + BitcoinTxHash, } from "./lib/bitcoin" import { Bridge, @@ -34,7 +34,7 @@ import { Hex } from "./lib/utils" */ export async function requestRedemption( walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScript: string, amount: BigNumber, tBTCToken: TBTCToken @@ -73,25 +73,27 @@ export async function submitRedemptionTransaction( bitcoinClient: BitcoinClient, bridge: Bridge, walletPrivateKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScripts: string[], witness: boolean ): Promise<{ - transactionHash: TransactionHash - newMainUtxo?: UnspentTransactionOutput + transactionHash: BitcoinTxHash + newMainUtxo?: BitcoinUtxo }> { const mainUtxoRawTransaction = await bitcoinClient.getRawTransaction( mainUtxo.transactionHash ) - const mainUtxoWithRaw: UnspentTransactionOutput & RawTransaction = { + const mainUtxoWithRaw: BitcoinUtxo & BitcoinRawTx = { ...mainUtxo, transactionHex: mainUtxoRawTransaction.transactionHex, } const redemptionRequests = await getWalletRedemptionRequests( bridge, - createKeyRing(walletPrivateKey).getPublicKey().toString("hex"), + BitcoinPrivateKeyUtils.createKeyRing(walletPrivateKey) + .getPublicKey() + .toString("hex"), redeemerOutputScripts, "pending" ) @@ -204,19 +206,22 @@ async function getWalletRedemptionRequests( */ export async function assembleRedemptionTransaction( walletPrivateKey: string, - mainUtxo: UnspentTransactionOutput & RawTransaction, + mainUtxo: BitcoinUtxo & BitcoinRawTx, redemptionRequests: RedemptionRequest[], witness: boolean ): Promise<{ - transactionHash: TransactionHash - newMainUtxo?: UnspentTransactionOutput - rawTransaction: RawTransaction + transactionHash: BitcoinTxHash + newMainUtxo?: BitcoinUtxo + rawTransaction: BitcoinRawTx }> { if (redemptionRequests.length < 1) { throw new Error("There must be at least one request to redeem") } - const walletKeyRing = createKeyRing(walletPrivateKey, witness) + const walletKeyRing = BitcoinPrivateKeyUtils.createKeyRing( + walletPrivateKey, + witness + ) const walletAddress = walletKeyRing.getAddress("string") // Use the main UTXO as the single transaction input @@ -283,7 +288,7 @@ export async function assembleRedemptionTransaction( transaction.sign(walletKeyRing) - const transactionHash = TransactionHash.from(transaction.txid()) + const transactionHash = BitcoinTxHash.from(transaction.txid()) // If there is a change output, it will be the new wallet's main UTXO. const newMainUtxo = changeOutputValue.gt(0) ? { @@ -315,14 +320,14 @@ export async function assembleRedemptionTransaction( * @returns Empty promise. */ export async function submitRedemptionProof( - transactionHash: TransactionHash, - mainUtxo: UnspentTransactionOutput, + transactionHash: BitcoinTxHash, + mainUtxo: BitcoinUtxo, walletPublicKey: string, bridge: Bridge, bitcoinClient: BitcoinClient ): Promise { const confirmations = await bridge.txProofDifficultyFactor() - const proof = await assembleTransactionProof( + const proof = await assembleBitcoinSpvProof( transactionHash, confirmations, bitcoinClient @@ -331,10 +336,10 @@ export async function submitRedemptionProof( // proof to the decomposed transaction data (version, inputs, outputs, locktime). // Use raw transaction data for now. const rawTransaction = await bitcoinClient.getRawTransaction(transactionHash) - const decomposedRawTransaction = decomposeRawTransaction(rawTransaction) + const rawTransactionVectors = extractBitcoinRawTxVectors(rawTransaction) await bridge.submitRedemptionProof( - decomposedRawTransaction, + rawTransactionVectors, proof, mainUtxo, walletPublicKey @@ -394,14 +399,14 @@ export async function findWalletForRedemption( bitcoinClient: BitcoinClient ): Promise<{ walletPublicKey: string - mainUtxo: UnspentTransactionOutput + mainUtxo: BitcoinUtxo }> { const wallets = await bridge.getNewWalletRegisteredEvents() let walletData: | { walletPublicKey: string - mainUtxo: UnspentTransactionOutput + mainUtxo: BitcoinUtxo } | undefined = undefined let maxAmount = BigNumber.from(0) diff --git a/typescript/src/wallet.ts b/typescript/src/wallet.ts index 6903042ff..8b2f0a6d5 100644 --- a/typescript/src/wallet.ts +++ b/typescript/src/wallet.ts @@ -1,12 +1,11 @@ import { Hex } from "./lib/utils" import { Bridge } from "./lib/contracts" import { - Client as BitcoinClient, + BitcoinClient, BitcoinNetwork, - createOutputScriptFromAddress, - encodeToBitcoinAddress, - TransactionOutput, - UnspentTransactionOutput, + BitcoinAddressConverter, + BitcoinTxOutput, + BitcoinUtxo, } from "./lib/bitcoin" /** @@ -30,7 +29,7 @@ export async function determineWalletMainUtxo( bridge: Bridge, bitcoinClient: BitcoinClient, bitcoinNetwork: BitcoinNetwork -): Promise { +): Promise { const { mainUtxoHash } = await bridge.wallets(walletPublicKeyHash) // Valid case when the wallet doesn't have a main UTXO registered into @@ -49,9 +48,9 @@ export async function determineWalletMainUtxo( // the given wallet address type. const determine = async ( witnessAddress: boolean - ): Promise => { + ): Promise => { // Build the wallet Bitcoin address based on its public key hash. - const walletAddress = encodeToBitcoinAddress( + const walletAddress = BitcoinAddressConverter.publicKeyHashToAddress( walletPublicKeyHash.toString(), witnessAddress, bitcoinNetwork @@ -74,11 +73,9 @@ export async function determineWalletMainUtxo( // Get the wallet script based on the wallet address. This is required // to find transaction outputs that lock funds on the wallet. - const walletScript = createOutputScriptFromAddress( - walletAddress, - bitcoinNetwork - ) - const isWalletOutput = (output: TransactionOutput) => + const walletScript = + BitcoinAddressConverter.addressToOutputScript(walletAddress) + const isWalletOutput = (output: BitcoinTxOutput) => walletScript.equals(output.scriptPubKey) // Start iterating from the latest transaction as the chance it matches @@ -100,7 +97,7 @@ export async function determineWalletMainUtxo( } // Build a candidate UTXO instance based on the detected output. - const utxo: UnspentTransactionOutput = { + const utxo: BitcoinUtxo = { transactionHash: walletTransaction.transactionHash, outputIndex: outputIndex, value: walletTransaction.outputs[outputIndex].value, diff --git a/typescript/test/bitcoin-network.test.ts b/typescript/test/bitcoin-network.test.ts index 92c258d53..aa87a5c0c 100644 --- a/typescript/test/bitcoin-network.test.ts +++ b/typescript/test/bitcoin-network.test.ts @@ -1,6 +1,6 @@ import { expect } from "chai" import { - TransactionHash, + BitcoinTxHash, BitcoinNetwork, toBcoinNetwork, } from "../src/lib/bitcoin" @@ -11,13 +11,13 @@ describe("BitcoinNetwork", () => { enumKey: BitcoinNetwork.Unknown, enumValue: "unknown", // any value that doesn't match other supported networks - genesisHash: TransactionHash.from("0x00010203"), + genesisHash: BitcoinTxHash.from("0x00010203"), expectedToBcoinResult: new Error("network not supported"), }, { enumKey: BitcoinNetwork.Testnet, enumValue: "testnet", - genesisHash: TransactionHash.from( + genesisHash: BitcoinTxHash.from( "0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" ), expectedToBcoinResult: "testnet", @@ -25,7 +25,7 @@ describe("BitcoinNetwork", () => { { enumKey: BitcoinNetwork.Mainnet, enumValue: "mainnet", - genesisHash: TransactionHash.from( + genesisHash: BitcoinTxHash.from( "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" ), expectedToBcoinResult: "main", diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index dcaf31853..7310d28b6 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -1,22 +1,14 @@ import { expect } from "chai" import { BitcoinNetwork, - compressPublicKey, - encodeToBitcoinAddress, - decodeBitcoinAddress, - isPublicKeyHashLength, - locktimeToNumber, - BlockHeader, - serializeBlockHeader, - deserializeBlockHeader, - hashLEToBigNumber, - bitsToTarget, - targetToDifficulty, - createOutputScriptFromAddress, - createAddressFromOutputScript, - readCompactSizeUint, - computeHash160, - computeHash256, + BitcoinPublicKeyUtils, + BitcoinLocktimeUtils, + BitcoinHeader, + BitcoinHeaderSerializer, + BitcoinHashUtils, + BitcoinTargetConverter, + BitcoinCompactSizeUint, + BitcoinAddressConverter, } from "../src/lib/bitcoin" import { calculateDepositRefundLocktime } from "../src/deposit" import { Hex } from "../src/lib/utils" @@ -24,89 +16,117 @@ import { BigNumber } from "ethers" import { btcAddresses } from "./data/bitcoin" describe("Bitcoin", () => { - describe("compressPublicKey", () => { - context("when public key parameter has a correct length", () => { - context("when the Y coordinate is divisible by 2", () => { - it("should compress the public key correctly", () => { - const uncompressedPublicKey = - "ff6e1857db52d6dba2bd4239fba722655622bc520709d38011f9adac8ea3477b" + - "45ae275b657f7bac7c1e3d146a564051aee1356895f01e4f29f333502416fa4a" - const compressedPublicKey = - "02ff6e1857db52d6dba2bd4239fba722655622bc520709d38011f9adac8ea3477b" + describe("BitcoinPublicKeyUtils", () => { + const { compressPublicKey } = BitcoinPublicKeyUtils + + describe("compressPublicKey", () => { + context("when public key parameter has a correct length", () => { + context("when the Y coordinate is divisible by 2", () => { + it("should compress the public key correctly", () => { + const uncompressedPublicKey = + "ff6e1857db52d6dba2bd4239fba722655622bc520709d38011f9adac8ea3477b" + + "45ae275b657f7bac7c1e3d146a564051aee1356895f01e4f29f333502416fa4a" + const compressedPublicKey = + "02ff6e1857db52d6dba2bd4239fba722655622bc520709d38011f9adac8ea3477b" + + expect(compressPublicKey(uncompressedPublicKey)).to.be.equal( + compressedPublicKey + ) + }) + }) - expect(compressPublicKey(uncompressedPublicKey)).to.be.equal( - compressedPublicKey - ) + context("when the Y coordinate is not divisible by 2", () => { + it("should compress the public key correctly", () => { + const uncompressedPublicKey = + "474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + + "7b5dff055ee1cc3a1fff4715dea2858ca4dd5bba0af30abcd881a6bda4fb70af" + const compressedPublicKey = + "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + + expect(compressPublicKey(uncompressedPublicKey)).to.be.equal( + compressedPublicKey + ) + }) }) }) - context("when the Y coordinate is not divisible by 2", () => { - it("should compress the public key correctly", () => { + context("when public key parameter has an incorrect length", () => { + it("should throw", () => { const uncompressedPublicKey = - "474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + + "04474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + "7b5dff055ee1cc3a1fff4715dea2858ca4dd5bba0af30abcd881a6bda4fb70af" - const compressedPublicKey = - "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" - expect(compressPublicKey(uncompressedPublicKey)).to.be.equal( - compressedPublicKey + expect(() => compressPublicKey(uncompressedPublicKey)).to.throw( + "The public key parameter must be 64-byte. Neither 0x nor 04 prefix is allowed" ) }) }) }) + }) - context("when public key parameter has an incorrect length", () => { - it("should throw", () => { - const uncompressedPublicKey = - "04474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + - "7b5dff055ee1cc3a1fff4715dea2858ca4dd5bba0af30abcd881a6bda4fb70af" + describe("BitcoinHashUtils", () => { + const { computeHash160, computeHash256, hashLEToBigNumber } = + BitcoinHashUtils - expect(() => compressPublicKey(uncompressedPublicKey)).to.throw( - "The public key parameter must be 64-byte. Neither 0x nor 04 prefix is allowed" - ) + describe("computeHash160", () => { + it("should compute hash160 correctly", () => { + const compressedPublicKey = + "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + const expectedHash160 = "3e1dfbd72483fb3964ca828ee71cf3270cafdc65" + + expect(computeHash160(compressedPublicKey)).to.be.equal(expectedHash160) }) }) - }) - describe("computeHash160", () => { - it("should compute hash160 correctly", () => { - const compressedPublicKey = - "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" - const expectedHash160 = "3e1dfbd72483fb3964ca828ee71cf3270cafdc65" + describe("computeHash256", () => { + it("should compute hash256 correctly", () => { + const hexValue = Hex.from( + "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + ) + const expectedHash256 = Hex.from( + "9f0b7447ca6ea11b8badd8a60a4dec1b846451551ef455975b1720f52bc90546" + ) - expect(computeHash160(compressedPublicKey)).to.be.equal(expectedHash160) + expect(computeHash256(hexValue).toString()).to.be.equal( + expectedHash256.toString() + ) + }) }) - }) - - describe("computeHash256", () => { - it("should compute hash256 correctly", () => { - const hexValue = Hex.from( - "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" - ) - const expectedHash256 = Hex.from( - "9f0b7447ca6ea11b8badd8a60a4dec1b846451551ef455975b1720f52bc90546" - ) - expect(computeHash256(hexValue).toString()).to.be.equal( - expectedHash256.toString() - ) + describe("hashLEToBigNumber", () => { + it("calculates correct value", () => { + const hash = Hex.from( + "31552151fbef8e96a33f979e6253d29edf65ac31b04802319e00000000000000" + ) + const expectedBigNumber = BigNumber.from( + "992983769452983078390935942095592601503357651673709518345521" + ) + expect(hashLEToBigNumber(hash)).to.equal(expectedBigNumber) + }) }) }) - describe("P2PKH <-> public key hash conversion", () => { + describe("BitcoinAddressConverter", () => { const publicKeyHash = "3a38d44d6a0c8d0bb84e0232cc632b7e48c72e0e" const P2WPKHAddress = "bc1q8gudgnt2pjxshwzwqgevccet0eyvwtswt03nuy" const P2PKHAddress = "16JrGhLx5bcBSA34kew9V6Mufa4aXhFe9X" const P2WPKHAddressTestnet = "tb1q8gudgnt2pjxshwzwqgevccet0eyvwtswpf2q8h" const P2PKHAddressTestnet = "mkpoZkRvtd3SDGWgUDuXK1aEXZfHRM2gKw" - describe("encodeToBitcoinAddress", () => { + const { + publicKeyHashToAddress, + addressToPublicKeyHash, + addressToOutputScript, + outputScriptToAddress, + } = BitcoinAddressConverter + + describe("publicKeyHashToAddress", () => { context("when network is mainnet", () => { context("when witness option is true", () => { context("when proper public key hash is provided", () => { it("should encode public key hash into bitcoin address properly", () => { expect( - encodeToBitcoinAddress( + publicKeyHashToAddress( publicKeyHash, true, BitcoinNetwork.Mainnet @@ -120,7 +140,7 @@ describe("Bitcoin", () => { const wrongPublicKeyHash = "02" + publicKeyHash expect(() => - encodeToBitcoinAddress( + publicKeyHashToAddress( wrongPublicKeyHash, true, BitcoinNetwork.Mainnet @@ -134,7 +154,7 @@ describe("Bitcoin", () => { context("when proper public key hash is provided", () => { it("should encode public key hash into bitcoin address properly", () => { expect( - encodeToBitcoinAddress( + publicKeyHashToAddress( publicKeyHash, false, BitcoinNetwork.Mainnet @@ -148,7 +168,7 @@ describe("Bitcoin", () => { const wrongPublicKeyHash = "02" + publicKeyHash expect(() => - encodeToBitcoinAddress( + publicKeyHashToAddress( wrongPublicKeyHash, false, BitcoinNetwork.Mainnet @@ -164,7 +184,7 @@ describe("Bitcoin", () => { context("when proper public key hash is provided", () => { it("should encode public key hash into bitcoin address properly", () => { expect( - encodeToBitcoinAddress( + publicKeyHashToAddress( publicKeyHash, true, BitcoinNetwork.Testnet @@ -178,7 +198,7 @@ describe("Bitcoin", () => { const wrongPublicKeyHash = "02" + publicKeyHash expect(() => - encodeToBitcoinAddress( + publicKeyHashToAddress( wrongPublicKeyHash, true, BitcoinNetwork.Testnet @@ -192,7 +212,7 @@ describe("Bitcoin", () => { context("when proper public key hash is provided", () => { it("should encode public key hash into bitcoin address properly", () => { expect( - encodeToBitcoinAddress( + publicKeyHashToAddress( publicKeyHash, false, BitcoinNetwork.Testnet @@ -206,7 +226,7 @@ describe("Bitcoin", () => { const wrongPublicKeyHash = "02" + publicKeyHash expect(() => - encodeToBitcoinAddress( + publicKeyHashToAddress( wrongPublicKeyHash, false, BitcoinNetwork.Testnet @@ -220,17 +240,17 @@ describe("Bitcoin", () => { context("when network is unknown", () => { it("should throw", () => { expect(() => - encodeToBitcoinAddress(publicKeyHash, true, BitcoinNetwork.Unknown) + publicKeyHashToAddress(publicKeyHash, true, BitcoinNetwork.Unknown) ).to.throw("network not supported") }) }) }) - describe("decodeAddress", () => { + describe("addressToPublicKeyHash", () => { context("when network is mainnet", () => { context("when proper P2WPKH address is provided", () => { it("should decode P2WPKH adress correctly", () => { - expect(decodeBitcoinAddress(P2WPKHAddress)).to.be.equal( + expect(addressToPublicKeyHash(P2WPKHAddress)).to.be.equal( publicKeyHash ) }) @@ -238,7 +258,7 @@ describe("Bitcoin", () => { context("when proper P2PKH address is provided", () => { it("should decode P2PKH address correctly", () => { - expect(decodeBitcoinAddress(P2PKHAddress)).to.be.equal( + expect(addressToPublicKeyHash(P2PKHAddress)).to.be.equal( publicKeyHash ) }) @@ -248,7 +268,7 @@ describe("Bitcoin", () => { it("should throw", () => { const bitcoinAddress = "123" + P2PKHAddress - expect(() => decodeBitcoinAddress(bitcoinAddress)).to.throw( + expect(() => addressToPublicKeyHash(bitcoinAddress)).to.throw( "Address is too long" ) }) @@ -257,7 +277,7 @@ describe("Bitcoin", () => { context("when unsupported P2SH address is provided", () => { it("should throw", () => { expect(() => - decodeBitcoinAddress("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX") + addressToPublicKeyHash("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX") ).to.throw("Address must be P2PKH or P2WPKH") }) }) @@ -265,7 +285,7 @@ describe("Bitcoin", () => { context("when unsupported P2WSH address is provided", () => { it("should throw", () => { expect(() => - decodeBitcoinAddress( + addressToPublicKeyHash( "bc1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhsdxuv4m" ) ).to.throw("Address must be P2PKH or P2WPKH") @@ -276,7 +296,7 @@ describe("Bitcoin", () => { context("when network is testnet", () => { context("when proper P2WPKH address is provided", () => { it("should decode P2WPKH adress correctly", () => { - expect(decodeBitcoinAddress(P2WPKHAddressTestnet)).to.be.equal( + expect(addressToPublicKeyHash(P2WPKHAddressTestnet)).to.be.equal( publicKeyHash ) }) @@ -284,7 +304,7 @@ describe("Bitcoin", () => { context("when proper P2PKH address is provided", () => { it("should decode P2PKH address correctly", () => { - expect(decodeBitcoinAddress(P2PKHAddressTestnet)).to.be.equal( + expect(addressToPublicKeyHash(P2PKHAddressTestnet)).to.be.equal( publicKeyHash ) }) @@ -294,7 +314,7 @@ describe("Bitcoin", () => { it("should throw", () => { const bitcoinAddress = "123" + P2PKHAddressTestnet - expect(() => decodeBitcoinAddress(bitcoinAddress)).to.throw( + expect(() => addressToPublicKeyHash(bitcoinAddress)).to.throw( "Address is too long" ) }) @@ -303,7 +323,7 @@ describe("Bitcoin", () => { context("when unsupported P2SH address is provided", () => { it("should throw", () => { expect(() => - decodeBitcoinAddress("2MyxShnGQ5NifGb8CHYrtmzosRySxZ9pZo5") + addressToPublicKeyHash("2MyxShnGQ5NifGb8CHYrtmzosRySxZ9pZo5") ).to.throw("Address must be P2PKH or P2WPKH") }) }) @@ -311,7 +331,7 @@ describe("Bitcoin", () => { context("when unsupported P2WSH address is provided", () => { it("should throw", () => { expect(() => - decodeBitcoinAddress( + addressToPublicKeyHash( "tb1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhs6w2r05" ) ).to.throw("Address must be P2PKH or P2WPKH") @@ -319,255 +339,245 @@ describe("Bitcoin", () => { }) }) }) - }) - - describe("isPublicKeyHashLength", () => { - const publicKeyHash = "3a38d44d6a0c8d0bb84e0232cc632b7e48c72e0e" - const wrongPublicKeyHash = "3a38d44d6a0c8d0" - context("when proper public key hash is provided", () => { - it("should return true", () => { - expect(isPublicKeyHashLength(publicKeyHash)).to.be.equal(true) + describe("addressToOutputScript", () => { + Object.keys(btcAddresses).forEach((bitcoinNetwork) => { + context(`with ${bitcoinNetwork} addresses`, () => { + Object.entries( + btcAddresses[bitcoinNetwork as keyof typeof btcAddresses] + ).forEach( + ([ + addressType, + { address, scriptPubKey: expectedOutputScript }, + ]) => { + it(`should create correct output script for ${addressType} address type`, () => { + const result = addressToOutputScript(address) + + expect(result.toString()).to.eq(expectedOutputScript.toString()) + }) + } + ) + }) }) }) - context("when wrong public key hash is provided", () => { - it("should return false", () => { - expect(isPublicKeyHashLength(wrongPublicKeyHash)).to.be.equal(false) + describe("outputScriptToAddress", () => { + Object.keys(btcAddresses).forEach((bitcoinNetwork) => { + context(`with ${bitcoinNetwork} addresses`, () => { + Object.entries( + btcAddresses[bitcoinNetwork as keyof typeof btcAddresses] + ).forEach(([addressType, { address, scriptPubKey }]) => { + it(`should return correct ${addressType} address`, () => { + const result = outputScriptToAddress( + scriptPubKey, + bitcoinNetwork === "mainnet" + ? BitcoinNetwork.Mainnet + : BitcoinNetwork.Testnet + ) + + expect(result.toString()).to.eq(address) + }) + }) + }) }) }) }) - describe("locktimeToNumber", () => { - const depositCreatedAt: number = 1640181600 - const depositRefundLocktimeDuration: number = 2592000 - const depositRefundLocktime = calculateDepositRefundLocktime( - depositCreatedAt, - depositRefundLocktimeDuration - ) - - const testData = [ - { - contextName: "when locktime is a block height", - unprefixedHex: "ede80600", - expectedDepositLocktime: 452845, - }, - { - contextName: "when locktime is a timestamp", - unprefixedHex: "06241559", - expectedDepositLocktime: 1494557702, - }, - { - contextName: "for deposit refund locktime", - unprefixedHex: depositRefundLocktime, - expectedDepositLocktime: - depositCreatedAt + depositRefundLocktimeDuration, - }, - ] - - testData.forEach((test) => { - context(test.contextName, () => { - context("when input is non-prefixed hex string", () => { - it("should return the locktime in seconds", async () => { - expect(locktimeToNumber(test.unprefixedHex)).to.be.equal( - test.expectedDepositLocktime - ) + describe("BitcoinLocktimeUtils", () => { + const { locktimeToNumber } = BitcoinLocktimeUtils + + describe("locktimeToNumber", () => { + const depositCreatedAt: number = 1640181600 + const depositRefundLocktimeDuration: number = 2592000 + const depositRefundLocktime = calculateDepositRefundLocktime( + depositCreatedAt, + depositRefundLocktimeDuration + ) + + const testData = [ + { + contextName: "when locktime is a block height", + unprefixedHex: "ede80600", + expectedDepositLocktime: 452845, + }, + { + contextName: "when locktime is a timestamp", + unprefixedHex: "06241559", + expectedDepositLocktime: 1494557702, + }, + { + contextName: "for deposit refund locktime", + unprefixedHex: depositRefundLocktime, + expectedDepositLocktime: + depositCreatedAt + depositRefundLocktimeDuration, + }, + ] + + testData.forEach((test) => { + context(test.contextName, () => { + context("when input is non-prefixed hex string", () => { + it("should return the locktime in seconds", async () => { + expect(locktimeToNumber(test.unprefixedHex)).to.be.equal( + test.expectedDepositLocktime + ) + }) }) - }) - context("when input is 0x prefixed hex string", () => { - it("should return the locktime in seconds", async () => { - expect(locktimeToNumber("0x" + test.unprefixedHex)).to.be.equal( - test.expectedDepositLocktime - ) + context("when input is 0x prefixed hex string", () => { + it("should return the locktime in seconds", async () => { + expect(locktimeToNumber("0x" + test.unprefixedHex)).to.be.equal( + test.expectedDepositLocktime + ) + }) }) - }) - context("when input is Buffer object", () => { - it("should return the locktime in seconds", async () => { - expect( - locktimeToNumber(Buffer.from(test.unprefixedHex, "hex")) - ).to.be.equal(test.expectedDepositLocktime) + context("when input is Buffer object", () => { + it("should return the locktime in seconds", async () => { + expect( + locktimeToNumber(Buffer.from(test.unprefixedHex, "hex")) + ).to.be.equal(test.expectedDepositLocktime) + }) }) }) }) }) }) - describe("serializeBlockHeader", () => { - it("calculates correct value", () => { - const blockHeader: BlockHeader = { - version: 536870916, - previousBlockHeaderHash: Hex.from( - "a5a3501e6ba1f3e2a1ee5d29327a549524ed33f272dfef300045660000000000" - ), - merkleRootHash: Hex.from( - "e27d241ca36de831ab17e6729056c14a383e7a3f43d56254f846b49649775112" - ), - time: 1641914003, - bits: 436256810, - nonce: 778087099, - } - - const expectedSerializedBlockHeader = Hex.from( - "04000020a5a3501e6ba1f3e2a1ee5d29327a549524ed33f272dfef30004566000000" + - "0000e27d241ca36de831ab17e6729056c14a383e7a3f43d56254f846b496497751" + - "12939edd612ac0001abbaa602e" - ) + describe("BitcoinHeaderSerializer", () => { + const { serializeHeader, deserializeHeader } = BitcoinHeaderSerializer + + describe("serializeHeader", () => { + it("calculates correct value", () => { + const blockHeader: BitcoinHeader = { + version: 536870916, + previousBlockHeaderHash: Hex.from( + "a5a3501e6ba1f3e2a1ee5d29327a549524ed33f272dfef300045660000000000" + ), + merkleRootHash: Hex.from( + "e27d241ca36de831ab17e6729056c14a383e7a3f43d56254f846b49649775112" + ), + time: 1641914003, + bits: 436256810, + nonce: 778087099, + } + + const expectedSerializedBlockHeader = Hex.from( + "04000020a5a3501e6ba1f3e2a1ee5d29327a549524ed33f272dfef30004566000000" + + "0000e27d241ca36de831ab17e6729056c14a383e7a3f43d56254f846b496497751" + + "12939edd612ac0001abbaa602e" + ) - expect(serializeBlockHeader(blockHeader)).to.be.deep.equal( - expectedSerializedBlockHeader - ) + expect(serializeHeader(blockHeader)).to.be.deep.equal( + expectedSerializedBlockHeader + ) + }) }) - }) - - describe("deserializeBlockHeader", () => { - it("calculates correct value", () => { - const rawBlockHeader = Hex.from( - "04000020a5a3501e6ba1f3e2a1ee5d29327a549524ed33f272dfef30004566000000" + - "0000e27d241ca36de831ab17e6729056c14a383e7a3f43d56254f846b496497751" + - "12939edd612ac0001abbaa602e" - ) - const expectedBlockHeader: BlockHeader = { - version: 536870916, - previousBlockHeaderHash: Hex.from( - "a5a3501e6ba1f3e2a1ee5d29327a549524ed33f272dfef300045660000000000" - ), - merkleRootHash: Hex.from( - "e27d241ca36de831ab17e6729056c14a383e7a3f43d56254f846b49649775112" - ), - time: 1641914003, - bits: 436256810, - nonce: 778087099, - } - - expect(deserializeBlockHeader(rawBlockHeader)).to.deep.equal( - expectedBlockHeader - ) - }) - }) + describe("deserializeHeader", () => { + it("calculates correct value", () => { + const rawBlockHeader = Hex.from( + "04000020a5a3501e6ba1f3e2a1ee5d29327a549524ed33f272dfef30004566000000" + + "0000e27d241ca36de831ab17e6729056c14a383e7a3f43d56254f846b496497751" + + "12939edd612ac0001abbaa602e" + ) - describe("hashLEToBigNumber", () => { - it("calculates correct value", () => { - const hash = Hex.from( - "31552151fbef8e96a33f979e6253d29edf65ac31b04802319e00000000000000" - ) - const expectedBigNumber = BigNumber.from( - "992983769452983078390935942095592601503357651673709518345521" - ) - expect(hashLEToBigNumber(hash)).to.equal(expectedBigNumber) + const expectedBlockHeader: BitcoinHeader = { + version: 536870916, + previousBlockHeaderHash: Hex.from( + "a5a3501e6ba1f3e2a1ee5d29327a549524ed33f272dfef300045660000000000" + ), + merkleRootHash: Hex.from( + "e27d241ca36de831ab17e6729056c14a383e7a3f43d56254f846b49649775112" + ), + time: 1641914003, + bits: 436256810, + nonce: 778087099, + } + + expect(deserializeHeader(rawBlockHeader)).to.deep.equal( + expectedBlockHeader + ) + }) }) }) - describe("bitsToTarget", () => { - it("calculates correct value for random block header bits", () => { - const difficultyBits = 436256810 - const expectedDifficultyTarget = BigNumber.from( - "1206233370197704583969288378458116959663044038027202007138304" - ) - expect(bitsToTarget(difficultyBits)).to.equal(expectedDifficultyTarget) - }) + describe("BitcoinTargetConverter", () => { + const { bitsToTarget, targetToDifficulty } = BitcoinTargetConverter - it("calculates correct value for block header with difficulty of 1", () => { - const difficultyBits = 486604799 - const expectedDifficultyTarget = BigNumber.from( - "26959535291011309493156476344723991336010898738574164086137773096960" - ) - expect(bitsToTarget(difficultyBits)).to.equal(expectedDifficultyTarget) - }) - }) + describe("bitsToTarget", () => { + it("calculates correct value for random block header bits", () => { + const difficultyBits = 436256810 + const expectedDifficultyTarget = BigNumber.from( + "1206233370197704583969288378458116959663044038027202007138304" + ) + expect(bitsToTarget(difficultyBits)).to.equal(expectedDifficultyTarget) + }) - describe("targetToDifficulty", () => { - it("calculates correct value for random block header bits", () => { - const target = BigNumber.from( - "1206233370197704583969288378458116959663044038027202007138304" - ) - const expectedDifficulty = BigNumber.from("22350181") - expect(targetToDifficulty(target)).to.equal(expectedDifficulty) + it("calculates correct value for block header with difficulty of 1", () => { + const difficultyBits = 486604799 + const expectedDifficultyTarget = BigNumber.from( + "26959535291011309493156476344723991336010898738574164086137773096960" + ) + expect(bitsToTarget(difficultyBits)).to.equal(expectedDifficultyTarget) + }) }) - it("calculates correct value for block header with difficulty of 1", () => { - const target = BigNumber.from( - "26959535291011309493156476344723991336010898738574164086137773096960" - ) - const expectedDifficulty = BigNumber.from("1") - expect(targetToDifficulty(target)).to.equal(expectedDifficulty) - }) - }) + describe("targetToDifficulty", () => { + it("calculates correct value for random block header bits", () => { + const target = BigNumber.from( + "1206233370197704583969288378458116959663044038027202007138304" + ) + const expectedDifficulty = BigNumber.from("22350181") + expect(targetToDifficulty(target)).to.equal(expectedDifficulty) + }) - describe("createOutputScriptFromAddress", () => { - Object.keys(btcAddresses).forEach((bitcoinNetwork) => { - context(`with ${bitcoinNetwork} addresses`, () => { - Object.entries( - btcAddresses[bitcoinNetwork as keyof typeof btcAddresses] - ).forEach( - ([addressType, { address, scriptPubKey: expectedOutputScript }]) => { - it(`should create correct output script for ${addressType} address type`, () => { - const result = createOutputScriptFromAddress(address) - - expect(result.toString()).to.eq(expectedOutputScript.toString()) - }) - } + it("calculates correct value for block header with difficulty of 1", () => { + const target = BigNumber.from( + "26959535291011309493156476344723991336010898738574164086137773096960" ) + const expectedDifficulty = BigNumber.from("1") + expect(targetToDifficulty(target)).to.equal(expectedDifficulty) }) }) }) - describe("getAddressFromScriptPubKey", () => { - Object.keys(btcAddresses).forEach((bitcoinNetwork) => { - context(`with ${bitcoinNetwork} addresses`, () => { - Object.entries( - btcAddresses[bitcoinNetwork as keyof typeof btcAddresses] - ).forEach(([addressType, { address, scriptPubKey }]) => { - it(`should return correct ${addressType} address`, () => { - const result = createAddressFromOutputScript( - scriptPubKey, - bitcoinNetwork === "mainnet" - ? BitcoinNetwork.Mainnet - : BitcoinNetwork.Testnet - ) + describe("BitcoinCompactSizeUint", () => { + const { read } = BitcoinCompactSizeUint - expect(result.toString()).to.eq(address) + describe("read", () => { + context("when the compact size uint is 1-byte", () => { + it("should return the the uint value and byte length", () => { + expect(read(Hex.from("bb"))).to.be.eql({ + value: 187, + byteLength: 1, }) }) }) - }) - }) - describe("readCompactSizeUint", () => { - context("when the compact size uint is 1-byte", () => { - it("should return the the uint value and byte length", () => { - expect(readCompactSizeUint(Hex.from("bb"))).to.be.eql({ - value: 187, - byteLength: 1, + context("when the compact size uint is 3-byte", () => { + it("should throw", () => { + expect(() => read(Hex.from("fd0302"))).to.throw( + "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + ) }) }) - }) - context("when the compact size uint is 3-byte", () => { - it("should throw", () => { - expect(() => readCompactSizeUint(Hex.from("fd0302"))).to.throw( - "support for 3, 5 and 9 bytes compact size uints is not implemented yet" - ) - }) - }) - - context("when the compact size uint is 5-byte", () => { - it("should throw", () => { - expect(() => readCompactSizeUint(Hex.from("fe703a0f00"))).to.throw( - "support for 3, 5 and 9 bytes compact size uints is not implemented yet" - ) + context("when the compact size uint is 5-byte", () => { + it("should throw", () => { + expect(() => read(Hex.from("fe703a0f00"))).to.throw( + "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + ) + }) }) - }) - context("when the compact size uint is 9-byte", () => { - it("should throw", () => { - expect(() => { - return readCompactSizeUint(Hex.from("ff57284e56dab40000")) - }).to.throw( - "support for 3, 5 and 9 bytes compact size uints is not implemented yet" - ) + context("when the compact size uint is 9-byte", () => { + it("should throw", () => { + expect(() => { + return read(Hex.from("ff57284e56dab40000")) + }).to.throw( + "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + ) + }) }) }) }) diff --git a/typescript/test/data/deposit-refund.ts b/typescript/test/data/deposit-refund.ts index d5763354b..1d0da98f3 100644 --- a/typescript/test/data/deposit-refund.ts +++ b/typescript/test/data/deposit-refund.ts @@ -1,9 +1,5 @@ import { BigNumber } from "ethers" -import { - RawTransaction, - UnspentTransactionOutput, - TransactionHash, -} from "../../src/lib/bitcoin" +import { BitcoinRawTx, BitcoinUtxo, BitcoinTxHash } from "../../src/lib/bitcoin" import { Deposit } from "../../src/lib/contracts" import { calculateDepositRefundLocktime } from "../../src/deposit" import { Address } from "../../src/lib/ethereum" @@ -21,13 +17,13 @@ export const refunderPrivateKey = */ export interface DepositRefundTestData { deposit: { - utxo: UnspentTransactionOutput & RawTransaction + utxo: BitcoinUtxo & BitcoinRawTx data: Deposit } refunderAddress: string expectedRefund: { - transactionHash: TransactionHash - transaction: RawTransaction + transactionHash: BitcoinTxHash + transaction: BitcoinRawTx } } @@ -40,7 +36,7 @@ export const depositRefundOfWitnessDepositAndWitnessRefunderAddress: DepositRefu { deposit: { utxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "6430be26d8564658bf3ff0f74e4a7ddce9d65e9c7157d6e4a203125fc01d3c6d" ), outputIndex: 0, @@ -67,7 +63,7 @@ export const depositRefundOfWitnessDepositAndWitnessRefunderAddress: DepositRefu // witness address associated with the refunder's private key refunderAddress: "tb1qrdnlyafhc7es5g7cenhmj6jv4n789kdpw5kty9", expectedRefund: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "b49bd6c0219066f0c76d85818b047e4685425844cda42dae9b9508b9bfbb483d" ), transaction: { @@ -94,7 +90,7 @@ export const depositRefundOfNonWitnessDepositAndWitnessRefunderAddress: DepositR { deposit: { utxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "60650462f367bf89b5a0dc52d7d1f65986296fa8d8903b129c444e2b742f0143" ), outputIndex: 0, @@ -120,7 +116,7 @@ export const depositRefundOfNonWitnessDepositAndWitnessRefunderAddress: DepositR // witness address associated with the refunder's private key refunderAddress: "tb1qrdnlyafhc7es5g7cenhmj6jv4n789kdpw5kty9", expectedRefund: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "7df9ed885525899ccbe144fd129062cec59be43d428b85fb847808b8790ad262" ), transaction: { @@ -147,7 +143,7 @@ export const depositRefundOfWitnessDepositAndNonWitnessRefunderAddress: DepositR { deposit: { utxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "b1fb065a61a6401279cafb95d10b502a6cd22f747bcfdb09ab25d4ee6f64319f" ), outputIndex: 0, @@ -173,7 +169,7 @@ export const depositRefundOfWitnessDepositAndNonWitnessRefunderAddress: DepositR // non-witness address associated with the refunder's private key refunderAddress: "mi1s4c2GtyVpqQb6MEpMbKimq3mwu5Z3a6", expectedRefund: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "0400678f7ae0275338cb0418236960c04c016b980cb7d1763c1d957f534ae0eb" ), transaction: { diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index ba394fc4d..18e96b513 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -1,11 +1,11 @@ import { - DecomposedRawTransaction, - Proof, - Transaction, - RawTransaction, - UnspentTransactionOutput, - TransactionMerkleBranch, - TransactionHash, + BitcoinRawTxVectors, + BitcoinSpvProof, + BitcoinTx, + BitcoinRawTx, + BitcoinUtxo, + BitcoinTxMerkleBranch, + BitcoinTxHash, } from "../../src/lib/bitcoin" import { Deposit } from "../../src/lib/contracts" import { calculateDepositRefundLocktime } from "../../src/deposit" @@ -14,7 +14,7 @@ import { Address } from "../../src/lib/ethereum" import { Hex } from "../../src" export const NO_MAIN_UTXO = { - transactionHash: TransactionHash.from(""), + transactionHash: BitcoinTxHash.from(""), outputIndex: 0, value: BigNumber.from(0), transactionHex: "", @@ -25,14 +25,14 @@ export const NO_MAIN_UTXO = { */ export interface DepositSweepTestData { deposits: { - utxo: UnspentTransactionOutput & RawTransaction + utxo: BitcoinUtxo & BitcoinRawTx data: Deposit }[] - mainUtxo: UnspentTransactionOutput & RawTransaction + mainUtxo: BitcoinUtxo & BitcoinRawTx witness: boolean expectedSweep: { - transactionHash: TransactionHash - transaction: RawTransaction + transactionHash: BitcoinTxHash + transaction: BitcoinRawTx } } @@ -46,7 +46,7 @@ export const depositSweepWithNoMainUtxoAndWitnessOutput: DepositSweepTestData = deposits: [ { utxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "74d0e353cdba99a6c17ce2cfeab62a26c09b5eb756eccdcfb83dbc12e67b18bc" ), outputIndex: 0, @@ -73,7 +73,7 @@ export const depositSweepWithNoMainUtxoAndWitnessOutput: DepositSweepTestData = }, { utxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "5c54ecdf946382fab2236f78423ddc22a757776fb8492671c588667b737e55dc" ), outputIndex: 0, @@ -103,7 +103,7 @@ export const depositSweepWithNoMainUtxoAndWitnessOutput: DepositSweepTestData = mainUtxo: NO_MAIN_UTXO, witness: true, expectedSweep: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f8eaf242a55ea15e602f9f990e33f67f99dfbe25d1802bbde63cc1caabf99668" ), transaction: { @@ -138,7 +138,7 @@ export const depositSweepWithNoMainUtxoAndNonWitnessOutput: DepositSweepTestData deposits: [ { utxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "4cdd899d7133cd681bdc4e80b3af09d34da1f7450c5b19167aa8a8223c7a8426" ), outputIndex: 0, @@ -161,7 +161,7 @@ export const depositSweepWithNoMainUtxoAndNonWitnessOutput: DepositSweepTestData mainUtxo: NO_MAIN_UTXO, witness: false, expectedSweep: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "1c42b0568d88bb4d21ae138769fd06199dd3ec689911972792e678be8516d58d" ), transaction: { @@ -183,7 +183,7 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa { // P2SH deposit utxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "d4fe2ef9068d039eae2210e893db518280d4757696fe9db8f3c696a94de90aed" ), outputIndex: 0, @@ -211,7 +211,7 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa { // P2WSH deposit utxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "b86ef64f8aff19778535e7c6e45ff82bc2f5f5eec800fd2b03a03fc22f557fe3" ), outputIndex: 0, @@ -239,7 +239,7 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa ], mainUtxo: { // P2WPKH - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f8eaf242a55ea15e602f9f990e33f67f99dfbe25d1802bbde63cc1caabf99668" ), outputIndex: 0, @@ -264,7 +264,7 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa }, witness: true, expectedSweep: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "435d4aff6d4bc34134877bd3213c17970142fdd04d4113d534120033b9eecb2e" ), transaction: { @@ -304,7 +304,7 @@ export const depositSweepWithNonWitnessMainUtxoAndWitnessOutput: DepositSweepTes deposits: [ { utxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "fda2323b4075a0311767ae8db07f4387bb53663a304278cd8c2c7a591f203a17" ), outputIndex: 0, @@ -332,7 +332,7 @@ export const depositSweepWithNonWitnessMainUtxoAndWitnessOutput: DepositSweepTes }, ], mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "c8a2c407309b9434cb73d4788ce4ac895084240eec7bb440e7f76b75be1296e1" ), outputIndex: 0, @@ -350,24 +350,25 @@ export const depositSweepWithNonWitnessMainUtxoAndWitnessOutput: DepositSweepTes }, witness: true, expectedSweep: { - transactionHash: TransactionHash.from( - "1933781f01f27f086c3a31c4a53035ebc7c4688e1f4b316babefa8f6dab77dc2" + transactionHash: BitcoinTxHash.from( + "7831d0dfde7e160f3b9bb66c433710f0d3110d73ea78b9db65e81c091a6718a0" ), transaction: { transactionHex: - "01000000000102e19612be756bf7e740b47bec0e24845089ace48c78d473cb34949" + - "b3007c4a2c8000000006a473044022013787be70eda0620002fa55c92abfcd32257" + - "d64fa652dd32bac65d705162a95902203407fea1abc99a9273ead3179ce60f60a34" + - "33fb2e93f58569e4bee9f63c0d679012103989d253b17a6a0f41838b84ff0d20e88" + - "98f9d7b1a98f2564da4cc29dcf8581d9ffffffff173a201f597a2c8ccd7842303a6" + - "653bb87437fb08dae671731a075403b32a2fd0000000000ffffffff010884000000" + - "0000001600148db50eb52063ea9d98b3eac91489a90f738986f6000348304502210" + - "0804f0fa989d632cda99a24159e28b8d31d4033c2d5de47d8207ea2767273d10a02" + - "20278e82d0714867b31eb013762306e2b97c2c1cc74b8135bee78d565e72ee630e0" + - "12103989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581" + - "d95c14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508f9f0c90d000395237" + - "576a9148db50eb52063ea9d98b3eac91489a90f738986f68763ac6776a914e257ec" + - "cafbc07c381642ce6e7e55120fb077fbed880448f2b262b175ac6800000000", + "01000000000102173a201f597a2c8ccd7842303a6653bb87437fb08dae671731a0" + + "75403b32a2fd0000000000ffffffffe19612be756bf7e740b47bec0e24845089ac" + + "e48c78d473cb34949b3007c4a2c8000000006a47304402204382deb051f9f3e2b5" + + "39e4bac2d1a50faf8d66bc7a3a3f3d286dabd96d92b58b02207c74c6aaf48e25d0" + + "7e02bb4039606d77ecfd80c492c050ab2486af6027fc2d5a012103989d253b17a6" + + "a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9ffffffff010884" + + "0000000000001600148db50eb52063ea9d98b3eac91489a90f738986f603483045" + + "022100c52bc876cdee80a3061ace3ffbce5e860942d444cd38e00e5f63fd8e818d" + + "7e7c022040a7017bb8213991697705e7092c481526c788a4731d06e582dc1c57be" + + "d7243b012103989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc2" + + "9dcf8581d95c14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508f9f0c90d" + + "000395237576a9148db50eb52063ea9d98b3eac91489a90f738986f68763ac6776" + + "a914e257eccafbc07c381642ce6e7e55120fb077fbed880448f2b262b175ac6800" + + "00000000", }, }, } @@ -377,17 +378,17 @@ export const depositSweepWithNonWitnessMainUtxoAndWitnessOutput: DepositSweepTes */ export interface DepositSweepProofTestData { bitcoinChainData: { - transaction: Transaction - rawTransaction: RawTransaction + transaction: BitcoinTx + rawTransaction: BitcoinRawTx accumulatedTxConfirmations: number latestBlockHeight: number headersChain: string - transactionMerkleBranch: TransactionMerkleBranch + transactionMerkleBranch: BitcoinTxMerkleBranch } expectedSweepProof: { - sweepTx: DecomposedRawTransaction - sweepProof: Proof - mainUtxo: UnspentTransactionOutput + sweepTx: BitcoinRawTxVectors + sweepProof: BitcoinSpvProof + mainUtxo: BitcoinUtxo } } @@ -398,33 +399,33 @@ export interface DepositSweepProofTestData { export const depositSweepProof: DepositSweepProofTestData = { bitcoinChainData: { transaction: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "5083822ed0b8d0bc661362b778e666cb572ff6d5152193992dd69d3207995753" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "ea4d9e45f8c1b8a187c007f36ba1e9b201e8511182c7083c4edcaf9325b2998f" ), outputIndex: 0, scriptSig: Hex.from(""), }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "c844ff4c1781c884bb5e80392398b81b984d7106367ae16675f132bd1a7f33fd" ), outputIndex: 0, scriptSig: Hex.from(""), }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "44c568bc0eac07a2a9c2b46829be5b5d46e7d00e17bfb613f506a75ccf86a473" ), outputIndex: 0, scriptSig: Hex.from(""), }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f548c00e464764e112826450a00cf005ca771a6108a629b559b6c60a519e4378" ), outputIndex: 0, diff --git a/typescript/test/data/deposit.ts b/typescript/test/data/deposit.ts index 42371740f..241c6e4bd 100644 --- a/typescript/test/data/deposit.ts +++ b/typescript/test/data/deposit.ts @@ -1,8 +1,4 @@ -import { - RawTransaction, - TransactionHash, - UnspentTransactionOutput, -} from "../../src/lib/bitcoin" +import { BitcoinRawTx, BitcoinTxHash, BitcoinUtxo } from "../../src/lib/bitcoin" import { BigNumber } from "ethers" /** @@ -20,7 +16,7 @@ export const testnetPrivateKey = /** * Hash of one of the transactions originating from testnetAddress. */ -export const testnetTransactionHash = TransactionHash.from( +export const testnetTransactionHash = BitcoinTxHash.from( "2f952bdc206bf51bb745b967cb7166149becada878d3191ffe341155ebcd4883" ) @@ -29,7 +25,7 @@ export const testnetTransactionHash = TransactionHash.from( * from testnetAddress. It can be decoded, for example, with: * https://live.blockcypher.com/btc-testnet/decodetx */ -export const testnetTransaction: RawTransaction = { +export const testnetTransaction: BitcoinRawTx = { transactionHex: "0100000000010162cae24e74ad64f9f0493b09f3964908b3b3038f4924882d3dbd853b" + "4c9bc7390100000000ffffffff02102700000000000017a914867120d5480a9cc0c11c" + @@ -43,7 +39,7 @@ export const testnetTransaction: RawTransaction = { /** * An UTXO from the testnetTransaction. */ -export const testnetUTXO: UnspentTransactionOutput & RawTransaction = { +export const testnetUTXO: BitcoinUtxo & BitcoinRawTx = { transactionHash: testnetTransactionHash, outputIndex: 1, value: BigNumber.from(3933200), diff --git a/typescript/test/data/electrum.ts b/typescript/test/data/electrum.ts index ddc3f6a06..374fe9c14 100644 --- a/typescript/test/data/electrum.ts +++ b/typescript/test/data/electrum.ts @@ -1,9 +1,9 @@ import { - Transaction, - RawTransaction, - UnspentTransactionOutput, - TransactionMerkleBranch, - TransactionHash, + BitcoinTx, + BitcoinRawTx, + BitcoinUtxo, + BitcoinTxMerkleBranch, + BitcoinTxHash, } from "../../src/lib/bitcoin" import { BigNumber } from "ethers" import { Hex } from "../../src" @@ -17,14 +17,14 @@ export const testnetAddress: string = /** * A testnet transaction originating from {@link testnetAddress} */ -export const testnetTransaction: Transaction = { - transactionHash: TransactionHash.from( +export const testnetTransaction: BitcoinTx = { + transactionHash: BitcoinTxHash.from( "72e7fd57c2adb1ed2305c4247486ff79aec363296f02ec65be141904f80d214e" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "c6ffe9e0f8cca057acad211023ff6b9d46604fbbcb76c6dd669c20b22985f802" ), outputIndex: 1, @@ -49,7 +49,7 @@ export const testnetTransaction: Transaction = { /** * Raw transaction corresponding to {@link testnetTransaction} */ -export const testnetRawTransaction: RawTransaction = { +export const testnetRawTransaction: BitcoinRawTx = { transactionHex: "0200000000010102f88529b2209c66ddc676cbbb4f60469d6bff231021adac57a0ccf8e" + "0e9ffc60100000000fdffffff0265000000000000001600144b47c798d12edd17dfb4ea" + @@ -63,7 +63,7 @@ export const testnetRawTransaction: RawTransaction = { /** * An UTXO being result of {@link testnetTransaction} */ -export const testnetUTXO: UnspentTransactionOutput = { +export const testnetUTXO: BitcoinUtxo = { transactionHash: testnetTransaction.transactionHash, outputIndex: 0, value: BigNumber.from(101), @@ -97,7 +97,7 @@ export const testnetHeadersChain = { /** * Transaction merkle branch corresponding to {@link testnetTransaction} */ -export const testnetTransactionMerkleBranch: TransactionMerkleBranch = { +export const testnetTransactionMerkleBranch: BitcoinTxMerkleBranch = { blockHeight: 1569342, merkle: [ "8b5bbb5bdf6727bf70fad4f46fe4eaab04c98119ffbd2d95c29adf32d26f8452", diff --git a/typescript/test/data/proof.ts b/typescript/test/data/proof.ts index ab3ae7942..ec212b497 100644 --- a/typescript/test/data/proof.ts +++ b/typescript/test/data/proof.ts @@ -1,9 +1,9 @@ import { - Proof, - RawTransaction, - Transaction, - TransactionHash, - TransactionMerkleBranch, + BitcoinSpvProof, + BitcoinRawTx, + BitcoinTx, + BitcoinTxHash, + BitcoinTxMerkleBranch, } from "../../src/lib/bitcoin" import { BigNumber } from "ethers" import { Hex } from "../../src" @@ -14,14 +14,14 @@ import { Hex } from "../../src" export interface ProofTestData { requiredConfirmations: number bitcoinChainData: { - transaction: Transaction - rawTransaction: RawTransaction + transaction: BitcoinTx + rawTransaction: BitcoinRawTx accumulatedTxConfirmations: number latestBlockHeight: number headersChain: string - transactionMerkleBranch: TransactionMerkleBranch + transactionMerkleBranch: BitcoinTxMerkleBranch } - expectedProof: Proof & Transaction + expectedProof: BitcoinSpvProof & BitcoinTx } /** @@ -32,12 +32,12 @@ export const singleInputProofTestData: ProofTestData = { requiredConfirmations: 6, bitcoinChainData: { transaction: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "44c568bc0eac07a2a9c2b46829be5b5d46e7d00e17bfb613f506a75ccf86a473" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "8ee67b585eeb682bf6907ea311282540ee53edf605e0f09757226a4dc3e72a67" ), outputIndex: 0, @@ -102,12 +102,12 @@ export const singleInputProofTestData: ProofTestData = { }, }, expectedProof: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "44c568bc0eac07a2a9c2b46829be5b5d46e7d00e17bfb613f506a75ccf86a473" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "8ee67b585eeb682bf6907ea311282540ee53edf605e0f09757226a4dc3e72a67" ), outputIndex: 0, @@ -160,33 +160,33 @@ export const multipleInputsProofTestData: ProofTestData = { bitcoinChainData: { transaction: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "5083822ed0b8d0bc661362b778e666cb572ff6d5152193992dd69d3207995753" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "ea4d9e45f8c1b8a187c007f36ba1e9b201e8511182c7083c4edcaf9325b2998f" ), outputIndex: 0, scriptSig: Hex.from(""), }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "c844ff4c1781c884bb5e80392398b81b984d7106367ae16675f132bd1a7f33fd" ), outputIndex: 0, scriptSig: Hex.from(""), }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "44c568bc0eac07a2a9c2b46829be5b5d46e7d00e17bfb613f506a75ccf86a473" ), outputIndex: 0, scriptSig: Hex.from(""), }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f548c00e464764e112826450a00cf005ca771a6108a629b559b6c60a519e4378" ), outputIndex: 0, @@ -269,33 +269,33 @@ export const multipleInputsProofTestData: ProofTestData = { }, }, expectedProof: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "5083822ed0b8d0bc661362b778e666cb572ff6d5152193992dd69d3207995753" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "ea4d9e45f8c1b8a187c007f36ba1e9b201e8511182c7083c4edcaf9325b2998f" ), outputIndex: 0, scriptSig: Hex.from(""), }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "c844ff4c1781c884bb5e80392398b81b984d7106367ae16675f132bd1a7f33fd" ), outputIndex: 0, scriptSig: Hex.from(""), }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "44c568bc0eac07a2a9c2b46829be5b5d46e7d00e17bfb613f506a75ccf86a473" ), outputIndex: 0, scriptSig: Hex.from(""), }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f548c00e464764e112826450a00cf005ca771a6108a629b559b6c60a519e4378" ), outputIndex: 0, @@ -343,11 +343,11 @@ export const multipleInputsProofTestData: ProofTestData = { export interface TransactionProofData { requiredConfirmations: number bitcoinChainData: { - transaction: Transaction + transaction: BitcoinTx accumulatedTxConfirmations: number latestBlockHeight: number headersChain: string - transactionMerkleBranch: TransactionMerkleBranch + transactionMerkleBranch: BitcoinTxMerkleBranch previousDifficulty: BigNumber currentDifficulty: BigNumber } @@ -362,12 +362,12 @@ export const transactionConfirmationsInOneEpochData: TransactionProofData = { requiredConfirmations: 6, bitcoinChainData: { transaction: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "713525ee9d9ab23433cd6ad470566ba1f47cac2d7f119cc50119128a84d718aa" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "91b83d443f32d5a1e87a200eac5d3501af0f156bef3a59d5e8805b4679c4a2a5" ), outputIndex: 3, @@ -460,12 +460,12 @@ export const transactionConfirmationsInTwoEpochsData: TransactionProofData = { requiredConfirmations: 6, bitcoinChainData: { transaction: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "e073636400e132b8c1082133ab2b48866919153998f4f04877b580e9932d5a17" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f160a6565d07fd2e8f1d0aaaff538f3150b7f9d2bc64f191076f45c92725b990" ), outputIndex: 0, @@ -535,12 +535,12 @@ export const testnetTransactionData: TransactionProofData = { requiredConfirmations: 6, bitcoinChainData: { transaction: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "b78636ae08e6c17261a9f3134109c13c2eb69f6df52e591cc0e0780f5ebf6472" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "b230eb52608287da6320fa0926b3ada60f8979fa662d878494d11909d9841aba" ), outputIndex: 1, diff --git a/typescript/test/data/redemption.ts b/typescript/test/data/redemption.ts index 3ba8b0b57..8cefbc42d 100644 --- a/typescript/test/data/redemption.ts +++ b/typescript/test/data/redemption.ts @@ -1,17 +1,17 @@ import { BigNumber, BytesLike } from "ethers" import { - DecomposedRawTransaction, - Proof, - Transaction, - RawTransaction, - UnspentTransactionOutput, - TransactionMerkleBranch, - TransactionHash, - createOutputScriptFromAddress, + BitcoinRawTxVectors, + BitcoinSpvProof, + BitcoinTx, + BitcoinRawTx, + BitcoinUtxo, + BitcoinTxMerkleBranch, + BitcoinTxHash, + BitcoinAddressConverter, } from "../../src/lib/bitcoin" import { RedemptionRequest, WalletState } from "../../src/lib/contracts" import { Address } from "../../src/lib/ethereum" -import { BitcoinTransaction, Hex } from "../../src" +import { Hex } from "../../src" /** * Private key (testnet) of the wallet. @@ -40,15 +40,15 @@ export const p2wpkhWalletAddress = "tb1q3k6sadfqv04fmx9naty3fzdfpaecnphkfm3cf3" * Represents a set of data used for given sweep scenario. */ export interface RedemptionTestData { - mainUtxo: UnspentTransactionOutput & RawTransaction + mainUtxo: BitcoinUtxo & BitcoinRawTx pendingRedemptions: { redemptionKey: BytesLike pendingRedemption: RedemptionRequest }[] witness: boolean expectedRedemption: { - transactionHash: TransactionHash - transaction: RawTransaction + transactionHash: BitcoinTxHash + transaction: BitcoinRawTx } } @@ -59,7 +59,7 @@ export interface RedemptionTestData { */ export const singleP2PKHRedemptionWithWitnessChange: RedemptionTestData = { mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "523e4bfb71804e5ed3b76c8933d733339563e560311c1bf835934ee7aae5db20" ), outputIndex: 1, @@ -91,7 +91,7 @@ export const singleP2PKHRedemptionWithWitnessChange: RedemptionTestData = { ], witness: true, expectedRedemption: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "c437f1117db977682334b53a71fbe63a42aab42f6e0976c35b69977f86308c20" ), transaction: { @@ -114,7 +114,7 @@ export const singleP2PKHRedemptionWithWitnessChange: RedemptionTestData = { */ export const singleP2WPKHRedemptionWithWitnessChange: RedemptionTestData = { mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "c437f1117db977682334b53a71fbe63a42aab42f6e0976c35b69977f86308c20" ), outputIndex: 1, @@ -145,7 +145,7 @@ export const singleP2WPKHRedemptionWithWitnessChange: RedemptionTestData = { ], witness: true, expectedRedemption: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "925e61dc31396e7f2cbcc8bc9b4009b4f24ba679257762df078b7e9b875ea110" ), transaction: { @@ -168,7 +168,7 @@ export const singleP2WPKHRedemptionWithWitnessChange: RedemptionTestData = { */ export const singleP2SHRedemptionWithWitnessChange: RedemptionTestData = { mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "925e61dc31396e7f2cbcc8bc9b4009b4f24ba679257762df078b7e9b875ea110" ), outputIndex: 1, @@ -199,7 +199,7 @@ export const singleP2SHRedemptionWithWitnessChange: RedemptionTestData = { ], witness: true, expectedRedemption: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "ef25c9c8f4df673def035c0c1880278c90030b3c94a56668109001a591c2c521" ), transaction: { @@ -222,7 +222,7 @@ export const singleP2SHRedemptionWithWitnessChange: RedemptionTestData = { */ export const singleP2WSHRedemptionWithWitnessChange: RedemptionTestData = { mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "ef25c9c8f4df673def035c0c1880278c90030b3c94a56668109001a591c2c521" ), outputIndex: 1, @@ -254,7 +254,7 @@ export const singleP2WSHRedemptionWithWitnessChange: RedemptionTestData = { ], witness: true, expectedRedemption: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "3d28bb5bf73379da51bc683f4d0ed31d7b024466c619d80ebd9378077d900be3" ), transaction: { @@ -277,7 +277,7 @@ export const singleP2WSHRedemptionWithWitnessChange: RedemptionTestData = { */ export const multipleRedemptionsWithWitnessChange: RedemptionTestData = { mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "3d28bb5bf73379da51bc683f4d0ed31d7b024466c619d80ebd9378077d900be3" ), outputIndex: 1, @@ -349,7 +349,7 @@ export const multipleRedemptionsWithWitnessChange: RedemptionTestData = { ], witness: true, expectedRedemption: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f70ff89fd2b6226183e4b8143cc5f0f457f05dd1dca0c6151ab66f4523d972b7" ), transaction: { @@ -375,7 +375,7 @@ export const multipleRedemptionsWithWitnessChange: RedemptionTestData = { */ export const multipleRedemptionsWithoutChange: RedemptionTestData = { mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "7dd38b48cb626580d317871c5b716eaf4a952ceb67ba3aa4ca76e3dc7cdcc65b" ), outputIndex: 1, @@ -420,7 +420,7 @@ export const multipleRedemptionsWithoutChange: RedemptionTestData = { ], witness: true, expectedRedemption: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "afcdf8f91273b73abc40018873978c22bbb7c3d8d669ef2faffa0c4b0898c8eb" ), transaction: { @@ -443,7 +443,7 @@ export const multipleRedemptionsWithoutChange: RedemptionTestData = { */ export const singleP2SHRedemptionWithNonWitnessChange: RedemptionTestData = { mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f70ff89fd2b6226183e4b8143cc5f0f457f05dd1dca0c6151ab66f4523d972b7" ), outputIndex: 4, @@ -477,7 +477,7 @@ export const singleP2SHRedemptionWithNonWitnessChange: RedemptionTestData = { ], witness: false, // False will result in a P2PKH output expectedRedemption: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "0fec22d0fecd6607a0429210d04e9465681507d514f3edf0f07def96eda0f89d" ), transaction: { @@ -498,17 +498,17 @@ export const singleP2SHRedemptionWithNonWitnessChange: RedemptionTestData = { */ export interface RedemptionProofTestData { bitcoinChainData: { - transaction: Transaction - rawTransaction: RawTransaction + transaction: BitcoinTx + rawTransaction: BitcoinRawTx accumulatedTxConfirmations: number latestBlockHeight: number headersChain: string - transactionMerkleBranch: TransactionMerkleBranch + transactionMerkleBranch: BitcoinTxMerkleBranch } expectedRedemptionProof: { - redemptionTx: DecomposedRawTransaction - redemptionProof: Proof - mainUtxo: UnspentTransactionOutput + redemptionTx: BitcoinRawTxVectors + redemptionProof: BitcoinSpvProof + mainUtxo: BitcoinUtxo walletPublicKey: string } } @@ -520,12 +520,12 @@ export interface RedemptionProofTestData { export const redemptionProof: RedemptionProofTestData = { bitcoinChainData: { transaction: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f70ff89fd2b6226183e4b8143cc5f0f457f05dd1dca0c6151ab66f4523d972b7" ), inputs: [ { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "3d28bb5bf73379da51bc683f4d0ed31d7b024466c619d80ebd9378077d900be3" ), outputIndex: 1, @@ -657,7 +657,7 @@ export const redemptionProof: RedemptionProofTestData = { "69eab449fb51823d58835a4aed9a5e62341f5c192fd94baa", }, mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "3d28bb5bf73379da51bc683f4d0ed31d7b024466c619d80ebd9378077d900be3" ), outputIndex: 1, @@ -674,8 +674,8 @@ interface FindWalletForRedemptionWalletData { mainUtxoHash: Hex walletPublicKey: Hex btcAddress: string - mainUtxo: UnspentTransactionOutput - transactions: BitcoinTransaction[] + mainUtxo: BitcoinUtxo + transactions: BitcoinTx[] pendingRedemptionsValue: BigNumber } event: { @@ -721,7 +721,7 @@ export const findWalletForRedemptionData: { { outputIndex: 0, value: BigNumber.from("791613461"), - scriptPubKey: createOutputScriptFromAddress( + scriptPubKey: BitcoinAddressConverter.addressToOutputScript( "tb1qqwm566yn44rdlhgph8sw8vecta8uutg79afuja" ), }, @@ -846,7 +846,7 @@ export const findWalletForRedemptionData: { { outputIndex: 0, value: BigNumber.from("3370000"), // 0.0337 BTC - scriptPubKey: createOutputScriptFromAddress( + scriptPubKey: BitcoinAddressConverter.addressToOutputScript( "tb1qx2xejtjltdcau5dpks8ucszkhxdg3fj88404lh" ), }, diff --git a/typescript/test/deposit-refund.test.ts b/typescript/test/deposit-refund.test.ts index a6e30ccf3..bafc68736 100644 --- a/typescript/test/deposit-refund.test.ts +++ b/typescript/test/deposit-refund.test.ts @@ -5,7 +5,7 @@ import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) import { expect } from "chai" import { submitDepositRefundTransaction } from "../src/deposit-refund" -import { TransactionHash, RawTransaction } from "./lib/bitcoin" +import { BitcoinTxHash, BitcoinRawTx } from "./lib/bitcoin" import { refunderPrivateKey, depositRefundOfWitnessDepositAndWitnessRefunderAddress, @@ -25,7 +25,7 @@ describe("Refund", () => { context("when the refund transaction is requested to be witness", () => { context("when the refunded deposit was witness", () => { - let transactionHash: TransactionHash + let transactionHash: BitcoinTxHash beforeEach(async () => { const utxo = @@ -37,7 +37,7 @@ describe("Refund", () => { const refunderPrivateKey = "cTWhf1nXc7aW8BN2qLtWcPtcgcWYKfzRXkCJNsuQ86HR8uJBYfMc" - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set(utxo.transactionHash.toString(), { transactionHex: utxo.transactionHex, }) @@ -69,7 +69,7 @@ describe("Refund", () => { }) context("when the refunded deposit was non-witness", () => { - let transactionHash: TransactionHash + let transactionHash: BitcoinTxHash beforeEach(async () => { const utxo = @@ -81,7 +81,7 @@ describe("Refund", () => { const refunderAddress = depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.refunderAddress - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set(utxo.transactionHash.toString(), { transactionHex: utxo.transactionHex, }) @@ -116,7 +116,7 @@ describe("Refund", () => { context( "when the refund transaction is requested to be non-witness", () => { - let transactionHash: TransactionHash + let transactionHash: BitcoinTxHash beforeEach(async () => { const utxo = @@ -128,7 +128,7 @@ describe("Refund", () => { const refunderAddress = depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.refunderAddress - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set(utxo.transactionHash.toString(), { transactionHex: utxo.transactionHex, }) diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index e7727de85..c23e0835d 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -1,9 +1,9 @@ import { BigNumber } from "ethers" import { - RawTransaction, - TransactionHash, - UnspentTransactionOutput, - Transaction, + BitcoinRawTx, + BitcoinTxHash, + BitcoinUtxo, + BitcoinTx, } from "../src/lib/bitcoin" import { testnetDepositScripthashAddress, @@ -46,13 +46,13 @@ describe("Sweep", () => { context("when the new main UTXO is requested to be witness", () => { context("when there is no main UTXO from previous deposit sweep", () => { - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo beforeEach(async () => { // Map transaction hashes for UTXOs to transactions in hexadecimal and // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() + const rawTransactions = new Map() for (const deposit of depositSweepWithNoMainUtxoAndWitnessOutput.deposits) { rawTransactions.set(deposit.utxo.transactionHash.toString(), { transactionHex: deposit.utxo.transactionHex, @@ -60,7 +60,7 @@ describe("Sweep", () => { } bitcoinClient.rawTransactions = rawTransactions - const utxos: UnspentTransactionOutput[] = + const utxos: BitcoinUtxo[] = depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map((data) => { return data.utxo }) @@ -113,13 +113,13 @@ describe("Sweep", () => { context("when there is main UTXO from previous deposit sweep", () => { context("when main UTXO from previous deposit sweep is witness", () => { - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo beforeEach(async () => { // Map transaction hashes for UTXOs to transactions in hexadecimal and // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() + const rawTransactions = new Map() for (const deposit of depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits) { rawTransactions.set(deposit.utxo.transactionHash.toString(), { transactionHex: deposit.utxo.transactionHex, @@ -134,7 +134,7 @@ describe("Sweep", () => { ) bitcoinClient.rawTransactions = rawTransactions - const utxos: UnspentTransactionOutput[] = + const utxos: BitcoinUtxo[] = depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( (deposit) => { return deposit.utxo @@ -197,13 +197,13 @@ describe("Sweep", () => { context( "when main UTXO from previous deposit sweep is non-witness", () => { - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo beforeEach(async () => { // Map transaction hashes for UTXOs to transactions in hexadecimal and // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() + const rawTransactions = new Map() for (const deposit of depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits) { rawTransactions.set(deposit.utxo.transactionHash.toString(), { transactionHex: deposit.utxo.transactionHex, @@ -219,7 +219,7 @@ describe("Sweep", () => { ) bitcoinClient.rawTransactions = rawTransactions - const utxos: UnspentTransactionOutput[] = + const utxos: BitcoinUtxo[] = depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( (deposit) => { return deposit.utxo @@ -286,13 +286,13 @@ describe("Sweep", () => { // The only difference between deposit sweep transactions with witness and // non-witness output is the output type itself. // Therefore only one test case was added for non-witness transactions. - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo beforeEach(async () => { // Map transaction hashes for UTXOs to transactions in hexadecimal and // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() + const rawTransactions = new Map() for (const deposit of depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits) { rawTransactions.set(deposit.utxo.transactionHash.toString(), { transactionHex: deposit.utxo.transactionHex, @@ -356,9 +356,9 @@ describe("Sweep", () => { describe("assembleDepositSweepTransaction", () => { context("when the new main UTXO is requested to be witness", () => { context("when there is no main UTXO from previous deposit sweep", () => { - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx const utxosWithRaw = depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map((data) => { @@ -477,9 +477,9 @@ describe("Sweep", () => { context("when there is main UTXO from previous deposit sweep", () => { context("when main UTXO prom previous deposit sweep is witness", () => { - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx const utxosWithRaw = depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( @@ -627,9 +627,9 @@ describe("Sweep", () => { context( "when main UTXO from previous deposit sweep is non-witness", () => { - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx const utxosWithRaw = depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( @@ -765,9 +765,9 @@ describe("Sweep", () => { // The only difference between deposit sweep transactions with witness and // non-witness output is the output type itself. // Therefore only one test case was added for non-witness transactions. - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx const utxosWithRaw = depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( @@ -952,7 +952,7 @@ describe("Sweep", () => { // The UTXO below does not belong to the wallet const mainUtxoWithRaw = { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "2f952bdc206bf51bb745b967cb7166149becada878d3191ffe341155ebcd4883" ), outputIndex: 1, @@ -1010,7 +1010,7 @@ describe("Sweep", () => { context("when the type of UTXO is unsupported", () => { // Use coinbase transaction of some block const utxoWithRaw = { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "025de155e6f2ffbbf4851493e0d28dad54020db221a3f38bf63c1f65e3d3595b" ), outputIndex: 0, @@ -1050,14 +1050,14 @@ describe("Sweep", () => { const transactionHash = depositSweepProof.bitcoinChainData.transaction.transactionHash - const transactions = new Map() + const transactions = new Map() transactions.set( transactionHash.toString(), depositSweepProof.bitcoinChainData.transaction ) bitcoinClient.transactions = transactions - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set( transactionHash.toString(), depositSweepProof.bitcoinChainData.rawTransaction diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index 7e34edd9c..f002c570d 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -8,10 +8,10 @@ import { testnetUTXO, } from "./data/deposit" import { - decomposeRawTransaction, - RawTransaction, - TransactionHash, - UnspentTransactionOutput, + extractBitcoinRawTxVectors, + BitcoinRawTx, + BitcoinTxHash, + BitcoinUtxo, } from "../src/lib/bitcoin" import { Deposit, @@ -70,7 +70,7 @@ describe("Deposit", () => { // Expected data of created deposit in P2WSH scenarios. const expectedP2WSHDeposit = { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "9eb901fc68f0d9bcaf575f23783b7d30ac5dd8d95f3c83dceaa13dce17de816a" ), @@ -100,7 +100,7 @@ describe("Deposit", () => { // Expected data of created deposit in P2SH scenarios. const expectedP2SHDeposit = { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f21a9922c0c136c6d288cf1258b732d0f84a7d50d14a01d7d81cb6cd810f3517" ), @@ -232,20 +232,20 @@ describe("Deposit", () => { // Tie used testnetAddress with testnetUTXO to use it during deposit // creation. - const utxos = new Map() + const utxos = new Map() utxos.set(testnetAddress, [testnetUTXO]) bitcoinClient.unspentTransactionOutputs = utxos // Tie testnetTransaction to testnetUTXO. This is needed since // submitDepositTransaction attach transaction data to each UTXO. - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set(testnetTransactionHash.toString(), testnetTransaction) bitcoinClient.rawTransactions = rawTransactions }) context("when witness option is true", () => { - let transactionHash: TransactionHash - let depositUtxo: UnspentTransactionOutput + let transactionHash: BitcoinTxHash + let depositUtxo: BitcoinUtxo beforeEach(async () => { ;({ transactionHash, depositUtxo } = await submitDepositTransaction( @@ -281,8 +281,8 @@ describe("Deposit", () => { }) context("when witness option is false", () => { - let transactionHash: TransactionHash - let depositUtxo: UnspentTransactionOutput + let transactionHash: BitcoinTxHash + let depositUtxo: BitcoinUtxo beforeEach(async () => { ;({ transactionHash, depositUtxo } = await submitDepositTransaction( @@ -320,9 +320,9 @@ describe("Deposit", () => { describe("assembleDepositTransaction", () => { context("when witness option is true", () => { - let transactionHash: TransactionHash - let depositUtxo: UnspentTransactionOutput - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let depositUtxo: BitcoinUtxo + let transaction: BitcoinRawTx beforeEach(async () => { ;({ @@ -417,9 +417,9 @@ describe("Deposit", () => { }) context("when witness option is false", () => { - let transactionHash: TransactionHash - let depositUtxo: UnspentTransactionOutput - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let depositUtxo: BitcoinUtxo + let transaction: BitcoinRawTx beforeEach(async () => { ;({ @@ -693,8 +693,8 @@ describe("Deposit", () => { }) describe("revealDeposit", () => { - let transaction: RawTransaction - let depositUtxo: UnspentTransactionOutput + let transaction: BitcoinRawTx + let depositUtxo: BitcoinUtxo let bitcoinClient: MockBitcoinClient let bridge: MockBridge @@ -713,7 +713,7 @@ describe("Deposit", () => { // Initialize the mock Bitcoin client to return the raw transaction // data for the given deposit UTXO. bitcoinClient = new MockBitcoinClient() - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set(depositUtxo.transactionHash.toString(), transaction) bitcoinClient.rawTransactions = rawTransactions @@ -728,7 +728,7 @@ describe("Deposit", () => { const revealDepositLogEntry = bridge.revealDepositLog[0] expect(revealDepositLogEntry.depositTx).to.be.eql( - decomposeRawTransaction(transaction) + extractBitcoinRawTxVectors(transaction) ) expect(revealDepositLogEntry.depositOutputIndex).to.be.equal(0) expect(revealDepositLogEntry.deposit).to.be.eql(deposit) @@ -736,7 +736,7 @@ describe("Deposit", () => { }) describe("getRevealedDeposit", () => { - let depositUtxo: UnspentTransactionOutput + let depositUtxo: BitcoinUtxo let revealedDeposit: RevealedDeposit let bridge: MockBridge diff --git a/typescript/test/ethereum.test.ts b/typescript/test/ethereum.test.ts index ae98d3f9a..363202e9b 100644 --- a/typescript/test/ethereum.test.ts +++ b/typescript/test/ethereum.test.ts @@ -10,7 +10,7 @@ import { abi as TBTCTokenABI } from "@keep-network/tbtc-v2/artifacts/TBTC.json" import { abi as WalletRegistryABI } from "@keep-network/ecdsa/artifacts/WalletRegistry.json" import { MockProvider } from "@ethereum-waffle/provider" import { waffleChai } from "@ethereum-waffle/chai" -import { TransactionHash, computeHash160 } from "../src/lib/bitcoin" +import { BitcoinTxHash, BitcoinHashUtils } from "../src/lib/bitcoin" import { Hex } from "../src/lib/utils" chai.use(waffleChai) @@ -182,7 +182,7 @@ describe("Ethereum", () => { bitcoinHeaders: "66666666", }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f8eaf242a55ea15e602f9f990e33f67f99dfbe25d1802bbde63cc1caabf99668" ), outputIndex: 8, @@ -235,7 +235,7 @@ describe("Ethereum", () => { await bridgeHandle.requestRedemption( "03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9", { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f8eaf242a55ea15e602f9f990e33f67f99dfbe25d1802bbde63cc1caabf99668" ), outputIndex: 8, @@ -278,7 +278,7 @@ describe("Ethereum", () => { bitcoinHeaders: "66666666", }, { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f8eaf242a55ea15e602f9f990e33f67f99dfbe25d1802bbde63cc1caabf99668" ), outputIndex: 8, @@ -336,7 +336,7 @@ describe("Ethereum", () => { it("should return the revealed deposit", async () => { expect( await bridgeHandle.deposits( - TransactionHash.from( + BitcoinTxHash.from( "c1082c460527079a84e39ec6481666db72e5a22e473a78db03b996d26fd1dc83" ), 0 @@ -375,7 +375,7 @@ describe("Ethereum", () => { it("should return the revealed deposit", async () => { expect( await bridgeHandle.deposits( - TransactionHash.from( + BitcoinTxHash.from( "c1082c460527079a84e39ec6481666db72e5a22e473a78db03b996d26fd1dc83" ), 0 @@ -496,7 +496,7 @@ describe("Ethereum", () => { walletPublicKey: "03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9", mainUtxo: { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "f8eaf242a55ea15e602f9f990e33f67f99dfbe25d1802bbde63cc1caabf99668" ), outputIndex: 8, @@ -537,7 +537,9 @@ describe("Ethereum", () => { ["address", "bytes20", "bytes32", "uint32", "uint64", "bytes"], [ redeemer.identifierHex, - Hex.from(computeHash160(walletPublicKey)).toPrefixedString(), + Hex.from( + BitcoinHashUtils.computeHash160(walletPublicKey) + ).toPrefixedString(), mainUtxo.transactionHash.reverse().toPrefixedString(), mainUtxo.outputIndex, mainUtxo.value, diff --git a/typescript/test/proof.test.ts b/typescript/test/proof.test.ts index 37c47ea8d..9f499ac1e 100644 --- a/typescript/test/proof.test.ts +++ b/typescript/test/proof.test.ts @@ -1,12 +1,11 @@ import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { - serializeBlockHeader, - Transaction, - BlockHeader, - Proof, - assembleTransactionProof, - validateTransactionProof, - splitBlockHeadersChain, + BitcoinHeaderSerializer, + BitcoinTx, + BitcoinHeader, + BitcoinSpvProof, + assembleBitcoinSpvProof, + validateBitcoinSpvProof, } from "../src/lib/bitcoin" import { Hex } from "../src/lib/utils" import { @@ -32,7 +31,7 @@ describe("Proof", () => { }) context("when the transaction has one input", () => { - let proof: Transaction & Proof + let proof: BitcoinTx & BitcoinSpvProof beforeEach(async () => { proof = await runProofScenario(singleInputProofTestData) @@ -52,7 +51,7 @@ describe("Proof", () => { }) context("when the transaction has multiple inputs", () => { - let proof: Transaction & Proof + let proof: BitcoinTx & BitcoinSpvProof beforeEach(async () => { proof = await runProofScenario(multipleInputsProofTestData) @@ -90,8 +89,8 @@ describe("Proof", () => { async function runProofScenario( data: ProofTestData - ): Promise { - const transactions = new Map() + ): Promise { + const transactions = new Map() const transactionHash = data.bitcoinChainData.transaction.transactionHash transactions.set( transactionHash.toString(), @@ -109,7 +108,7 @@ describe("Proof", () => { ) bitcoinClient.confirmations = confirmations - const proof = await assembleTransactionProof( + const proof = await assembleBitcoinSpvProof( transactionHash, data.requiredConfirmations, bitcoinClient @@ -283,14 +282,16 @@ describe("Proof", () => { it("should throw", async () => { // Corrupt data by modifying previous block header hash of one of the // headers. - const headers: BlockHeader[] = splitBlockHeadersChain( - transactionConfirmationsInOneEpochData.bitcoinChainData.headersChain - ) + const headers: BitcoinHeader[] = + BitcoinHeaderSerializer.deserializeHeadersChain( + transactionConfirmationsInOneEpochData.bitcoinChainData + .headersChain + ) headers[headers.length - 1].previousBlockHeaderHash = Hex.from( "ff".repeat(32) ) const corruptedHeadersChain: string = headers - .map(serializeBlockHeader) + .map(BitcoinHeaderSerializer.serializeHeader) .join("") const corruptedProofData: TransactionProofData = { @@ -311,12 +312,14 @@ describe("Proof", () => { it("should throw", async () => { // Corrupt data by modifying the nonce of one of the headers, so that // the resulting hash will be above the required difficulty target. - const headers: BlockHeader[] = splitBlockHeadersChain( - transactionConfirmationsInOneEpochData.bitcoinChainData.headersChain - ) + const headers: BitcoinHeader[] = + BitcoinHeaderSerializer.deserializeHeadersChain( + transactionConfirmationsInOneEpochData.bitcoinChainData + .headersChain + ) headers[headers.length - 1].nonce++ const corruptedHeadersChain: string = headers - .map(serializeBlockHeader) + .map(BitcoinHeaderSerializer.serializeHeader) .join("") const corruptedProofData: TransactionProofData = { @@ -361,7 +364,7 @@ describe("Proof", () => { }) async function runProofValidationScenario(data: TransactionProofData) { - const transactions = new Map() + const transactions = new Map() const transactionHash = data.bitcoinChainData.transaction.transactionHash transactions.set( transactionHash.toString(), @@ -379,7 +382,7 @@ describe("Proof", () => { ) bitcoinClient.confirmations = confirmations - await validateTransactionProof( + await validateBitcoinSpvProof( data.bitcoinChainData.transaction.transactionHash, data.requiredConfirmations, data.bitcoinChainData.previousDifficulty, diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index ee59f3b48..ef90d3cae 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -1,9 +1,9 @@ import { BitcoinNetwork, - Transaction, - RawTransaction, - TransactionHash, - UnspentTransactionOutput, + BitcoinTx, + BitcoinRawTx, + BitcoinTxHash, + BitcoinUtxo, } from "../src/lib/bitcoin" import bcoin from "bcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" @@ -38,7 +38,6 @@ import chaiAsPromised from "chai-as-promised" import { expect } from "chai" import { BigNumberish, BigNumber } from "ethers" import { MockTBTCToken } from "./utils/mock-tbtc-token" -import { BitcoinTransaction } from "../src" chai.use(chaiAsPromised) @@ -99,8 +98,8 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2PKHRedemptionWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined beforeEach(async () => { ;({ transactionHash, newMainUtxo } = @@ -144,8 +143,8 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2WPKHRedemptionWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined beforeEach(async () => { ;({ transactionHash, newMainUtxo } = @@ -189,8 +188,8 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2SHRedemptionWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined beforeEach(async () => { ;({ transactionHash, newMainUtxo } = @@ -234,8 +233,8 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2WSHRedemptionWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined beforeEach(async () => { ;({ transactionHash, newMainUtxo } = @@ -278,8 +277,8 @@ describe("Redemption", () => { const data: RedemptionTestData = multipleRedemptionsWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined beforeEach(async () => { ;({ transactionHash, newMainUtxo } = @@ -323,8 +322,8 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2SHRedemptionWithNonWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined beforeEach(async () => { ;({ transactionHash, newMainUtxo } = @@ -367,8 +366,8 @@ describe("Redemption", () => { // will not contain the change output. const data: RedemptionTestData = multipleRedemptionsWithoutChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined beforeEach(async () => { ;({ transactionHash, newMainUtxo } = await runRedemptionScenario( @@ -405,7 +404,7 @@ describe("Redemption", () => { const data: RedemptionTestData = multipleRedemptionsWithWitnessChange beforeEach(async () => { - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set(data.mainUtxo.transactionHash.toString(), { transactionHex: data.mainUtxo.transactionHex, }) @@ -450,7 +449,7 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2WPKHRedemptionWithWitnessChange beforeEach(async () => { - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set(data.mainUtxo.transactionHash.toString(), { transactionHex: data.mainUtxo.transactionHex, }) @@ -483,9 +482,9 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2PKHRedemptionWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { const redemptionRequests = data.pendingRedemptions.map( @@ -596,9 +595,9 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2WPKHRedemptionWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { const redemptionRequests = data.pendingRedemptions.map( @@ -708,9 +707,9 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2SHRedemptionWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { const redemptionRequests = data.pendingRedemptions.map( @@ -820,9 +819,9 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2WSHRedemptionWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { const redemptionRequests = data.pendingRedemptions.map( @@ -931,9 +930,9 @@ describe("Redemption", () => { const data: RedemptionTestData = multipleRedemptionsWithWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { const redemptionRequests = data.pendingRedemptions.map( @@ -1088,9 +1087,9 @@ describe("Redemption", () => { const data: RedemptionTestData = singleP2SHRedemptionWithNonWitnessChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { const redemptionRequests = data.pendingRedemptions.map( @@ -1194,9 +1193,9 @@ describe("Redemption", () => { context("when there is no change UTXO created", () => { const data: RedemptionTestData = multipleRedemptionsWithoutChange - let transactionHash: TransactionHash - let newMainUtxo: UnspentTransactionOutput | undefined - let transaction: RawTransaction + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { const redemptionRequests = data.pendingRedemptions.map( @@ -1309,7 +1308,7 @@ describe("Redemption", () => { describe("submitRedemptionProof", () => { const mainUtxo = { - transactionHash: TransactionHash.from( + transactionHash: BitcoinTxHash.from( "3d28bb5bf73379da51bc683f4d0ed31d7b024466c619d80ebd9378077d900be3" ), outputIndex: 1, @@ -1328,14 +1327,14 @@ describe("Redemption", () => { const transactionHash = redemptionProof.bitcoinChainData.transaction.transactionHash - const transactions = new Map() + const transactions = new Map() transactions.set( transactionHash.toString(), redemptionProof.bitcoinChainData.transaction ) bitcoinClient.transactions = transactions - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set( transactionHash.toString(), redemptionProof.bitcoinChainData.rawTransaction @@ -1490,10 +1489,7 @@ describe("Redemption", () => { (wallet) => wallet.event ) - const walletsTransactionHistory = new Map< - string, - BitcoinTransaction[] - >() + const walletsTransactionHistory = new Map() walletsOrder.forEach((wallet) => { const { @@ -1740,10 +1736,10 @@ async function runRedemptionScenario( bridge: MockBridge, data: RedemptionTestData ): Promise<{ - transactionHash: TransactionHash - newMainUtxo?: UnspentTransactionOutput + transactionHash: BitcoinTxHash + newMainUtxo?: BitcoinUtxo }> { - const rawTransactions = new Map() + const rawTransactions = new Map() rawTransactions.set(data.mainUtxo.transactionHash.toString(), { transactionHex: data.mainUtxo.transactionHex, }) diff --git a/typescript/test/utils/mock-bitcoin-client.ts b/typescript/test/utils/mock-bitcoin-client.ts index fdb0e17fb..96b01b249 100644 --- a/typescript/test/utils/mock-bitcoin-client.ts +++ b/typescript/test/utils/mock-bitcoin-client.ts @@ -1,45 +1,40 @@ import { BitcoinNetwork, - Client, - UnspentTransactionOutput, - TransactionMerkleBranch, - RawTransaction, - Transaction, - TransactionHash, + BitcoinClient, + BitcoinUtxo, + BitcoinTxMerkleBranch, + BitcoinRawTx, + BitcoinTx, + BitcoinTxHash, } from "../../src/lib/bitcoin" /** * Mock Bitcoin client used for test purposes. */ -export class MockBitcoinClient implements Client { - private _unspentTransactionOutputs = new Map< - string, - UnspentTransactionOutput[] - >() - private _rawTransactions = new Map() - private _transactions = new Map() +export class MockBitcoinClient implements BitcoinClient { + private _unspentTransactionOutputs = new Map() + private _rawTransactions = new Map() + private _transactions = new Map() private _confirmations = new Map() private _latestHeight = 0 private _headersChain = "" - private _transactionMerkle: TransactionMerkleBranch = { + private _transactionMerkle: BitcoinTxMerkleBranch = { blockHeight: 0, merkle: [], position: 0, } - private _broadcastLog: RawTransaction[] = [] - private _transactionHistory = new Map() + private _broadcastLog: BitcoinRawTx[] = [] + private _transactionHistory = new Map() - set unspentTransactionOutputs( - value: Map - ) { + set unspentTransactionOutputs(value: Map) { this._unspentTransactionOutputs = value } - set rawTransactions(value: Map) { + set rawTransactions(value: Map) { this._rawTransactions = value } - set transactions(value: Map) { + set transactions(value: Map) { this._transactions = value } @@ -55,15 +50,15 @@ export class MockBitcoinClient implements Client { this._headersChain = value } - set transactionMerkle(value: TransactionMerkleBranch) { + set transactionMerkle(value: BitcoinTxMerkleBranch) { this._transactionMerkle = value } - set transactionHistory(value: Map) { + set transactionHistory(value: Map) { this._transactionHistory = value } - get broadcastLog(): RawTransaction[] { + get broadcastLog(): BitcoinRawTx[] { return this._broadcastLog } @@ -73,24 +68,15 @@ export class MockBitcoinClient implements Client { }) } - findAllUnspentTransactionOutputs( - address: string - ): Promise { - return new Promise((resolve, _) => { - resolve( - this._unspentTransactionOutputs.get( - address - ) as UnspentTransactionOutput[] - ) + findAllUnspentTransactionOutputs(address: string): Promise { + return new Promise((resolve, _) => { + resolve(this._unspentTransactionOutputs.get(address) as BitcoinUtxo[]) }) } - getTransactionHistory( - address: string, - limit?: number - ): Promise { - return new Promise((resolve, _) => { - let transactions = this._transactionHistory.get(address) as Transaction[] + getTransactionHistory(address: string, limit?: number): Promise { + return new Promise((resolve, _) => { + let transactions = this._transactionHistory.get(address) as BitcoinTx[] if ( typeof limit !== "undefined" && @@ -104,23 +90,21 @@ export class MockBitcoinClient implements Client { }) } - getTransaction(transactionHash: TransactionHash): Promise { - return new Promise((resolve, _) => { - resolve(this._transactions.get(transactionHash.toString()) as Transaction) + getTransaction(transactionHash: BitcoinTxHash): Promise { + return new Promise((resolve, _) => { + resolve(this._transactions.get(transactionHash.toString()) as BitcoinTx) }) } - getRawTransaction(transactionHash: TransactionHash): Promise { - return new Promise((resolve, _) => { + getRawTransaction(transactionHash: BitcoinTxHash): Promise { + return new Promise((resolve, _) => { resolve( - this._rawTransactions.get(transactionHash.toString()) as RawTransaction + this._rawTransactions.get(transactionHash.toString()) as BitcoinRawTx ) }) } - getTransactionConfirmations( - transactionHash: TransactionHash - ): Promise { + getTransactionConfirmations(transactionHash: BitcoinTxHash): Promise { return new Promise((resolve, _) => { resolve(this._confirmations.get(transactionHash.toString()) as number) }) @@ -139,15 +123,15 @@ export class MockBitcoinClient implements Client { } getTransactionMerkle( - transactionHash: TransactionHash, + transactionHash: BitcoinTxHash, blockHeight: number - ): Promise { - return new Promise((resolve, _) => { + ): Promise { + return new Promise((resolve, _) => { resolve(this._transactionMerkle) }) } - broadcast(transaction: RawTransaction): Promise { + broadcast(transaction: BitcoinRawTx): Promise { this._broadcastLog.push(transaction) return new Promise((resolve, _) => { resolve() diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index bdbca6683..aabdc0c92 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -12,11 +12,11 @@ import { RevealedDeposit, } from "../../src/lib/contracts" import { - DecomposedRawTransaction, - Proof, - UnspentTransactionOutput, - computeHash160, - TransactionHash, + BitcoinRawTxVectors, + BitcoinSpvProof, + BitcoinUtxo, + BitcoinHashUtils, + BitcoinTxHash, } from "../../src/lib/bitcoin" import { BigNumberish, BigNumber, utils, constants } from "ethers" import { depositSweepWithNoMainUtxoAndWitnessOutput } from "../data/deposit-sweep" @@ -24,28 +24,28 @@ import { Address } from "../../src/lib/ethereum" import { Hex } from "../../src/lib/utils" interface DepositSweepProofLogEntry { - sweepTx: DecomposedRawTransaction - sweepProof: Proof - mainUtxo: UnspentTransactionOutput + sweepTx: BitcoinRawTxVectors + sweepProof: BitcoinSpvProof + mainUtxo: BitcoinUtxo } interface RevealDepositLogEntry { - depositTx: DecomposedRawTransaction + depositTx: BitcoinRawTxVectors depositOutputIndex: number deposit: Deposit } interface RequestRedemptionLogEntry { walletPublicKey: string - mainUtxo: UnspentTransactionOutput + mainUtxo: BitcoinUtxo redeemerOutputScript: string amount: BigNumber } interface RedemptionProofLogEntry { - redemptionTx: DecomposedRawTransaction - redemptionProof: Proof - mainUtxo: UnspentTransactionOutput + redemptionTx: BitcoinRawTxVectors + redemptionProof: BitcoinSpvProof + mainUtxo: BitcoinUtxo walletPublicKey: string } @@ -155,9 +155,9 @@ export class MockBridge implements Bridge { } submitDepositSweepProof( - sweepTx: DecomposedRawTransaction, - sweepProof: Proof, - mainUtxo: UnspentTransactionOutput, + sweepTx: BitcoinRawTxVectors, + sweepProof: BitcoinSpvProof, + mainUtxo: BitcoinUtxo, vault?: Identifier ): Promise { this._depositSweepProofLog.push({ sweepTx, sweepProof, mainUtxo }) @@ -167,7 +167,7 @@ export class MockBridge implements Bridge { } revealDeposit( - depositTx: DecomposedRawTransaction, + depositTx: BitcoinRawTxVectors, depositOutputIndex: number, deposit: Deposit ): Promise { @@ -181,7 +181,7 @@ export class MockBridge implements Bridge { } deposits( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { return new Promise((resolve, _) => { @@ -206,7 +206,7 @@ export class MockBridge implements Bridge { } static buildDepositKey( - depositTxHash: TransactionHash, + depositTxHash: BitcoinTxHash, depositOutputIndex: number ): string { const prefixedReversedDepositTxHash = depositTxHash @@ -220,9 +220,9 @@ export class MockBridge implements Bridge { } submitRedemptionProof( - redemptionTx: DecomposedRawTransaction, - redemptionProof: Proof, - mainUtxo: UnspentTransactionOutput, + redemptionTx: BitcoinRawTxVectors, + redemptionProof: BitcoinSpvProof, + mainUtxo: BitcoinUtxo, walletPublicKey: string ): Promise { this._redemptionProofLog.push({ @@ -238,7 +238,7 @@ export class MockBridge implements Bridge { requestRedemption( walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScript: string, amount: BigNumber ) { @@ -295,7 +295,7 @@ export class MockBridge implements Bridge { redemptionsMap: Map ): RedemptionRequest { const redemptionKey = MockBridge.buildRedemptionKey( - computeHash160(walletPublicKey), + BitcoinHashUtils.computeHash160(walletPublicKey), redeemerOutputScript ) @@ -359,7 +359,7 @@ export class MockBridge implements Bridge { return wallet! } - buildUtxoHash(utxo: UnspentTransactionOutput): Hex { + buildUtxoHash(utxo: BitcoinUtxo): Hex { return Hex.from( utils.solidityKeccak256( ["bytes32", "uint32", "uint64"], diff --git a/typescript/test/utils/mock-tbtc-token.ts b/typescript/test/utils/mock-tbtc-token.ts index 588615404..29ba32497 100644 --- a/typescript/test/utils/mock-tbtc-token.ts +++ b/typescript/test/utils/mock-tbtc-token.ts @@ -1,11 +1,11 @@ import { TBTCToken } from "../../src/lib/contracts" import { Hex } from "../../src/lib/utils" import { BigNumber } from "ethers" -import { UnspentTransactionOutput } from "../../src/lib/bitcoin" +import { BitcoinUtxo } from "../../src/lib/bitcoin" interface RequestRedemptionLog { walletPublicKey: string - mainUtxo: UnspentTransactionOutput + mainUtxo: BitcoinUtxo redeemerOutputScript: string amount: BigNumber } @@ -23,7 +23,7 @@ export class MockTBTCToken implements TBTCToken { async requestRedemption( walletPublicKey: string, - mainUtxo: UnspentTransactionOutput, + mainUtxo: BitcoinUtxo, redeemerOutputScript: string, amount: BigNumber ): Promise { diff --git a/typescript/test/wallet.test.ts b/typescript/test/wallet.test.ts index 5e5f83997..5cbd48fce 100644 --- a/typescript/test/wallet.test.ts +++ b/typescript/test/wallet.test.ts @@ -1,9 +1,13 @@ import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { MockBridge } from "./utils/mock-bridge" -import { BitcoinNetwork, BitcoinTransaction, Hex } from "../src" +import { Hex } from "../src" import { determineWalletMainUtxo } from "../src/wallet" import { expect } from "chai" -import { encodeToBitcoinAddress } from "../src/lib/bitcoin" +import { + BitcoinNetwork, + BitcoinAddressConverter, + BitcoinTx, +} from "../src/lib/bitcoin" import { Wallet } from "../src/lib/contracts" import { BigNumber } from "ethers" @@ -18,7 +22,7 @@ describe("Wallet", () => { const mockTransaction = ( hash: string, outputs: Record // key: locking script, value: amount of locked satoshis - ): BitcoinTransaction => { + ): BitcoinTx => { return { transactionHash: Hex.from(hash), inputs: [], // not relevant in this test scenario @@ -33,7 +37,7 @@ describe("Wallet", () => { } // Create a fake wallet witness transaction history that consists of 6 transactions. - const walletWitnessTransactionHistory: BitcoinTransaction[] = [ + const walletWitnessTransactionHistory: BitcoinTx[] = [ mockTransaction( "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1", { @@ -80,7 +84,7 @@ describe("Wallet", () => { ] // Create a fake wallet legacy transaction history that consists of 6 transactions. - const walletLegacyTransactionHistory: BitcoinTransaction[] = [ + const walletLegacyTransactionHistory: BitcoinTx[] = [ mockTransaction( "230a19d8867ff3f5b409e924d9dd6413188e215f9bb52f1c47de6154dac42267", { @@ -238,22 +242,21 @@ describe("Wallet", () => { beforeEach(async () => { bitcoinNetwork = network - const walletWitnessAddress = encodeToBitcoinAddress( - walletPublicKeyHash.toString(), - true, - bitcoinNetwork - ) - const walletLegacyAddress = encodeToBitcoinAddress( - walletPublicKeyHash.toString(), - false, - bitcoinNetwork - ) + const walletWitnessAddress = + BitcoinAddressConverter.publicKeyHashToAddress( + walletPublicKeyHash.toString(), + true, + bitcoinNetwork + ) + const walletLegacyAddress = + BitcoinAddressConverter.publicKeyHashToAddress( + walletPublicKeyHash.toString(), + false, + bitcoinNetwork + ) // Record the fake transaction history for both address types. - const transactionHistory = new Map< - string, - BitcoinTransaction[] - >() + const transactionHistory = new Map() transactionHistory.set( walletWitnessAddress, walletWitnessTransactionHistory From 955788dc3ca394fd49cbbd9d7ffed2aada4655e9 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 26 Sep 2023 11:13:38 +0200 Subject: [PATCH 167/205] Final iteration on `lib/contracts` Here we make a final rework of the `lib/contracts` module. The main work is focused on improving component names. --- typescript/src/deposit-sweep.ts | 4 +-- typescript/src/deposit.ts | 4 +-- typescript/src/lib/contracts/bridge.ts | 26 +++++++-------- typescript/src/lib/contracts/chain-event.ts | 6 ++-- .../src/lib/contracts/chain-identifier.ts | 4 +-- typescript/src/lib/contracts/tbtc-token.ts | 2 +- typescript/src/lib/contracts/tbtc-vault.ts | 32 +++++++++---------- .../src/lib/contracts/wallet-registry.ts | 20 ++++++------ typescript/src/lib/ethereum/address.ts | 2 +- typescript/src/lib/ethereum/bridge.ts | 10 +++--- .../src/lib/ethereum/contract-handle.ts | 4 +-- typescript/src/lib/ethereum/tbtc-vault.ts | 8 ++--- .../src/lib/ethereum/wallet-registry.ts | 8 ++--- typescript/test/utils/mock-bridge.ts | 14 ++++---- 14 files changed, 72 insertions(+), 72 deletions(-) diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 6b20c142f..2961ece02 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -12,7 +12,7 @@ import { BitcoinHashUtils, } from "./lib/bitcoin" import { assembleDepositScript } from "./deposit" -import { Bridge, Identifier, Deposit } from "./lib/contracts" +import { Bridge, ChainIdentifier, Deposit } from "./lib/contracts" /** * Submits a deposit sweep by combining all the provided P2(W)SH UTXOs and @@ -403,7 +403,7 @@ export async function submitDepositSweepProof( mainUtxo: BitcoinUtxo, bridge: Bridge, bitcoinClient: BitcoinClient, - vault?: Identifier + vault?: ChainIdentifier ): Promise { const confirmations = await bridge.txProofDifficultyFactor() const proof = await assembleBitcoinSpvProof( diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 78b2b8fcc..4d4684998 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -12,7 +12,7 @@ import { } from "./lib/bitcoin" import { Bridge, - Identifier, + ChainIdentifier, Deposit, DepositScriptParameters, RevealedDeposit, @@ -298,7 +298,7 @@ export async function revealDeposit( deposit: DepositScriptParameters, bitcoinClient: BitcoinClient, bridge: Bridge, - vault?: Identifier + vault?: ChainIdentifier ): Promise { const depositTx = extractBitcoinRawTxVectors( await bitcoinClient.getRawTransaction(utxo.transactionHash) diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index b92d54911..eaea4f64b 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -6,8 +6,8 @@ import { BitcoinTxHash, } from "../bitcoin" import { Hex } from "../utils" -import { Event, GetEvents } from "./chain-event" -import { Identifier } from "./chain-identifier" +import { ChainEvent, GetChainEvents } from "./chain-event" +import { ChainIdentifier } from "./chain-identifier" import { WalletRegistry } from "./wallet-registry" /** @@ -18,7 +18,7 @@ export interface Bridge { * Get emitted DepositRevealed events. * @see GetEventsFunction */ - getDepositRevealedEvents: GetEvents.Function + getDepositRevealedEvents: GetChainEvents.Function /** * Submits a deposit sweep transaction proof to the on-chain contract. @@ -32,7 +32,7 @@ export interface Bridge { sweepTx: BitcoinRawTxVectors, sweepProof: BitcoinSpvProof, mainUtxo: BitcoinUtxo, - vault?: Identifier + vault?: ChainIdentifier ): Promise /** @@ -49,7 +49,7 @@ export interface Bridge { depositTx: BitcoinRawTxVectors, depositOutputIndex: number, deposit: DepositScriptParameters, - vault?: Identifier + vault?: ChainIdentifier ): Promise // TODO: Update to Hex /** @@ -147,7 +147,7 @@ export interface Bridge { * Get emitted NewWalletRegisteredEvent events. * @see GetEventsFunction */ - getNewWalletRegisteredEvents: GetEvents.Function + getNewWalletRegisteredEvents: GetChainEvents.Function /** * Returns the attached WalletRegistry instance. @@ -173,7 +173,7 @@ export interface Bridge { * Get emitted RedemptionRequested events. * @see GetEventsFunction */ - getRedemptionRequestedEvents: GetEvents.Function + getRedemptionRequestedEvents: GetChainEvents.Function } // TODO: Replace all properties that are expected to be un-prefixed hexadecimal @@ -186,7 +186,7 @@ export interface Deposit { /** * Depositor's chain identifier. */ - depositor: Identifier + depositor: ChainIdentifier /** * Deposit amount in satoshis. @@ -223,7 +223,7 @@ export interface Deposit { /** * Optional identifier of the vault the deposit should be routed in. */ - vault?: Identifier + vault?: ChainIdentifier } /** @@ -270,7 +270,7 @@ export type RevealedDeposit = Pick< export type DepositRevealedEvent = Deposit & { fundingTxHash: BitcoinTxHash fundingOutputIndex: number -} & Event +} & ChainEvent /** * Represents a redemption request. @@ -279,7 +279,7 @@ export interface RedemptionRequest { /** * On-chain identifier of the redeemer. */ - redeemer: Identifier + redeemer: ChainIdentifier /** * The output script the redeemed Bitcoin funds are locked to. It is un-prefixed @@ -326,7 +326,7 @@ export type RedemptionRequestedEvent = Omit< * be an unprefixed hex string (without 0x prefix). */ walletPublicKeyHash: string -} & Event +} & ChainEvent /* eslint-disable no-unused-vars */ export enum WalletState { @@ -439,4 +439,4 @@ export type NewWalletRegisteredEvent = { * hash160 on the compressed public key of the ECDSA Wallet. */ walletPublicKeyHash: Hex -} & Event +} & ChainEvent diff --git a/typescript/src/lib/contracts/chain-event.ts b/typescript/src/lib/contracts/chain-event.ts index 2d58b9ddd..e93a4c411 100644 --- a/typescript/src/lib/contracts/chain-event.ts +++ b/typescript/src/lib/contracts/chain-event.ts @@ -3,7 +3,7 @@ import { ExecutionLoggerFn, Hex } from "../utils" /** * Represents a generic chain event. */ -export interface Event { +export interface ChainEvent { /** * Block number of the event emission. */ @@ -18,7 +18,7 @@ export interface Event { transactionHash: Hex } -export namespace GetEvents { +export namespace GetChainEvents { /** * Represents generic options used for getting events from the chain. */ @@ -50,7 +50,7 @@ export namespace GetEvents { /** * Represents a generic function to get events emitted on the chain. */ - export interface Function { + export interface Function { /** * Get emitted events. * @param options Options for getting events. diff --git a/typescript/src/lib/contracts/chain-identifier.ts b/typescript/src/lib/contracts/chain-identifier.ts index 3591f7bd1..de598d079 100644 --- a/typescript/src/lib/contracts/chain-identifier.ts +++ b/typescript/src/lib/contracts/chain-identifier.ts @@ -1,7 +1,7 @@ /** * Represents a generic chain identifier. */ -export interface Identifier { +export interface ChainIdentifier { /** * Identifier as an un-prefixed hex string. */ @@ -11,5 +11,5 @@ export interface Identifier { * * @param identifier Another identifier */ - equals(identifier: Identifier): boolean + equals(identifier: ChainIdentifier): boolean } diff --git a/typescript/src/lib/contracts/tbtc-token.ts b/typescript/src/lib/contracts/tbtc-token.ts index 9e32a4801..7770510dd 100644 --- a/typescript/src/lib/contracts/tbtc-token.ts +++ b/typescript/src/lib/contracts/tbtc-token.ts @@ -19,7 +19,7 @@ export interface TBTCToken { totalSupply(blockNumber?: number): Promise /** - * Requests redemption in one transacion using the `approveAndCall` function + * Requests redemption in one transaction using the `approveAndCall` function * from the tBTC on-chain token contract. Then the tBTC token contract calls * the `receiveApproval` function from the `TBTCVault` contract which burns * tBTC tokens and requests redemption. diff --git a/typescript/src/lib/contracts/tbtc-vault.ts b/typescript/src/lib/contracts/tbtc-vault.ts index 8a61c5f8e..2869fa4a8 100644 --- a/typescript/src/lib/contracts/tbtc-vault.ts +++ b/typescript/src/lib/contracts/tbtc-vault.ts @@ -1,7 +1,7 @@ import { BitcoinTxHash } from "../bitcoin" import { Hex } from "../utils" -import { Identifier } from "./chain-identifier" -import { Event, GetEvents } from "./chain-event" +import { ChainIdentifier } from "./chain-identifier" +import { ChainEvent, GetChainEvents } from "./chain-event" import { BigNumber } from "ethers" /** @@ -22,21 +22,21 @@ export interface TBTCVault { * * @returns Array containing identifiers of all currently registered minters. */ - getMinters(): Promise + getMinters(): Promise /** * Checks if given identifier is registered as minter. * * @param identifier Chain identifier to check. */ - isMinter(identifier: Identifier): Promise + isMinter(identifier: ChainIdentifier): Promise /** * Checks if given identifier is registered as guardian. * * @param identifier Chain identifier to check. */ - isGuardian(identifier: Identifier): Promise + isGuardian(identifier: ChainIdentifier): Promise /** * Requests optimistic minting for a deposit in an on-chain contract. @@ -93,19 +93,19 @@ export interface TBTCVault { * Get emitted OptimisticMintingRequested events. * @see GetEventsFunction */ - getOptimisticMintingRequestedEvents: GetEvents.Function + getOptimisticMintingRequestedEvents: GetChainEvents.Function /** * Get emitted OptimisticMintingCancelled events. * @see GetEventsFunction */ - getOptimisticMintingCancelledEvents: GetEvents.Function + getOptimisticMintingCancelledEvents: GetChainEvents.Function /** * Get emitted OptimisticMintingFinalized events. * @see GetEventsFunction */ - getOptimisticMintingFinalizedEvents: GetEvents.Function + getOptimisticMintingFinalizedEvents: GetChainEvents.Function } /** @@ -132,7 +132,7 @@ export type OptimisticMintingRequestedEvent = { /** * Minter's chain identifier. */ - minter: Identifier + minter: ChainIdentifier /** * Unique deposit identifier. * @see Bridge.buildDepositKey @@ -141,7 +141,7 @@ export type OptimisticMintingRequestedEvent = { /** * Depositor's chain identifier. */ - depositor: Identifier + depositor: ChainIdentifier /** * Amount of tokens requested to mint. * This value is in ERC 1e18 precision, it has to be converted before using @@ -158,7 +158,7 @@ export type OptimisticMintingRequestedEvent = { * Index of an output in the funding transaction made to fund the deposit. */ fundingOutputIndex: number -} & Event +} & ChainEvent /** * Represents an event that is emitted when an optimistic minting request @@ -168,13 +168,13 @@ export type OptimisticMintingCancelledEvent = { /** * Guardian's chain identifier. */ - guardian: Identifier + guardian: ChainIdentifier /** * Unique deposit identifier. * @see Bridge.buildDepositKey */ depositKey: Hex -} & Event +} & ChainEvent /** * Represents an event that is emitted when an optimistic minting request @@ -184,7 +184,7 @@ export type OptimisticMintingFinalizedEvent = { /** * Minter's chain identifier. */ - minter: Identifier + minter: ChainIdentifier /** * Unique deposit identifier. * @see Bridge.buildDepositKey @@ -193,7 +193,7 @@ export type OptimisticMintingFinalizedEvent = { /** * Depositor's chain identifier. */ - depositor: Identifier + depositor: ChainIdentifier /** * Value of the new optimistic minting debt of the depositor. * This value is in ERC 1e18 precision, it has to be converted before using @@ -202,4 +202,4 @@ export type OptimisticMintingFinalizedEvent = { // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 // precision to Bitcoin in 1e8 precision (satoshi). optimisticMintingDebt: BigNumber -} & Event +} & ChainEvent diff --git a/typescript/src/lib/contracts/wallet-registry.ts b/typescript/src/lib/contracts/wallet-registry.ts index 969756a88..417e9c745 100644 --- a/typescript/src/lib/contracts/wallet-registry.ts +++ b/typescript/src/lib/contracts/wallet-registry.ts @@ -1,7 +1,7 @@ import { Hex } from "../utils" -import { Event, GetEvents } from "./chain-event" +import { ChainEvent, GetChainEvents } from "./chain-event" import { BigNumber } from "ethers" -import { Identifier } from "./chain-identifier" +import { ChainIdentifier } from "./chain-identifier" /** * Interface for communication with the WalletRegistry on-chain contract. @@ -18,19 +18,19 @@ export interface WalletRegistry { * Get emitted DkgResultSubmittedEvent events. * @see GetEventsFunction */ - getDkgResultSubmittedEvents: GetEvents.Function + getDkgResultSubmittedEvents: GetChainEvents.Function /** * Get emitted DkgResultApprovedEvent events. * @see GetEventsFunction */ - getDkgResultApprovedEvents: GetEvents.Function + getDkgResultApprovedEvents: GetChainEvents.Function /** * Get emitted DkgResultChallengedEvent events. * @see GetEventsFunction */ - getDkgResultChallengedEvents: GetEvents.Function + getDkgResultChallengedEvents: GetChainEvents.Function } /** @@ -50,7 +50,7 @@ export type DkgResultSubmittedEvent = { * DKG result object. */ result: DkgResult -} & Event +} & ChainEvent /** * Represents an event emitted when a DKG result is approved on the on-chain @@ -64,8 +64,8 @@ export type DkgResultApprovedEvent = { /** * Approver's chain identifier. */ - approver: Identifier -} & Event + approver: ChainIdentifier +} & ChainEvent /** * Represents an event emitted when a DKG result is challenged on the on-chain @@ -79,12 +79,12 @@ export type DkgResultChallengedEvent = { /** * Challenger's chain identifier. */ - challenger: Identifier + challenger: ChainIdentifier /** * Reason of the challenge. */ reason: string -} & Event +} & ChainEvent /** * Represents a DKG on-chain result. diff --git a/typescript/src/lib/ethereum/address.ts b/typescript/src/lib/ethereum/address.ts index cd9f1a054..6b45775c5 100644 --- a/typescript/src/lib/ethereum/address.ts +++ b/typescript/src/lib/ethereum/address.ts @@ -1,4 +1,4 @@ -import { Identifier as ChainIdentifier } from "../contracts" +import { ChainIdentifier } from "../contracts" import { utils } from "ethers" /** diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index 03da23321..7d6b7d600 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -6,8 +6,8 @@ import { } from "../../../typechain/Bridge" import { Bridge as ChainBridge, - GetEvents, - Identifier as ChainIdentifier, + GetChainEvents, + ChainIdentifier, WalletRegistry as ChainWalletRegistry, NewWalletRegisteredEvent, Wallet, @@ -61,7 +61,7 @@ export class Bridge * @see {ChainBridge#getDepositRevealedEvents} */ async getDepositRevealedEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { const events: EthersEvent[] = await this.getEvents( @@ -478,7 +478,7 @@ export class Bridge * @see {ChainBridge#getNewWalletRegisteredEvents} */ async getNewWalletRegisteredEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { const events: EthersEvent[] = await this.getEvents( @@ -583,7 +583,7 @@ export class Bridge * @see {ChainBridge#getDepositRevealedEvents} */ async getRedemptionRequestedEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { // FIXME: Filtering by indexed walletPubKeyHash field may not work diff --git a/typescript/src/lib/ethereum/contract-handle.ts b/typescript/src/lib/ethereum/contract-handle.ts index 12ad04230..2faf1c674 100644 --- a/typescript/src/lib/ethereum/contract-handle.ts +++ b/typescript/src/lib/ethereum/contract-handle.ts @@ -4,7 +4,7 @@ import { Event as EthersEvent, EventFilter as EthersEventFilter, } from "@ethersproject/contracts" -import { GetEvents } from "../contracts" +import { GetChainEvents } from "../contracts" import { backoffRetrier, ExecutionLoggerFn, @@ -121,7 +121,7 @@ export class EthereumContract { */ async getEvents( eventName: string, - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { // TODO: Test if we need a workaround for querying events from big range in chunks, diff --git a/typescript/src/lib/ethereum/tbtc-vault.ts b/typescript/src/lib/ethereum/tbtc-vault.ts index 30c7eccec..43c206a3d 100644 --- a/typescript/src/lib/ethereum/tbtc-vault.ts +++ b/typescript/src/lib/ethereum/tbtc-vault.ts @@ -1,6 +1,6 @@ import { TBTCVault as ContractTBTCVault } from "../../../typechain/TBTCVault" import { - GetEvents, + GetChainEvents, TBTCVault as ChainTBTCVault, OptimisticMintingCancelledEvent, OptimisticMintingFinalizedEvent, @@ -196,7 +196,7 @@ export class TBTCVault * @see {ChainBridge#getOptimisticMintingRequestedEvents} */ async getOptimisticMintingRequestedEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { const events = await this.getEvents( @@ -229,7 +229,7 @@ export class TBTCVault * @see {ChainBridge#getOptimisticMintingCancelledEvents} */ async getOptimisticMintingCancelledEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { const events = await this.getEvents( @@ -256,7 +256,7 @@ export class TBTCVault * @see {ChainBridge#getOptimisticMintingFinalizedEvents} */ async getOptimisticMintingFinalizedEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { const events = await this.getEvents( diff --git a/typescript/src/lib/ethereum/wallet-registry.ts b/typescript/src/lib/ethereum/wallet-registry.ts index 859a01661..f893ead8f 100644 --- a/typescript/src/lib/ethereum/wallet-registry.ts +++ b/typescript/src/lib/ethereum/wallet-registry.ts @@ -1,6 +1,6 @@ import { WalletRegistry as ContractWalletRegistry } from "../../../typechain/WalletRegistry" import { - GetEvents, + GetChainEvents, WalletRegistry as ChainWalletRegistry, DkgResultApprovedEvent, DkgResultChallengedEvent, @@ -45,7 +45,7 @@ export class WalletRegistry * @see {ChainWalletRegistry#getDkgResultSubmittedEvents} */ async getDkgResultSubmittedEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { const events: EthersEvent[] = await this.getEvents( @@ -88,7 +88,7 @@ export class WalletRegistry * @see {ChainWalletRegistry#getDkgResultApprovedEvents} */ async getDkgResultApprovedEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { const events: EthersEvent[] = await this.getEvents( @@ -113,7 +113,7 @@ export class WalletRegistry * @see {ChainWalletRegistry#getDkgResultChallengedEvents} */ async getDkgResultChallengedEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { const events: EthersEvent[] = await this.getEvents( diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index aabdc0c92..7981adc7c 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -1,8 +1,8 @@ import { Bridge, WalletRegistry, - GetEvents, - Identifier, + GetChainEvents, + ChainIdentifier, NewWalletRegisteredEvent, Wallet, RedemptionRequest, @@ -50,7 +50,7 @@ interface RedemptionProofLogEntry { } interface NewWalletRegisteredEventsLog { - options?: GetEvents.Options + options?: GetChainEvents.Options filterArgs: unknown[] } @@ -125,7 +125,7 @@ export class MockBridge implements Bridge { } getDepositRevealedEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { const deposit = depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0] @@ -158,7 +158,7 @@ export class MockBridge implements Bridge { sweepTx: BitcoinRawTxVectors, sweepProof: BitcoinSpvProof, mainUtxo: BitcoinUtxo, - vault?: Identifier + vault?: ChainIdentifier ): Promise { this._depositSweepProofLog.push({ sweepTx, sweepProof, mainUtxo }) return new Promise((resolve, _) => { @@ -340,7 +340,7 @@ export class MockBridge implements Bridge { } async getNewWalletRegisteredEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { this._newWalletRegisteredEventsLog.push({ options, filterArgs }) @@ -373,7 +373,7 @@ export class MockBridge implements Bridge { } getRedemptionRequestedEvents( - options?: GetEvents.Options, + options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { throw new Error("not implemented") From d7308781788f50e4f0e522d2e4ebc6c485e4df3f Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 26 Sep 2023 11:27:59 +0200 Subject: [PATCH 168/205] Final iteration on `lib/electrum` Here we make a final rework of the `lib/electrum` module. The main work is focused on improving component names. --- typescript/src/index.ts | 2 +- typescript/src/lib/electrum/client.ts | 38 ++++++++++++++------------- typescript/test/electrum.test.ts | 12 +++++---- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/typescript/src/index.ts b/typescript/src/index.ts index c522694f8..86ea36d1d 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -59,7 +59,7 @@ export { BitcoinNetwork, } from "./lib/bitcoin" -export { Client as ElectrumClient } from "./lib/electrum" +export { ElectrumClient } from "./lib/electrum" export { Bridge as EthereumBridge, diff --git a/typescript/src/lib/electrum/client.ts b/typescript/src/lib/electrum/client.ts index cf12baca5..c24b68d57 100644 --- a/typescript/src/lib/electrum/client.ts +++ b/typescript/src/lib/electrum/client.ts @@ -20,7 +20,7 @@ import { backoffRetrier, Hex, RetrierFn } from "../utils" /** * Represents a set of credentials required to establish an Electrum connection. */ -export interface Credentials { +export interface ElectrumCredentials { /** * Host pointing to the Electrum server. */ @@ -38,7 +38,7 @@ export interface Credentials { /** * Additional options used by the Electrum server. */ -export type ClientOptions = object +export type ElectrumClientOptions = object /** * Type for {@link Electrum} client from electrum-client-js library. @@ -50,21 +50,21 @@ type Electrum = any * is supposed to take a proper Electrum connection, do the work, and return * a promise holding the outcome of given type. */ -type Action = (electrum: Electrum) => Promise +type ElectrumAction = (electrum: Electrum) => Promise /** * Electrum-based implementation of the Bitcoin client. */ -export class Client implements BitcoinClient { - private credentials: Credentials[] - private options?: ClientOptions +export class ElectrumClient implements BitcoinClient { + private credentials: ElectrumCredentials[] + private options?: ElectrumClientOptions private totalRetryAttempts: number private retryBackoffStep: number private connectionTimeout: number constructor( - credentials: Credentials[], - options?: ClientOptions, + credentials: ElectrumCredentials[], + options?: ElectrumClientOptions, totalRetryAttempts = 3, retryBackoffStep = 10000, // 10 seconds connectionTimeout = 20000 // 20 seconds @@ -89,19 +89,19 @@ export class Client implements BitcoinClient { */ static fromUrl( url: string | string[], - options?: ClientOptions, + options?: ElectrumClientOptions, totalRetryAttempts = 3, retryBackoffStep = 1000, // 10 seconds connectionTimeout = 20000 // 20 seconds - ): Client { - let credentials: Credentials[] + ): ElectrumClient { + let credentials: ElectrumCredentials[] if (Array.isArray(url)) { credentials = url.map(this.parseElectrumCredentials) } else { credentials = [this.parseElectrumCredentials(url)] } - return new Client( + return new ElectrumClient( credentials, options, totalRetryAttempts, @@ -115,7 +115,7 @@ export class Client implements BitcoinClient { * @param url - URL to be parsed. * @returns Electrum credentials object. */ - private static parseElectrumCredentials(url: string): Credentials { + private static parseElectrumCredentials(url: string): ElectrumCredentials { const urlObj = new URL(url) return { @@ -136,8 +136,10 @@ export class Client implements BitcoinClient { * @param action - Action that makes use of the Electrum connection. * @returns Promise holding the outcome. */ - private async withElectrum(action: Action): Promise { - const connect = async (credentials: Credentials): Promise => { + private async withElectrum(action: ElectrumAction): Promise { + const connect = async ( + credentials: ElectrumCredentials + ): Promise => { const electrum: Electrum = new Electrum( credentials.host, credentials.port, @@ -237,7 +239,7 @@ export class Client implements BitcoinClient { const unspentTransactions: UnspentOutput[] = await this.withBackoffRetrier()(async () => { return await electrum.blockchain_scripthash_listunspent( - computeScriptHash(script) + computeElectrumScriptHash(script) ) }) @@ -265,7 +267,7 @@ export class Client implements BitcoinClient { HistoryItem[] >()(async () => { return await electrum.blockchain_scripthash_getHistory( - computeScriptHash(script) + computeElectrumScriptHash(script) ) }) @@ -547,7 +549,7 @@ export class Client implements BitcoinClient { * @param script - Bitcoin script as hex string * @returns Electrum script hash as a hex string. */ -export function computeScriptHash(script: string): string { +export function computeElectrumScriptHash(script: string): string { const _script = Hex.from(Buffer.from(script, "hex")).toPrefixedString() const hash256 = utils.sha256(_script) diff --git a/typescript/test/electrum.test.ts b/typescript/test/electrum.test.ts index 8d643309e..0775f4b5e 100644 --- a/typescript/test/electrum.test.ts +++ b/typescript/test/electrum.test.ts @@ -1,7 +1,7 @@ import { - Credentials as ElectrumCredentials, - Client as ElectrumClient, - computeScriptHash, + ElectrumCredentials, + ElectrumClient, + computeElectrumScriptHash, } from "../src/lib/electrum" import { BitcoinNetwork } from "../src/lib/bitcoin" import { @@ -219,13 +219,15 @@ describe("Electrum", () => { }) }) - describe("computeScriptHash", () => { + describe("computeElectrumScriptHash", () => { it("should convert Bitcoin script to an Electrum script hash correctly", () => { const script = "00144b47c798d12edd17dfb4ea98e5447926f664731c" const expectedScriptHash = "cabdea0bfc10fb3521721dde503487dd1f0e41dd6609da228066757563f292ab" - expect(computeScriptHash(script)).to.be.equal(expectedScriptHash) + expect(computeElectrumScriptHash(script)).to.be.equal( + expectedScriptHash + ) }) }) }) From 7478d3fd92ab431c99ee1569e04122f869d24142 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 26 Sep 2023 13:00:52 +0200 Subject: [PATCH 169/205] Final iteration on `lib/ethereum` Here we make a final rework of the `lib/ethereum` module. The main work is focused on improving component names and structure. --- typescript/src/index.ts | 10 +- typescript/src/lib/ethereum/adapter.ts | 307 ++++++++++++++++++ typescript/src/lib/ethereum/address.ts | 11 +- typescript/src/lib/ethereum/bridge.ts | 190 ++++++----- .../src/lib/ethereum/contract-handle.ts | 288 ---------------- typescript/src/lib/ethereum/index.ts | 4 +- typescript/src/lib/ethereum/tbtc-token.ts | 48 +-- typescript/src/lib/ethereum/tbtc-vault.ts | 70 ++-- .../src/lib/ethereum/wallet-registry.ts | 30 +- typescript/test/data/deposit-refund.ts | 14 +- typescript/test/data/deposit-sweep.ts | 26 +- typescript/test/data/redemption.ts | 50 ++- typescript/test/deposit.test.ts | 4 +- typescript/test/ethereum.test.ts | 48 ++- typescript/test/utils/mock-bridge.ts | 10 +- 15 files changed, 604 insertions(+), 506 deletions(-) create mode 100644 typescript/src/lib/ethereum/adapter.ts delete mode 100644 typescript/src/lib/ethereum/contract-handle.ts diff --git a/typescript/src/index.ts b/typescript/src/index.ts index 86ea36d1d..dfc6b3bd1 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -62,11 +62,11 @@ export { export { ElectrumClient } from "./lib/electrum" export { - Bridge as EthereumBridge, - WalletRegistry as EthereumWalletRegistry, - Address as EthereumAddress, - TBTCVault as EthereumTBTCVault, - TBTCToken as EthereumTBTCToken, + EthereumBridge, + EthereumWalletRegistry, + EthereumAddress, + EthereumTBTCVault, + EthereumTBTCToken, } from "./lib/ethereum" export { Hex } from "./lib/utils" diff --git a/typescript/src/lib/ethereum/adapter.ts b/typescript/src/lib/ethereum/adapter.ts new file mode 100644 index 000000000..8a678acc3 --- /dev/null +++ b/typescript/src/lib/ethereum/adapter.ts @@ -0,0 +1,307 @@ +import { + ContractTransaction as EthersContractTransaction, + providers, + Signer, + utils, +} from "ethers" +import { + Contract as EthersContract, + Event as EthersEvent, + EventFilter as EthersEventFilter, +} from "@ethersproject/contracts" +import { GetChainEvents } from "../contracts" +import { + backoffRetrier, + ExecutionLoggerFn, + skipRetryWhenMatched, +} from "../utils" +import { EthereumAddress } from "./address" + +/** + * Contract deployment artifact. + * @see [hardhat-deploy#Deployment](https://github.com/wighawag/hardhat-deploy/blob/0c969e9a27b4eeff9f5ccac7e19721ef2329eed2/types.ts#L358)} + */ +export interface EthersContractDeployment { + /** + * Address of the deployed contract. + */ + address: string + /** + * Contract's ABI. + */ + abi: any[] + /** + * Deployment transaction receipt. + */ + receipt: { + /** + * Number of block in which the contract was deployed. + */ + blockNumber: number + } +} + +/** + * Represents a config set required to connect an Ethereum contract. + */ +export interface EthersContractConfig { + /** + * Address of the Ethereum contract as a 0x-prefixed hex string. + * Optional parameter, if not provided the value will be resolved from the + * contract artifact. + */ + address?: string + /** + * Signer - will return a Contract which will act on behalf of that signer. The signer will sign all contract transactions. + * Provider - will return a downgraded Contract which only has read-only access (i.e. constant calls) + */ + signerOrProvider: Signer | providers.Provider + /** + * Number of a block in which the contract was deployed. + * Optional parameter, if not provided the value will be resolved from the + * contract artifact. + */ + deployedAtBlockNumber?: number +} + +/** + * Ethers-based contract handle. + */ +export class EthersContractHandle { + /** + * Ethers instance of the deployed contract. + */ + protected readonly _instance: T + /** + * Number of a block within which the contract was deployed. Value is read from + * the contract deployment artifact. It can be overwritten by setting a + * {@link EthersContractConfig.deployedAtBlockNumber} property. + */ + protected readonly _deployedAtBlockNumber: number + /** + * Number of retries for ethereum requests. + */ + protected readonly _totalRetryAttempts: number + + /** + * @param config Configuration for contract instance initialization. + * @param deployment Contract Deployment artifact. + * @param totalRetryAttempts Number of retries for ethereum requests. + */ + constructor( + config: EthersContractConfig, + deployment: EthersContractDeployment, + totalRetryAttempts = 3 + ) { + this._instance = new EthersContract( + config.address ?? utils.getAddress(deployment.address), + `${JSON.stringify(deployment.abi)}`, + config.signerOrProvider + ) as T + + this._deployedAtBlockNumber = + config.deployedAtBlockNumber ?? deployment.receipt.blockNumber + + this._totalRetryAttempts = totalRetryAttempts + } + + /** + * Get address of the contract instance. + * @returns Address of this contract instance. + */ + getAddress(): EthereumAddress { + return EthereumAddress.from(this._instance.address) + } + + /** + * Get events emitted by the Ethereum contract. + * It starts searching from provided block number. If the {@link GetEvents.Options#fromBlock} + * option is missing it looks for a contract's defined property + * {@link _deployedAtBlockNumber}. If the property is missing starts searching + * from block `0`. + * @param eventName Name of the event. + * @param options Options for events fetching. + * @param filterArgs Arguments for events filtering. + * @returns Array of found events. + */ + async getEvents( + eventName: string, + options?: GetChainEvents.Options, + ...filterArgs: Array + ): Promise { + // TODO: Test if we need a workaround for querying events from big range in chunks, + // see: https://github.com/keep-network/tbtc-monitoring/blob/e169357d7b8c638d4eaf73d52aa8f53ee4aebc1d/src/lib/ethereum-helper.js#L44-L73 + return backoffRetrier( + options?.retries ?? this._totalRetryAttempts + )(async () => { + return await EthersEventUtils.getEvents( + this._instance, + this._instance.filters[eventName](...filterArgs), + options?.fromBlock ?? this._deployedAtBlockNumber, + options?.toBlock, + options?.batchedQueryBlockInterval, + options?.logger + ) + }) + } +} + +/** + * Ethers-based utilities for transactions. + */ +export namespace EthersTransactionUtils { + /** + * Sends ethereum transaction with retries. + * @param fn Function to execute with retries. + * @param retries The number of retries to perform before bubbling the failure out. + * @param logger A logger function to pass execution messages. + * @param nonRetryableErrors List of error messages that if returned from executed + * function, should break the retry loop and return immediately. + * @returns Result of function execution. + * @throws An error returned by function execution. An error thrown by the executed + * function is processed by {@link resolveEthersError} function to resolve + * the revert message in case of a transaction revert. + */ + export async function sendWithRetry( + fn: () => Promise, + retries: number, + logger?: ExecutionLoggerFn, + nonRetryableErrors?: Array + ): Promise { + return backoffRetrier( + retries, + 1000, + logger, + nonRetryableErrors ? skipRetryWhenMatched(nonRetryableErrors) : undefined + )(async () => { + try { + return await fn() + } catch (err: unknown) { + throw resolveEthersError(err) + } + }) + } + + /** + * Represents an interface that matches the errors structure thrown by ethers library. + * {@see {@link https://github.com/ethers-io/ethers.js/blob/c80fcddf50a9023486e9f9acb1848aba4c19f7b6/packages/logger/src.ts/index.ts#L268-L277 ethers source code}} + */ + interface EthersError extends Error { + reason: string + code: string + error: unknown + } + + /** + * Takes an error and tries to resolve a revert message if the error is related + * to reverted transaction. + * @param err Error to process. + * @returns Error with a revert message or the input error when the error could + * not be resolved successfully. + */ + function resolveEthersError(err: unknown): unknown { + const isEthersError = (obj: any): obj is EthersError => { + return "reason" in obj && "code" in obj && "error" in obj + } + + if (isEthersError(err) && err !== null) { + // Ethers errors are nested. The parent UNPREDICTABLE_GAS_LIMIT has a general + // reason "cannot estimate gas; transaction may fail or may require manual gas limit", + if (err.code === "UNPREDICTABLE_GAS_LIMIT") { + if (typeof isEthersError(err["error"]) && err["error"] !== null) { + // The nested error is expected to contain a reason property with a message + // of the transaction revert. + return new Error((err["error"] as EthersError).reason) + } + } + } + + return err + } +} + +/** + * Ethers-based utilities for events. + */ +export namespace EthersEventUtils { + const GET_EVENTS_BLOCK_INTERVAL = 10_000 + + /** + * Looks up all existing events defined by the {@link event} filter on + * {@link sourceContract}, searching past blocks and then returning them. + * Does not wait for any new events. It starts searching from provided block number. + * If the {@link fromBlock} is missing it starts searching from block `0`. + * It pulls events in one `getLogs` call. If the call fails it fallbacks to querying + * events in batches of {@link batchedQueryBlockInterval} blocks. If the parameter + * is not set it queries in {@link GET_EVENTS_BLOCK_INTERVAL} blocks batches. + * @param sourceContract The contract instance that emits the event. + * @param event The event filter to query. + * @param fromBlock Starting block for events search. + * @param toBlock Ending block for events search. + * @param batchedQueryBlockInterval Block interval for batched events pulls. + * @param logger A logger function to pass execution messages. + * @returns A promise that will be fulfilled by the list of event objects once + * they are found. + */ + export async function getEvents( + sourceContract: EthersContract, + event: EthersEventFilter, + fromBlock: number = 0, + toBlock: number | string = "latest", + batchedQueryBlockInterval: number = GET_EVENTS_BLOCK_INTERVAL, + logger: ExecutionLoggerFn = console.debug + ): Promise { + return new Promise(async (resolve, reject) => { + let resultEvents: EthersEvent[] = [] + try { + resultEvents = await sourceContract.queryFilter( + event, + fromBlock, + toBlock + ) + } catch (err) { + logger( + `switching to partial events pulls; ` + + `failed to get events in one request from contract: [${event.address}], ` + + `fromBlock: [${fromBlock}], toBlock: [${toBlock}]: [${err}]` + ) + + try { + if (typeof toBlock === "string") { + toBlock = (await sourceContract.provider.getBlock(toBlock)).number + } + + let batchStartBlock = fromBlock + + while (batchStartBlock <= toBlock) { + let batchEndBlock = batchStartBlock + batchedQueryBlockInterval + if (batchEndBlock > toBlock) { + batchEndBlock = toBlock + } + logger( + `executing partial events pull from contract: [${event.address}], ` + + `fromBlock: [${batchStartBlock}], toBlock: [${batchEndBlock}]` + ) + const foundEvents = await sourceContract.queryFilter( + event, + batchStartBlock, + batchEndBlock + ) + + resultEvents = resultEvents.concat(foundEvents) + logger( + `fetched [${foundEvents.length}] events, has ` + + `[${resultEvents.length}] total` + ) + + batchStartBlock = batchEndBlock + 1 + } + } catch (error) { + return reject(error) + } + } + + return resolve(resultEvents) + }) + } +} diff --git a/typescript/src/lib/ethereum/address.ts b/typescript/src/lib/ethereum/address.ts index 6b45775c5..9135dddd0 100644 --- a/typescript/src/lib/ethereum/address.ts +++ b/typescript/src/lib/ethereum/address.ts @@ -5,11 +5,10 @@ import { utils } from "ethers" * Represents an Ethereum address. */ // TODO: Make Address extends Hex -export class Address implements ChainIdentifier { +export class EthereumAddress implements ChainIdentifier { readonly identifierHex: string - // TODO: Make constructor private - constructor(address: string) { + private constructor(address: string) { let validAddress: string try { @@ -21,12 +20,12 @@ export class Address implements ChainIdentifier { this.identifierHex = validAddress.substring(2).toLowerCase() } - static from(address: string): Address { - return new Address(address) + static from(address: string): EthereumAddress { + return new EthereumAddress(address) } // TODO: Remove once extends Hex - equals(otherValue: Address): boolean { + equals(otherValue: EthereumAddress): boolean { return this.identifierHex === otherValue.identifierHex } } diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index 7d6b7d600..1d424dd1b 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -1,14 +1,14 @@ import { - Bridge as ContractBridge, - Deposit as ContractDeposit, - Redemption as ContractRedemption, - Wallets, + Bridge as BridgeTypechain, + Deposit as DepositTypechain, + Redemption as RedemptionTypechain, + Wallets as WalletsTypechain, } from "../../../typechain/Bridge" import { - Bridge as ChainBridge, + Bridge, GetChainEvents, ChainIdentifier, - WalletRegistry as ChainWalletRegistry, + WalletRegistry, NewWalletRegisteredEvent, Wallet, WalletState, @@ -31,34 +31,34 @@ import { BitcoinUtxo, } from "../bitcoin" import { - ContractConfig, - EthereumContract, - sendWithRetry, -} from "./contract-handle" + EthersContractConfig, + EthersContractHandle, + EthersTransactionUtils, +} from "./adapter" import BridgeDeployment from "@keep-network/tbtc-v2/artifacts/Bridge.json" -import { Address } from "./address" -import { WalletRegistry } from "./wallet-registry" +import { EthereumAddress } from "./address" +import { EthereumWalletRegistry } from "./wallet-registry" -type ContractDepositRequest = ContractDeposit.DepositRequestStructOutput +type DepositRequestTypechain = DepositTypechain.DepositRequestStructOutput -type ContractRedemptionRequest = - ContractRedemption.RedemptionRequestStructOutput +type RedemptionRequestTypechain = + RedemptionTypechain.RedemptionRequestStructOutput /** * Implementation of the Ethereum Bridge handle. - * @see {ChainBridge} for reference. + * @see {Bridge} for reference. */ -export class Bridge - extends EthereumContract - implements ChainBridge +export class EthereumBridge + extends EthersContractHandle + implements Bridge { - constructor(config: ContractConfig) { + constructor(config: EthersContractConfig) { super(config, BridgeDeployment) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#getDepositRevealedEvents} + * @see {Bridge#getDepositRevealedEvents} */ async getDepositRevealedEvents( options?: GetChainEvents.Options, @@ -79,7 +79,7 @@ export class Bridge fundingOutputIndex: BigNumber.from( event.args!.fundingOutputIndex ).toNumber(), - depositor: new Address(event.args!.depositor), + depositor: EthereumAddress.from(event.args!.depositor), amount: BigNumber.from(event.args!.amount), blindingFactor: Hex.from(event.args!.blindingFactor).toString(), walletPublicKeyHash: Hex.from(event.args!.walletPubKeyHash).toString(), @@ -88,53 +88,53 @@ export class Bridge vault: event.args!.vault === constants.AddressZero ? undefined - : new Address(event.args!.vault), + : EthereumAddress.from(event.args!.vault), } }) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#pendingRedemptions} + * @see {Bridge#pendingRedemptions} */ async pendingRedemptions( walletPublicKey: string, redeemerOutputScript: string ): Promise { - const redemptionKey = Bridge.buildRedemptionKey( + const redemptionKey = EthereumBridge.buildRedemptionKey( BitcoinHashUtils.computeHash160(walletPublicKey), redeemerOutputScript ) - const request: ContractRedemptionRequest = - await backoffRetrier(this._totalRetryAttempts)( - async () => { - return await this._instance.pendingRedemptions(redemptionKey) - } - ) + const request: RedemptionRequestTypechain = + await backoffRetrier( + this._totalRetryAttempts + )(async () => { + return await this._instance.pendingRedemptions(redemptionKey) + }) return this.parseRedemptionRequest(request, redeemerOutputScript) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#timedOutRedemptions} + * @see {Bridge#timedOutRedemptions} */ async timedOutRedemptions( walletPublicKey: string, redeemerOutputScript: string ): Promise { - const redemptionKey = Bridge.buildRedemptionKey( + const redemptionKey = EthereumBridge.buildRedemptionKey( BitcoinHashUtils.computeHash160(walletPublicKey), redeemerOutputScript ) - const request: ContractRedemptionRequest = - await backoffRetrier(this._totalRetryAttempts)( - async () => { - return await this._instance.timedOutRedemptions(redemptionKey) - } - ) + const request: RedemptionRequestTypechain = + await backoffRetrier( + this._totalRetryAttempts + )(async () => { + return await this._instance.timedOutRedemptions(redemptionKey) + }) return this.parseRedemptionRequest(request, redeemerOutputScript) } @@ -180,11 +180,11 @@ export class Bridge * @returns Parsed redemption request. */ private parseRedemptionRequest( - request: ContractRedemptionRequest, + request: RedemptionRequestTypechain, redeemerOutputScript: string ): RedemptionRequest { return { - redeemer: new Address(request.redeemer), + redeemer: EthereumAddress.from(request.redeemer), redeemerOutputScript: redeemerOutputScript, requestedAmount: BigNumber.from(request.requestedAmount), treasuryFee: BigNumber.from(request.treasuryFee), @@ -195,7 +195,7 @@ export class Bridge // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#revealDeposit} + * @see {Bridge#revealDeposit} */ async revealDeposit( depositTx: BitcoinRawTxVectors, @@ -219,7 +219,7 @@ export class Bridge vault: vault ? `0x${vault.identifierHex}` : constants.AddressZero, } - const tx = await sendWithRetry( + const tx = await EthersTransactionUtils.sendWithRetry( async () => { return await this._instance.revealDeposit(depositTxParam, revealParam) }, @@ -233,7 +233,7 @@ export class Bridge // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#submitDepositSweepProof} + * @see {Bridge#submitDepositSweepProof} */ async submitDepositSweepProof( sweepTx: BitcoinRawTxVectors, @@ -266,19 +266,22 @@ export class Bridge ? `0x${vault.identifierHex}` : constants.AddressZero - await sendWithRetry(async () => { - return await this._instance.submitDepositSweepProof( - sweepTxParam, - sweepProofParam, - mainUtxoParam, - vaultParam - ) - }, this._totalRetryAttempts) + await EthersTransactionUtils.sendWithRetry( + async () => { + return await this._instance.submitDepositSweepProof( + sweepTxParam, + sweepProofParam, + mainUtxoParam, + vaultParam + ) + }, + this._totalRetryAttempts + ) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#txProofDifficultyFactor} + * @see {Bridge#txProofDifficultyFactor} */ async txProofDifficultyFactor(): Promise { const txProofDifficultyFactor: BigNumber = await backoffRetrier( @@ -292,7 +295,7 @@ export class Bridge // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#requestRedemption} + * @see {Bridge#requestRedemption} */ async requestRedemption( walletPublicKey: string, @@ -320,19 +323,22 @@ export class Bridge rawRedeemerOutputScript, ]).toString("hex")}` - await sendWithRetry(async () => { - return await this._instance.requestRedemption( - walletPublicKeyHash, - mainUtxoParam, - prefixedRawRedeemerOutputScript, - amount - ) - }, this._totalRetryAttempts) + await EthersTransactionUtils.sendWithRetry( + async () => { + return await this._instance.requestRedemption( + walletPublicKeyHash, + mainUtxoParam, + prefixedRawRedeemerOutputScript, + amount + ) + }, + this._totalRetryAttempts + ) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#submitRedemptionProof} + * @see {Bridge#submitRedemptionProof} */ async submitRedemptionProof( redemptionTx: BitcoinRawTxVectors, @@ -365,28 +371,34 @@ export class Bridge walletPublicKey )}` - await sendWithRetry(async () => { - return await this._instance.submitRedemptionProof( - redemptionTxParam, - redemptionProofParam, - mainUtxoParam, - walletPublicKeyHash - ) - }, this._totalRetryAttempts) + await EthersTransactionUtils.sendWithRetry( + async () => { + return await this._instance.submitRedemptionProof( + redemptionTxParam, + redemptionProofParam, + mainUtxoParam, + walletPublicKeyHash + ) + }, + this._totalRetryAttempts + ) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#deposits} + * @see {Bridge#deposits} */ async deposits( depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { - const depositKey = Bridge.buildDepositKey(depositTxHash, depositOutputIndex) + const depositKey = EthereumBridge.buildDepositKey( + depositTxHash, + depositOutputIndex + ) - const deposit: ContractDepositRequest = - await backoffRetrier(this._totalRetryAttempts)( + const deposit: DepositRequestTypechain = + await backoffRetrier(this._totalRetryAttempts)( async () => { return await this._instance.deposits(depositKey) } @@ -422,15 +434,15 @@ export class Bridge * @returns Parsed revealed deposit. */ private parseRevealedDeposit( - deposit: ContractDepositRequest + deposit: DepositRequestTypechain ): RevealedDeposit { return { - depositor: new Address(deposit.depositor), + depositor: EthereumAddress.from(deposit.depositor), amount: BigNumber.from(deposit.amount), vault: deposit.vault === constants.AddressZero ? undefined - : new Address(deposit.vault), + : EthereumAddress.from(deposit.vault), revealedAt: BigNumber.from(deposit.revealedAt).toNumber(), sweptAt: BigNumber.from(deposit.sweptAt).toNumber(), treasuryFee: BigNumber.from(deposit.treasuryFee), @@ -439,7 +451,7 @@ export class Bridge // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#activeWalletPublicKey} + * @see {Bridge#activeWalletPublicKey} */ async activeWalletPublicKey(): Promise { const activeWalletPublicKeyHash: string = await backoffRetrier( @@ -475,7 +487,7 @@ export class Bridge // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#getNewWalletRegisteredEvents} + * @see {Bridge#getNewWalletRegisteredEvents} */ async getNewWalletRegisteredEvents( options?: GetChainEvents.Options, @@ -500,16 +512,16 @@ export class Bridge // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#walletRegistry} + * @see {Bridge#walletRegistry} */ - async walletRegistry(): Promise { + async walletRegistry(): Promise { const { ecdsaWalletRegistry } = await backoffRetrier<{ ecdsaWalletRegistry: string }>(this._totalRetryAttempts)(async () => { return await this._instance.contractReferences() }) - return new WalletRegistry({ + return new EthereumWalletRegistry({ address: ecdsaWalletRegistry, signerOrProvider: this._instance.signer || this._instance.provider, }) @@ -517,10 +529,10 @@ export class Bridge // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#wallets} + * @see {Bridge#wallets} */ async wallets(walletPublicKeyHash: Hex): Promise { - const wallet = await backoffRetrier( + const wallet = await backoffRetrier( this._totalRetryAttempts )(async () => { return await this._instance.wallets( @@ -537,7 +549,7 @@ export class Bridge * @returns Parsed wallet data. */ private async parseWalletDetails( - wallet: Wallets.WalletStructOutput + wallet: WalletsTypechain.WalletStructOutput ): Promise { const ecdsaWalletID = Hex.from(wallet.ecdsaWalletID) @@ -563,7 +575,7 @@ export class Bridge * Builds the UTXO hash based on the UTXO components. UTXO hash is computed as * `keccak256(txHash | txOutputIndex | txOutputValue)`. * - * @see {ChainBridge#buildUtxoHash} + * @see {Bridge#buildUtxoHash} */ buildUtxoHash(utxo: BitcoinUtxo): Hex { return Hex.from( @@ -580,7 +592,7 @@ export class Bridge // eslint-disable-next-line valid-jsdoc /** - * @see {ChainBridge#getDepositRevealedEvents} + * @see {Bridge#getDepositRevealedEvents} */ async getRedemptionRequestedEvents( options?: GetChainEvents.Options, @@ -614,7 +626,7 @@ export class Bridge blockHash: Hex.from(event.blockHash), transactionHash: Hex.from(event.transactionHash), walletPublicKeyHash: Hex.from(event.args!.walletPubKeyHash).toString(), - redeemer: new Address(event.args!.redeemer), + redeemer: EthereumAddress.from(event.args!.redeemer), redeemerOutputScript: redeemerOutputScript, requestedAmount: BigNumber.from(event.args!.requestedAmount), treasuryFee: BigNumber.from(event.args!.treasuryFee), diff --git a/typescript/src/lib/ethereum/contract-handle.ts b/typescript/src/lib/ethereum/contract-handle.ts deleted file mode 100644 index 2faf1c674..000000000 --- a/typescript/src/lib/ethereum/contract-handle.ts +++ /dev/null @@ -1,288 +0,0 @@ -import { providers, Signer, utils } from "ethers" -import { - Contract as EthersContract, - Event as EthersEvent, - EventFilter as EthersEventFilter, -} from "@ethersproject/contracts" -import { GetChainEvents } from "../contracts" -import { - backoffRetrier, - ExecutionLoggerFn, - skipRetryWhenMatched, -} from "../utils" -import { Address } from "./address" - -/** - * Contract deployment artifact. - * @see [hardhat-deploy#Deployment](https://github.com/wighawag/hardhat-deploy/blob/0c969e9a27b4eeff9f5ccac7e19721ef2329eed2/types.ts#L358)} - */ -export interface Deployment { - /** - * Address of the deployed contract. - */ - address: string - /** - * Contract's ABI. - */ - abi: any[] - /** - * Deployment transaction receipt. - */ - receipt: { - /** - * Number of block in which the contract was deployed. - */ - blockNumber: number - } -} - -/** - * Represents a config set required to connect an Ethereum contract. - */ -export interface ContractConfig { - /** - * Address of the Ethereum contract as a 0x-prefixed hex string. - * Optional parameter, if not provided the value will be resolved from the - * contract artifact. - */ - address?: string - /** - * Signer - will return a Contract which will act on behalf of that signer. The signer will sign all contract transactions. - * Provider - will return a downgraded Contract which only has read-only access (i.e. constant calls) - */ - signerOrProvider: Signer | providers.Provider - /** - * Number of a block in which the contract was deployed. - * Optional parameter, if not provided the value will be resolved from the - * contract artifact. - */ - deployedAtBlockNumber?: number -} - -/** - * Deployed Ethereum contract - */ -export class EthereumContract { - /** - * Ethers instance of the deployed contract. - */ - protected readonly _instance: T - /** - * Number of a block within which the contract was deployed. Value is read from - * the contract deployment artifact. It can be overwritten by setting a - * {@link ContractConfig.deployedAtBlockNumber} property. - */ - protected readonly _deployedAtBlockNumber: number - /** - * Number of retries for ethereum requests. - */ - protected readonly _totalRetryAttempts: number - - /** - * @param config Configuration for contract instance initialization. - * @param deployment Contract Deployment artifact. - * @param totalRetryAttempts Number of retries for ethereum requests. - */ - constructor( - config: ContractConfig, - deployment: Deployment, - totalRetryAttempts = 3 - ) { - this._instance = new EthersContract( - config.address ?? utils.getAddress(deployment.address), - `${JSON.stringify(deployment.abi)}`, - config.signerOrProvider - ) as T - - this._deployedAtBlockNumber = - config.deployedAtBlockNumber ?? deployment.receipt.blockNumber - - this._totalRetryAttempts = totalRetryAttempts - } - - /** - * Get address of the contract instance. - * @returns Address of this contract instance. - */ - getAddress(): Address { - return Address.from(this._instance.address) - } - - /** - * Get events emitted by the Ethereum contract. - * It starts searching from provided block number. If the {@link GetEvents.Options#fromBlock} - * option is missing it looks for a contract's defined property - * {@link _deployedAtBlockNumber}. If the property is missing starts searching - * from block `0`. - * @param eventName Name of the event. - * @param options Options for events fetching. - * @param filterArgs Arguments for events filtering. - * @returns Array of found events. - */ - async getEvents( - eventName: string, - options?: GetChainEvents.Options, - ...filterArgs: Array - ): Promise { - // TODO: Test if we need a workaround for querying events from big range in chunks, - // see: https://github.com/keep-network/tbtc-monitoring/blob/e169357d7b8c638d4eaf73d52aa8f53ee4aebc1d/src/lib/ethereum-helper.js#L44-L73 - return backoffRetrier( - options?.retries ?? this._totalRetryAttempts - )(async () => { - return await getEvents( - this._instance, - this._instance.filters[eventName](...filterArgs), - options?.fromBlock ?? this._deployedAtBlockNumber, - options?.toBlock, - options?.batchedQueryBlockInterval, - options?.logger - ) - }) - } -} - -/** - * Sends ethereum transaction with retries. - * @param fn Function to execute with retries. - * @param retries The number of retries to perform before bubbling the failure out. - * @param logger A logger function to pass execution messages. - * @param nonRetryableErrors List of error messages that if returned from executed - * function, should break the retry loop and return immediately. - * @returns Result of function execution. - * @throws An error returned by function execution. An error thrown by the executed - * function is processed by {@link resolveEthersError} function to resolve - * the revert message in case of a transaction revert. - */ -export async function sendWithRetry( - fn: () => Promise, - retries: number, - logger?: ExecutionLoggerFn, - nonRetryableErrors?: Array -): Promise { - return backoffRetrier( - retries, - 1000, - logger, - nonRetryableErrors ? skipRetryWhenMatched(nonRetryableErrors) : undefined - )(async () => { - try { - return await fn() - } catch (err: unknown) { - throw resolveEthersError(err) - } - }) -} - -/** - * Represents an interface that matches the errors structure thrown by ethers library. - * {@see {@link https://github.com/ethers-io/ethers.js/blob/c80fcddf50a9023486e9f9acb1848aba4c19f7b6/packages/logger/src.ts/index.ts#L268-L277 ethers source code}} - */ -interface EthersError extends Error { - reason: string - code: string - error: unknown -} - -/** - * Takes an error and tries to resolve a revert message if the error is related - * to reverted transaction. - * @param err Error to process. - * @returns Error with a revert message or the input error when the error could - * not be resolved successfully. - */ -function resolveEthersError(err: unknown): unknown { - const isEthersError = (obj: any): obj is EthersError => { - return "reason" in obj && "code" in obj && "error" in obj - } - - if (isEthersError(err) && err !== null) { - // Ethers errors are nested. The parent UNPREDICTABLE_GAS_LIMIT has a general - // reason "cannot estimate gas; transaction may fail or may require manual gas limit", - if (err.code === "UNPREDICTABLE_GAS_LIMIT") { - if (typeof isEthersError(err["error"]) && err["error"] !== null) { - // The nested error is expected to contain a reason property with a message - // of the transaction revert. - return new Error((err["error"] as EthersError).reason) - } - } - } - - return err -} - -const GET_EVENTS_BLOCK_INTERVAL = 10_000 - -/** - * Looks up all existing events defined by the {@link event} filter on - * {@link sourceContract}, searching past blocks and then returning them. - * Does not wait for any new events. It starts searching from provided block number. - * If the {@link fromBlock} is missing it starts searching from block `0`. - * It pulls events in one `getLogs` call. If the call fails it fallbacks to querying - * events in batches of {@link batchedQueryBlockInterval} blocks. If the parameter - * is not set it queries in {@link GET_EVENTS_BLOCK_INTERVAL} blocks batches. - * @param sourceContract The contract instance that emits the event. - * @param event The event filter to query. - * @param fromBlock Starting block for events search. - * @param toBlock Ending block for events search. - * @param batchedQueryBlockInterval Block interval for batched events pulls. - * @param logger A logger function to pass execution messages. - * @returns A promise that will be fulfilled by the list of event objects once - * they are found. - */ -async function getEvents( - sourceContract: EthersContract, - event: EthersEventFilter, - fromBlock: number = 0, - toBlock: number | string = "latest", - batchedQueryBlockInterval: number = GET_EVENTS_BLOCK_INTERVAL, - logger: ExecutionLoggerFn = console.debug -): Promise { - return new Promise(async (resolve, reject) => { - let resultEvents: EthersEvent[] = [] - try { - resultEvents = await sourceContract.queryFilter(event, fromBlock, toBlock) - } catch (err) { - logger( - `switching to partial events pulls; ` + - `failed to get events in one request from contract: [${event.address}], ` + - `fromBlock: [${fromBlock}], toBlock: [${toBlock}]: [${err}]` - ) - - try { - if (typeof toBlock === "string") { - toBlock = (await sourceContract.provider.getBlock(toBlock)).number - } - - let batchStartBlock = fromBlock - - while (batchStartBlock <= toBlock) { - let batchEndBlock = batchStartBlock + batchedQueryBlockInterval - if (batchEndBlock > toBlock) { - batchEndBlock = toBlock - } - logger( - `executing partial events pull from contract: [${event.address}], ` + - `fromBlock: [${batchStartBlock}], toBlock: [${batchEndBlock}]` - ) - const foundEvents = await sourceContract.queryFilter( - event, - batchStartBlock, - batchEndBlock - ) - - resultEvents = resultEvents.concat(foundEvents) - logger( - `fetched [${foundEvents.length}] events, has ` + - `[${resultEvents.length}] total` - ) - - batchStartBlock = batchEndBlock + 1 - } - } catch (error) { - return reject(error) - } - } - - return resolve(resultEvents) - }) -} diff --git a/typescript/src/lib/ethereum/index.ts b/typescript/src/lib/ethereum/index.ts index e6ac22fcf..5e822f8f1 100644 --- a/typescript/src/lib/ethereum/index.ts +++ b/typescript/src/lib/ethereum/index.ts @@ -4,7 +4,7 @@ export * from "./tbtc-token" export * from "./tbtc-vault" export * from "./wallet-registry" -// The `contract-handle` module should not be re-exported directly as it +// The `adapter` module should not be re-exported directly as it // contains low-level contract integration code. Re-export only components // that are relevant for `lib/ethereum` clients. -export { ContractConfig } from "./contract-handle" +export { EthersContractConfig as EthereumContractConfig } from "./adapter" diff --git a/typescript/src/lib/ethereum/tbtc-token.ts b/typescript/src/lib/ethereum/tbtc-token.ts index 825a8c920..cb174a045 100644 --- a/typescript/src/lib/ethereum/tbtc-token.ts +++ b/typescript/src/lib/ethereum/tbtc-token.ts @@ -1,30 +1,31 @@ -import { TBTC as ContractTBTC } from "../../../typechain/TBTC" -import { TBTCToken as ChainTBTCToken } from "../contracts" +import { TBTC as TBTCTypechain } from "../../../typechain/TBTC" +import { TBTCToken } from "../contracts" import { BigNumber, ContractTransaction, utils } from "ethers" import { BitcoinHashUtils, BitcoinUtxo } from "../bitcoin" import { Hex } from "../utils" import { - ContractConfig, - EthereumContract, - sendWithRetry, -} from "./contract-handle" + EthersContractConfig, + EthersContractHandle, + EthersTransactionUtils, +} from "./adapter" import TBTCDeployment from "@keep-network/tbtc-v2/artifacts/TBTC.json" -import { Address } from "./address" +import { EthereumAddress } from "./address" /** * Implementation of the Ethereum TBTC v2 token handle. + * @see {TBTCToken} for reference. */ -export class TBTCToken - extends EthereumContract - implements ChainTBTCToken +export class EthereumTBTCToken + extends EthersContractHandle + implements TBTCToken { - constructor(config: ContractConfig) { + constructor(config: EthersContractConfig) { super(config, TBTCDeployment) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCToken#totalSupply} + * @see {TBTCToken#totalSupply} */ async totalSupply(blockNumber?: number): Promise { return this._instance.totalSupply({ @@ -34,7 +35,7 @@ export class TBTCToken // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCToken#requestRedemption} + * @see {TBTCToken#requestRedemption} */ async requestRedemption( walletPublicKey: string, @@ -49,25 +50,28 @@ export class TBTCToken const vault = await this._instance.owner() const extraData = this.buildRequestRedemptionData( - Address.from(redeemer), + EthereumAddress.from(redeemer), walletPublicKey, mainUtxo, redeemerOutputScript ) - const tx = await sendWithRetry(async () => { - return await this._instance.approveAndCall( - vault, - amount, - extraData.toPrefixedString() - ) - }, this._totalRetryAttempts) + const tx = await EthersTransactionUtils.sendWithRetry( + async () => { + return await this._instance.approveAndCall( + vault, + amount, + extraData.toPrefixedString() + ) + }, + this._totalRetryAttempts + ) return Hex.from(tx.hash) } private buildRequestRedemptionData( - redeemer: Address, + redeemer: EthereumAddress, walletPublicKey: string, mainUtxo: BitcoinUtxo, redeemerOutputScript: string diff --git a/typescript/src/lib/ethereum/tbtc-vault.ts b/typescript/src/lib/ethereum/tbtc-vault.ts index 43c206a3d..20a60590b 100644 --- a/typescript/src/lib/ethereum/tbtc-vault.ts +++ b/typescript/src/lib/ethereum/tbtc-vault.ts @@ -1,7 +1,7 @@ -import { TBTCVault as ContractTBTCVault } from "../../../typechain/TBTCVault" +import { TBTCVault as TBTCVaultTypechain } from "../../../typechain/TBTCVault" import { GetChainEvents, - TBTCVault as ChainTBTCVault, + TBTCVault, OptimisticMintingCancelledEvent, OptimisticMintingFinalizedEvent, OptimisticMintingRequest, @@ -12,12 +12,12 @@ import { BitcoinTxHash } from "../bitcoin" import { backoffRetrier, Hex } from "../utils" import TBTCVaultDeployment from "@keep-network/tbtc-v2/artifacts/TBTCVault.json" import { - ContractConfig, - EthereumContract, - sendWithRetry, -} from "./contract-handle" -import { Address } from "./address" -import { Bridge } from "./bridge" + EthersContractConfig, + EthersContractHandle, + EthersTransactionUtils, +} from "./adapter" +import { EthereumAddress } from "./address" +import { EthereumBridge } from "./bridge" type ContractOptimisticMintingRequest = { requestedAt: BigNumber @@ -26,18 +26,19 @@ type ContractOptimisticMintingRequest = { /** * Implementation of the Ethereum TBTCVault handle. + * @see {TBTCVault} for reference. */ -export class TBTCVault - extends EthereumContract - implements ChainTBTCVault +export class EthereumTBTCVault + extends EthersContractHandle + implements TBTCVault { - constructor(config: ContractConfig) { + constructor(config: EthersContractConfig) { super(config, TBTCVaultDeployment) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCVault#optimisticMintingDelay} + * @see {TBTCVault#optimisticMintingDelay} */ async optimisticMintingDelay(): Promise { const delaySeconds = await backoffRetrier(this._totalRetryAttempts)( @@ -51,23 +52,23 @@ export class TBTCVault // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCVault#getMinters} + * @see {TBTCVault#getMinters} */ - async getMinters(): Promise { + async getMinters(): Promise { const minters: string[] = await backoffRetrier( this._totalRetryAttempts )(async () => { return await this._instance.getMinters() }) - return minters.map(Address.from) + return minters.map(EthereumAddress.from) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCVault#isMinter} + * @see {TBTCVault#isMinter} */ - async isMinter(address: Address): Promise { + async isMinter(address: EthereumAddress): Promise { return await backoffRetrier(this._totalRetryAttempts)(async () => { return await this._instance.isMinter(`0x${address.identifierHex}`) }) @@ -75,9 +76,9 @@ export class TBTCVault // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCVault#isGuardian} + * @see {TBTCVault#isGuardian} */ - async isGuardian(address: Address): Promise { + async isGuardian(address: EthereumAddress): Promise { return await backoffRetrier(this._totalRetryAttempts)(async () => { return await this._instance.isGuardian(`0x${address.identifierHex}`) }) @@ -85,13 +86,13 @@ export class TBTCVault // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCVault#requestOptimisticMint} + * @see {TBTCVault#requestOptimisticMint} */ async requestOptimisticMint( depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { - const tx = await sendWithRetry( + const tx = await EthersTransactionUtils.sendWithRetry( async () => { return await this._instance.requestOptimisticMint( depositTxHash.reverse().toPrefixedString(), @@ -111,13 +112,13 @@ export class TBTCVault // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCVault#cancelOptimisticMint} + * @see {TBTCVault#cancelOptimisticMint} */ async cancelOptimisticMint( depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { - const tx = await sendWithRetry( + const tx = await EthersTransactionUtils.sendWithRetry( async () => { return await this._instance.cancelOptimisticMint( depositTxHash.reverse().toPrefixedString(), @@ -134,13 +135,13 @@ export class TBTCVault // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCVault#finalizeOptimisticMint} + * @see {TBTCVault#finalizeOptimisticMint} */ async finalizeOptimisticMint( depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { - const tx = await sendWithRetry( + const tx = await EthersTransactionUtils.sendWithRetry( async () => { return await this._instance.finalizeOptimisticMint( depositTxHash.reverse().toPrefixedString(), @@ -160,13 +161,16 @@ export class TBTCVault // eslint-disable-next-line valid-jsdoc /** - * @see {ChainTBTCVault#optimisticMintingRequests} + * @see {TBTCVault#optimisticMintingRequests} */ async optimisticMintingRequests( depositTxHash: BitcoinTxHash, depositOutputIndex: number ): Promise { - const depositKey = Bridge.buildDepositKey(depositTxHash, depositOutputIndex) + const depositKey = EthereumBridge.buildDepositKey( + depositTxHash, + depositOutputIndex + ) const request: ContractOptimisticMintingRequest = await backoffRetrier( @@ -210,11 +214,11 @@ export class TBTCVault blockNumber: BigNumber.from(event.blockNumber).toNumber(), blockHash: Hex.from(event.blockHash), transactionHash: Hex.from(event.transactionHash), - minter: new Address(event.args!.minter), + minter: EthereumAddress.from(event.args!.minter), depositKey: Hex.from( BigNumber.from(event.args!.depositKey).toHexString() ), - depositor: new Address(event.args!.depositor), + depositor: EthereumAddress.from(event.args!.depositor), amount: BigNumber.from(event.args!.amount), fundingTxHash: BitcoinTxHash.from(event.args!.fundingTxHash).reverse(), fundingOutputIndex: BigNumber.from( @@ -243,7 +247,7 @@ export class TBTCVault blockNumber: BigNumber.from(event.blockNumber).toNumber(), blockHash: Hex.from(event.blockHash), transactionHash: Hex.from(event.transactionHash), - guardian: new Address(event.args!.guardian), + guardian: EthereumAddress.from(event.args!.guardian), depositKey: Hex.from( BigNumber.from(event.args!.depositKey).toHexString() ), @@ -270,11 +274,11 @@ export class TBTCVault blockNumber: BigNumber.from(event.blockNumber).toNumber(), blockHash: Hex.from(event.blockHash), transactionHash: Hex.from(event.transactionHash), - minter: new Address(event.args!.minter), + minter: EthereumAddress.from(event.args!.minter), depositKey: Hex.from( BigNumber.from(event.args!.depositKey).toHexString() ), - depositor: new Address(event.args!.depositor), + depositor: EthereumAddress.from(event.args!.depositor), optimisticMintingDebt: BigNumber.from( event.args!.optimisticMintingDebt ), diff --git a/typescript/src/lib/ethereum/wallet-registry.ts b/typescript/src/lib/ethereum/wallet-registry.ts index f893ead8f..a71940e78 100644 --- a/typescript/src/lib/ethereum/wallet-registry.ts +++ b/typescript/src/lib/ethereum/wallet-registry.ts @@ -1,7 +1,7 @@ -import { WalletRegistry as ContractWalletRegistry } from "../../../typechain/WalletRegistry" +import { WalletRegistry as WalletRegistryTypechain } from "../../../typechain/WalletRegistry" import { GetChainEvents, - WalletRegistry as ChainWalletRegistry, + WalletRegistry, DkgResultApprovedEvent, DkgResultChallengedEvent, DkgResultSubmittedEvent, @@ -10,24 +10,24 @@ import { backoffRetrier, Hex } from "../utils" import { Event as EthersEvent } from "@ethersproject/contracts" import { BigNumber } from "ethers" import WalletRegistryDeployment from "@keep-network/ecdsa/artifacts/WalletRegistry.json" -import { ContractConfig, EthereumContract } from "./contract-handle" -import { Address } from "./address" +import { EthersContractConfig, EthersContractHandle } from "./adapter" +import { EthereumAddress } from "./address" /** * Implementation of the Ethereum WalletRegistry handle. - * @see {ChainWalletRegistry} for reference. + * @see {WalletRegistry} for reference. */ -export class WalletRegistry - extends EthereumContract - implements ChainWalletRegistry +export class EthereumWalletRegistry + extends EthersContractHandle + implements WalletRegistry { - constructor(config: ContractConfig) { + constructor(config: EthersContractConfig) { super(config, WalletRegistryDeployment) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainWalletRegistry#getWalletPublicKey} + * @see {WalletRegistry#getWalletPublicKey} */ async getWalletPublicKey(walletID: Hex): Promise { const publicKey = await backoffRetrier(this._totalRetryAttempts)( @@ -42,7 +42,7 @@ export class WalletRegistry // eslint-disable-next-line valid-jsdoc /** - * @see {ChainWalletRegistry#getDkgResultSubmittedEvents} + * @see {WalletRegistry#getDkgResultSubmittedEvents} */ async getDkgResultSubmittedEvents( options?: GetChainEvents.Options, @@ -85,7 +85,7 @@ export class WalletRegistry // eslint-disable-next-line valid-jsdoc /** - * @see {ChainWalletRegistry#getDkgResultApprovedEvents} + * @see {WalletRegistry#getDkgResultApprovedEvents} */ async getDkgResultApprovedEvents( options?: GetChainEvents.Options, @@ -103,14 +103,14 @@ export class WalletRegistry blockHash: Hex.from(event.blockHash), transactionHash: Hex.from(event.transactionHash), resultHash: Hex.from(event.args!.resultHash), - approver: Address.from(event.args!.approver), + approver: EthereumAddress.from(event.args!.approver), } }) } // eslint-disable-next-line valid-jsdoc /** - * @see {ChainWalletRegistry#getDkgResultChallengedEvents} + * @see {WalletRegistry#getDkgResultChallengedEvents} */ async getDkgResultChallengedEvents( options?: GetChainEvents.Options, @@ -128,7 +128,7 @@ export class WalletRegistry blockHash: Hex.from(event.blockHash), transactionHash: Hex.from(event.transactionHash), resultHash: Hex.from(event.args!.resultHash), - challenger: Address.from(event.args!.challenger), + challenger: EthereumAddress.from(event.args!.challenger), reason: event.args!.reason, } }) diff --git a/typescript/test/data/deposit-refund.ts b/typescript/test/data/deposit-refund.ts index 1d0da98f3..00ea5c0ef 100644 --- a/typescript/test/data/deposit-refund.ts +++ b/typescript/test/data/deposit-refund.ts @@ -2,7 +2,7 @@ import { BigNumber } from "ethers" import { BitcoinRawTx, BitcoinUtxo, BitcoinTxHash } from "../../src/lib/bitcoin" import { Deposit } from "../../src/lib/contracts" import { calculateDepositRefundLocktime } from "../../src/deposit" -import { Address } from "../../src/lib/ethereum" +import { EthereumAddress } from "../../src/lib/ethereum" /** * Testnet private key that can be used to refund the deposits used in tests. @@ -52,7 +52,9 @@ export const depositRefundOfWitnessDepositAndWitnessRefunderAddress: DepositRefu "00000000", }, data: { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), amount: BigNumber.from(100000), walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "1b67f27537c7b30a23d8ccefb96a4cacfc72d9a1", @@ -105,7 +107,9 @@ export const depositRefundOfNonWitnessDepositAndWitnessRefunderAddress: DepositR "2eb90b4af908db60231d117aeede04e7bc11907bfa00000000", }, data: { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), amount: BigNumber.from(90000), walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "1b67f27537c7b30a23d8ccefb96a4cacfc72d9a1", @@ -158,7 +162,9 @@ export const depositRefundOfWitnessDepositAndNonWitnessRefunderAddress: DepositR "d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa00000000", }, data: { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), amount: BigNumber.from(150000), walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "1b67f27537c7b30a23d8ccefb96a4cacfc72d9a1", diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index 18e96b513..abaf1d7dd 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -10,7 +10,7 @@ import { import { Deposit } from "../../src/lib/contracts" import { calculateDepositRefundLocktime } from "../../src/deposit" import { BigNumber } from "ethers" -import { Address } from "../../src/lib/ethereum" +import { EthereumAddress } from "../../src/lib/ethereum" import { Hex } from "../../src" export const NO_MAIN_UTXO = { @@ -61,7 +61,9 @@ export const depositSweepWithNoMainUtxoAndWitnessOutput: DepositSweepTestData = "db60231d117aeede04e7bc11907bfa00000000", }, data: { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), amount: BigNumber.from(25000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", @@ -88,7 +90,9 @@ export const depositSweepWithNoMainUtxoAndWitnessOutput: DepositSweepTestData = "8d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa00000000", }, data: { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), amount: BigNumber.from(12000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. @@ -147,7 +151,9 @@ export const depositSweepWithNoMainUtxoAndNonWitnessOutput: DepositSweepTestData "01000000000101dcd1de7b256376f1e05b3c20846868401aee2a85c27990b95886e0d2970a3fc40100000000ffffffff02983a00000000000017a914a9a5f97d5d3c4687a52e90718168270005b369c487f065120000000000160014e257eccafbc07c381642ce6e7e55120fb077fbed02483045022100baccb37cb46a20d79ccd3875162ab8b614a671cc64dc37d3477e24ef5eb61d7102204c68c5a5caff7e5089c1cacaa173fb5aad9529642773501b5e8d88abe7b4fc9c0121039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa00000000", }, data: { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), amount: BigNumber.from(15000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", @@ -198,7 +204,9 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa "08db60231d117aeede04e7bc11907bfa00000000", }, data: { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), amount: BigNumber.from(17000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", @@ -226,7 +234,9 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa "8d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa00000000", }, data: { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), amount: BigNumber.from(10000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", @@ -320,7 +330,9 @@ export const depositSweepWithNonWitnessMainUtxoAndWitnessOutput: DepositSweepTes "e7bc11907bfa00000000", }, data: { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), amount: BigNumber.from(19000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", diff --git a/typescript/test/data/redemption.ts b/typescript/test/data/redemption.ts index 8cefbc42d..c66863c50 100644 --- a/typescript/test/data/redemption.ts +++ b/typescript/test/data/redemption.ts @@ -10,7 +10,7 @@ import { BitcoinAddressConverter, } from "../../src/lib/bitcoin" import { RedemptionRequest, WalletState } from "../../src/lib/contracts" -import { Address } from "../../src/lib/ethereum" +import { EthereumAddress } from "../../src/lib/ethereum" import { Hex } from "../../src" /** @@ -78,7 +78,9 @@ export const singleP2PKHRedemptionWithWitnessChange: RedemptionTestData = { redemptionKey: "0xcb493004c645792101cfa4cc5da4c16aa3148065034371a6f1478b7df4b92d39", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2PKH address mmTeMR8RKu6QzMGTG4ipA71uewm3EuJng5 redeemerOutputScript: "76a9144130879211c54df460e484ddf9aac009cb38ee7488ac", @@ -133,7 +135,9 @@ export const singleP2WPKHRedemptionWithWitnessChange: RedemptionTestData = { redemptionKey: "0x52a5e94b7f933cbc9565c61d43a83921a6b7bbf950156a2dfda7743a7cefffbf", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2WPKH address tb1qgycg0ys3c4xlgc8ysnwln2kqp89n3mn5ts7z3l redeemerOutputScript: "00144130879211c54df460e484ddf9aac009cb38ee74", requestedAmount: BigNumber.from(15000), @@ -187,7 +191,9 @@ export const singleP2SHRedemptionWithWitnessChange: RedemptionTestData = { redemptionKey: "0x4f5c364239f365622168b8fcb3f4556a8bbad22f5b5ae598757c4fe83b3a78d7", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2SH address 2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C redeemerOutputScript: "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87", requestedAmount: BigNumber.from(13000), @@ -241,7 +247,9 @@ export const singleP2WSHRedemptionWithWitnessChange: RedemptionTestData = { redemptionKey: "0x2636de6d29da2c7e229a31f3a39b151e2dcd149b1cc2c4e28008f9ab1b02c112", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2WSH address tb1qs63s8nwjut4tr5t8nudgzwp4m3dpkefjzpmumn90pruce0cye2tq2jkq0y redeemerOutputScript: "002086a303cdd2e2eab1d1679f1a813835dc5a1b65321077cdccaf08f98cbf04ca96", @@ -296,7 +304,9 @@ export const multipleRedemptionsWithWitnessChange: RedemptionTestData = { redemptionKey: "0xcb493004c645792101cfa4cc5da4c16aa3148065034371a6f1478b7df4b92d39", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2PKH address mmTeMR8RKu6QzMGTG4ipA71uewm3EuJng5 redeemerOutputScript: "76a9144130879211c54df460e484ddf9aac009cb38ee7488ac", @@ -310,7 +320,9 @@ export const multipleRedemptionsWithWitnessChange: RedemptionTestData = { redemptionKey: "0x52a5e94b7f933cbc9565c61d43a83921a6b7bbf950156a2dfda7743a7cefffbf", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2WPKH address tb1qgycg0ys3c4xlgc8ysnwln2kqp89n3mn5ts7z3l redeemerOutputScript: "00144130879211c54df460e484ddf9aac009cb38ee74", requestedAmount: BigNumber.from(13000), @@ -323,7 +335,9 @@ export const multipleRedemptionsWithWitnessChange: RedemptionTestData = { redemptionKey: "0x4f5c364239f365622168b8fcb3f4556a8bbad22f5b5ae598757c4fe83b3a78d7", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2SH address 2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C redeemerOutputScript: "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87", requestedAmount: BigNumber.from(12000), @@ -336,7 +350,9 @@ export const multipleRedemptionsWithWitnessChange: RedemptionTestData = { redemptionKey: "0x2636de6d29da2c7e229a31f3a39b151e2dcd149b1cc2c4e28008f9ab1b02c112", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2WSH address tb1qs63s8nwjut4tr5t8nudgzwp4m3dpkefjzpmumn90pruce0cye2tq2jkq0y redeemerOutputScript: "002086a303cdd2e2eab1d1679f1a813835dc5a1b65321077cdccaf08f98cbf04ca96", @@ -394,7 +410,9 @@ export const multipleRedemptionsWithoutChange: RedemptionTestData = { redemptionKey: "0xcb493004c645792101cfa4cc5da4c16aa3148065034371a6f1478b7df4b92d39", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2PKH address mmTeMR8RKu6QzMGTG4ipA71uewm3EuJng5 redeemerOutputScript: "76a9144130879211c54df460e484ddf9aac009cb38ee7488ac", @@ -408,7 +426,9 @@ export const multipleRedemptionsWithoutChange: RedemptionTestData = { redemptionKey: "0xa690d9da3e64c337eb11344b94cf948ec2da333f0a985e09f1c120a326f6de87", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2WPKH address tb1qf0ulldawp79s7knz9v254j5zjyn0demfx2d0xx redeemerOutputScript: "00144bf9ffb7ae0f8b0f5a622b154aca829126f6e769", requestedAmount: BigNumber.from(4000), @@ -465,7 +485,9 @@ export const singleP2SHRedemptionWithNonWitnessChange: RedemptionTestData = { redemptionKey: "0x4f5c364239f365622168b8fcb3f4556a8bbad22f5b5ae598757c4fe83b3a78d7", pendingRedemption: { - redeemer: Address.from("82883a4c7a8dd73ef165deb402d432613615ced4"), + redeemer: EthereumAddress.from( + "82883a4c7a8dd73ef165deb402d432613615ced4" + ), // script for testnet P2SH address 2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C redeemerOutputScript: "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87", requestedAmount: BigNumber.from(12000), @@ -872,7 +894,9 @@ export const findWalletForRedemptionData: { }, }, pendingRedemption: { - redeemer: Address.from("0xeb9af8E66869902476347a4eFe59a527a57240ED"), + redeemer: EthereumAddress.from( + "0xeb9af8E66869902476347a4eFe59a527a57240ED" + ), // script for testnet P2PKH address mjc2zGWypwpNyDi4ZxGbBNnUA84bfgiwYc redeemerOutputScript: "76a9142cd680318747b720d67bf4246eb7403b476adb3488ac", requestedAmount: BigNumber.from(1000000), diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index f002c570d..c8cac6779 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -32,7 +32,7 @@ import { suggestDepositWallet, } from "../src/deposit" import { MockBridge } from "./utils/mock-bridge" -import { Address } from "../src/lib/ethereum" +import { EthereumAddress } from "../src/lib/ethereum" import { BitcoinNetwork } from "../src" describe("Deposit", () => { @@ -40,7 +40,7 @@ describe("Deposit", () => { const depositRefundLocktimeDuration: number = 2592000 const deposit: Deposit = { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), amount: BigNumber.from(10000), // 0.0001 BTC // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", diff --git a/typescript/test/ethereum.test.ts b/typescript/test/ethereum.test.ts index 363202e9b..1a9c9f1ba 100644 --- a/typescript/test/ethereum.test.ts +++ b/typescript/test/ethereum.test.ts @@ -1,4 +1,8 @@ -import { Address, Bridge, TBTCToken } from "../src/lib/ethereum" +import { + EthereumAddress, + EthereumBridge, + EthereumTBTCToken, +} from "../src/lib/ethereum" import { deployMockContract, MockContract, @@ -19,7 +23,7 @@ describe("Ethereum", () => { describe("Bridge", () => { let walletRegistry: MockContract let bridgeContract: MockContract - let bridgeHandle: Bridge + let bridgeHandle: EthereumBridge beforeEach(async () => { const [signer] = new MockProvider().getWallets() @@ -41,7 +45,7 @@ describe("Ethereum", () => { constants.AddressZero ) - bridgeHandle = new Bridge({ + bridgeHandle = new EthereumBridge({ address: bridgeContract.address, signerOrProvider: signer, }) @@ -73,7 +77,9 @@ describe("Ethereum", () => { "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87" ) ).to.be.eql({ - redeemer: Address.from("f39fd6e51aad88f6f4ce6ab8827279cfffb92266"), + redeemer: EthereumAddress.from( + "f39fd6e51aad88f6f4ce6ab8827279cfffb92266" + ), redeemerOutputScript: "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87", requestedAmount: BigNumber.from(10000), @@ -110,7 +116,9 @@ describe("Ethereum", () => { "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87" ) ).to.be.eql({ - redeemer: Address.from("f39fd6e51aad88f6f4ce6ab8827279cfffb92266"), + redeemer: EthereumAddress.from( + "f39fd6e51aad88f6f4ce6ab8827279cfffb92266" + ), redeemerOutputScript: "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87", requestedAmount: BigNumber.from(10000), @@ -135,13 +143,15 @@ describe("Ethereum", () => { }, 2, { - depositor: Address.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + depositor: EthereumAddress.from( + "934b98637ca318a4d6e7ca6ffd1690b8e77df637" + ), walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "28e081f285138ccbe389c1eb8985716230129f89", blindingFactor: "f9f0c90d00039523", refundLocktime: "60bcea61", }, - Address.from("82883a4c7a8dd73ef165deb402d432613615ced4") + EthereumAddress.from("82883a4c7a8dd73ef165deb402d432613615ced4") ) }) @@ -188,7 +198,7 @@ describe("Ethereum", () => { outputIndex: 8, value: BigNumber.from(9999), }, - Address.from("82883a4c7a8dd73ef165deb402d432613615ced4") + EthereumAddress.from("82883a4c7a8dd73ef165deb402d432613615ced4") ) }) @@ -342,9 +352,13 @@ describe("Ethereum", () => { 0 ) ).to.be.eql({ - depositor: Address.from("f39fd6e51aad88f6f4ce6ab8827279cfffb92266"), + depositor: EthereumAddress.from( + "f39fd6e51aad88f6f4ce6ab8827279cfffb92266" + ), amount: BigNumber.from(10000), - vault: Address.from("014e1bfbe0f85f129749a8ae0fcb20175433741b"), + vault: EthereumAddress.from( + "014e1bfbe0f85f129749a8ae0fcb20175433741b" + ), revealedAt: 1654774330, sweptAt: 1655033516, treasuryFee: BigNumber.from(200), @@ -381,7 +395,9 @@ describe("Ethereum", () => { 0 ) ).to.be.eql({ - depositor: Address.from("f39fd6e51aad88f6f4ce6ab8827279cfffb92266"), + depositor: EthereumAddress.from( + "f39fd6e51aad88f6f4ce6ab8827279cfffb92266" + ), amount: BigNumber.from(10000), vault: undefined, revealedAt: 1654774330, @@ -475,7 +491,7 @@ describe("Ethereum", () => { describe("TBTCToken", () => { let tbtcToken: MockContract - let tokenHandle: TBTCToken + let tokenHandle: EthereumTBTCToken const signer: Wallet = new MockProvider().getWallets()[0] beforeEach(async () => { @@ -484,7 +500,7 @@ describe("Ethereum", () => { `${JSON.stringify(TBTCTokenABI)}` ) - tokenHandle = new TBTCToken({ + tokenHandle = new EthereumTBTCToken({ address: tbtcToken.address, signerOrProvider: signer, }) @@ -492,7 +508,9 @@ describe("Ethereum", () => { describe("requestRedemption", () => { const data = { - vault: Address.from("0x24BE35e7C04E2e0a628614Ce0Ed58805e1C894F7"), + vault: EthereumAddress.from( + "0x24BE35e7C04E2e0a628614Ce0Ed58805e1C894F7" + ), walletPublicKey: "03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9", mainUtxo: { @@ -502,7 +520,7 @@ describe("Ethereum", () => { outputIndex: 8, value: BigNumber.from(9999), }, - redeemer: Address.from(signer.address), + redeemer: EthereumAddress.from(signer.address), amount: BigNumber.from(10000), redeemerOutputScript: { unprefixed: diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index 7981adc7c..481234a82 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -20,7 +20,7 @@ import { } from "../../src/lib/bitcoin" import { BigNumberish, BigNumber, utils, constants } from "ethers" import { depositSweepWithNoMainUtxoAndWitnessOutput } from "../data/deposit-sweep" -import { Address } from "../../src/lib/ethereum" +import { EthereumAddress } from "../../src/lib/ethereum" import { Hex } from "../../src/lib/utils" interface DepositSweepProofLogEntry { @@ -148,7 +148,7 @@ export class MockBridge implements Bridge { walletPublicKeyHash: deposit.data.walletPublicKeyHash, refundPublicKeyHash: deposit.data.refundPublicKeyHash, refundLocktime: deposit.data.refundLocktime, - vault: new Address(constants.AddressZero), + vault: EthereumAddress.from(constants.AddressZero), }, ]) }) @@ -194,9 +194,9 @@ export class MockBridge implements Bridge { this._deposits.has(depositKey) ? (this._deposits.get(depositKey) as RevealedDeposit) : { - depositor: Address.from(constants.AddressZero), + depositor: EthereumAddress.from(constants.AddressZero), amount: BigNumber.from(0), - vault: Address.from(constants.AddressZero), + vault: EthereumAddress.from(constants.AddressZero), revealedAt: 0, sweptAt: 0, treasuryFee: BigNumber.from(0), @@ -304,7 +304,7 @@ export class MockBridge implements Bridge { return redemptionsMap.has(redemptionKey) ? (redemptionsMap.get(redemptionKey) as RedemptionRequest) : { - redeemer: Address.from(constants.AddressZero), + redeemer: EthereumAddress.from(constants.AddressZero), redeemerOutputScript: "", requestedAmount: BigNumber.from(0), treasuryFee: BigNumber.from(0), From 2016d5e3aafbd8a6ce104d3b660b6e152cc5b126 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 26 Sep 2023 13:58:03 +0200 Subject: [PATCH 170/205] Rework deposit domain objects Replace current objects with `DepositReceipt` carrying state relevant for Bitcoin and `DepositRequest` carrying state relevant for the Bridge contract. --- typescript/src/deposit-refund.ts | 42 ++++-------------- typescript/src/deposit-sweep.ts | 28 +++++------- typescript/src/deposit.ts | 40 ++++++++++------- typescript/src/lib/contracts/bridge.ts | 61 +++++++++++--------------- typescript/src/lib/ethereum/bridge.ts | 20 ++++----- typescript/test/data/deposit-refund.ts | 7 +-- typescript/test/data/deposit-sweep.ts | 11 +---- typescript/test/deposit-sweep.test.ts | 25 ----------- typescript/test/deposit.test.ts | 43 ++++++------------ typescript/test/utils/mock-bridge.ts | 18 ++++---- 10 files changed, 103 insertions(+), 192 deletions(-) diff --git a/typescript/src/deposit-refund.ts b/typescript/src/deposit-refund.ts index d2fe47da8..0cf2bac52 100644 --- a/typescript/src/deposit-refund.ts +++ b/typescript/src/deposit-refund.ts @@ -9,11 +9,8 @@ import { BitcoinHashUtils, BitcoinPublicKeyUtils, } from "./lib/bitcoin" -import { Deposit } from "./lib/contracts" -import { - assembleDepositScript, - validateDepositScriptParameters, -} from "./deposit" +import { assembleDepositScript, validateDepositReceipt } from "./deposit" +import { DepositReceipt } from "./lib/contracts" /** * Submits a deposit refund by creating and broadcasting a Bitcoin P2(W)PKH @@ -39,7 +36,7 @@ export async function submitDepositRefundTransaction( bitcoinClient: BitcoinClient, fee: BigNumber, utxo: BitcoinUtxo, - deposit: Deposit, + deposit: DepositReceipt, refunderAddress: string, refunderPrivateKey: string ): Promise<{ transactionHash: BitcoinTxHash }> { @@ -87,14 +84,14 @@ export async function submitDepositRefundTransaction( export async function assembleDepositRefundTransaction( fee: BigNumber, utxo: BitcoinUtxo & BitcoinRawTx, - deposit: Deposit, + deposit: DepositReceipt, refunderAddress: string, refunderPrivateKey: string ): Promise<{ transactionHash: BitcoinTxHash rawTransaction: BitcoinRawTx }> { - validateInputParameters(deposit, utxo) + validateDepositReceipt(deposit) const refunderKeyRing = BitcoinPrivateKeyUtils.createKeyRing(refunderPrivateKey) @@ -171,7 +168,7 @@ export async function assembleDepositRefundTransaction( async function prepareInputSignData( transaction: any, inputIndex: number, - deposit: Deposit, + deposit: DepositReceipt, refunderKeyRing: any ): Promise<{ refunderPublicKey: string @@ -181,10 +178,6 @@ async function prepareInputSignData( const previousOutpoint = transaction.inputs[inputIndex].prevout const previousOutput = transaction.view.getOutput(previousOutpoint) - if (previousOutput.value != deposit.amount.toNumber()) { - throw new Error("Mismatch between amount in deposit and deposit refund tx") - } - const refunderPublicKey = refunderKeyRing.getPublicKey("hex") if ( BitcoinHashUtils.computeHash160(refunderKeyRing.getPublicKey("hex")) != @@ -199,11 +192,8 @@ async function prepareInputSignData( throw new Error("Refunder public key must be compressed") } - // eslint-disable-next-line no-unused-vars - const { amount, vault, ...depositScriptParameters } = deposit - const depositScript = bcoin.Script.fromRaw( - Buffer.from(await assembleDepositScript(depositScriptParameters), "hex") + Buffer.from(await assembleDepositScript(deposit), "hex") ) return { @@ -225,7 +215,7 @@ async function prepareInputSignData( async function signP2SHDepositInput( transaction: any, inputIndex: number, - deposit: Deposit, + deposit: DepositReceipt, refunderKeyRing: any ) { const { refunderPublicKey, depositScript, previousOutputValue } = @@ -266,7 +256,7 @@ async function signP2SHDepositInput( async function signP2WSHDepositInput( transaction: any, inputIndex: number, - deposit: Deposit, + deposit: DepositReceipt, refunderKeyRing: any ) { const { refunderPublicKey, depositScript, previousOutputValue } = @@ -309,17 +299,3 @@ function locktimeToUnixTimestamp(locktime: string): number { return parseInt(bigEndianLocktime, 16) } - -/** - * Validates whether the provided input parameters are correct. - * @param deposit - Data of the deposit to be refunded. - * @param utxo - UTXO that was created during depositing that needs be refunded. - * @returns Empty return. - */ -function validateInputParameters(deposit: Deposit, utxo: BitcoinUtxo) { - validateDepositScriptParameters(deposit) - - if (!deposit.amount.eq(utxo.value)) { - throw new Error("Mismatch between provided deposit amount and utxo value") - } -} diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index 2961ece02..cfe828a69 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -12,7 +12,7 @@ import { BitcoinHashUtils, } from "./lib/bitcoin" import { assembleDepositScript } from "./deposit" -import { Bridge, ChainIdentifier, Deposit } from "./lib/contracts" +import { Bridge, ChainIdentifier, DepositReceipt } from "./lib/contracts" /** * Submits a deposit sweep by combining all the provided P2(W)SH UTXOs and @@ -42,7 +42,7 @@ export async function submitDepositSweepTransaction( walletPrivateKey: string, witness: boolean, utxos: BitcoinUtxo[], - deposits: Deposit[], + deposits: DepositReceipt[], mainUtxo?: BitcoinUtxo ): Promise<{ transactionHash: BitcoinTxHash @@ -115,7 +115,7 @@ export async function assembleDepositSweepTransaction( walletPrivateKey: string, witness: boolean, utxos: (BitcoinUtxo & BitcoinRawTx)[], - deposits: Deposit[], + deposits: DepositReceipt[], mainUtxo?: BitcoinUtxo & BitcoinRawTx ): Promise<{ transactionHash: BitcoinTxHash @@ -180,12 +180,11 @@ export async function assembleDepositSweepTransaction( // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any // order - const utxosWithDeposits: (BitcoinUtxo & BitcoinRawTx & Deposit)[] = utxos.map( - (utxo, index) => ({ + const utxosWithDeposits: (BitcoinUtxo & BitcoinRawTx & DepositReceipt)[] = + utxos.map((utxo, index) => ({ ...utxo, ...deposits[index], - }) - ) + })) for (let i = 0; i < transaction.inputs.length; i++) { const previousOutpoint = transaction.inputs[i].prevout @@ -274,7 +273,7 @@ async function signMainUtxoInput( async function signP2SHDepositInput( transaction: any, inputIndex: number, - deposit: Deposit, + deposit: DepositReceipt, walletKeyRing: any ): Promise { const { walletPublicKey, depositScript, previousOutputValue } = @@ -310,7 +309,7 @@ async function signP2SHDepositInput( async function signP2WSHDepositInput( transaction: any, inputIndex: number, - deposit: Deposit, + deposit: DepositReceipt, walletKeyRing: any ): Promise { const { walletPublicKey, depositScript, previousOutputValue } = @@ -346,7 +345,7 @@ async function signP2WSHDepositInput( async function prepareInputSignData( transaction: any, inputIndex: number, - deposit: Deposit, + deposit: DepositReceipt, walletKeyRing: any ): Promise<{ walletPublicKey: string @@ -356,10 +355,6 @@ async function prepareInputSignData( const previousOutpoint = transaction.inputs[inputIndex].prevout const previousOutput = transaction.view.getOutput(previousOutpoint) - if (previousOutput.value != deposit.amount.toNumber()) { - throw new Error("Mismatch between amount in deposit and deposit tx") - } - const walletPublicKey = walletKeyRing.getPublicKey("hex") if ( BitcoinHashUtils.computeHash160(walletKeyRing.getPublicKey("hex")) != @@ -374,11 +369,8 @@ async function prepareInputSignData( throw new Error("Wallet public key must be compressed") } - // eslint-disable-next-line no-unused-vars - const { amount, vault, ...depositScriptParameters } = deposit - const depositScript = bcoin.Script.fromRaw( - Buffer.from(await assembleDepositScript(depositScriptParameters), "hex") + Buffer.from(await assembleDepositScript(deposit), "hex") ) return { diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts index 4d4684998..78b506dd9 100644 --- a/typescript/src/deposit.ts +++ b/typescript/src/deposit.ts @@ -13,14 +13,23 @@ import { import { Bridge, ChainIdentifier, - Deposit, - DepositScriptParameters, - RevealedDeposit, + DepositReceipt, + DepositRequest, } from "./lib/contracts" import { Hex } from "./lib/utils" const { opcodes } = bcoin.script.common +/** + * Deposit receipt enhanced with deposit amount information. + */ +export type DepositReceiptWithAmount = DepositReceipt & { + /** + * Deposit amount in satoshis. + */ + amount: BigNumber +} + /** * Submits a deposit by creating and broadcasting a Bitcoin P2(W)SH * deposit transaction. @@ -34,7 +43,7 @@ const { opcodes } = bcoin.script.common * - the deposit UTXO produced by this transaction. */ export async function submitDepositTransaction( - deposit: Deposit, + deposit: DepositReceiptWithAmount, depositorPrivateKey: string, bitcoinClient: BitcoinClient, witness: boolean @@ -91,7 +100,7 @@ export async function submitDepositTransaction( * - the deposit transaction in the raw format */ export async function assembleDepositTransaction( - deposit: Deposit, + deposit: DepositReceiptWithAmount, utxos: (BitcoinUtxo & BitcoinRawTx)[], depositorPrivateKey: string, witness: boolean @@ -152,9 +161,9 @@ export async function assembleDepositTransaction( * @returns Script as an un-prefixed hex string. */ export async function assembleDepositScript( - deposit: DepositScriptParameters + deposit: DepositReceipt ): Promise { - validateDepositScriptParameters(deposit) + validateDepositReceipt(deposit) // All HEXes pushed to the script must be un-prefixed. const script = new bcoin.Script() @@ -187,15 +196,12 @@ export async function assembleDepositScript( // eslint-disable-next-line valid-jsdoc /** - * Validates the given deposit script parameters. Throws in case of a - * validation error. - * @param deposit - The validated deposit script parameters. + * Validates the given deposit receipt. Throws in case of a validation error. + * @param deposit - The validated deposit receipt. * @dev This function does not validate the depositor's identifier as its * validity is chain-specific. This parameter must be validated outside. */ -export function validateDepositScriptParameters( - deposit: DepositScriptParameters -) { +export function validateDepositReceipt(deposit: DepositReceipt) { if (deposit.blindingFactor.length != 16) { throw new Error("Blinding factor must be an 8-byte number") } @@ -250,7 +256,7 @@ export function calculateDepositRefundLocktime( * @returns Buffer with script hash. */ export async function calculateDepositScriptHash( - deposit: DepositScriptParameters, + deposit: DepositReceipt, witness: boolean ): Promise { const script = await assembleDepositScript(deposit) @@ -270,7 +276,7 @@ export async function calculateDepositScriptHash( * @returns Address as string. */ export async function calculateDepositAddress( - deposit: DepositScriptParameters, + deposit: DepositReceipt, network: BitcoinNetwork, witness: boolean ): Promise { @@ -295,7 +301,7 @@ export async function calculateDepositAddress( */ export async function revealDeposit( utxo: BitcoinUtxo, - deposit: DepositScriptParameters, + deposit: DepositReceipt, bitcoinClient: BitcoinClient, bridge: Bridge, vault?: ChainIdentifier @@ -316,7 +322,7 @@ export async function revealDeposit( export async function getRevealedDeposit( utxo: BitcoinUtxo, bridge: Bridge -): Promise { +): Promise { return bridge.deposits(utxo.transactionHash, utxo.outputIndex) } diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index eaea4f64b..503acf77b 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -48,7 +48,7 @@ export interface Bridge { revealDeposit( depositTx: BitcoinRawTxVectors, depositOutputIndex: number, - deposit: DepositScriptParameters, + deposit: DepositReceipt, vault?: ChainIdentifier ): Promise // TODO: Update to Hex @@ -62,7 +62,7 @@ export interface Bridge { deposits( depositTxHash: BitcoinTxHash, depositOutputIndex: number - ): Promise + ): Promise /** * Requests a redemption from the on-chain contract. @@ -180,19 +180,15 @@ export interface Bridge { // strings with a Hex type. /** - * Represents a deposit. + * Represents a deposit receipt. The receipt holds all information required + * to build a unique deposit address on Bitcoin chain. */ -export interface Deposit { +export interface DepositReceipt { /** * Depositor's chain identifier. */ depositor: ChainIdentifier - /** - * Deposit amount in satoshis. - */ - amount: BigNumber - /** * An 8-byte blinding factor as an un-prefixed hex string. Must be unique * for the given depositor, wallet public key and refund public key. @@ -219,35 +215,27 @@ export interface Deposit { * A 4-byte little-endian refund locktime as an un-prefixed hex string. */ refundLocktime: string +} + +/** + * Represents a deposit request revealed to the on-chain bridge. + */ +export interface DepositRequest { + /** + * Depositor's chain identifier. + */ + depositor: ChainIdentifier + + /** + * Deposit amount in satoshis. + */ + amount: BigNumber /** * Optional identifier of the vault the deposit should be routed in. */ vault?: ChainIdentifier -} -/** - * Helper type that groups deposit's fields required to assemble a deposit - * script. - */ -export type DepositScriptParameters = Pick< - Deposit, - | "depositor" - | "blindingFactor" - | "refundLocktime" - | "walletPublicKeyHash" - | "refundPublicKeyHash" -> & {} - -/** - * Represents a deposit revealed to the on-chain bridge. This type emphasizes - * the on-chain state of the revealed deposit and omits the deposit script - * parameters as they are not relevant in this context. - */ -export type RevealedDeposit = Pick< - Deposit, - "depositor" | "amount" | "vault" -> & { /** * UNIX timestamp the deposit was revealed at. */ @@ -267,10 +255,11 @@ export type RevealedDeposit = Pick< /** * Represents an event emitted on deposit reveal to the on-chain bridge. */ -export type DepositRevealedEvent = Deposit & { - fundingTxHash: BitcoinTxHash - fundingOutputIndex: number -} & ChainEvent +export type DepositRevealedEvent = DepositReceipt & + Pick & { + fundingTxHash: BitcoinTxHash + fundingOutputIndex: number + } & ChainEvent /** * Represents a redemption request. diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index 1d424dd1b..fda724628 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -15,8 +15,8 @@ import { RedemptionRequest, RedemptionRequestedEvent, DepositRevealedEvent, - DepositScriptParameters, - RevealedDeposit, + DepositReceipt, + DepositRequest, } from "../contracts" import { Event as EthersEvent } from "@ethersproject/contracts" import { BigNumber, constants, ContractTransaction, utils } from "ethers" @@ -200,7 +200,7 @@ export class EthereumBridge async revealDeposit( depositTx: BitcoinRawTxVectors, depositOutputIndex: number, - deposit: DepositScriptParameters, + deposit: DepositReceipt, vault?: ChainIdentifier ): Promise { const depositTxParam = { @@ -391,7 +391,7 @@ export class EthereumBridge async deposits( depositTxHash: BitcoinTxHash, depositOutputIndex: number - ): Promise { + ): Promise { const depositKey = EthereumBridge.buildDepositKey( depositTxHash, depositOutputIndex @@ -404,7 +404,7 @@ export class EthereumBridge } ) - return this.parseRevealedDeposit(deposit) + return this.parseDepositRequest(deposit) } /** @@ -429,13 +429,13 @@ export class EthereumBridge } /** - * Parses a revealed deposit using data fetched from the on-chain contract. - * @param deposit Data of the revealed deposit. - * @returns Parsed revealed deposit. + * Parses a deposit request using data fetched from the on-chain contract. + * @param deposit Data of the deposit request. + * @returns Parsed deposit request. */ - private parseRevealedDeposit( + private parseDepositRequest( deposit: DepositRequestTypechain - ): RevealedDeposit { + ): DepositRequest { return { depositor: EthereumAddress.from(deposit.depositor), amount: BigNumber.from(deposit.amount), diff --git a/typescript/test/data/deposit-refund.ts b/typescript/test/data/deposit-refund.ts index 00ea5c0ef..4edde113c 100644 --- a/typescript/test/data/deposit-refund.ts +++ b/typescript/test/data/deposit-refund.ts @@ -1,6 +1,6 @@ import { BigNumber } from "ethers" import { BitcoinRawTx, BitcoinUtxo, BitcoinTxHash } from "../../src/lib/bitcoin" -import { Deposit } from "../../src/lib/contracts" +import { DepositReceipt } from "../../src/lib/contracts" import { calculateDepositRefundLocktime } from "../../src/deposit" import { EthereumAddress } from "../../src/lib/ethereum" @@ -18,7 +18,7 @@ export const refunderPrivateKey = export interface DepositRefundTestData { deposit: { utxo: BitcoinUtxo & BitcoinRawTx - data: Deposit + data: DepositReceipt } refunderAddress: string expectedRefund: { @@ -55,7 +55,6 @@ export const depositRefundOfWitnessDepositAndWitnessRefunderAddress: DepositRefu depositor: EthereumAddress.from( "934b98637ca318a4d6e7ca6ffd1690b8e77df637" ), - amount: BigNumber.from(100000), walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "1b67f27537c7b30a23d8ccefb96a4cacfc72d9a1", blindingFactor: "f9f0c90d00039523", @@ -110,7 +109,6 @@ export const depositRefundOfNonWitnessDepositAndWitnessRefunderAddress: DepositR depositor: EthereumAddress.from( "934b98637ca318a4d6e7ca6ffd1690b8e77df637" ), - amount: BigNumber.from(90000), walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "1b67f27537c7b30a23d8ccefb96a4cacfc72d9a1", blindingFactor: "f9f0c90d00039523", @@ -165,7 +163,6 @@ export const depositRefundOfWitnessDepositAndNonWitnessRefunderAddress: DepositR depositor: EthereumAddress.from( "934b98637ca318a4d6e7ca6ffd1690b8e77df637" ), - amount: BigNumber.from(150000), walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "1b67f27537c7b30a23d8ccefb96a4cacfc72d9a1", blindingFactor: "f9f0c90d00039523", diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index abaf1d7dd..fd85dcd64 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -7,7 +7,7 @@ import { BitcoinTxMerkleBranch, BitcoinTxHash, } from "../../src/lib/bitcoin" -import { Deposit } from "../../src/lib/contracts" +import { DepositReceipt } from "../../src/lib/contracts" import { calculateDepositRefundLocktime } from "../../src/deposit" import { BigNumber } from "ethers" import { EthereumAddress } from "../../src/lib/ethereum" @@ -26,7 +26,7 @@ export const NO_MAIN_UTXO = { export interface DepositSweepTestData { deposits: { utxo: BitcoinUtxo & BitcoinRawTx - data: Deposit + data: DepositReceipt }[] mainUtxo: BitcoinUtxo & BitcoinRawTx witness: boolean @@ -64,7 +64,6 @@ export const depositSweepWithNoMainUtxoAndWitnessOutput: DepositSweepTestData = depositor: EthereumAddress.from( "934b98637ca318a4d6e7ca6ffd1690b8e77df637" ), - amount: BigNumber.from(25000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. @@ -93,8 +92,6 @@ export const depositSweepWithNoMainUtxoAndWitnessOutput: DepositSweepTestData = depositor: EthereumAddress.from( "934b98637ca318a4d6e7ca6ffd1690b8e77df637" ), - - amount: BigNumber.from(12000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. @@ -154,7 +151,6 @@ export const depositSweepWithNoMainUtxoAndNonWitnessOutput: DepositSweepTestData depositor: EthereumAddress.from( "934b98637ca318a4d6e7ca6ffd1690b8e77df637" ), - amount: BigNumber.from(15000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. @@ -207,7 +203,6 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa depositor: EthereumAddress.from( "934b98637ca318a4d6e7ca6ffd1690b8e77df637" ), - amount: BigNumber.from(17000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. @@ -237,7 +232,6 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa depositor: EthereumAddress.from( "934b98637ca318a4d6e7ca6ffd1690b8e77df637" ), - amount: BigNumber.from(10000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. @@ -333,7 +327,6 @@ export const depositSweepWithNonWitnessMainUtxoAndWitnessOutput: DepositSweepTes depositor: EthereumAddress.from( "934b98637ca318a4d6e7ca6ffd1690b8e77df637" ), - amount: BigNumber.from(19000), // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index c23e0835d..b92c63b84 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -919,31 +919,6 @@ describe("Sweep", () => { } ) - context( - "when there is a mismatch between the UTXO's value and amount in deposit", - () => { - const utxoWithRaw = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo - // Use a deposit that does not match the UTXO - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].data - - it("should revert", async () => { - await expect( - assembleDepositSweepTransaction( - fee, - testnetWalletPrivateKey, - true, - [utxoWithRaw], - [deposit] - ) - ).to.be.rejectedWith( - "Mismatch between amount in deposit and deposit tx" - ) - }) - } - ) - context("when the main UTXO does not belong to the wallet", () => { const utxoWithRaw = depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index c8cac6779..5d327fe58 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -13,11 +13,7 @@ import { BitcoinTxHash, BitcoinUtxo, } from "../src/lib/bitcoin" -import { - Deposit, - DepositScriptParameters, - RevealedDeposit, -} from "../src/lib/contracts" +import { DepositRequest } from "../src/lib/contracts" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import bcoin from "bcoin" import { @@ -26,6 +22,7 @@ import { calculateDepositAddress, calculateDepositRefundLocktime, calculateDepositScriptHash, + DepositReceiptWithAmount, getRevealedDeposit, revealDeposit, submitDepositTransaction, @@ -39,7 +36,7 @@ describe("Deposit", () => { const depositCreatedAt: number = 1640181600 const depositRefundLocktimeDuration: number = 2592000 - const deposit: Deposit = { + const deposit: DepositReceiptWithAmount = { depositor: EthereumAddress.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), amount: BigNumber.from(10000), // 0.0001 BTC // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. @@ -53,14 +50,6 @@ describe("Deposit", () => { ), } - const depositScriptParameters: DepositScriptParameters = { - depositor: deposit.depositor, - walletPublicKeyHash: deposit.walletPublicKeyHash, - refundPublicKeyHash: deposit.refundPublicKeyHash, - blindingFactor: deposit.blindingFactor, - refundLocktime: deposit.refundLocktime, - } - // All test scenarios using the deposit script within `Deposit` group // expect the same deposit script: const expectedDepositScript = @@ -518,7 +507,7 @@ describe("Deposit", () => { let script: string beforeEach(async () => { - script = await assembleDepositScript(depositScriptParameters) + script = await assembleDepositScript(deposit) }) it("should return script with proper structure", async () => { @@ -567,10 +556,7 @@ describe("Deposit", () => { let scriptHash: Buffer beforeEach(async () => { - scriptHash = await calculateDepositScriptHash( - depositScriptParameters, - true - ) + scriptHash = await calculateDepositScriptHash(deposit, true) }) it("should return proper witness script hash", async () => { @@ -591,10 +577,7 @@ describe("Deposit", () => { let scriptHash: Buffer beforeEach(async () => { - scriptHash = await calculateDepositScriptHash( - depositScriptParameters, - false - ) + scriptHash = await calculateDepositScriptHash(deposit, false) }) it("should return proper non-witness script hash", async () => { @@ -619,7 +602,7 @@ describe("Deposit", () => { context("when witness option is true", () => { beforeEach(async () => { address = await calculateDepositAddress( - depositScriptParameters, + deposit, BitcoinNetwork.Mainnet, true ) @@ -637,7 +620,7 @@ describe("Deposit", () => { context("when witness option is false", () => { beforeEach(async () => { address = await calculateDepositAddress( - depositScriptParameters, + deposit, BitcoinNetwork.Mainnet, false ) @@ -657,7 +640,7 @@ describe("Deposit", () => { context("when witness option is true", () => { beforeEach(async () => { address = await calculateDepositAddress( - depositScriptParameters, + deposit, BitcoinNetwork.Testnet, true ) @@ -675,7 +658,7 @@ describe("Deposit", () => { context("when witness option is false", () => { beforeEach(async () => { address = await calculateDepositAddress( - depositScriptParameters, + deposit, BitcoinNetwork.Testnet, false ) @@ -737,7 +720,7 @@ describe("Deposit", () => { describe("getRevealedDeposit", () => { let depositUtxo: BitcoinUtxo - let revealedDeposit: RevealedDeposit + let revealedDeposit: DepositRequest let bridge: MockBridge beforeEach(async () => { @@ -752,13 +735,13 @@ describe("Deposit", () => { revealedDeposit = { depositor: deposit.depositor, amount: deposit.amount, - vault: deposit.vault, + vault: EthereumAddress.from("954b98637ca318a4d6e7ca6ffd1690b8e77df637"), revealedAt: 1654774330, sweptAt: 1655033516, treasuryFee: BigNumber.from(200), } - const revealedDeposits = new Map() + const revealedDeposits = new Map() revealedDeposits.set( MockBridge.buildDepositKey( depositUtxo.transactionHash, diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index 481234a82..8e7ecc118 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -7,9 +7,9 @@ import { Wallet, RedemptionRequest, RedemptionRequestedEvent, - Deposit, + DepositReceipt, DepositRevealedEvent, - RevealedDeposit, + DepositRequest, } from "../../src/lib/contracts" import { BitcoinRawTxVectors, @@ -32,7 +32,7 @@ interface DepositSweepProofLogEntry { interface RevealDepositLogEntry { depositTx: BitcoinRawTxVectors depositOutputIndex: number - deposit: Deposit + deposit: DepositReceipt } interface RequestRedemptionLogEntry { @@ -69,7 +69,7 @@ export class MockBridge implements Bridge { private _revealDepositLog: RevealDepositLogEntry[] = [] private _requestRedemptionLog: RequestRedemptionLogEntry[] = [] private _redemptionProofLog: RedemptionProofLogEntry[] = [] - private _deposits = new Map() + private _deposits = new Map() private _activeWalletPublicKey: string | undefined private _newWalletRegisteredEvents: NewWalletRegisteredEvent[] = [] private _newWalletRegisteredEventsLog: NewWalletRegisteredEventsLog[] = [] @@ -116,7 +116,7 @@ export class MockBridge implements Bridge { return this._walletsLog } - setDeposits(value: Map) { + setDeposits(value: Map) { this._deposits = value } @@ -169,7 +169,7 @@ export class MockBridge implements Bridge { revealDeposit( depositTx: BitcoinRawTxVectors, depositOutputIndex: number, - deposit: Deposit + deposit: DepositReceipt ): Promise { this._revealDepositLog.push({ depositTx, depositOutputIndex, deposit }) return new Promise((resolve, _) => { @@ -183,8 +183,8 @@ export class MockBridge implements Bridge { deposits( depositTxHash: BitcoinTxHash, depositOutputIndex: number - ): Promise { - return new Promise((resolve, _) => { + ): Promise { + return new Promise((resolve, _) => { const depositKey = MockBridge.buildDepositKey( depositTxHash, depositOutputIndex @@ -192,7 +192,7 @@ export class MockBridge implements Bridge { resolve( this._deposits.has(depositKey) - ? (this._deposits.get(depositKey) as RevealedDeposit) + ? (this._deposits.get(depositKey) as DepositRequest) : { depositor: EthereumAddress.from(constants.AddressZero), amount: BigNumber.from(0), From dbfe946535090806701ae0f644e4516332f79206 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 28 Sep 2023 15:22:15 +0200 Subject: [PATCH 171/205] Implement the `./services/deposits` feature module Here we remove the existing `deposit.ts` file, move it to the new `./services/deposits` feature module and do a general refactoring to make it easy to use. --- typescript/src/deposit-refund.ts | 6 +- typescript/src/deposit-sweep.ts | 4 +- typescript/src/deposit.ts | 339 ------- typescript/src/index.ts | 11 - typescript/src/lib/bitcoin/tx.ts | 28 + typescript/src/lib/contracts/bridge.ts | 24 + typescript/src/lib/contracts/index.ts | 15 + typescript/src/lib/contracts/tbtc-vault.ts | 5 + typescript/src/lib/ethereum/tbtc-vault.ts | 9 + typescript/src/services/deposits/deposit.ts | 237 +++++ .../src/services/deposits/deposits-service.ts | 97 ++ typescript/src/services/deposits/funding.ts | 155 +++ typescript/src/services/deposits/index.ts | 3 + typescript/test/bitcoin.test.ts | 63 +- typescript/test/data/deposit-refund.ts | 23 +- typescript/test/data/deposit-sweep.ts | 32 +- typescript/test/deposit.test.ts | 914 ++++++++---------- typescript/test/utils/mock-tbtc-contracts.ts | 19 + typescript/test/utils/mock-tbtc-vault.ts | 83 ++ typescript/test/utils/mock-wallet-registry.ts | 35 + 20 files changed, 1229 insertions(+), 873 deletions(-) delete mode 100644 typescript/src/deposit.ts create mode 100644 typescript/src/services/deposits/deposit.ts create mode 100644 typescript/src/services/deposits/deposits-service.ts create mode 100644 typescript/src/services/deposits/funding.ts create mode 100644 typescript/src/services/deposits/index.ts create mode 100644 typescript/test/utils/mock-tbtc-contracts.ts create mode 100644 typescript/test/utils/mock-tbtc-vault.ts create mode 100644 typescript/test/utils/mock-wallet-registry.ts diff --git a/typescript/src/deposit-refund.ts b/typescript/src/deposit-refund.ts index 0cf2bac52..952516e9a 100644 --- a/typescript/src/deposit-refund.ts +++ b/typescript/src/deposit-refund.ts @@ -9,8 +9,8 @@ import { BitcoinHashUtils, BitcoinPublicKeyUtils, } from "./lib/bitcoin" -import { assembleDepositScript, validateDepositReceipt } from "./deposit" -import { DepositReceipt } from "./lib/contracts" +import { DepositReceipt, validateDepositReceipt } from "./lib/contracts" +import { DepositScript } from "./services/deposits" /** * Submits a deposit refund by creating and broadcasting a Bitcoin P2(W)PKH @@ -193,7 +193,7 @@ async function prepareInputSignData( } const depositScript = bcoin.Script.fromRaw( - Buffer.from(await assembleDepositScript(deposit), "hex") + Buffer.from(await DepositScript.fromReceipt(deposit).getPlainText(), "hex") ) return { diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts index cfe828a69..440bfa219 100644 --- a/typescript/src/deposit-sweep.ts +++ b/typescript/src/deposit-sweep.ts @@ -11,8 +11,8 @@ import { BitcoinTxHash, BitcoinHashUtils, } from "./lib/bitcoin" -import { assembleDepositScript } from "./deposit" import { Bridge, ChainIdentifier, DepositReceipt } from "./lib/contracts" +import { DepositScript } from "./services/deposits" /** * Submits a deposit sweep by combining all the provided P2(W)SH UTXOs and @@ -370,7 +370,7 @@ async function prepareInputSignData( } const depositScript = bcoin.Script.fromRaw( - Buffer.from(await assembleDepositScript(deposit), "hex") + Buffer.from(await DepositScript.fromReceipt(deposit).getPlainText(), "hex") ) return { diff --git a/typescript/src/deposit.ts b/typescript/src/deposit.ts deleted file mode 100644 index 78b506dd9..000000000 --- a/typescript/src/deposit.ts +++ /dev/null @@ -1,339 +0,0 @@ -import bcoin from "bcoin" -import { BigNumber } from "ethers" -import { - BitcoinClient, - BitcoinNetwork, - toBcoinNetwork, - extractBitcoinRawTxVectors, - BitcoinPrivateKeyUtils, - BitcoinRawTx, - BitcoinUtxo, - BitcoinTxHash, -} from "./lib/bitcoin" -import { - Bridge, - ChainIdentifier, - DepositReceipt, - DepositRequest, -} from "./lib/contracts" -import { Hex } from "./lib/utils" - -const { opcodes } = bcoin.script.common - -/** - * Deposit receipt enhanced with deposit amount information. - */ -export type DepositReceiptWithAmount = DepositReceipt & { - /** - * Deposit amount in satoshis. - */ - amount: BigNumber -} - -/** - * Submits a deposit by creating and broadcasting a Bitcoin P2(W)SH - * deposit transaction. - * @param deposit - Details of the deposit. - * @param depositorPrivateKey - Bitcoin private key of the depositor. - * @param bitcoinClient - Bitcoin client used to interact with the network. - * @param witness - If true, a witness (P2WSH) transaction will be created. - * Otherwise, a legacy P2SH transaction will be made. - * @returns The outcome consisting of: - * - the deposit transaction hash, - * - the deposit UTXO produced by this transaction. - */ -export async function submitDepositTransaction( - deposit: DepositReceiptWithAmount, - depositorPrivateKey: string, - bitcoinClient: BitcoinClient, - witness: boolean -): Promise<{ - transactionHash: BitcoinTxHash - depositUtxo: BitcoinUtxo -}> { - const depositorKeyRing = - BitcoinPrivateKeyUtils.createKeyRing(depositorPrivateKey) - const depositorAddress = depositorKeyRing.getAddress("string") - - const utxos = await bitcoinClient.findAllUnspentTransactionOutputs( - depositorAddress - ) - - const utxosWithRaw: (BitcoinUtxo & BitcoinRawTx)[] = [] - for (const utxo of utxos) { - const utxoRawTransaction = await bitcoinClient.getRawTransaction( - utxo.transactionHash - ) - - utxosWithRaw.push({ - ...utxo, - transactionHex: utxoRawTransaction.transactionHex, - }) - } - - const { transactionHash, depositUtxo, rawTransaction } = - await assembleDepositTransaction( - deposit, - utxosWithRaw, - depositorPrivateKey, - witness - ) - - await bitcoinClient.broadcast(rawTransaction) - - return { - transactionHash, - depositUtxo, - } -} - -/** - * Assembles a Bitcoin P2(W)SH deposit transaction. - * @param deposit - Details of the deposit. - * @param utxos - UTXOs that should be used as transaction inputs. - * @param depositorPrivateKey - Bitcoin private key of the depositor. - * @param witness - If true, a witness (P2WSH) transaction will be created. - * Otherwise, a legacy P2SH transaction will be made. - * @returns The outcome consisting of: - * - the deposit transaction hash, - * - the deposit UTXO produced by this transaction. - * - the deposit transaction in the raw format - */ -export async function assembleDepositTransaction( - deposit: DepositReceiptWithAmount, - utxos: (BitcoinUtxo & BitcoinRawTx)[], - depositorPrivateKey: string, - witness: boolean -): Promise<{ - transactionHash: BitcoinTxHash - depositUtxo: BitcoinUtxo - rawTransaction: BitcoinRawTx -}> { - const depositorKeyRing = - BitcoinPrivateKeyUtils.createKeyRing(depositorPrivateKey) - const depositorAddress = depositorKeyRing.getAddress("string") - - const inputCoins = utxos.map((utxo) => - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), - utxo.outputIndex, - -1 - ) - ) - - const transaction = new bcoin.MTX() - - const scriptHash = await calculateDepositScriptHash(deposit, witness) - - transaction.addOutput({ - script: witness - ? bcoin.Script.fromProgram(0, scriptHash) - : bcoin.Script.fromScripthash(scriptHash), - value: deposit.amount.toNumber(), - }) - - await transaction.fund(inputCoins, { - rate: null, // set null explicitly to always use the default value - changeAddress: depositorAddress, - subtractFee: false, // do not subtract the fee from outputs - }) - - transaction.sign(depositorKeyRing) - - const transactionHash = BitcoinTxHash.from(transaction.txid()) - - return { - transactionHash, - depositUtxo: { - transactionHash, - outputIndex: 0, // The deposit is always the first output. - value: deposit.amount, - }, - rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), - }, - } -} - -/** - * Assembles a Bitcoin locking script for P2(W)SH deposit transaction. - * @param deposit - Details of the deposit. - * @returns Script as an un-prefixed hex string. - */ -export async function assembleDepositScript( - deposit: DepositReceipt -): Promise { - validateDepositReceipt(deposit) - - // All HEXes pushed to the script must be un-prefixed. - const script = new bcoin.Script() - script.clear() - script.pushData(Buffer.from(deposit.depositor.identifierHex, "hex")) - script.pushOp(opcodes.OP_DROP) - script.pushData(Buffer.from(deposit.blindingFactor, "hex")) - script.pushOp(opcodes.OP_DROP) - script.pushOp(opcodes.OP_DUP) - script.pushOp(opcodes.OP_HASH160) - script.pushData(Buffer.from(deposit.walletPublicKeyHash, "hex")) - script.pushOp(opcodes.OP_EQUAL) - script.pushOp(opcodes.OP_IF) - script.pushOp(opcodes.OP_CHECKSIG) - script.pushOp(opcodes.OP_ELSE) - script.pushOp(opcodes.OP_DUP) - script.pushOp(opcodes.OP_HASH160) - script.pushData(Buffer.from(deposit.refundPublicKeyHash, "hex")) - script.pushOp(opcodes.OP_EQUALVERIFY) - script.pushData(Buffer.from(deposit.refundLocktime, "hex")) - script.pushOp(opcodes.OP_CHECKLOCKTIMEVERIFY) - script.pushOp(opcodes.OP_DROP) - script.pushOp(opcodes.OP_CHECKSIG) - script.pushOp(opcodes.OP_ENDIF) - script.compile() - - // Return script as HEX string. - return script.toRaw().toString("hex") -} - -// eslint-disable-next-line valid-jsdoc -/** - * Validates the given deposit receipt. Throws in case of a validation error. - * @param deposit - The validated deposit receipt. - * @dev This function does not validate the depositor's identifier as its - * validity is chain-specific. This parameter must be validated outside. - */ -export function validateDepositReceipt(deposit: DepositReceipt) { - if (deposit.blindingFactor.length != 16) { - throw new Error("Blinding factor must be an 8-byte number") - } - if (deposit.walletPublicKeyHash.length != 40) { - throw new Error("Invalid wallet public key hash") - } - - if (deposit.refundPublicKeyHash.length != 40) { - throw new Error("Invalid refund public key hash") - } - - if (deposit.refundLocktime.length != 8) { - throw new Error("Refund locktime must be a 4-byte number") - } -} - -/** - * Calculates a refund locktime parameter for the given deposit creation timestamp. - * Throws if the resulting locktime is not a 4-byte number. - * @param depositCreatedAt - Unix timestamp in seconds determining the moment - * of deposit creation. - * @param depositRefundLocktimeDuration - Deposit refund locktime duration in seconds. - * @returns A 4-byte little-endian deposit refund locktime as an un-prefixed - * hex string. - */ -export function calculateDepositRefundLocktime( - depositCreatedAt: number, - depositRefundLocktimeDuration: number -): string { - // Locktime is a Unix timestamp in seconds, computed as deposit creation - // timestamp plus locktime duration. - const locktime = BigNumber.from( - depositCreatedAt + depositRefundLocktimeDuration - ) - - const locktimeHex: Hex = Hex.from(locktime.toHexString()) - - if (locktimeHex.toString().length != 8) { - throw new Error("Refund locktime must be a 4 bytes number") - } - - // Bitcoin locktime is interpreted as little-endian integer so we must - // adhere to that convention by converting the locktime accordingly. - return locktimeHex.reverse().toString() -} - -/** - * Calculates a Bitcoin locking script hash for P2(W)SH deposit transaction. - * @param deposit - Details of the deposit. - * @param witness - If true, a witness script hash will be created. - * Otherwise, a legacy script hash will be made. - * @returns Buffer with script hash. - */ -export async function calculateDepositScriptHash( - deposit: DepositReceipt, - witness: boolean -): Promise { - const script = await assembleDepositScript(deposit) - // Parse the script from HEX string. - const parsedScript = bcoin.Script.fromRaw(Buffer.from(script, "hex")) - // If witness script hash should be produced, SHA256 should be used. - // Legacy script hash needs HASH160. - return witness ? parsedScript.sha256() : parsedScript.hash160() -} - -/** - * Calculates a Bitcoin target address for P2(W)SH deposit transaction. - * @param deposit - Details of the deposit. - * @param network - Network that the address should be created for. - * @param witness - If true, a witness address will be created. - * Otherwise, a legacy address will be made. - * @returns Address as string. - */ -export async function calculateDepositAddress( - deposit: DepositReceipt, - network: BitcoinNetwork, - witness: boolean -): Promise { - const scriptHash = await calculateDepositScriptHash(deposit, witness) - const address = witness - ? bcoin.Address.fromWitnessScripthash(scriptHash) - : bcoin.Address.fromScripthash(scriptHash) - return address.toString(toBcoinNetwork(network)) -} - -/** - * Reveals the given deposit to the on-chain Bridge contract. - * @param utxo - Deposit UTXO of the revealed deposit - * @param deposit - Data of the revealed deposit - * @param bitcoinClient - Bitcoin client used to interact with the network - * @param bridge - Handle to the Bridge on-chain contract - * @param vault - vault - * @returns Transaction hash of the reveal deposit transaction as string - * @dev The caller must ensure that the given deposit data are valid and - * the given deposit UTXO actually originates from a deposit transaction - * that matches the given deposit data. - */ -export async function revealDeposit( - utxo: BitcoinUtxo, - deposit: DepositReceipt, - bitcoinClient: BitcoinClient, - bridge: Bridge, - vault?: ChainIdentifier -): Promise { - const depositTx = extractBitcoinRawTxVectors( - await bitcoinClient.getRawTransaction(utxo.transactionHash) - ) - - return await bridge.revealDeposit(depositTx, utxo.outputIndex, deposit, vault) -} - -/** - * Gets a revealed deposit from the bridge. - * @param utxo Deposit UTXO of the revealed deposit - * @param bridge Handle to the Bridge on-chain contract - * @returns Revealed deposit data. - */ -export async function getRevealedDeposit( - utxo: BitcoinUtxo, - bridge: Bridge -): Promise { - return bridge.deposits(utxo.transactionHash, utxo.outputIndex) -} - -/** - * Suggests a wallet that should be used as the deposit target at the given moment. - * @param bridge Handle to the Bridge on-chain contract. - * @returns Compressed (33 bytes long with 02 or 03 prefix) public key of - * the wallet. - */ -export async function suggestDepositWallet( - bridge: Bridge -): Promise { - return bridge.activeWalletPublicKey() -} diff --git a/typescript/src/index.ts b/typescript/src/index.ts index dfc6b3bd1..84130baa0 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -2,13 +2,6 @@ import { validateBitcoinSpvProof } from "./lib/bitcoin" -import { - calculateDepositAddress, - getRevealedDeposit, - revealDeposit, - suggestDepositWallet, -} from "./deposit" - import { submitDepositSweepProof } from "./deposit-sweep" import { @@ -26,10 +19,6 @@ import { } from "./optimistic-minting" export const TBTC = { - calculateDepositAddress, - suggestDepositWallet, - revealDeposit, - getRevealedDeposit, requestRedemption, getRedemptionRequest, findWalletForRedemption, diff --git a/typescript/src/lib/bitcoin/tx.ts b/typescript/src/lib/bitcoin/tx.ts index e51532dc1..6841f4225 100644 --- a/typescript/src/lib/bitcoin/tx.ts +++ b/typescript/src/lib/bitcoin/tx.ts @@ -194,9 +194,37 @@ function locktimeToNumber(locktimeLE: Buffer | string): number { return BigNumber.from(locktimeBE).toNumber() } +/** + * Calculates locktime parameter for the given locktime start timestamp. + * Throws if the resulting locktime is not a 4-byte number. + * @param locktimeStartedAt - Unix timestamp in seconds determining the moment + * of the locktime start. + * @param locktimeDuration Locktime duration in seconds. + * @returns A 4-byte little-endian locktime as an un-prefixed hex string. + */ +function calculateLocktime( + locktimeStartedAt: number, + locktimeDuration: number +): string { + // Locktime is a Unix timestamp in seconds, computed as locktime start + // timestamp plus locktime duration. + const locktime = BigNumber.from(locktimeStartedAt + locktimeDuration) + + const locktimeHex: Hex = Hex.from(locktime.toHexString()) + + if (locktimeHex.toString().length != 8) { + throw new Error("Locktime must be a 4 bytes number") + } + + // Bitcoin locktime is interpreted as little-endian integer, so we must + // adhere to that convention by converting the locktime accordingly. + return locktimeHex.reverse().toString() +} + /** * Utility functions allowing to deal with Bitcoin locktime. */ export const BitcoinLocktimeUtils = { locktimeToNumber, + calculateLocktime, } diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index 503acf77b..52c06f3bd 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -217,6 +217,30 @@ export interface DepositReceipt { refundLocktime: string } +// eslint-disable-next-line valid-jsdoc +/** + * Validates the given deposit receipt. Throws in case of a validation error. + * @param receipt The validated deposit receipt. + * @dev This function does not validate the depositor's identifier as its + * validity is chain-specific. This parameter must be validated outside. + */ +export function validateDepositReceipt(receipt: DepositReceipt) { + if (receipt.blindingFactor.length != 16) { + throw new Error("Blinding factor must be an 8-byte number") + } + if (receipt.walletPublicKeyHash.length != 40) { + throw new Error("Invalid wallet public key hash") + } + + if (receipt.refundPublicKeyHash.length != 40) { + throw new Error("Invalid refund public key hash") + } + + if (receipt.refundLocktime.length != 8) { + throw new Error("Refund locktime must be a 4-byte number") + } +} + /** * Represents a deposit request revealed to the on-chain bridge. */ diff --git a/typescript/src/lib/contracts/index.ts b/typescript/src/lib/contracts/index.ts index 58f2565df..387367de9 100644 --- a/typescript/src/lib/contracts/index.ts +++ b/typescript/src/lib/contracts/index.ts @@ -4,3 +4,18 @@ export * from "./chain-identifier" export * from "./tbtc-token" export * from "./tbtc-vault" export * from "./wallet-registry" + +import { Bridge } from "./bridge" +import { TBTCToken } from "./tbtc-token" +import { TBTCVault } from "./tbtc-vault" +import { WalletRegistry } from "./wallet-registry" + +/** + * Convenience type aggregating all TBTC contracts handles. + */ +export type TBTCContracts = { + bridge: Bridge + tbtcToken: TBTCToken + tbtcVault: TBTCVault + walletRegistry: WalletRegistry +} diff --git a/typescript/src/lib/contracts/tbtc-vault.ts b/typescript/src/lib/contracts/tbtc-vault.ts index 2869fa4a8..277e445ff 100644 --- a/typescript/src/lib/contracts/tbtc-vault.ts +++ b/typescript/src/lib/contracts/tbtc-vault.ts @@ -8,6 +8,11 @@ import { BigNumber } from "ethers" * Interface for communication with the TBTCVault on-chain contract. */ export interface TBTCVault { + /** + * Gets the chain-specific identifier of this contract. + */ + getChainIdentifier(): ChainIdentifier + /** * Gets optimistic minting delay. * diff --git a/typescript/src/lib/ethereum/tbtc-vault.ts b/typescript/src/lib/ethereum/tbtc-vault.ts index 20a60590b..7a49d3b65 100644 --- a/typescript/src/lib/ethereum/tbtc-vault.ts +++ b/typescript/src/lib/ethereum/tbtc-vault.ts @@ -6,6 +6,7 @@ import { OptimisticMintingFinalizedEvent, OptimisticMintingRequest, OptimisticMintingRequestedEvent, + ChainIdentifier, } from "../contracts" import { BigNumber, ContractTransaction } from "ethers" import { BitcoinTxHash } from "../bitcoin" @@ -36,6 +37,14 @@ export class EthereumTBTCVault super(config, TBTCVaultDeployment) } + // eslint-disable-next-line valid-jsdoc + /** + * @see {TBTCVault#getChainIdentifier} + */ + getChainIdentifier(): ChainIdentifier { + return EthereumAddress.from(this._instance.address) + } + // eslint-disable-next-line valid-jsdoc /** * @see {TBTCVault#optimisticMintingDelay} diff --git a/typescript/src/services/deposits/deposit.ts b/typescript/src/services/deposits/deposit.ts new file mode 100644 index 000000000..4ce3099a3 --- /dev/null +++ b/typescript/src/services/deposits/deposit.ts @@ -0,0 +1,237 @@ +import { + DepositReceipt, + TBTCContracts, + validateDepositReceipt, +} from "../../lib/contracts" +import bcoin from "bcoin" +import { + BitcoinClient, + BitcoinNetwork, + BitcoinTxOutpoint, + BitcoinUtxo, + extractBitcoinRawTxVectors, + toBcoinNetwork, +} from "../../lib/bitcoin" + +const { opcodes } = bcoin.script.common + +/** + * Component representing an instance of the tBTC v2 deposit process. + * Depositing is a complex process spanning both the Bitcoin and the target chain. + * This component tries to abstract away that complexity. + */ +export class Deposit { + /** + * Bitcoin script corresponding to this deposit. + */ + private readonly script: DepositScript + /** + * Handle to tBTC contracts. + */ + private readonly tbtcContracts: TBTCContracts + /** + * Bitcoin client handle. + */ + private readonly bitcoinClient: BitcoinClient + /** + * Bitcoin network the deposit is relevant for. Has an impact on the + * generated deposit address. + */ + public readonly bitcoinNetwork: BitcoinNetwork + + private constructor( + receipt: DepositReceipt, + tbtcContracts: TBTCContracts, + bitcoinClient: BitcoinClient, + bitcoinNetwork: BitcoinNetwork + ) { + this.script = DepositScript.fromReceipt(receipt) + this.tbtcContracts = tbtcContracts + this.bitcoinClient = bitcoinClient + this.bitcoinNetwork = bitcoinNetwork + } + + static async fromReceipt( + receipt: DepositReceipt, + tbtcContracts: TBTCContracts, + bitcoinClient: BitcoinClient + ): Promise { + const bitcoinNetwork = await bitcoinClient.getNetwork() + + return new Deposit(receipt, tbtcContracts, bitcoinClient, bitcoinNetwork) + } + + /** + * @returns Receipt corresponding to this deposit. + */ + getReceipt(): DepositReceipt { + return this.script.receipt + } + + /** + * @returns Bitcoin address corresponding to this deposit. + */ + async getBitcoinAddress(): Promise { + return this.script.deriveAddress(this.bitcoinNetwork) + } + + /** + * Detects Bitcoin funding transactions transferring BTC to this deposit. + * @return Specific UTXOs targeting this deposit. Empty array in case + * there are no UTXOs referring this deposit. + */ + // TODO: Cover with unit tests. + async detectFunding(): Promise { + const utxos = await this.bitcoinClient.findAllUnspentTransactionOutputs( + await this.getBitcoinAddress() + ) + + if (!utxos || utxos.length === 0) { + return [] + } + + return utxos + } + + /** + * Initiates minting of the TBTC token, based on the Bitcoin funding + * transaction outpoint targeting this deposit. By default, it detects and + * uses the outpoint of the recent Bitcoin funding transaction and throws if + * such a transaction does not exist. This behavior can be changed by pointing + * a funding transaction explicitly, using the fundingOutpoint parameter. + * @param fundingOutpoint Optional parameter. Can be used to point + * the funding transaction's outpoint manually. + * @returns Target chain hash of the initiate minting transaction. + * @throws Throws an error if there are no funding transactions while using + * the default funding detection mode. + * @throws Throws an error if the provided funding outpoint does not + * actually refer to this deposit while using the manual funding + * provision mode. + * @throws Throws an error if the funding outpoint was already used to + * initiate minting (both modes). + */ + // TODO: Cover auto funding outpoint detection with unit tests. + async initiateMinting(fundingOutpoint?: BitcoinTxOutpoint): Promise { + let resolvedFundingOutpoint: BitcoinTxOutpoint + + if (typeof fundingOutpoint !== "undefined") { + resolvedFundingOutpoint = fundingOutpoint + } else { + const fundingUtxos = await this.detectFunding() + + if (fundingUtxos.length == 0) { + throw new Error("Deposit not funded yet") + } + + // Take the most recent one. + resolvedFundingOutpoint = fundingUtxos[0] + } + + const { transactionHash, outputIndex } = resolvedFundingOutpoint + + const depositFundingTx = extractBitcoinRawTxVectors( + await this.bitcoinClient.getRawTransaction(transactionHash) + ) + + const { bridge, tbtcVault } = this.tbtcContracts + + return bridge.revealDeposit( + depositFundingTx, + outputIndex, + this.getReceipt(), + tbtcVault.getChainIdentifier() + ) + } +} + +/** + * Represents a Bitcoin script corresponding to a tBTC v2 deposit. + * On a high-level, the script is used to derive the Bitcoin address that is + * used to fund the deposit with BTC. On a low-level, the script is used to + * produce a properly locked funding transaction output that can be unlocked + * by the target wallet during the deposit sweep process. + */ +export class DepositScript { + /** + * Deposit receipt holding the most important information about the deposit + * and allowing to build a unique deposit script (and address) on Bitcoin chain. + */ + public readonly receipt: DepositReceipt + /** + * Flag indicating whether the generated Bitcoin deposit script (and address) + * should be a witness P2WSH one. If false, legacy P2SH will be used instead. + */ + public readonly witness: boolean + + private constructor(receipt: DepositReceipt, witness: boolean) { + validateDepositReceipt(receipt) + + this.receipt = receipt + this.witness = witness + } + + static fromReceipt( + receipt: DepositReceipt, + witness: boolean = true + ): DepositScript { + return new DepositScript(receipt, witness) + } + + /** + * @returns Hashed deposit script as Buffer. + */ + async getHash(): Promise { + const script = await this.getPlainText() + // Parse the script from HEX string. + const parsedScript = bcoin.Script.fromRaw(Buffer.from(script, "hex")) + // If witness script hash should be produced, SHA256 should be used. + // Legacy script hash needs HASH160. + return this.witness ? parsedScript.sha256() : parsedScript.hash160() + } + + /** + * @returns Plain-text deposit script as an un-prefixed hex string. + */ + async getPlainText(): Promise { + // All HEXes pushed to the script must be un-prefixed. + const script = new bcoin.Script() + script.clear() + script.pushData(Buffer.from(this.receipt.depositor.identifierHex, "hex")) + script.pushOp(opcodes.OP_DROP) + script.pushData(Buffer.from(this.receipt.blindingFactor, "hex")) + script.pushOp(opcodes.OP_DROP) + script.pushOp(opcodes.OP_DUP) + script.pushOp(opcodes.OP_HASH160) + script.pushData(Buffer.from(this.receipt.walletPublicKeyHash, "hex")) + script.pushOp(opcodes.OP_EQUAL) + script.pushOp(opcodes.OP_IF) + script.pushOp(opcodes.OP_CHECKSIG) + script.pushOp(opcodes.OP_ELSE) + script.pushOp(opcodes.OP_DUP) + script.pushOp(opcodes.OP_HASH160) + script.pushData(Buffer.from(this.receipt.refundPublicKeyHash, "hex")) + script.pushOp(opcodes.OP_EQUALVERIFY) + script.pushData(Buffer.from(this.receipt.refundLocktime, "hex")) + script.pushOp(opcodes.OP_CHECKLOCKTIMEVERIFY) + script.pushOp(opcodes.OP_DROP) + script.pushOp(opcodes.OP_CHECKSIG) + script.pushOp(opcodes.OP_ENDIF) + script.compile() + + // Return script as HEX string. + return script.toRaw().toString("hex") + } + + /** + * Derives a Bitcoin address for the given network for this deposit script. + * @param bitcoinNetwork Bitcoin network the address should be derived for. + * @returns Bitcoin address corresponding to this deposit script. + */ + async deriveAddress(bitcoinNetwork: BitcoinNetwork): Promise { + const scriptHash = await this.getHash() + const address = this.witness + ? bcoin.Address.fromWitnessScripthash(scriptHash) + : bcoin.Address.fromScripthash(scriptHash) + return address.toString(toBcoinNetwork(bitcoinNetwork)) + } +} diff --git a/typescript/src/services/deposits/deposits-service.ts b/typescript/src/services/deposits/deposits-service.ts new file mode 100644 index 000000000..8b6a2e3be --- /dev/null +++ b/typescript/src/services/deposits/deposits-service.ts @@ -0,0 +1,97 @@ +import { + ChainIdentifier, + DepositReceipt, + TBTCContracts, +} from "../../lib/contracts" +import { + BitcoinAddressConverter, + BitcoinClient, + BitcoinHashUtils, + BitcoinLocktimeUtils, +} from "../../lib/bitcoin" +import { Deposit } from "./deposit" +import * as crypto from "crypto" + +/** + * Service exposing features related to tBTC v2 deposits. + */ +export class DepositsService { + /** + * Deposit refund locktime duration in seconds. + * This is 9 month in seconds assuming 1 month = 30 days + */ + private readonly depositRefundLocktimeDuration = 23328000 + /** + * Handle to tBTC contracts. + */ + private readonly tbtcContracts: TBTCContracts + /** + * Bitcoin client handle. + */ + private readonly bitcoinClient: BitcoinClient + + constructor(tbtcContracts: TBTCContracts, bitcoinClient: BitcoinClient) { + this.tbtcContracts = tbtcContracts + this.bitcoinClient = bitcoinClient + } + + /** + * Initiates a new deposit for the given depositor and Bitcoin recovery address. + * @param depositor Identifier of the depositor specific for the target chain + * deposited BTC are bridged to. For example, this is a + * 20-byte address on Ethereum. + * @param bitcoinRecoveryAddress P2PKH or P2WPKH Bitcoin address that can + * be used for emergency recovery of the + * deposited funds. + * @returns Handle to the initiated deposit. + */ + // TODO: Accept depositor as string and automatically validate & convert OR + // explore the possibility of fetching this from the account instance. + // TODO: Cover with unit tests. + async initiateDeposit( + depositor: ChainIdentifier, + bitcoinRecoveryAddress: string + ): Promise { + const receipt = await this.generateDepositReceipt( + depositor, + bitcoinRecoveryAddress + ) + + return Deposit.fromReceipt(receipt, this.tbtcContracts, this.bitcoinClient) + } + + private async generateDepositReceipt( + depositor: ChainIdentifier, + bitcoinRecoveryAddress: string + ): Promise { + const blindingFactor = crypto.randomBytes(8).toString("hex") + + const walletPublicKey = + await this.tbtcContracts.bridge.activeWalletPublicKey() + + if (!walletPublicKey) { + throw new Error("Could not get active wallet public key") + } + + const walletPublicKeyHash = BitcoinHashUtils.computeHash160(walletPublicKey) + + const refundPublicKeyHash = BitcoinAddressConverter.addressToPublicKeyHash( + bitcoinRecoveryAddress + ) + + const currentTimestamp = Math.floor(new Date().getTime() / 1000) + + const refundLocktime = BitcoinLocktimeUtils.calculateLocktime( + currentTimestamp, + this.depositRefundLocktimeDuration + ) + + return { + depositor, + blindingFactor, + walletPublicKeyHash, + refundPublicKeyHash, + refundLocktime, + } + } +} diff --git a/typescript/src/services/deposits/funding.ts b/typescript/src/services/deposits/funding.ts new file mode 100644 index 000000000..a13cc86f5 --- /dev/null +++ b/typescript/src/services/deposits/funding.ts @@ -0,0 +1,155 @@ +import { DepositScript } from "./deposit" +import { + BitcoinClient, + BitcoinPrivateKeyUtils, + BitcoinRawTx, + BitcoinTxHash, + BitcoinUtxo, +} from "../../lib/bitcoin" +import { BigNumber } from "ethers" +import bcoin from "bcoin" + +/** + * Component allowing to craft and submit the Bitcoin funding transaction using + * the given tBTC v2 deposit script. + * + * @experimental THIS IS EXPERIMENTAL CODE THAT CAN BE CHANGED OR REMOVED + * IN FUTURE RELEASES. IT SHOULD BE USED ONLY FOR INTERNAL + * PURPOSES AND EXTERNAL APPLICATIONS SHOULD NOT DEPEND ON IT. + */ +// TODO: Abstract away transaction signing so there is no need to deal with +// private key directly. +export class DepositFunding { + public readonly script: DepositScript + + private constructor(script: DepositScript) { + this.script = script + } + + static fromScript(script: DepositScript): DepositFunding { + return new DepositFunding(script) + } + + /** + * Assembles and signs the Bitcoin P2(W)SH funding transaction using + * the underlying deposit script. + * @dev It is up to the caller to ensure that input UTXOs are valid and + * can be unlocked using the depositor's private key. It is also + * caller's responsibility to ensure the given deposit is funded exactly + * once. + * @param amount Deposit amount in satoshis. + * @param inputUtxos UTXOs that should be used as transaction inputs. + * @param depositorPrivateKey Bitcoin private key of the depositor. Must + * be able to unlock input UTXOs. + * @returns The outcome consisting of: + * - the deposit transaction hash, + * - the deposit UTXO produced by this transaction. + * - the deposit transaction in the raw format + */ + async assembleTransaction( + amount: BigNumber, + inputUtxos: (BitcoinUtxo & BitcoinRawTx)[], + depositorPrivateKey: string + ): Promise<{ + transactionHash: BitcoinTxHash + depositUtxo: BitcoinUtxo + rawTransaction: BitcoinRawTx + }> { + const depositorKeyRing = + BitcoinPrivateKeyUtils.createKeyRing(depositorPrivateKey) + const depositorAddress = depositorKeyRing.getAddress("string") + + const inputCoins = inputUtxos.map((utxo) => + bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), + utxo.outputIndex, + -1 + ) + ) + + const transaction = new bcoin.MTX() + + const scriptHash = await this.script.getHash() + + transaction.addOutput({ + script: this.script.witness + ? bcoin.Script.fromProgram(0, scriptHash) + : bcoin.Script.fromScripthash(scriptHash), + value: amount.toNumber(), + }) + + await transaction.fund(inputCoins, { + rate: null, // set null explicitly to always use the default value + changeAddress: depositorAddress, + subtractFee: false, // do not subtract the fee from outputs + }) + + transaction.sign(depositorKeyRing) + + const transactionHash = BitcoinTxHash.from(transaction.txid()) + + return { + transactionHash, + depositUtxo: { + transactionHash, + outputIndex: 0, // The deposit is always the first output. + value: amount, + }, + rawTransaction: { + transactionHex: transaction.toRaw().toString("hex"), + }, + } + } + + /** + * Assembles, signs and submits the Bitcoin P2(W)SH funding transaction + * using the underlying deposit script. + * @dev It is up to the caller to ensure that depositor's private key controls + * some UTXOs that can be used as input. It is also caller's responsibility + * to ensure the given deposit is funded exactly once. + * @param amount Deposit amount in satoshis. + * @param depositorPrivateKey Bitcoin private key of the depositor. + * @param bitcoinClient Bitcoin client used to interact with the network. + * @returns The outcome consisting of: + * - the deposit transaction hash, + * - the deposit UTXO produced by this transaction. + */ + async submitTransaction( + amount: BigNumber, + depositorPrivateKey: string, + bitcoinClient: BitcoinClient + ): Promise<{ + transactionHash: BitcoinTxHash + depositUtxo: BitcoinUtxo + }> { + const depositorKeyRing = + BitcoinPrivateKeyUtils.createKeyRing(depositorPrivateKey) + const depositorAddress = depositorKeyRing.getAddress("string") + + const utxos = await bitcoinClient.findAllUnspentTransactionOutputs( + depositorAddress + ) + + const utxosWithRaw: (BitcoinUtxo & BitcoinRawTx)[] = [] + for (const utxo of utxos) { + const utxoRawTransaction = await bitcoinClient.getRawTransaction( + utxo.transactionHash + ) + + utxosWithRaw.push({ + ...utxo, + transactionHex: utxoRawTransaction.transactionHex, + }) + } + + const { transactionHash, depositUtxo, rawTransaction } = + await this.assembleTransaction(amount, utxosWithRaw, depositorPrivateKey) + + await bitcoinClient.broadcast(rawTransaction) + + return { + transactionHash, + depositUtxo, + } + } +} diff --git a/typescript/src/services/deposits/index.ts b/typescript/src/services/deposits/index.ts new file mode 100644 index 000000000..f75596a11 --- /dev/null +++ b/typescript/src/services/deposits/index.ts @@ -0,0 +1,3 @@ +export * from "./deposit" +export * from "./deposits-service" +export * from "./funding" diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 7310d28b6..6b03fff4b 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -10,7 +10,6 @@ import { BitcoinCompactSizeUint, BitcoinAddressConverter, } from "../src/lib/bitcoin" -import { calculateDepositRefundLocktime } from "../src/deposit" import { Hex } from "../src/lib/utils" import { BigNumber } from "ethers" import { btcAddresses } from "./data/bitcoin" @@ -384,32 +383,31 @@ describe("Bitcoin", () => { }) describe("BitcoinLocktimeUtils", () => { - const { locktimeToNumber } = BitcoinLocktimeUtils + const { locktimeToNumber, calculateLocktime } = BitcoinLocktimeUtils describe("locktimeToNumber", () => { - const depositCreatedAt: number = 1640181600 - const depositRefundLocktimeDuration: number = 2592000 - const depositRefundLocktime = calculateDepositRefundLocktime( - depositCreatedAt, - depositRefundLocktimeDuration + const locktimeStartedAt: number = 1640181600 + const locktimeDuration: number = 2592000 + const locktime = BitcoinLocktimeUtils.calculateLocktime( + locktimeStartedAt, + locktimeDuration ) const testData = [ { contextName: "when locktime is a block height", unprefixedHex: "ede80600", - expectedDepositLocktime: 452845, + expectedLocktime: 452845, }, { contextName: "when locktime is a timestamp", unprefixedHex: "06241559", - expectedDepositLocktime: 1494557702, + expectedLocktime: 1494557702, }, { - contextName: "for deposit refund locktime", - unprefixedHex: depositRefundLocktime, - expectedDepositLocktime: - depositCreatedAt + depositRefundLocktimeDuration, + contextName: "for locktime", + unprefixedHex: locktime, + expectedLocktime: locktimeStartedAt + locktimeDuration, }, ] @@ -418,7 +416,7 @@ describe("Bitcoin", () => { context("when input is non-prefixed hex string", () => { it("should return the locktime in seconds", async () => { expect(locktimeToNumber(test.unprefixedHex)).to.be.equal( - test.expectedDepositLocktime + test.expectedLocktime ) }) }) @@ -426,7 +424,7 @@ describe("Bitcoin", () => { context("when input is 0x prefixed hex string", () => { it("should return the locktime in seconds", async () => { expect(locktimeToNumber("0x" + test.unprefixedHex)).to.be.equal( - test.expectedDepositLocktime + test.expectedLocktime ) }) }) @@ -435,12 +433,45 @@ describe("Bitcoin", () => { it("should return the locktime in seconds", async () => { expect( locktimeToNumber(Buffer.from(test.unprefixedHex, "hex")) - ).to.be.equal(test.expectedDepositLocktime) + ).to.be.equal(test.expectedLocktime) }) }) }) }) }) + + describe("calculateLocktime", () => { + context("when the resulting locktime is lesser than 4 bytes", () => { + it("should throw", () => { + // This will result with 2592001 as the locktime which is a 3-byte number. + expect(() => calculateLocktime(1, 2592000)).to.throw( + "Locktime must be a 4 bytes number" + ) + }) + }) + + context("when the resulting locktime is greater than 4 bytes", () => { + it("should throw", () => { + // This will result with 259200144444 as the locktime which is a 5-byte number. + expect(() => calculateLocktime(259197552444, 2592000)).to.throw( + "Locktime must be a 4 bytes number" + ) + }) + }) + + context("when the resulting locktime is a 4-byte number", () => { + it("should compute a proper 4-byte little-endian locktime as un-prefixed hex string", () => { + const locktimeStartedAt = 1652776752 + + const locktime = calculateLocktime(locktimeStartedAt, 2592000) + + // The start timestamp is 1652776752 and locktime duration 2592000 (30 days). + // So, the locktime timestamp is 1652776752 + 2592000 = 1655368752 which + // is represented as 30ecaa62 hex in the little-endian format. + expect(locktime).to.be.equal("30ecaa62") + }) + }) + }) }) describe("BitcoinHeaderSerializer", () => { diff --git a/typescript/test/data/deposit-refund.ts b/typescript/test/data/deposit-refund.ts index 4edde113c..57a41762d 100644 --- a/typescript/test/data/deposit-refund.ts +++ b/typescript/test/data/deposit-refund.ts @@ -1,7 +1,11 @@ import { BigNumber } from "ethers" -import { BitcoinRawTx, BitcoinUtxo, BitcoinTxHash } from "../../src/lib/bitcoin" +import { + BitcoinRawTx, + BitcoinUtxo, + BitcoinTxHash, + BitcoinLocktimeUtils, +} from "../../src/lib/bitcoin" import { DepositReceipt } from "../../src/lib/contracts" -import { calculateDepositRefundLocktime } from "../../src/deposit" import { EthereumAddress } from "../../src/lib/ethereum" /** @@ -58,7 +62,10 @@ export const depositRefundOfWitnessDepositAndWitnessRefunderAddress: DepositRefu walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "1b67f27537c7b30a23d8ccefb96a4cacfc72d9a1", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime(1674820800, 3600), + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( + 1674820800, + 3600 + ), }, }, // witness address associated with the refunder's private key @@ -112,7 +119,10 @@ export const depositRefundOfNonWitnessDepositAndWitnessRefunderAddress: DepositR walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "1b67f27537c7b30a23d8ccefb96a4cacfc72d9a1", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime(1674820800, 3600), + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( + 1674820800, + 3600 + ), }, }, // witness address associated with the refunder's private key @@ -166,7 +176,10 @@ export const depositRefundOfWitnessDepositAndNonWitnessRefunderAddress: DepositR walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", refundPublicKeyHash: "1b67f27537c7b30a23d8ccefb96a4cacfc72d9a1", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime(1674820800, 3600), + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( + 1674820800, + 3600 + ), }, }, // non-witness address associated with the refunder's private key diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index fd85dcd64..14251228b 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -6,9 +6,9 @@ import { BitcoinUtxo, BitcoinTxMerkleBranch, BitcoinTxHash, + BitcoinLocktimeUtils, } from "../../src/lib/bitcoin" import { DepositReceipt } from "../../src/lib/contracts" -import { calculateDepositRefundLocktime } from "../../src/deposit" import { BigNumber } from "ethers" import { EthereumAddress } from "../../src/lib/ethereum" import { Hex } from "../../src" @@ -69,7 +69,10 @@ export const depositSweepWithNoMainUtxoAndWitnessOutput: DepositSweepTestData = // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. refundPublicKeyHash: "e257eccafbc07c381642ce6e7e55120fb077fbed", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime(1641650400, 2592000), + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( + 1641650400, + 2592000 + ), }, }, { @@ -97,7 +100,10 @@ export const depositSweepWithNoMainUtxoAndWitnessOutput: DepositSweepTestData = // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. refundPublicKeyHash: "e257eccafbc07c381642ce6e7e55120fb077fbed", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime(1641650400, 2592000), + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( + 1641650400, + 2592000 + ), }, }, ], @@ -156,7 +162,10 @@ export const depositSweepWithNoMainUtxoAndNonWitnessOutput: DepositSweepTestData // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. refundPublicKeyHash: "e257eccafbc07c381642ce6e7e55120fb077fbed", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime(1653302600, 2592000), + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( + 1653302600, + 2592000 + ), }, }, ], @@ -208,7 +217,10 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. refundPublicKeyHash: "e257eccafbc07c381642ce6e7e55120fb077fbed", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime(1641650400, 2592000), + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( + 1641650400, + 2592000 + ), }, }, { @@ -237,7 +249,10 @@ export const depositSweepWithWitnessMainUtxoAndWitnessOutput: DepositSweepTestDa // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. refundPublicKeyHash: "e257eccafbc07c381642ce6e7e55120fb077fbed", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime(1641650400, 2592000), + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( + 1641650400, + 2592000 + ), }, }, ], @@ -332,7 +347,10 @@ export const depositSweepWithNonWitnessMainUtxoAndWitnessOutput: DepositSweepTes // HASH160 of 039d61d62dcd048d3f8550d22eb90b4af908db60231d117aeede04e7bc11907bfa. refundPublicKeyHash: "e257eccafbc07c381642ce6e7e55120fb077fbed", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime(1653302600, 2592000), + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( + 1653302600, + 2592000 + ), }, }, ], diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index 5d327fe58..3b179c4c5 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -1,5 +1,5 @@ import { expect } from "chai" -import { BigNumber, BigNumberish } from "ethers" +import { BigNumber } from "ethers" import { testnetAddress, testnetPrivateKey, @@ -8,43 +8,38 @@ import { testnetUTXO, } from "./data/deposit" import { - extractBitcoinRawTxVectors, + BitcoinLocktimeUtils, BitcoinRawTx, BitcoinTxHash, BitcoinUtxo, + extractBitcoinRawTxVectors, } from "../src/lib/bitcoin" -import { DepositRequest } from "../src/lib/contracts" +import { DepositReceipt } from "../src/lib/contracts" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import bcoin from "bcoin" -import { - assembleDepositScript, - assembleDepositTransaction, - calculateDepositAddress, - calculateDepositRefundLocktime, - calculateDepositScriptHash, - DepositReceiptWithAmount, - getRevealedDeposit, - revealDeposit, - submitDepositTransaction, - suggestDepositWallet, -} from "../src/deposit" -import { MockBridge } from "./utils/mock-bridge" import { EthereumAddress } from "../src/lib/ethereum" import { BitcoinNetwork } from "../src" +import { + DepositFunding, + DepositScript, + Deposit, +} from "../src/services/deposits" +import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" describe("Deposit", () => { const depositCreatedAt: number = 1640181600 const depositRefundLocktimeDuration: number = 2592000 - const deposit: DepositReceiptWithAmount = { + const depositAmount = BigNumber.from(10000) // 0.0001 BTC + + const deposit: DepositReceipt = { depositor: EthereumAddress.from("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), - amount: BigNumber.from(10000), // 0.0001 BTC // HASH160 of 03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9. walletPublicKeyHash: "8db50eb52063ea9d98b3eac91489a90f738986f6", // HASH160 of 0300d6f28a2f6bf9836f57fcda5d284c9a8f849316119779f0d6090830d97763a9. refundPublicKeyHash: "28e081f285138ccbe389c1eb8985716230129f89", blindingFactor: "f9f0c90d00039523", - refundLocktime: calculateDepositRefundLocktime( + refundLocktime: BitcoinLocktimeUtils.calculateLocktime( depositCreatedAt, depositRefundLocktimeDuration ), @@ -211,572 +206,511 @@ describe("Deposit", () => { expect(script.substring(182, 184)).to.be.equal("68") } - describe("submitDepositTransaction", () => { - let bitcoinClient: MockBitcoinClient - - beforeEach(async () => { - bcoin.set("testnet") - - bitcoinClient = new MockBitcoinClient() - - // Tie used testnetAddress with testnetUTXO to use it during deposit - // creation. - const utxos = new Map() - utxos.set(testnetAddress, [testnetUTXO]) - bitcoinClient.unspentTransactionOutputs = utxos - - // Tie testnetTransaction to testnetUTXO. This is needed since - // submitDepositTransaction attach transaction data to each UTXO. - const rawTransactions = new Map() - rawTransactions.set(testnetTransactionHash.toString(), testnetTransaction) - bitcoinClient.rawTransactions = rawTransactions - }) - - context("when witness option is true", () => { - let transactionHash: BitcoinTxHash - let depositUtxo: BitcoinUtxo + describe("DepositFunding", () => { + describe("submitTransaction", () => { + let bitcoinClient: MockBitcoinClient beforeEach(async () => { - ;({ transactionHash, depositUtxo } = await submitDepositTransaction( - deposit, - testnetPrivateKey, - bitcoinClient, - true - )) - }) - - it("should broadcast P2WSH transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - expectedP2WSHDeposit.transaction + bcoin.set("testnet") + + bitcoinClient = new MockBitcoinClient() + + // Tie used testnetAddress with testnetUTXO to use it during deposit + // creation. + const utxos = new Map() + utxos.set(testnetAddress, [testnetUTXO]) + bitcoinClient.unspentTransactionOutputs = utxos + + // Tie testnetTransaction to testnetUTXO. This is needed since + // submitDepositTransaction attach transaction data to each UTXO. + const rawTransactions = new Map() + rawTransactions.set( + testnetTransactionHash.toString(), + testnetTransaction ) + bitcoinClient.rawTransactions = rawTransactions }) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - expectedP2WSHDeposit.transactionHash - ) - }) - - it("should return the proper deposit UTXO", () => { - const expectedDepositUtxo = { - transactionHash: expectedP2WSHDeposit.transactionHash, - outputIndex: 0, - value: deposit.amount, - } - - expect(depositUtxo).to.be.eql(expectedDepositUtxo) - }) - }) - - context("when witness option is false", () => { - let transactionHash: BitcoinTxHash - let depositUtxo: BitcoinUtxo - - beforeEach(async () => { - ;({ transactionHash, depositUtxo } = await submitDepositTransaction( - deposit, - testnetPrivateKey, - bitcoinClient, - false - )) - }) + context("when witness option is true", () => { + let transactionHash: BitcoinTxHash + let depositUtxo: BitcoinUtxo - it("should broadcast P2SH transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - expectedP2SHDeposit.transaction - ) - }) + beforeEach(async () => { + const depositFunding = DepositFunding.fromScript( + DepositScript.fromReceipt(deposit, true) + ) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - expectedP2SHDeposit.transactionHash - ) - }) + ;({ transactionHash, depositUtxo } = + await depositFunding.submitTransaction( + depositAmount, + testnetPrivateKey, + bitcoinClient + )) + }) - it("should return the proper deposit UTXO", () => { - const expectedDepositUtxo = { - transactionHash: expectedP2SHDeposit.transactionHash, - outputIndex: 0, - value: deposit.amount, - } + it("should broadcast P2WSH transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + expectedP2WSHDeposit.transaction + ) + }) - expect(depositUtxo).to.be.eql(expectedDepositUtxo) - }) - }) - }) + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + expectedP2WSHDeposit.transactionHash + ) + }) - describe("assembleDepositTransaction", () => { - context("when witness option is true", () => { - let transactionHash: BitcoinTxHash - let depositUtxo: BitcoinUtxo - let transaction: BitcoinRawTx + it("should return the proper deposit UTXO", () => { + const expectedDepositUtxo = { + transactionHash: expectedP2WSHDeposit.transactionHash, + outputIndex: 0, + value: depositAmount, + } - beforeEach(async () => { - ;({ - transactionHash, - depositUtxo, - rawTransaction: transaction, - } = await assembleDepositTransaction( - deposit, - [testnetUTXO], - testnetPrivateKey, - true - )) + expect(depositUtxo).to.be.eql(expectedDepositUtxo) + }) }) - it("should return P2WSH transaction with proper structure", async () => { - // Compare HEXes. - expect(transaction).to.be.eql(expectedP2WSHDeposit.transaction) + context("when witness option is false", () => { + let transactionHash: BitcoinTxHash + let depositUtxo: BitcoinUtxo - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + beforeEach(async () => { + const depositFunding = DepositFunding.fromScript( + DepositScript.fromReceipt(deposit, false) + ) - expect(txJSON.hash).to.be.equal( - expectedP2WSHDeposit.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) + ;({ transactionHash, depositUtxo } = + await depositFunding.submitTransaction( + depositAmount, + testnetPrivateKey, + bitcoinClient + )) + }) - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(1) + it("should broadcast P2SH transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + expectedP2SHDeposit.transaction + ) + }) - const input = txJSON.inputs[0] + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + expectedP2SHDeposit.transactionHash + ) + }) - expect(input.prevout.hash).to.be.equal( - testnetUTXO.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) - // Transaction should be signed but this is SegWit input so the `script` - // field should be empty and the `witness` field should be filled instead. - expect(input.script.length).to.be.equal(0) - expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(testnetAddress) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(2) - - const depositOutput = txJSON.outputs[0] - const changeOutput = txJSON.outputs[1] - - // Value should correspond to the deposit amount. - expect(depositOutput.value).to.be.equal(deposit.amount.toNumber()) - // Should be OP_0 . The script hash is the same as in - // expectedP2WSHDeposit.scriptHash (see calculateDepositScriptHash - // witness scenario) and it should be prefixed with its byte length: - // 0x20. The OP_0 opcode is 0x00. - expect(depositOutput.script).to.be.equal( - `0020${expectedP2WSHDeposit.scriptHash}` - ) - // The address should correspond to the script hash - // expectedP2WSHDeposit.scriptHash on testnet so it should be: - // expectedP2WSHDeposit.testnetAddress (see calculateDepositAddress - // witness scenario). - expect(depositOutput.address).to.be.equal( - expectedP2WSHDeposit.testnetAddress - ) + it("should return the proper deposit UTXO", () => { + const expectedDepositUtxo = { + transactionHash: expectedP2SHDeposit.transactionHash, + outputIndex: 0, + value: depositAmount, + } - // Change value should be equal to: inputValue - depositAmount - fee. - expect(changeOutput.value).to.be.equal(3921680) - // Should be OP_0 . Public key corresponds to - // depositor BTC address. - expect(changeOutput.script).to.be.equal( - "00147ac2d9378a1c47e589dfb8095ca95ed2140d2726" - ) - // Should return the change to depositor BTC address. - expect(changeOutput.address).to.be.equal(testnetAddress) + expect(depositUtxo).to.be.eql(expectedDepositUtxo) + }) }) + }) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - expectedP2WSHDeposit.transactionHash - ) - }) + describe("assembleTransaction", () => { + context("when witness option is true", () => { + let transactionHash: BitcoinTxHash + let depositUtxo: BitcoinUtxo + let transaction: BitcoinRawTx - it("should return the proper deposit UTXO", () => { - const expectedDepositUtxo = { - transactionHash: expectedP2WSHDeposit.transactionHash, - outputIndex: 0, - value: deposit.amount, - } + beforeEach(async () => { + const depositFunding = DepositFunding.fromScript( + DepositScript.fromReceipt(deposit, true) + ) - expect(depositUtxo).to.be.eql(expectedDepositUtxo) - }) - }) + ;({ + transactionHash, + depositUtxo, + rawTransaction: transaction, + } = await depositFunding.assembleTransaction( + depositAmount, + [testnetUTXO], + testnetPrivateKey + )) + }) - context("when witness option is false", () => { - let transactionHash: BitcoinTxHash - let depositUtxo: BitcoinUtxo - let transaction: BitcoinRawTx + it("should return P2WSH transaction with proper structure", async () => { + // Compare HEXes. + expect(transaction).to.be.eql(expectedP2WSHDeposit.transaction) - beforeEach(async () => { - ;({ - transactionHash, - depositUtxo, - rawTransaction: transaction, - } = await assembleDepositTransaction( - deposit, - [testnetUTXO], - testnetPrivateKey, - false - )) - }) + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - it("should return P2SH transaction with proper structure", async () => { - // Compare HEXes. - expect(transaction).to.be.eql(expectedP2SHDeposit.transaction) + expect(txJSON.hash).to.be.equal( + expectedP2WSHDeposit.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(1) - expect(txJSON.hash).to.be.equal( - expectedP2SHDeposit.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) + const input = txJSON.inputs[0] - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(1) + expect(input.prevout.hash).to.be.equal( + testnetUTXO.transactionHash.toString() + ) + expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) + // Transaction should be signed but this is SegWit input so the `script` + // field should be empty and the `witness` field should be filled instead. + expect(input.script.length).to.be.equal(0) + expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(testnetAddress) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(2) + + const depositOutput = txJSON.outputs[0] + const changeOutput = txJSON.outputs[1] + + // Value should correspond to the deposit amount. + expect(depositOutput.value).to.be.equal(depositAmount.toNumber()) + // Should be OP_0 . The script hash is the same as in + // expectedP2WSHDeposit.scriptHash (see DepositScript.getHash + // witness scenario) and it should be prefixed with its byte length: + // 0x20. The OP_0 opcode is 0x00. + expect(depositOutput.script).to.be.equal( + `0020${expectedP2WSHDeposit.scriptHash}` + ) + // The address should correspond to the script hash + // expectedP2WSHDeposit.scriptHash on testnet so it should be: + // expectedP2WSHDeposit.testnetAddress (see DepositScript.deriveAddress + // witness scenario). + expect(depositOutput.address).to.be.equal( + expectedP2WSHDeposit.testnetAddress + ) - const input = txJSON.inputs[0] + // Change value should be equal to: inputValue - depositAmount - fee. + expect(changeOutput.value).to.be.equal(3921680) + // Should be OP_0 . Public key corresponds to + // depositor BTC address. + expect(changeOutput.script).to.be.equal( + "00147ac2d9378a1c47e589dfb8095ca95ed2140d2726" + ) + // Should return the change to depositor BTC address. + expect(changeOutput.address).to.be.equal(testnetAddress) + }) - expect(input.prevout.hash).to.be.equal( - testnetUTXO.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) - // Transaction should be signed but this is SegWit input so the `script` - // field should be empty and the `witness` field should be filled instead. - expect(input.script.length).to.be.equal(0) - expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(testnetAddress) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(2) - - const depositOutput = txJSON.outputs[0] - const changeOutput = txJSON.outputs[1] - - // Value should correspond to the deposit amount. - expect(depositOutput.value).to.be.equal(deposit.amount.toNumber()) - // Should be OP_HASH160 OP_EQUAL. The script hash is - // expectedP2SHDeposit.scriptHash (see calculateDepositScriptHash - // non-witness scenario) and it should be prefixed with its byte - // length: 0x14. The OP_HASH160 opcode is 0xa9 and OP_EQUAL is 0x87. - expect(depositOutput.script).to.be.equal( - `a914${expectedP2SHDeposit.scriptHash}87` - ) - // The address should correspond to the script hash - // expectedP2SHDeposit.scriptHash on testnet so it should be - // expectedP2SHDeposit.testnetAddress (see calculateDepositAddress - // non-witness scenario). - expect(depositOutput.address).to.be.equal( - expectedP2SHDeposit.testnetAddress - ) + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + expectedP2WSHDeposit.transactionHash + ) + }) - // Change value should be equal to: inputValue - depositAmount - fee. - expect(changeOutput.value).to.be.equal(3921790) - // Should be OP_0 . Public key corresponds to - // depositor BTC address. - expect(changeOutput.script).to.be.equal( - "00147ac2d9378a1c47e589dfb8095ca95ed2140d2726" - ) - // Should return the change to depositor BTC address. - expect(changeOutput.address).to.be.equal(testnetAddress) - }) + it("should return the proper deposit UTXO", () => { + const expectedDepositUtxo = { + transactionHash: expectedP2WSHDeposit.transactionHash, + outputIndex: 0, + value: depositAmount, + } - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - expectedP2SHDeposit.transactionHash - ) + expect(depositUtxo).to.be.eql(expectedDepositUtxo) + }) }) - it("should return the proper deposit UTXO", () => { - const expectedDepositUtxo = { - transactionHash: expectedP2SHDeposit.transactionHash, - outputIndex: 0, - value: deposit.amount, - } + context("when witness option is false", () => { + let transactionHash: BitcoinTxHash + let depositUtxo: BitcoinUtxo + let transaction: BitcoinRawTx - expect(depositUtxo).to.be.deep.equal(expectedDepositUtxo) - }) - }) - }) + beforeEach(async () => { + const depositFunding = DepositFunding.fromScript( + DepositScript.fromReceipt(deposit, false) + ) - describe("assembleDepositScript", () => { - let script: string + ;({ + transactionHash, + depositUtxo, + rawTransaction: transaction, + } = await depositFunding.assembleTransaction( + depositAmount, + [testnetUTXO], + testnetPrivateKey + )) + }) - beforeEach(async () => { - script = await assembleDepositScript(deposit) - }) + it("should return P2SH transaction with proper structure", async () => { + // Compare HEXes. + expect(transaction).to.be.eql(expectedP2SHDeposit.transaction) - it("should return script with proper structure", async () => { - assertValidDepositScript(script) - }) - }) + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - describe("calculateDepositRefundLocktime", () => { - context("when the resulting locktime is lesser than 4 bytes", () => { - it("should throw", () => { - // This will result with 2592001 as the locktime which is a 3-byte number. - expect(() => calculateDepositRefundLocktime(1, 2592000)).to.throw( - "Refund locktime must be a 4 bytes number" - ) - }) - }) + expect(txJSON.hash).to.be.equal( + expectedP2SHDeposit.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) - context("when the resulting locktime is greater than 4 bytes", () => { - it("should throw", () => { - // This will result with 259200144444 as the locktime which is a 5-byte number. - expect(() => - calculateDepositRefundLocktime(259197552444, 2592000) - ).to.throw("Refund locktime must be a 4 bytes number") - }) - }) + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(1) - context("when the resulting locktime is a 4-byte number", () => { - it("should compute a proper 4-byte little-endian locktime as un-prefixed hex string", () => { - const depositCreatedAt = 1652776752 + const input = txJSON.inputs[0] - const refundLocktime = calculateDepositRefundLocktime( - depositCreatedAt, - 2592000 - ) + expect(input.prevout.hash).to.be.equal( + testnetUTXO.transactionHash.toString() + ) + expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) + // Transaction should be signed but this is SegWit input so the `script` + // field should be empty and the `witness` field should be filled instead. + expect(input.script.length).to.be.equal(0) + expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(testnetAddress) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(2) + + const depositOutput = txJSON.outputs[0] + const changeOutput = txJSON.outputs[1] + + // Value should correspond to the deposit amount. + expect(depositOutput.value).to.be.equal(depositAmount.toNumber()) + // Should be OP_HASH160 OP_EQUAL. The script hash is + // expectedP2SHDeposit.scriptHash (see DepositScript.getHash + // non-witness scenario) and it should be prefixed with its byte + // length: 0x14. The OP_HASH160 opcode is 0xa9 and OP_EQUAL is 0x87. + expect(depositOutput.script).to.be.equal( + `a914${expectedP2SHDeposit.scriptHash}87` + ) + // The address should correspond to the script hash + // expectedP2SHDeposit.scriptHash on testnet so it should be + // expectedP2SHDeposit.testnetAddress (see DepositScript.deriveAddress + // non-witness scenario). + expect(depositOutput.address).to.be.equal( + expectedP2SHDeposit.testnetAddress + ) - // The creation timestamp is 1652776752 and locktime duration 2592000 (30 days). - // So, the locktime timestamp is 1652776752 + 2592000 = 1655368752 which - // is represented as 30ecaa62 hex in the little-endian format. - expect(refundLocktime).to.be.equal("30ecaa62") - }) - }) - }) + // Change value should be equal to: inputValue - depositAmount - fee. + expect(changeOutput.value).to.be.equal(3921790) + // Should be OP_0 . Public key corresponds to + // depositor BTC address. + expect(changeOutput.script).to.be.equal( + "00147ac2d9378a1c47e589dfb8095ca95ed2140d2726" + ) + // Should return the change to depositor BTC address. + expect(changeOutput.address).to.be.equal(testnetAddress) + }) - describe("calculateDepositScriptHash", () => { - context("when witness option is true", () => { - let scriptHash: Buffer + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + expectedP2SHDeposit.transactionHash + ) + }) - beforeEach(async () => { - scriptHash = await calculateDepositScriptHash(deposit, true) - }) + it("should return the proper deposit UTXO", () => { + const expectedDepositUtxo = { + transactionHash: expectedP2SHDeposit.transactionHash, + outputIndex: 0, + value: depositAmount, + } - it("should return proper witness script hash", async () => { - // The script for given deposit should be the same as in - // assembleDepositScript test scenario i.e. expectedDepositScript. - // The hash of this script should correspond to the OP_SHA256 opcode - // which applies SHA-256 on the input. In this case the hash is - // expectedP2WSHDeposit.scriptHash and it can be verified with - // the following command: - // echo -n $SCRIPT | xxd -r -p | openssl dgst -sha256 - expect(scriptHash.toString("hex")).to.be.equal( - expectedP2WSHDeposit.scriptHash - ) + expect(depositUtxo).to.be.deep.equal(expectedDepositUtxo) + }) }) }) + }) - context("when witness option is false", () => { - let scriptHash: Buffer + describe("DepositScript", () => { + describe("getPlainText", () => { + let script: string beforeEach(async () => { - scriptHash = await calculateDepositScriptHash(deposit, false) + script = await DepositScript.fromReceipt(deposit).getPlainText() }) - it("should return proper non-witness script hash", async () => { - // The script for given deposit should be the same as in - // assembleDepositScript test scenario i.e. expectedDepositScript. - // The hash of this script should correspond to the OP_HASH160 opcode - // which applies SHA-256 and then RIPEMD-160 on the input. In this case - // the hash is expectedP2SHDeposit.scriptHash and it can be verified - // with the following command: - // echo -n $SCRIPT | xxd -r -p | openssl dgst -sha256 -binary | openssl dgst -rmd160 - expect(scriptHash.toString("hex")).to.be.equal( - expectedP2SHDeposit.scriptHash - ) + it("should return script with proper structure", async () => { + assertValidDepositScript(script) }) }) - }) - - describe("calculateDepositAddress", () => { - let address: string - context("when network is main", () => { + describe("getHash", () => { context("when witness option is true", () => { + let scriptHash: Buffer + beforeEach(async () => { - address = await calculateDepositAddress( - deposit, - BitcoinNetwork.Mainnet, - true - ) + scriptHash = await DepositScript.fromReceipt(deposit, true).getHash() }) - it("should return proper address with prefix bc1", async () => { - // Address is created from same script hash as presented in the witness - // calculateDepositScriptHash scenario i.e. expectedP2WSHDeposit.scriptHash. - // According to https://en.bitcoin.it/wiki/List_of_address_prefixes - // the P2WSH (Bech32) address prefix for mainnet is bc1. - expect(address).to.be.equal(expectedP2WSHDeposit.mainnetAddress) + it("should return proper witness script hash", async () => { + // The script for given deposit should be the same as in + // assembleDepositScript test scenario i.e. expectedDepositScript. + // The hash of this script should correspond to the OP_SHA256 opcode + // which applies SHA-256 on the input. In this case the hash is + // expectedP2WSHDeposit.scriptHash and it can be verified with + // the following command: + // echo -n $SCRIPT | xxd -r -p | openssl dgst -sha256 + expect(scriptHash.toString("hex")).to.be.equal( + expectedP2WSHDeposit.scriptHash + ) }) }) context("when witness option is false", () => { + let scriptHash: Buffer + beforeEach(async () => { - address = await calculateDepositAddress( - deposit, - BitcoinNetwork.Mainnet, - false - ) + scriptHash = await DepositScript.fromReceipt(deposit, false).getHash() }) - it("should return proper address with prefix 3", async () => { - // Address is created from same script hash as presented in the non-witness - // calculateDepositScriptHash scenario i.e. expectedP2SHDeposit.scriptHash. - // According to https://en.bitcoin.it/wiki/List_of_address_prefixes - // the P2SH address prefix for mainnet is 3. - expect(address).to.be.equal(expectedP2SHDeposit.mainnetAddress) + it("should return proper non-witness script hash", async () => { + // The script for given deposit should be the same as in + // assembleDepositScript test scenario i.e. expectedDepositScript. + // The hash of this script should correspond to the OP_HASH160 opcode + // which applies SHA-256 and then RIPEMD-160 on the input. In this case + // the hash is expectedP2SHDeposit.scriptHash and it can be verified + // with the following command: + // echo -n $SCRIPT | xxd -r -p | openssl dgst -sha256 -binary | openssl dgst -rmd160 + expect(scriptHash.toString("hex")).to.be.equal( + expectedP2SHDeposit.scriptHash + ) }) }) }) - context("when network is testnet", () => { - context("when witness option is true", () => { - beforeEach(async () => { - address = await calculateDepositAddress( - deposit, - BitcoinNetwork.Testnet, - true - ) + describe("deriveAddress", () => { + let address: string + + context("when network is mainnet", () => { + context("when witness option is true", () => { + beforeEach(async () => { + address = await DepositScript.fromReceipt( + deposit, + true + ).deriveAddress(BitcoinNetwork.Mainnet) + }) + + it("should return proper address with prefix bc1", async () => { + // Address is created from same script hash as presented in the witness + // DepositScript.getHash scenario i.e. expectedP2WSHDeposit.scriptHash. + // According to https://en.bitcoin.it/wiki/List_of_address_prefixes + // the P2WSH (Bech32) address prefix for mainnet is bc1. + expect(address).to.be.equal(expectedP2WSHDeposit.mainnetAddress) + }) }) - it("should return proper address with prefix tb1", async () => { - // Address is created from same script hash as presented in the witness - // calculateDepositScriptHash scenario i.e. expectedP2WSHDeposit.scriptHash. - // According to https://en.bitcoin.it/wiki/List_of_address_prefixes - // the P2WSH (Bech32) address prefix for testnet is tb1. - expect(address).to.be.equal(expectedP2WSHDeposit.testnetAddress) + context("when witness option is false", () => { + beforeEach(async () => { + address = await DepositScript.fromReceipt( + deposit, + false + ).deriveAddress(BitcoinNetwork.Mainnet) + }) + + it("should return proper address with prefix 3", async () => { + // Address is created from same script hash as presented in the non-witness + // DepositScript.getHash scenario i.e. expectedP2SHDeposit.scriptHash. + // According to https://en.bitcoin.it/wiki/List_of_address_prefixes + // the P2SH address prefix for mainnet is 3. + expect(address).to.be.equal(expectedP2SHDeposit.mainnetAddress) + }) }) }) - context("when witness option is false", () => { - beforeEach(async () => { - address = await calculateDepositAddress( - deposit, - BitcoinNetwork.Testnet, - false - ) + context("when network is testnet", () => { + context("when witness option is true", () => { + beforeEach(async () => { + address = await DepositScript.fromReceipt( + deposit, + true + ).deriveAddress(BitcoinNetwork.Testnet) + }) + + it("should return proper address with prefix tb1", async () => { + // Address is created from same script hash as presented in the witness + // DepositScript.getHash scenario i.e. expectedP2WSHDeposit.scriptHash. + // According to https://en.bitcoin.it/wiki/List_of_address_prefixes + // the P2WSH (Bech32) address prefix for testnet is tb1. + expect(address).to.be.equal(expectedP2WSHDeposit.testnetAddress) + }) }) - it("should return proper address with prefix 2", async () => { - // Address is created from same script hash as presented in the witness - // calculateDepositScriptHash scenario i.e. expectedP2SHDeposit.scriptHash. - // According to https://en.bitcoin.it/wiki/List_of_address_prefixes - // the P2SH address prefix for testnet is 2. - expect(address).to.be.equal(expectedP2SHDeposit.testnetAddress) + context("when witness option is false", () => { + beforeEach(async () => { + address = await DepositScript.fromReceipt( + deposit, + false + ).deriveAddress(BitcoinNetwork.Testnet) + }) + + it("should return proper address with prefix 2", async () => { + // Address is created from same script hash as presented in the witness + // DepositScript.getHash scenario i.e. expectedP2SHDeposit.scriptHash. + // According to https://en.bitcoin.it/wiki/List_of_address_prefixes + // the P2SH address prefix for testnet is 2. + expect(address).to.be.equal(expectedP2SHDeposit.testnetAddress) + }) }) }) }) }) - describe("revealDeposit", () => { - let transaction: BitcoinRawTx - let depositUtxo: BitcoinUtxo - let bitcoinClient: MockBitcoinClient - let bridge: MockBridge - - beforeEach(async () => { - // Create a deposit transaction. - const result = await assembleDepositTransaction( - deposit, - [testnetUTXO], - testnetPrivateKey, - true - ) - - transaction = result.rawTransaction - depositUtxo = result.depositUtxo + describe("Deposit", () => { + describe("", () => { + describe("auto funding outpoint detection mode", () => { + // TODO: Unit test for this case. + }) - // Initialize the mock Bitcoin client to return the raw transaction - // data for the given deposit UTXO. - bitcoinClient = new MockBitcoinClient() - const rawTransactions = new Map() - rawTransactions.set(depositUtxo.transactionHash.toString(), transaction) - bitcoinClient.rawTransactions = rawTransactions + describe("manual funding outpoint provision mode", () => { + let transaction: BitcoinRawTx + let depositUtxo: BitcoinUtxo + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient - // Initialize the mock Bridge. - bridge = new MockBridge() + beforeEach(async () => { + const depositFunding = DepositFunding.fromScript( + DepositScript.fromReceipt(deposit) + ) - await revealDeposit(depositUtxo, deposit, bitcoinClient, bridge) - }) + // Create a deposit transaction. + const result = await depositFunding.assembleTransaction( + depositAmount, + [testnetUTXO], + testnetPrivateKey + ) - it("should reveal the deposit to the Bridge", () => { - expect(bridge.revealDepositLog.length).to.be.equal(1) + transaction = result.rawTransaction + depositUtxo = result.depositUtxo - const revealDepositLogEntry = bridge.revealDepositLog[0] - expect(revealDepositLogEntry.depositTx).to.be.eql( - extractBitcoinRawTxVectors(transaction) - ) - expect(revealDepositLogEntry.depositOutputIndex).to.be.equal(0) - expect(revealDepositLogEntry.deposit).to.be.eql(deposit) - }) - }) + // Initialize the mock Bitcoin client to return the raw transaction + // data for the given deposit UTXO. + bitcoinClient = new MockBitcoinClient() + const rawTransactions = new Map() + rawTransactions.set( + depositUtxo.transactionHash.toString(), + transaction + ) + bitcoinClient.rawTransactions = rawTransactions - describe("getRevealedDeposit", () => { - let depositUtxo: BitcoinUtxo - let revealedDeposit: DepositRequest - let bridge: MockBridge - - beforeEach(async () => { - // Create a deposit transaction. - ;({ depositUtxo } = await assembleDepositTransaction( - deposit, - [testnetUTXO], - testnetPrivateKey, - true - )) - - revealedDeposit = { - depositor: deposit.depositor, - amount: deposit.amount, - vault: EthereumAddress.from("954b98637ca318a4d6e7ca6ffd1690b8e77df637"), - revealedAt: 1654774330, - sweptAt: 1655033516, - treasuryFee: BigNumber.from(200), - } - - const revealedDeposits = new Map() - revealedDeposits.set( - MockBridge.buildDepositKey( - depositUtxo.transactionHash, - depositUtxo.outputIndex - ), - revealedDeposit - ) + // Initialize the mock Bridge. + tbtcContracts = new MockTBTCContracts() - bridge = new MockBridge() - bridge.setDeposits(revealedDeposits) - }) + await ( + await Deposit.fromReceipt(deposit, tbtcContracts, bitcoinClient) + ).initiateMinting(depositUtxo) + }) - it("should return the expected revealed deposit", async () => { - const actualRevealedDeposit = await getRevealedDeposit( - depositUtxo, - bridge - ) + it("should reveal the deposit to the Bridge", () => { + expect(tbtcContracts.bridge.revealDepositLog.length).to.be.equal(1) - expect(actualRevealedDeposit).to.be.eql(revealedDeposit) + const revealDepositLogEntry = tbtcContracts.bridge.revealDepositLog[0] + expect(revealDepositLogEntry.depositTx).to.be.eql( + extractBitcoinRawTxVectors(transaction) + ) + expect(revealDepositLogEntry.depositOutputIndex).to.be.equal(0) + expect(revealDepositLogEntry.deposit).to.be.eql(deposit) + }) + }) }) }) - describe("suggestDepositWallet", () => { - const publicKey = - "03989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9" - - let bridge: MockBridge - - beforeEach(async () => { - bridge = new MockBridge() - bridge.setActiveWalletPublicKey(publicKey) - }) - - it("should return the deposit wallet's public key", async () => { - expect(await suggestDepositWallet(bridge)).to.be.equal(publicKey) - }) + describe("DepositsService", () => { + // TODO: Implement unit tests. }) }) diff --git a/typescript/test/utils/mock-tbtc-contracts.ts b/typescript/test/utils/mock-tbtc-contracts.ts new file mode 100644 index 000000000..5a6568dbb --- /dev/null +++ b/typescript/test/utils/mock-tbtc-contracts.ts @@ -0,0 +1,19 @@ +import { TBTCContracts } from "../../src/lib/contracts" +import { MockBridge } from "./mock-bridge" +import { MockTBTCToken } from "./mock-tbtc-token" +import { MockTBTCVault } from "./mock-tbtc-vault" +import { MockWalletRegistry } from "./mock-wallet-registry" + +export class MockTBTCContracts implements TBTCContracts { + public readonly bridge: MockBridge + public readonly tbtcToken: MockTBTCToken + public readonly tbtcVault: MockTBTCVault + public readonly walletRegistry: MockWalletRegistry + + constructor() { + this.bridge = new MockBridge() + this.tbtcToken = new MockTBTCToken() + this.tbtcVault = new MockTBTCVault() + this.walletRegistry = new MockWalletRegistry() + } +} diff --git a/typescript/test/utils/mock-tbtc-vault.ts b/typescript/test/utils/mock-tbtc-vault.ts new file mode 100644 index 000000000..3b58011e5 --- /dev/null +++ b/typescript/test/utils/mock-tbtc-vault.ts @@ -0,0 +1,83 @@ +import { + TBTCVault, + OptimisticMintingCancelledEvent, + OptimisticMintingFinalizedEvent, + OptimisticMintingRequestedEvent, + ChainIdentifier, + GetChainEvents, + OptimisticMintingRequest, +} from "../../src/lib/contracts" +import { BitcoinTxHash } from "../../src/lib/bitcoin" +import { Hex } from "../../src/lib/utils" +import { EthereumAddress } from "../../src" + +export class MockTBTCVault implements TBTCVault { + getOptimisticMintingCancelledEvents( + options?: GetChainEvents.Options, + ...filterArgs: Array + ): Promise { + throw new Error("not implemented") + } + + getOptimisticMintingFinalizedEvents( + options?: GetChainEvents.Options, + ...filterArgs: Array + ): Promise { + throw new Error("not implemented") + } + + getOptimisticMintingRequestedEvents( + options?: GetChainEvents.Options, + ...filterArgs: Array + ): Promise { + throw new Error("not implemented") + } + + cancelOptimisticMint( + depositTxHash: BitcoinTxHash, + depositOutputIndex: number + ): Promise { + throw new Error("not implemented") + } + + finalizeOptimisticMint( + depositTxHash: BitcoinTxHash, + depositOutputIndex: number + ): Promise { + throw new Error("not implemented") + } + + getChainIdentifier(): ChainIdentifier { + return EthereumAddress.from("0x594cfd89700040163727828AE20B52099C58F02C") + } + + getMinters(): Promise { + throw new Error("not implemented") + } + + isGuardian(identifier: ChainIdentifier): Promise { + throw new Error("not implemented") + } + + isMinter(identifier: ChainIdentifier): Promise { + throw new Error("not implemented") + } + + optimisticMintingDelay(): Promise { + throw new Error("not implemented") + } + + optimisticMintingRequests( + depositTxHash: BitcoinTxHash, + depositOutputIndex: number + ): Promise { + throw new Error("not implemented") + } + + requestOptimisticMint( + depositTxHash: BitcoinTxHash, + depositOutputIndex: number + ): Promise { + throw new Error("not implemented") + } +} diff --git a/typescript/test/utils/mock-wallet-registry.ts b/typescript/test/utils/mock-wallet-registry.ts new file mode 100644 index 000000000..708c6fb00 --- /dev/null +++ b/typescript/test/utils/mock-wallet-registry.ts @@ -0,0 +1,35 @@ +import { + GetChainEvents, + WalletRegistry, + DkgResultApprovedEvent, + DkgResultChallengedEvent, + DkgResultSubmittedEvent, +} from "../../src/lib/contracts" +import { Hex } from "../../src/lib/utils" + +export class MockWalletRegistry implements WalletRegistry { + getDkgResultApprovedEvents( + options?: GetChainEvents.Options, + ...filterArgs: Array + ): Promise { + throw new Error("not implemented") + } + + getDkgResultChallengedEvents( + options?: GetChainEvents.Options, + ...filterArgs: Array + ): Promise { + throw new Error("not implemented") + } + + getDkgResultSubmittedEvents( + options?: GetChainEvents.Options, + ...filterArgs: Array + ): Promise { + throw new Error("not implemented") + } + + getWalletPublicKey(walletID: Hex): Promise { + throw new Error("not implemented") + } +} From 40b990c87cd641f80dcae4d87f59bcb5934c64f2 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 28 Sep 2023 15:56:39 +0200 Subject: [PATCH 172/205] Move `deposit-refund.ts` to the `./services/deposits` feature module This code is part of the user-facing deposit flow so should live in the `./services/deposits` module. --- typescript/src/deposit-refund.ts | 301 --------------------- typescript/src/services/deposits/refund.ts | 301 +++++++++++++++++++++ typescript/test/deposit-refund.test.ts | 280 ++++++++++--------- 3 files changed, 449 insertions(+), 433 deletions(-) delete mode 100644 typescript/src/deposit-refund.ts create mode 100644 typescript/src/services/deposits/refund.ts diff --git a/typescript/src/deposit-refund.ts b/typescript/src/deposit-refund.ts deleted file mode 100644 index 952516e9a..000000000 --- a/typescript/src/deposit-refund.ts +++ /dev/null @@ -1,301 +0,0 @@ -import bcoin from "bcoin" -import { BigNumber } from "ethers" -import { - BitcoinPrivateKeyUtils, - BitcoinRawTx, - BitcoinClient, - BitcoinTxHash, - BitcoinUtxo, - BitcoinHashUtils, - BitcoinPublicKeyUtils, -} from "./lib/bitcoin" -import { DepositReceipt, validateDepositReceipt } from "./lib/contracts" -import { DepositScript } from "./services/deposits" - -/** - * Submits a deposit refund by creating and broadcasting a Bitcoin P2(W)PKH - * deposit refund transaction. - * @param bitcoinClient - Bitcoin client used to interact with the network. - * @param fee - the value that will be subtracted from the deposit UTXO being - * refunded and used as the transaction fee. - * @param utxo - UTXO that was created during depositing that needs be refunded. - * @param deposit - Details of the deposit being refunded. It should contain - * the same data that was used during depositing. - * @param refunderAddress - Recipient Bitcoin wallet address of the refunded - * deposit. - * @param refunderPrivateKey - Bitcoin wallet private key of the refunder. - * It must correspond to the `refundPublicKeyHash` of the deposit script. - * @returns The outcome is the deposit refund transaction hash. - * @dev This function should be called by the refunder after `refundLocktime` - * passes plus 1 hour. The additional hour of waiting is the result of - * adopting BIP113 which compares the transaction's locktime against the - * median timestamp of the last 11 blocks. This median time lags - * the current unix time by about 1 hour. - */ -export async function submitDepositRefundTransaction( - bitcoinClient: BitcoinClient, - fee: BigNumber, - utxo: BitcoinUtxo, - deposit: DepositReceipt, - refunderAddress: string, - refunderPrivateKey: string -): Promise<{ transactionHash: BitcoinTxHash }> { - const utxoRawTransaction = await bitcoinClient.getRawTransaction( - utxo.transactionHash - ) - - const utxoWithRaw = { - ...utxo, - transactionHex: utxoRawTransaction.transactionHex, - } - - const { transactionHash, rawTransaction } = - await assembleDepositRefundTransaction( - fee, - utxoWithRaw, - deposit, - refunderAddress, - refunderPrivateKey - ) - - // Note that `broadcast` may fail silently (i.e. no error will be returned, - // even if the transaction is rejected by other nodes and does not enter the - // mempool, for example due to an UTXO being already spent). - await bitcoinClient.broadcast(rawTransaction) - - return { transactionHash } -} - -/** - * Assembles a Bitcoin P2(W)PKH deposit refund transaction. - * @param fee - the value that will be subtracted from the deposit UTXO being - * refunded and used as the transaction fee. - * @param utxo - UTXO that was created during depositing that needs be refunded. - * @param deposit - Details of the deposit being refunded. It should contain - * the same data that was used during depositing. - * @param refunderAddress - Recipient Bitcoin wallet address of the refunded - * deposit. - * @param refunderPrivateKey - Bitcoin wallet private key of the refunder. - * It must correspond to the `refundPublicKeyHash` of the deposit script. - * @returns The outcome consisting of: - * - the deposit refund transaction hash, - * - the refund transaction in the raw format. - */ -export async function assembleDepositRefundTransaction( - fee: BigNumber, - utxo: BitcoinUtxo & BitcoinRawTx, - deposit: DepositReceipt, - refunderAddress: string, - refunderPrivateKey: string -): Promise<{ - transactionHash: BitcoinTxHash - rawTransaction: BitcoinRawTx -}> { - validateDepositReceipt(deposit) - - const refunderKeyRing = - BitcoinPrivateKeyUtils.createKeyRing(refunderPrivateKey) - - const transaction = new bcoin.MTX() - - transaction.addOutput({ - script: bcoin.Script.fromAddress(refunderAddress), - value: utxo.value.toNumber(), - }) - - const inputCoin = bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), - utxo.outputIndex, - -1 - ) - - await transaction.fund([inputCoin], { - changeAddress: refunderAddress, - hardFee: fee.toNumber(), - subtractFee: true, - }) - - if (transaction.outputs.length != 1) { - throw new Error("Deposit refund transaction must have only one output") - } - - // In order to be able to spend the UTXO being refunded the transaction's - // locktime must be set to a value equal to or higher than the refund locktime. - // Additionally, the input's sequence must be set to a value different than - // `0xffffffff`. These requirements are the result of BIP-65. - transaction.locktime = locktimeToUnixTimestamp(deposit.refundLocktime) - transaction.inputs[0].sequence = 0xfffffffe - - // Sign the input - const previousOutpoint = transaction.inputs[0].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - const previousScript = previousOutput.script - - if (previousScript.isScripthash()) { - // P2SH UTXO deposit input - await signP2SHDepositInput(transaction, 0, deposit, refunderKeyRing) - } else if (previousScript.isWitnessScripthash()) { - // P2WSH UTXO deposit input - await signP2WSHDepositInput(transaction, 0, deposit, refunderKeyRing) - } else { - throw new Error("Unsupported UTXO script type") - } - - // Verify the transaction by executing its input scripts. - const tx = transaction.toTX() - if (!tx.verify(transaction.view)) { - throw new Error("Transaction verification failure") - } - - const transactionHash = BitcoinTxHash.from(transaction.txid()) - - return { - transactionHash, - rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), - }, - } -} - -/** - * Creates data needed to sign a deposit input to be refunded. - * @param transaction - Mutable transaction containing the input to be refunded. - * @param inputIndex - Index that points to the input. - * @param deposit - Data of the deposit to be refunded. - * @param refunderKeyRing - Key ring created using the refunder's private key. - * @returns Data needed to sign the input. - */ -async function prepareInputSignData( - transaction: any, - inputIndex: number, - deposit: DepositReceipt, - refunderKeyRing: any -): Promise<{ - refunderPublicKey: string - depositScript: any - previousOutputValue: number -}> { - const previousOutpoint = transaction.inputs[inputIndex].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - - const refunderPublicKey = refunderKeyRing.getPublicKey("hex") - if ( - BitcoinHashUtils.computeHash160(refunderKeyRing.getPublicKey("hex")) != - deposit.refundPublicKeyHash - ) { - throw new Error( - "Refund public key does not correspond to the refunder private key" - ) - } - - if (!BitcoinPublicKeyUtils.isCompressedPublicKey(refunderPublicKey)) { - throw new Error("Refunder public key must be compressed") - } - - const depositScript = bcoin.Script.fromRaw( - Buffer.from(await DepositScript.fromReceipt(deposit).getPlainText(), "hex") - ) - - return { - refunderPublicKey: refunderPublicKey, - depositScript: depositScript, - previousOutputValue: previousOutput.value, - } -} - -/** - * Creates and sets `scriptSig` for the transaction input at the given index by - * combining signature, refunder's public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param refunderKeyRing - Key ring created using the refunder's private key. - * @returns Empty return. - */ -async function signP2SHDepositInput( - transaction: any, - inputIndex: number, - deposit: DepositReceipt, - refunderKeyRing: any -) { - const { refunderPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData( - transaction, - inputIndex, - deposit, - refunderKeyRing - ) - - const signature: Buffer = transaction.signature( - inputIndex, - depositScript, - previousOutputValue, - refunderKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 0 // legacy sighash version - ) - const scriptSig = new bcoin.Script() - scriptSig.clear() - scriptSig.pushData(signature) - scriptSig.pushData(Buffer.from(refunderPublicKey, "hex")) - scriptSig.pushData(depositScript.toRaw()) - scriptSig.compile() - - transaction.inputs[inputIndex].script = scriptSig -} - -/** - * Creates and sets witness script for the transaction input at the given index - * by combining signature, refunder public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param refunderKeyRing - Key ring created using the refunder's private key. - * @returns Empty return. - */ -async function signP2WSHDepositInput( - transaction: any, - inputIndex: number, - deposit: DepositReceipt, - refunderKeyRing: any -) { - const { refunderPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData( - transaction, - inputIndex, - deposit, - refunderKeyRing - ) - - const signature: Buffer = transaction.signature( - inputIndex, - depositScript, - previousOutputValue, - refunderKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 1 // segwit sighash version - ) - - const witness = new bcoin.Witness() - witness.clear() - witness.pushData(signature) - witness.pushData(Buffer.from(refunderPublicKey, "hex")) - witness.pushData(depositScript.toRaw()) - witness.compile() - - transaction.inputs[inputIndex].witness = witness -} - -/** - * Converts locktime from the little endian hexstring format to the Unix - * timestamp. - * @param locktime - Locktime as a little endian hexstring. - * @returns Locktime as a Unix timestamp. - */ -function locktimeToUnixTimestamp(locktime: string): number { - const bigEndianLocktime = Buffer.from(locktime, "hex") - .reverse() - .toString("hex") - - return parseInt(bigEndianLocktime, 16) -} diff --git a/typescript/src/services/deposits/refund.ts b/typescript/src/services/deposits/refund.ts new file mode 100644 index 000000000..4582c7f1c --- /dev/null +++ b/typescript/src/services/deposits/refund.ts @@ -0,0 +1,301 @@ +import bcoin from "bcoin" +import { BigNumber } from "ethers" +import { + BitcoinPrivateKeyUtils, + BitcoinRawTx, + BitcoinClient, + BitcoinTxHash, + BitcoinUtxo, + BitcoinHashUtils, + BitcoinPublicKeyUtils, +} from "../../lib/bitcoin" +import { validateDepositReceipt } from "../../lib/contracts" +import { DepositScript } from "./" + +/** + * Component allowing to craft and submit the Bitcoin refund transaction using + * the given tBTC v2 deposit script. + * + * @experimental THIS IS EXPERIMENTAL CODE THAT CAN BE CHANGED OR REMOVED + * IN FUTURE RELEASES. IT SHOULD BE USED ONLY FOR INTERNAL + * PURPOSES AND EXTERNAL APPLICATIONS SHOULD NOT DEPEND ON IT. + */ +// TODO: Abstract away transaction signing so there is no need to deal with +// private key directly. +export class DepositRefund { + public readonly script: DepositScript + + private constructor(script: DepositScript) { + this.script = script + } + + static fromScript(script: DepositScript): DepositRefund { + return new DepositRefund(script) + } + + /** + * Submits a deposit refund by creating and broadcasting a Bitcoin P2(W)PKH + * deposit refund transaction. + * @param bitcoinClient - Bitcoin client used to interact with the network. + * @param fee - the value that will be subtracted from the deposit UTXO being + * refunded and used as the transaction fee. + * @param utxo - UTXO that was created during depositing that needs be refunded. + * @param refunderAddress - Recipient Bitcoin wallet address of the refunded + * deposit. + * @param refunderPrivateKey - Bitcoin wallet private key of the refunder. + * It must correspond to the `refundPublicKeyHash` of the deposit script. + * @returns The outcome is the deposit refund transaction hash. + * @dev This function should be called by the refunder after `refundLocktime` + * passes plus 1 hour. The additional hour of waiting is the result of + * adopting BIP113 which compares the transaction's locktime against the + * median timestamp of the last 11 blocks. This median time lags + * the current unix time by about 1 hour. + */ + async submitTransaction( + bitcoinClient: BitcoinClient, + fee: BigNumber, + utxo: BitcoinUtxo, + refunderAddress: string, + refunderPrivateKey: string + ): Promise<{ transactionHash: BitcoinTxHash }> { + const utxoRawTransaction = await bitcoinClient.getRawTransaction( + utxo.transactionHash + ) + + const utxoWithRaw = { + ...utxo, + transactionHex: utxoRawTransaction.transactionHex, + } + + const { transactionHash, rawTransaction } = await this.assembleTransaction( + fee, + utxoWithRaw, + refunderAddress, + refunderPrivateKey + ) + + // Note that `broadcast` may fail silently (i.e. no error will be returned, + // even if the transaction is rejected by other nodes and does not enter the + // mempool, for example due to an UTXO being already spent). + await bitcoinClient.broadcast(rawTransaction) + + return { transactionHash } + } + + /** + * Assembles a Bitcoin P2(W)PKH deposit refund transaction. + * @param fee - the value that will be subtracted from the deposit UTXO being + * refunded and used as the transaction fee. + * @param utxo - UTXO that was created during depositing that needs be refunded. + * @param refunderAddress - Recipient Bitcoin wallet address of the refunded + * deposit. + * @param refunderPrivateKey - Bitcoin wallet private key of the refunder. + * It must correspond to the `refundPublicKeyHash` of the deposit script. + * @returns The outcome consisting of: + * - the deposit refund transaction hash, + * - the refund transaction in the raw format. + */ + async assembleTransaction( + fee: BigNumber, + utxo: BitcoinUtxo & BitcoinRawTx, + refunderAddress: string, + refunderPrivateKey: string + ): Promise<{ + transactionHash: BitcoinTxHash + rawTransaction: BitcoinRawTx + }> { + validateDepositReceipt(this.script.receipt) + + const refunderKeyRing = + BitcoinPrivateKeyUtils.createKeyRing(refunderPrivateKey) + + const transaction = new bcoin.MTX() + + transaction.addOutput({ + script: bcoin.Script.fromAddress(refunderAddress), + value: utxo.value.toNumber(), + }) + + const inputCoin = bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), + utxo.outputIndex, + -1 + ) + + await transaction.fund([inputCoin], { + changeAddress: refunderAddress, + hardFee: fee.toNumber(), + subtractFee: true, + }) + + if (transaction.outputs.length != 1) { + throw new Error("Deposit refund transaction must have only one output") + } + + // In order to be able to spend the UTXO being refunded the transaction's + // locktime must be set to a value equal to or higher than the refund locktime. + // Additionally, the input's sequence must be set to a value different than + // `0xffffffff`. These requirements are the result of BIP-65. + transaction.locktime = locktimeToUnixTimestamp( + this.script.receipt.refundLocktime + ) + transaction.inputs[0].sequence = 0xfffffffe + + // Sign the input + const previousOutpoint = transaction.inputs[0].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) + const previousScript = previousOutput.script + + if (previousScript.isScripthash()) { + // P2SH UTXO deposit input + await this.signP2SHDepositInput(transaction, 0, refunderKeyRing) + } else if (previousScript.isWitnessScripthash()) { + // P2WSH UTXO deposit input + await this.signP2WSHDepositInput(transaction, 0, refunderKeyRing) + } else { + throw new Error("Unsupported UTXO script type") + } + + // Verify the transaction by executing its input scripts. + const tx = transaction.toTX() + if (!tx.verify(transaction.view)) { + throw new Error("Transaction verification failure") + } + + const transactionHash = BitcoinTxHash.from(transaction.txid()) + + return { + transactionHash, + rawTransaction: { + transactionHex: transaction.toRaw().toString("hex"), + }, + } + } + + /** + * Creates data needed to sign a deposit input to be refunded. + * @param transaction - Mutable transaction containing the input to be refunded. + * @param inputIndex - Index that points to the input. + * @param refunderKeyRing - Key ring created using the refunder's private key. + * @returns Data needed to sign the input. + */ + private async prepareInputSignData( + transaction: any, + inputIndex: number, + refunderKeyRing: any + ): Promise<{ + refunderPublicKey: string + depositScript: any + previousOutputValue: number + }> { + const previousOutpoint = transaction.inputs[inputIndex].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) + + const refunderPublicKey = refunderKeyRing.getPublicKey("hex") + if ( + BitcoinHashUtils.computeHash160(refunderKeyRing.getPublicKey("hex")) != + this.script.receipt.refundPublicKeyHash + ) { + throw new Error( + "Refund public key does not correspond to the refunder private key" + ) + } + + if (!BitcoinPublicKeyUtils.isCompressedPublicKey(refunderPublicKey)) { + throw new Error("Refunder public key must be compressed") + } + + const depositScript = bcoin.Script.fromRaw( + Buffer.from(await this.script.getPlainText(), "hex") + ) + + return { + refunderPublicKey: refunderPublicKey, + depositScript: depositScript, + previousOutputValue: previousOutput.value, + } + } + + /** + * Creates and sets `scriptSig` for the transaction input at the given index by + * combining signature, refunder's public key and deposit script. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param refunderKeyRing - Key ring created using the refunder's private key. + * @returns Empty return. + */ + private async signP2SHDepositInput( + transaction: any, + inputIndex: number, + refunderKeyRing: any + ) { + const { refunderPublicKey, depositScript, previousOutputValue } = + await this.prepareInputSignData(transaction, inputIndex, refunderKeyRing) + + const signature: Buffer = transaction.signature( + inputIndex, + depositScript, + previousOutputValue, + refunderKeyRing.privateKey, + bcoin.Script.hashType.ALL, + 0 // legacy sighash version + ) + const scriptSig = new bcoin.Script() + scriptSig.clear() + scriptSig.pushData(signature) + scriptSig.pushData(Buffer.from(refunderPublicKey, "hex")) + scriptSig.pushData(depositScript.toRaw()) + scriptSig.compile() + + transaction.inputs[inputIndex].script = scriptSig + } + + /** + * Creates and sets witness script for the transaction input at the given index + * by combining signature, refunder public key and deposit script. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param refunderKeyRing - Key ring created using the refunder's private key. + * @returns Empty return. + */ + private async signP2WSHDepositInput( + transaction: any, + inputIndex: number, + refunderKeyRing: any + ) { + const { refunderPublicKey, depositScript, previousOutputValue } = + await this.prepareInputSignData(transaction, inputIndex, refunderKeyRing) + + const signature: Buffer = transaction.signature( + inputIndex, + depositScript, + previousOutputValue, + refunderKeyRing.privateKey, + bcoin.Script.hashType.ALL, + 1 // segwit sighash version + ) + + const witness = new bcoin.Witness() + witness.clear() + witness.pushData(signature) + witness.pushData(Buffer.from(refunderPublicKey, "hex")) + witness.pushData(depositScript.toRaw()) + witness.compile() + + transaction.inputs[inputIndex].witness = witness + } +} + +/** + * Converts locktime from the little endian hexstring format to the Unix + * timestamp. + * @param locktime - Locktime as a little endian hexstring. + * @returns Locktime as a Unix timestamp. + */ +function locktimeToUnixTimestamp(locktime: string): number { + const bigEndianLocktime = Buffer.from(locktime, "hex") + .reverse() + .toString("hex") + + return parseInt(bigEndianLocktime, 16) +} diff --git a/typescript/test/deposit-refund.test.ts b/typescript/test/deposit-refund.test.ts index bafc68736..6825e6fa8 100644 --- a/typescript/test/deposit-refund.test.ts +++ b/typescript/test/deposit-refund.test.ts @@ -1,10 +1,10 @@ import { BigNumber } from "ethers" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" +import bcoin from "bcoin" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) import { expect } from "chai" -import { submitDepositRefundTransaction } from "../src/deposit-refund" import { BitcoinTxHash, BitcoinRawTx } from "./lib/bitcoin" import { refunderPrivateKey, @@ -12,156 +12,172 @@ import { depositRefundOfNonWitnessDepositAndWitnessRefunderAddress, depositRefundOfWitnessDepositAndNonWitnessRefunderAddress, } from "./data/deposit-refund" +import { DepositRefund } from "../src/services/deposits/refund" +import { DepositScript } from "../src/services/deposits" describe("Refund", () => { const fee = BigNumber.from(1520) - describe("submitDepositRefundTransaction", () => { - let bitcoinClient: MockBitcoinClient + describe("DepositRefund", () => { + describe("submitTransaction", () => { + let bitcoinClient: MockBitcoinClient - beforeEach(async () => { - bitcoinClient = new MockBitcoinClient() - }) + beforeEach(async () => { + bcoin.set("testnet") + + bitcoinClient = new MockBitcoinClient() + }) - context("when the refund transaction is requested to be witness", () => { - context("when the refunded deposit was witness", () => { - let transactionHash: BitcoinTxHash - - beforeEach(async () => { - const utxo = - depositRefundOfWitnessDepositAndWitnessRefunderAddress.deposit.utxo - const deposit = - depositRefundOfWitnessDepositAndWitnessRefunderAddress.deposit.data - const refunderAddress = - depositRefundOfWitnessDepositAndWitnessRefunderAddress.refunderAddress - const refunderPrivateKey = - "cTWhf1nXc7aW8BN2qLtWcPtcgcWYKfzRXkCJNsuQ86HR8uJBYfMc" - - const rawTransactions = new Map() - rawTransactions.set(utxo.transactionHash.toString(), { - transactionHex: utxo.transactionHex, + context("when the refund transaction is requested to be witness", () => { + context("when the refunded deposit was witness", () => { + let transactionHash: BitcoinTxHash + + beforeEach(async () => { + const utxo = + depositRefundOfWitnessDepositAndWitnessRefunderAddress.deposit + .utxo + const deposit = + depositRefundOfWitnessDepositAndWitnessRefunderAddress.deposit + .data + const refunderAddress = + depositRefundOfWitnessDepositAndWitnessRefunderAddress.refunderAddress + const refunderPrivateKey = + "cTWhf1nXc7aW8BN2qLtWcPtcgcWYKfzRXkCJNsuQ86HR8uJBYfMc" + + const rawTransactions = new Map() + rawTransactions.set(utxo.transactionHash.toString(), { + transactionHex: utxo.transactionHex, + }) + bitcoinClient.rawTransactions = rawTransactions + + const depositRefund = DepositRefund.fromScript( + DepositScript.fromReceipt(deposit) + ) + + ;({ transactionHash } = await depositRefund.submitTransaction( + bitcoinClient, + fee, + utxo, + refunderAddress, + refunderPrivateKey + )) }) - bitcoinClient.rawTransactions = rawTransactions - ;({ transactionHash } = await submitDepositRefundTransaction( - bitcoinClient, - fee, - utxo, - deposit, - refunderAddress, - refunderPrivateKey - )) - }) - it("should broadcast refund transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositRefundOfWitnessDepositAndWitnessRefunderAddress - .expectedRefund.transaction - ) - }) + it("should broadcast refund transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositRefundOfWitnessDepositAndWitnessRefunderAddress + .expectedRefund.transaction + ) + }) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositRefundOfWitnessDepositAndWitnessRefunderAddress - .expectedRefund.transactionHash - ) + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositRefundOfWitnessDepositAndWitnessRefunderAddress + .expectedRefund.transactionHash + ) + }) }) - }) - context("when the refunded deposit was non-witness", () => { - let transactionHash: BitcoinTxHash - - beforeEach(async () => { - const utxo = - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.deposit - .utxo - const deposit = - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.deposit - .data - const refunderAddress = - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.refunderAddress - - const rawTransactions = new Map() - rawTransactions.set(utxo.transactionHash.toString(), { - transactionHex: utxo.transactionHex, + context("when the refunded deposit was non-witness", () => { + let transactionHash: BitcoinTxHash + + beforeEach(async () => { + const utxo = + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.deposit + .utxo + const deposit = + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.deposit + .data + const refunderAddress = + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.refunderAddress + + const rawTransactions = new Map() + rawTransactions.set(utxo.transactionHash.toString(), { + transactionHex: utxo.transactionHex, + }) + bitcoinClient.rawTransactions = rawTransactions + + const depositRefund = DepositRefund.fromScript( + DepositScript.fromReceipt(deposit) + ) + + ;({ transactionHash } = await depositRefund.submitTransaction( + bitcoinClient, + fee, + utxo, + refunderAddress, + refunderPrivateKey + )) }) - bitcoinClient.rawTransactions = rawTransactions - ;({ transactionHash } = await submitDepositRefundTransaction( - bitcoinClient, - fee, - utxo, - deposit, - refunderAddress, - refunderPrivateKey - )) - }) - it("should broadcast refund transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress - .expectedRefund.transaction - ) - }) + it("should broadcast refund transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress + .expectedRefund.transaction + ) + }) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress - .expectedRefund.transactionHash - ) + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress + .expectedRefund.transactionHash + ) + }) }) }) - }) - context( - "when the refund transaction is requested to be non-witness", - () => { - let transactionHash: BitcoinTxHash - - beforeEach(async () => { - const utxo = - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.deposit - .utxo - const deposit = - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.deposit - .data - const refunderAddress = - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.refunderAddress - - const rawTransactions = new Map() - rawTransactions.set(utxo.transactionHash.toString(), { - transactionHex: utxo.transactionHex, + context( + "when the refund transaction is requested to be non-witness", + () => { + let transactionHash: BitcoinTxHash + + beforeEach(async () => { + const utxo = + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.deposit + .utxo + const deposit = + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.deposit + .data + const refunderAddress = + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.refunderAddress + + const rawTransactions = new Map() + rawTransactions.set(utxo.transactionHash.toString(), { + transactionHex: utxo.transactionHex, + }) + + const depositRefund = DepositRefund.fromScript( + DepositScript.fromReceipt(deposit) + ) + + bitcoinClient.rawTransactions = rawTransactions + ;({ transactionHash } = await depositRefund.submitTransaction( + bitcoinClient, + fee, + utxo, + refunderAddress, + refunderPrivateKey + )) }) - bitcoinClient.rawTransactions = rawTransactions - ;({ transactionHash } = await submitDepositRefundTransaction( - bitcoinClient, - fee, - utxo, - deposit, - refunderAddress, - refunderPrivateKey - )) - }) - - it("should broadcast refund transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress - .expectedRefund.transaction - ) - }) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress - .expectedRefund.transactionHash - ) - }) - } - ) - }) + it("should broadcast refund transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress + .expectedRefund.transaction + ) + }) - describe("assembleDepositRefundTransaction", () => { - // TODO + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress + .expectedRefund.transactionHash + ) + }) + } + ) + }) }) }) From 8ec25d6ac33cbbd2fd7542f92c1f90287948a234 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 29 Sep 2023 09:04:02 +0200 Subject: [PATCH 173/205] Add some TODOs around deposits --- typescript/src/services/deposits/deposit.ts | 1 + typescript/src/services/deposits/deposits-service.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/typescript/src/services/deposits/deposit.ts b/typescript/src/services/deposits/deposit.ts index 4ce3099a3..e455724ad 100644 --- a/typescript/src/services/deposits/deposit.ts +++ b/typescript/src/services/deposits/deposit.ts @@ -111,6 +111,7 @@ export class Deposit { * initiate minting (both modes). */ // TODO: Cover auto funding outpoint detection with unit tests. + // TODO: Return Hex. async initiateMinting(fundingOutpoint?: BitcoinTxOutpoint): Promise { let resolvedFundingOutpoint: BitcoinTxOutpoint diff --git a/typescript/src/services/deposits/deposits-service.ts b/typescript/src/services/deposits/deposits-service.ts index 8b6a2e3be..d7c5c73b5 100644 --- a/typescript/src/services/deposits/deposits-service.ts +++ b/typescript/src/services/deposits/deposits-service.ts @@ -75,6 +75,9 @@ export class DepositsService { const walletPublicKeyHash = BitcoinHashUtils.computeHash160(walletPublicKey) + // TODO: Only P2(W)PKH addresses can be used for recovery. The below conversion + // function ensures that but it would be good to check it here as well + // in case the converter implementation changes. const refundPublicKeyHash = BitcoinAddressConverter.addressToPublicKeyHash( bitcoinRecoveryAddress ) From 14ecaef2e7a6a05b19550beb46dc935651bab219 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 29 Sep 2023 11:54:28 +0200 Subject: [PATCH 174/205] Move part of `redemption.ts` to the `./services/redemptions` feature module Move the user-facing redemption code to the new `./services/redemptions` module. Some refactoring meant to facilitate usage was done as well. --- typescript/src/index.ts | 13 +- typescript/src/redemption.ts | 291 +--- typescript/src/services/redemptions/index.ts | 1 + .../redemptions/redemptions-service.ts | 363 +++++ typescript/src/wallet.ts | 124 -- typescript/test/redemption.test.ts | 1172 +++++++++++------ typescript/test/wallet.test.ts | 291 ---- 7 files changed, 1170 insertions(+), 1085 deletions(-) create mode 100644 typescript/src/services/redemptions/index.ts create mode 100644 typescript/src/services/redemptions/redemptions-service.ts delete mode 100644 typescript/src/wallet.ts delete mode 100644 typescript/test/wallet.test.ts diff --git a/typescript/src/index.ts b/typescript/src/index.ts index 84130baa0..1c50e4168 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -4,12 +4,7 @@ import { validateBitcoinSpvProof } from "./lib/bitcoin" import { submitDepositSweepProof } from "./deposit-sweep" -import { - requestRedemption, - submitRedemptionProof, - getRedemptionRequest, - findWalletForRedemption, -} from "./redemption" +import { submitRedemptionProof } from "./redemption" import { requestOptimisticMint, @@ -18,12 +13,6 @@ import { getOptimisticMintingRequest, } from "./optimistic-minting" -export const TBTC = { - requestRedemption, - getRedemptionRequest, - findWalletForRedemption, -} - export const SpvMaintainer = { submitDepositSweepProof, submitRedemptionProof, diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts index cda5658f2..5c1696812 100644 --- a/typescript/src/redemption.ts +++ b/typescript/src/redemption.ts @@ -2,7 +2,6 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" import { assembleBitcoinSpvProof, - BitcoinNetwork, BitcoinPrivateKeyUtils, extractBitcoinRawTxVectors, BitcoinRawTx, @@ -10,42 +9,7 @@ import { BitcoinClient, BitcoinTxHash, } from "./lib/bitcoin" -import { - Bridge, - RedemptionRequest, - TBTCToken, - WalletState, -} from "./lib/contracts" -import { determineWalletMainUtxo } from "./wallet" -import { Hex } from "./lib/utils" - -/** - * Requests a redemption of tBTC into BTC. - * @param walletPublicKey - The Bitcoin public key of the wallet. Must be in the - * compressed form (33 bytes long with 02 or 03 prefix). - * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO held - * by the on-chain Bridge contract. - * @param redeemerOutputScript - The output script that the redeemed funds will - * be locked to. Must be un-prefixed and not prepended with length. - * @param amount - The amount to be redeemed with the precision of the tBTC - * on-chain token contract. - * @param tBTCToken - Handle to the TBTCToken on-chain contract. - * @returns Transaction hash of the request redemption transaction. - */ -export async function requestRedemption( - walletPublicKey: string, - mainUtxo: BitcoinUtxo, - redeemerOutputScript: string, - amount: BigNumber, - tBTCToken: TBTCToken -): Promise { - return await tBTCToken.requestRedemption( - walletPublicKey, - mainUtxo, - redeemerOutputScript, - amount - ) -} +import { Bridge, RedemptionRequest } from "./lib/contracts" /** * Handles pending redemption requests by creating a redemption transaction @@ -89,14 +53,27 @@ export async function submitRedemptionTransaction( transactionHex: mainUtxoRawTransaction.transactionHex, } - const redemptionRequests = await getWalletRedemptionRequests( - bridge, - BitcoinPrivateKeyUtils.createKeyRing(walletPrivateKey) - .getPublicKey() - .toString("hex"), - redeemerOutputScripts, - "pending" - ) + const walletPublicKey = BitcoinPrivateKeyUtils.createKeyRing(walletPrivateKey) + .getPublicKey() + .toString("hex") + + const redemptionRequests: RedemptionRequest[] = [] + + for (const redeemerOutputScript of redeemerOutputScripts) { + const redemptionRequest = await bridge.pendingRedemptions( + walletPublicKey, + redeemerOutputScript + ) + + if (redemptionRequest.requestedAt == 0) { + throw new Error("Redemption request does not exist") + } + + redemptionRequests.push({ + ...redemptionRequest, + redeemerOutputScript: redeemerOutputScript, + }) + } const { transactionHash, newMainUtxo, rawTransaction } = await assembleRedemptionTransaction( @@ -114,74 +91,6 @@ export async function submitRedemptionTransaction( return { transactionHash, newMainUtxo } } -/** - * Gets a list of wallet's redemption requests from the provided Bridge - * on-chain contract handle. - * @dev It is up to the caller of this function to ensure that each of the - * redeemer output scripts represents a valid redemption request - * in the Bridge on-chain contract. An exception will be thrown if any of - * the redeemer output scripts (along with the wallet public key - * corresponding to the provided private key) does not represent a valid - * redemption request. - * @param bridge - The handle to the Bridge on-chain contract - * @param walletPublicKey - Bitcoin public key of the wallet. Must be in the - * compressed form (33 bytes long with 02 or 03 prefix). - * @param redeemerOutputScripts - The list of output scripts that the redeemed - * funds are locked to. The output scripts must be un-prefixed and - * not prepended with length - * @param type Type of redemption requests the function will look for. Can be - * either `pending` or `timedOut`. - * @returns The list of redemption requests. - */ -async function getWalletRedemptionRequests( - bridge: Bridge, - walletPublicKey: string, - redeemerOutputScripts: string[], - type: "pending" | "timedOut" -): Promise { - const redemptionRequests: RedemptionRequest[] = [] - - for (const redeemerOutputScript of redeemerOutputScripts) { - let redemptionRequest: RedemptionRequest - - switch (type) { - case "pending": { - redemptionRequest = await bridge.pendingRedemptions( - walletPublicKey, - redeemerOutputScript - ) - break - } - case "timedOut": { - redemptionRequest = await bridge.timedOutRedemptions( - walletPublicKey, - redeemerOutputScript - ) - break - } - default: { - throw new Error("Unsupported redemption request type") - } - } - - if (redemptionRequest.requestedAt == 0) { - // The requested redemption does not exist among `pendingRedemptions` - // in the Bridge. - throw new Error( - "Provided redeemer output script and wallet public key do not identify a redemption request" - ) - } - - // Redemption exists in the Bridge. Add it to the list. - redemptionRequests.push({ - ...redemptionRequest, - redeemerOutputScript: redeemerOutputScript, - }) - } - - return redemptionRequests -} - /** * Assembles a Bitcoin redemption transaction. * The transaction will have a single input (main UTXO of the wallet making @@ -345,159 +254,3 @@ export async function submitRedemptionProof( walletPublicKey ) } - -/** - * Gets a redemption request from the bridge. - * @param walletPublicKey Bitcoin public key of the wallet the request is - * targeted to. Must be in the compressed form (33 bytes long with 02 - * or 03 prefix). - * @param redeemerOutputScript The redeemer output script the redeemed funds - * are supposed to be locked on. Must be un-prefixed and not prepended - * with length. - * @param type Type of the redemption request the function will look for. Can be - * either `pending` or `timedOut`. - * @param bridge The handle to the Bridge on-chain contract - * @returns The resulting redemption request. - */ -export async function getRedemptionRequest( - walletPublicKey: string, - redeemerOutputScript: string, - type: "pending" | "timedOut", - bridge: Bridge -): Promise { - const redemptionRequests = await getWalletRedemptionRequests( - bridge, - walletPublicKey, - [redeemerOutputScript], - type - ) - - if (redemptionRequests.length != 1) { - throw new Error(`Returned an incorrect number of redemption requests`) - } - - return redemptionRequests[0] -} - -/** - * Finds the oldest live wallet that has enough BTC to handle a redemption - * request. - * @param amount The amount to be redeemed in satoshis. - * @param redeemerOutputScript The redeemer output script the redeemed funds are - * supposed to be locked on. Must be un-prefixed and not prepended with - * length. - * @param bitcoinNetwork Bitcoin network. - * @param bridge The handle to the Bridge on-chain contract. - * @param bitcoinClient Bitcoin client used to interact with the network. - * @returns Promise with the wallet details needed to request a redemption. - */ -export async function findWalletForRedemption( - amount: BigNumber, - redeemerOutputScript: string, - bitcoinNetwork: BitcoinNetwork, - bridge: Bridge, - bitcoinClient: BitcoinClient -): Promise<{ - walletPublicKey: string - mainUtxo: BitcoinUtxo -}> { - const wallets = await bridge.getNewWalletRegisteredEvents() - - let walletData: - | { - walletPublicKey: string - mainUtxo: BitcoinUtxo - } - | undefined = undefined - let maxAmount = BigNumber.from(0) - let liveWalletsCounter = 0 - - for (const wallet of wallets) { - const { walletPublicKeyHash } = wallet - const { state, walletPublicKey, pendingRedemptionsValue } = - await bridge.wallets(walletPublicKeyHash) - - // Wallet must be in Live state. - if (state !== WalletState.Live) { - console.debug( - `Wallet is not in Live state ` + - `(wallet public key hash: ${walletPublicKeyHash.toString()}). ` + - `Continue the loop execution to the next wallet...` - ) - continue - } - liveWalletsCounter++ - - // Wallet must have a main UTXO that can be determined. - const mainUtxo = await determineWalletMainUtxo( - walletPublicKeyHash, - bridge, - bitcoinClient, - bitcoinNetwork - ) - if (!mainUtxo) { - console.debug( - `Could not find matching UTXO on chains ` + - `for wallet public key hash (${walletPublicKeyHash.toString()}). ` + - `Continue the loop execution to the next wallet...` - ) - continue - } - - const pendingRedemption = await bridge.pendingRedemptions( - walletPublicKey.toString(), - redeemerOutputScript - ) - - if (pendingRedemption.requestedAt != 0) { - console.debug( - `There is a pending redemption request from this wallet to the ` + - `same Bitcoin address. Given wallet public key hash` + - `(${walletPublicKeyHash.toString()}) and redeemer output script ` + - `(${redeemerOutputScript}) pair can be used for only one ` + - `pending request at the same time. ` + - `Continue the loop execution to the next wallet...` - ) - continue - } - - const walletBTCBalance = mainUtxo.value.sub(pendingRedemptionsValue) - - // Save the max possible redemption amount. - maxAmount = walletBTCBalance.gt(maxAmount) ? walletBTCBalance : maxAmount - - if (walletBTCBalance.gte(amount)) { - walletData = { - walletPublicKey: walletPublicKey.toString(), - mainUtxo, - } - - break - } - - console.debug( - `The wallet (${walletPublicKeyHash.toString()})` + - `cannot handle the redemption request. ` + - `Continue the loop execution to the next wallet...` - ) - } - - if (liveWalletsCounter === 0) { - throw new Error("Currently, there are no live wallets in the network.") - } - - // Cover a corner case when the user requested redemption for all live wallets - // in the network using the same Bitcoin address. - if (!walletData && liveWalletsCounter > 0 && maxAmount.eq(0)) { - throw new Error( - "All live wallets in the network have the pending redemption for a given Bitcoin address. Please use another Bitcoin address." - ) - } - - if (!walletData) - throw new Error( - `Could not find a wallet with enough funds. Maximum redemption amount is ${maxAmount} Satoshi.` - ) - - return walletData -} diff --git a/typescript/src/services/redemptions/index.ts b/typescript/src/services/redemptions/index.ts new file mode 100644 index 000000000..112a3ad8c --- /dev/null +++ b/typescript/src/services/redemptions/index.ts @@ -0,0 +1 @@ +export * from "./redemptions-service" diff --git a/typescript/src/services/redemptions/redemptions-service.ts b/typescript/src/services/redemptions/redemptions-service.ts new file mode 100644 index 000000000..2b99e7fbd --- /dev/null +++ b/typescript/src/services/redemptions/redemptions-service.ts @@ -0,0 +1,363 @@ +import { + RedemptionRequest, + TBTCContracts, + WalletState, +} from "../../lib/contracts" +import { + BitcoinAddressConverter, + BitcoinClient, + BitcoinNetwork, + BitcoinTxOutput, + BitcoinUtxo, +} from "../../lib/bitcoin" +import { BigNumber } from "ethers" +import { Hex } from "../../lib/utils" + +/** + * Service exposing features related to tBTC v2 redemptions. + */ +export class RedemptionsService { + /** + * Handle to tBTC contracts. + */ + private readonly tbtcContracts: TBTCContracts + /** + * Bitcoin client handle. + */ + private readonly bitcoinClient: BitcoinClient + + constructor(tbtcContracts: TBTCContracts, bitcoinClient: BitcoinClient) { + this.tbtcContracts = tbtcContracts + this.bitcoinClient = bitcoinClient + } + + /** + * Requests a redemption of TBTC v2 token into BTC. + * @param bitcoinRedeemerAddress Bitcoin address redeemed BTC should be + * sent to. Only P2PKH, P2WPKH, P2SH, and P2WSH + * address types are supported. + * @param amount The amount to be redeemed with the precision of the tBTC + * on-chain token contract. + * @returns Object containing: + * - Target chain hash of the request redemption transaction + * (for example, Ethereum transaction hash) + * - Bitcoin public key of the wallet asked to handle the redemption. + * Presented in the compressed form (33 bytes long with 02 or 03 prefix). + */ + async requestRedemption( + bitcoinRedeemerAddress: string, + amount: BigNumber + ): Promise<{ + targetChainTxHash: Hex + walletPublicKey: string + }> { + const redeemerOutputScript = BitcoinAddressConverter.addressToOutputScript( + bitcoinRedeemerAddress + ).toString() + + // TODO: Validate the given script is supported for redemption. + + const { walletPublicKey, mainUtxo } = await this.findWalletForRedemption( + redeemerOutputScript, + amount + ) + + const txHash = await this.tbtcContracts.tbtcToken.requestRedemption( + walletPublicKey, + mainUtxo, + redeemerOutputScript, + amount + ) + + return { + targetChainTxHash: txHash, + walletPublicKey, + } + } + + /** + * Finds the oldest live wallet that has enough BTC to handle a redemption + * request. + * @param redeemerOutputScript The redeemer output script the redeemed funds are + * supposed to be locked on. Must be un-prefixed and not prepended with + * length. + * @param amount The amount to be redeemed in satoshis. + * @returns Promise with the wallet details needed to request a redemption. + */ + protected async findWalletForRedemption( + redeemerOutputScript: string, + amount: BigNumber + ): Promise<{ + walletPublicKey: string + mainUtxo: BitcoinUtxo + }> { + const wallets = + await this.tbtcContracts.bridge.getNewWalletRegisteredEvents() + + let walletData: + | { + walletPublicKey: string + mainUtxo: BitcoinUtxo + } + | undefined = undefined + let maxAmount = BigNumber.from(0) + let liveWalletsCounter = 0 + + const bitcoinNetwork = await this.bitcoinClient.getNetwork() + + for (const wallet of wallets) { + const { walletPublicKeyHash } = wallet + const { state, walletPublicKey, pendingRedemptionsValue } = + await this.tbtcContracts.bridge.wallets(walletPublicKeyHash) + + // Wallet must be in Live state. + if (state !== WalletState.Live) { + console.debug( + `Wallet is not in Live state ` + + `(wallet public key hash: ${walletPublicKeyHash.toString()}). ` + + `Continue the loop execution to the next wallet...` + ) + continue + } + liveWalletsCounter++ + + // Wallet must have a main UTXO that can be determined. + const mainUtxo = await this.determineWalletMainUtxo( + walletPublicKeyHash, + bitcoinNetwork + ) + if (!mainUtxo) { + console.debug( + `Could not find matching UTXO on chains ` + + `for wallet public key hash (${walletPublicKeyHash.toString()}). ` + + `Continue the loop execution to the next wallet...` + ) + continue + } + + const pendingRedemption = + await this.tbtcContracts.bridge.pendingRedemptions( + walletPublicKey.toString(), + redeemerOutputScript + ) + + if (pendingRedemption.requestedAt != 0) { + console.debug( + `There is a pending redemption request from this wallet to the ` + + `same Bitcoin address. Given wallet public key hash` + + `(${walletPublicKeyHash.toString()}) and redeemer output script ` + + `(${redeemerOutputScript}) pair can be used for only one ` + + `pending request at the same time. ` + + `Continue the loop execution to the next wallet...` + ) + continue + } + + const walletBTCBalance = mainUtxo.value.sub(pendingRedemptionsValue) + + // Save the max possible redemption amount. + maxAmount = walletBTCBalance.gt(maxAmount) ? walletBTCBalance : maxAmount + + if (walletBTCBalance.gte(amount)) { + walletData = { + walletPublicKey: walletPublicKey.toString(), + mainUtxo, + } + + break + } + + console.debug( + `The wallet (${walletPublicKeyHash.toString()})` + + `cannot handle the redemption request. ` + + `Continue the loop execution to the next wallet...` + ) + } + + if (liveWalletsCounter === 0) { + throw new Error("Currently, there are no live wallets in the network.") + } + + // Cover a corner case when the user requested redemption for all live wallets + // in the network using the same Bitcoin address. + if (!walletData && liveWalletsCounter > 0 && maxAmount.eq(0)) { + throw new Error( + "All live wallets in the network have the pending redemption for a given Bitcoin address. " + + "Please use another Bitcoin address." + ) + } + + if (!walletData) + throw new Error( + `Could not find a wallet with enough funds. Maximum redemption amount is ${maxAmount} Satoshi.` + ) + + return walletData + } + + /** + * Determines the plain-text wallet main UTXO currently registered in the + * Bridge on-chain contract. The returned main UTXO can be undefined if the + * wallet does not have a main UTXO registered in the Bridge at the moment. + * + * WARNING: THIS FUNCTION CANNOT DETERMINE THE MAIN UTXO IF IT COMES FROM A + * BITCOIN TRANSACTION THAT IS NOT ONE OF THE LATEST FIVE TRANSACTIONS + * TARGETING THE GIVEN WALLET PUBLIC KEY HASH. HOWEVER, SUCH A CASE IS + * VERY UNLIKELY. + * + * @param walletPublicKeyHash - Public key hash of the wallet. + * @param bitcoinNetwork - Bitcoin network. + * @returns Promise holding the wallet main UTXO or undefined value. + */ + protected async determineWalletMainUtxo( + walletPublicKeyHash: Hex, + bitcoinNetwork: BitcoinNetwork + ): Promise { + const { mainUtxoHash } = await this.tbtcContracts.bridge.wallets( + walletPublicKeyHash + ) + + // Valid case when the wallet doesn't have a main UTXO registered into + // the Bridge. + if ( + mainUtxoHash.equals( + Hex.from( + "0x0000000000000000000000000000000000000000000000000000000000000000" + ) + ) + ) { + return undefined + } + + // Declare a helper function that will try to determine the main UTXO for + // the given wallet address type. + const determine = async ( + witnessAddress: boolean + ): Promise => { + // Build the wallet Bitcoin address based on its public key hash. + const walletAddress = BitcoinAddressConverter.publicKeyHashToAddress( + walletPublicKeyHash.toString(), + witnessAddress, + bitcoinNetwork + ) + + // Get the wallet transaction history. The wallet main UTXO registered in the + // Bridge almost always comes from the latest BTC transaction made by the wallet. + // However, there may be cases where the BTC transaction was made but their + // SPV proof is not yet submitted to the Bridge thus the registered main UTXO + // points to the second last BTC transaction. In theory, such a gap between + // the actual latest BTC transaction and the registered main UTXO in the + // Bridge may be even wider. The exact behavior is a wallet implementation + // detail and not a protocol invariant so, it may be subject of changes. + // To cover the worst possible cases, we always take the five latest + // transactions made by the wallet for consideration. + const walletTransactions = await this.bitcoinClient.getTransactionHistory( + walletAddress, + 5 + ) + + // Get the wallet script based on the wallet address. This is required + // to find transaction outputs that lock funds on the wallet. + const walletScript = + BitcoinAddressConverter.addressToOutputScript(walletAddress) + const isWalletOutput = (output: BitcoinTxOutput) => + walletScript.equals(output.scriptPubKey) + + // Start iterating from the latest transaction as the chance it matches + // the wallet main UTXO is the highest. + for (let i = walletTransactions.length - 1; i >= 0; i--) { + const walletTransaction = walletTransactions[i] + + // Find the output that locks the funds on the wallet. Only such an output + // can be a wallet main UTXO. + const outputIndex = walletTransaction.outputs.findIndex(isWalletOutput) + + // Should never happen as all transactions come from wallet history. Just + // in case check whether the wallet output was actually found. + if (outputIndex < 0) { + console.error( + `wallet output for transaction ${walletTransaction.transactionHash.toString()} not found` + ) + continue + } + + // Build a candidate UTXO instance based on the detected output. + const utxo: BitcoinUtxo = { + transactionHash: walletTransaction.transactionHash, + outputIndex: outputIndex, + value: walletTransaction.outputs[outputIndex].value, + } + + // Check whether the candidate UTXO hash matches the main UTXO hash stored + // on the Bridge. + if ( + mainUtxoHash.equals(this.tbtcContracts.bridge.buildUtxoHash(utxo)) + ) { + return utxo + } + } + + return undefined + } + + // The most common case is that the wallet uses a witness address for all + // operations. Try to determine the main UTXO for that address first as the + // chance for success is the highest here. + const mainUtxo = await determine(true) + + // In case the main UTXO was not found for witness address, there is still + // a chance it exists for the legacy wallet address. + return mainUtxo ?? (await determine(false)) + } + + /** + * Gets data of a registered redemption request from the Bridge contract. + * @param bitcoinRedeemerAddress Bitcoin redeemer address used to request + * the redemption. + * @param walletPublicKey Bitcoin public key of the wallet handling the + * redemption. Must be in the compressed form + * (33 bytes long with 02 or 03 prefix). + * @param type Type of redemption requests the function will look for. Can be + * either `pending` or `timedOut`. By default, `pending` is used. + * @returns Matching redemption requests. + * @throws Throws an error if no redemption request exists for the given + * input parameters. + */ + async getRedemptionRequests( + bitcoinRedeemerAddress: string, + walletPublicKey: string, + type: "pending" | "timedOut" = "pending" + ): Promise { + const redeemerOutputScript = BitcoinAddressConverter.addressToOutputScript( + bitcoinRedeemerAddress + ).toString() + + let redemptionRequest: RedemptionRequest | undefined = undefined + + switch (type) { + case "pending": { + redemptionRequest = await this.tbtcContracts.bridge.pendingRedemptions( + walletPublicKey, + redeemerOutputScript + ) + break + } + case "timedOut": { + redemptionRequest = await this.tbtcContracts.bridge.timedOutRedemptions( + walletPublicKey, + redeemerOutputScript + ) + break + } + default: { + throw new Error("Unsupported redemption request type") + } + } + + if (!redemptionRequest || redemptionRequest.requestedAt == 0) { + throw new Error("Redemption request does not exist") + } + + return redemptionRequest + } +} diff --git a/typescript/src/wallet.ts b/typescript/src/wallet.ts deleted file mode 100644 index 8b2f0a6d5..000000000 --- a/typescript/src/wallet.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { Hex } from "./lib/utils" -import { Bridge } from "./lib/contracts" -import { - BitcoinClient, - BitcoinNetwork, - BitcoinAddressConverter, - BitcoinTxOutput, - BitcoinUtxo, -} from "./lib/bitcoin" - -/** - * Determines the plain-text wallet main UTXO currently registered in the - * Bridge on-chain contract. The returned main UTXO can be undefined if the - * wallet does not have a main UTXO registered in the Bridge at the moment. - * - * WARNING: THIS FUNCTION CANNOT DETERMINE THE MAIN UTXO IF IT COMES FROM A - * BITCOIN TRANSACTION THAT IS NOT ONE OF THE LATEST FIVE TRANSACTIONS - * TARGETING THE GIVEN WALLET PUBLIC KEY HASH. HOWEVER, SUCH A CASE IS - * VERY UNLIKELY. - * - * @param walletPublicKeyHash - Public key hash of the wallet. - * @param bridge - The handle to the Bridge on-chain contract. - * @param bitcoinClient - Bitcoin client used to interact with the network. - * @param bitcoinNetwork - Bitcoin network. - * @returns Promise holding the wallet main UTXO or undefined value. - */ -export async function determineWalletMainUtxo( - walletPublicKeyHash: Hex, - bridge: Bridge, - bitcoinClient: BitcoinClient, - bitcoinNetwork: BitcoinNetwork -): Promise { - const { mainUtxoHash } = await bridge.wallets(walletPublicKeyHash) - - // Valid case when the wallet doesn't have a main UTXO registered into - // the Bridge. - if ( - mainUtxoHash.equals( - Hex.from( - "0x0000000000000000000000000000000000000000000000000000000000000000" - ) - ) - ) { - return undefined - } - - // Declare a helper function that will try to determine the main UTXO for - // the given wallet address type. - const determine = async ( - witnessAddress: boolean - ): Promise => { - // Build the wallet Bitcoin address based on its public key hash. - const walletAddress = BitcoinAddressConverter.publicKeyHashToAddress( - walletPublicKeyHash.toString(), - witnessAddress, - bitcoinNetwork - ) - - // Get the wallet transaction history. The wallet main UTXO registered in the - // Bridge almost always comes from the latest BTC transaction made by the wallet. - // However, there may be cases where the BTC transaction was made but their - // SPV proof is not yet submitted to the Bridge thus the registered main UTXO - // points to the second last BTC transaction. In theory, such a gap between - // the actual latest BTC transaction and the registered main UTXO in the - // Bridge may be even wider. The exact behavior is a wallet implementation - // detail and not a protocol invariant so, it may be subject of changes. - // To cover the worst possible cases, we always take the five latest - // transactions made by the wallet for consideration. - const walletTransactions = await bitcoinClient.getTransactionHistory( - walletAddress, - 5 - ) - - // Get the wallet script based on the wallet address. This is required - // to find transaction outputs that lock funds on the wallet. - const walletScript = - BitcoinAddressConverter.addressToOutputScript(walletAddress) - const isWalletOutput = (output: BitcoinTxOutput) => - walletScript.equals(output.scriptPubKey) - - // Start iterating from the latest transaction as the chance it matches - // the wallet main UTXO is the highest. - for (let i = walletTransactions.length - 1; i >= 0; i--) { - const walletTransaction = walletTransactions[i] - - // Find the output that locks the funds on the wallet. Only such an output - // can be a wallet main UTXO. - const outputIndex = walletTransaction.outputs.findIndex(isWalletOutput) - - // Should never happen as all transactions come from wallet history. Just - // in case check whether the wallet output was actually found. - if (outputIndex < 0) { - console.error( - `wallet output for transaction ${walletTransaction.transactionHash.toString()} not found` - ) - continue - } - - // Build a candidate UTXO instance based on the detected output. - const utxo: BitcoinUtxo = { - transactionHash: walletTransaction.transactionHash, - outputIndex: outputIndex, - value: walletTransaction.outputs[outputIndex].value, - } - - // Check whether the candidate UTXO hash matches the main UTXO hash stored - // on the Bridge. - if (mainUtxoHash.equals(bridge.buildUtxoHash(utxo))) { - return utxo - } - } - - return undefined - } - - // The most common case is that the wallet uses a witness address for all - // operations. Try to determine the main UTXO for that address first as the - // chance for success is the highest here. - const mainUtxo = await determine(true) - - // In case the main UTXO was not found for witness address, there is still - // a chance it exists for the legacy wallet address. - return mainUtxo ?? (await determine(false)) -} diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index ef90d3cae..f9a3a5c68 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -1,76 +1,817 @@ import { + BitcoinAddressConverter, + BitcoinHashUtils, BitcoinNetwork, - BitcoinTx, BitcoinRawTx, + BitcoinTx, BitcoinTxHash, BitcoinUtxo, } from "../src/lib/bitcoin" import bcoin from "bcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { - walletPrivateKey, - walletPublicKey, - singleP2PKHRedemptionWithWitnessChange, - singleP2WPKHRedemptionWithWitnessChange, - singleP2SHRedemptionWithWitnessChange, - singleP2WSHRedemptionWithWitnessChange, - multipleRedemptionsWithWitnessChange, + findWalletForRedemptionData, multipleRedemptionsWithoutChange, - singleP2SHRedemptionWithNonWitnessChange, - redemptionProof, + multipleRedemptionsWithWitnessChange, p2pkhWalletAddress, p2wpkhWalletAddress, + redemptionProof, RedemptionTestData, - findWalletForRedemptionData, + singleP2PKHRedemptionWithWitnessChange, + singleP2SHRedemptionWithNonWitnessChange, + singleP2SHRedemptionWithWitnessChange, + singleP2WPKHRedemptionWithWitnessChange, + singleP2WSHRedemptionWithWitnessChange, + walletPrivateKey, + walletPublicKey, } from "./data/redemption" -import { RedemptionRequest, Wallet } from "../src/lib/contracts" +import { + NewWalletRegisteredEvent, + RedemptionRequest, + Wallet, + WalletState, +} from "../src/lib/contracts" import { assembleRedemptionTransaction, - findWalletForRedemption, - getRedemptionRequest, - requestRedemption, submitRedemptionProof, submitRedemptionTransaction, } from "../src/redemption" import { MockBridge } from "./utils/mock-bridge" import * as chai from "chai" -import chaiAsPromised from "chai-as-promised" import { expect } from "chai" -import { BigNumberish, BigNumber } from "ethers" -import { MockTBTCToken } from "./utils/mock-tbtc-token" +import chaiAsPromised from "chai-as-promised" +import { BigNumber, BigNumberish } from "ethers" +import { RedemptionsService } from "../src/services/redemptions" +import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" +import { Hex } from "../src" chai.use(chaiAsPromised) describe("Redemption", () => { - describe("requestRedemption", () => { - const data: RedemptionTestData = singleP2PKHRedemptionWithWitnessChange - const mainUtxo = data.mainUtxo - const redeemerOutputScript = - data.pendingRedemptions[0].pendingRedemption.redeemerOutputScript - const amount = data.pendingRedemptions[0].pendingRedemption.requestedAmount - const token: MockTBTCToken = new MockTBTCToken() + describe("RedemptionsService", () => { + describe("requestRedemption", () => { + const data: RedemptionTestData = singleP2PKHRedemptionWithWitnessChange + const { transactionHash, value } = data.mainUtxo + const mainUtxo: BitcoinUtxo = { + transactionHash, + outputIndex: 0, + value, + } + const redeemerOutputScript = + data.pendingRedemptions[0].pendingRedemption.redeemerOutputScript + const amount = + data.pendingRedemptions[0].pendingRedemption.requestedAmount - beforeEach(async () => { - bcoin.set("testnet") + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient - await requestRedemption( - walletPublicKey, - mainUtxo, - redeemerOutputScript, - amount, - token + beforeEach(async () => { + bcoin.set("testnet") + + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + + const walletPublicKeyHash = Hex.from( + BitcoinHashUtils.computeHash160(walletPublicKey) + ) + + // Prepare NewWalletRegisteredEvent history. Set only relevant fields. + tbtcContracts.bridge.newWalletRegisteredEvents = [ + { + walletPublicKeyHash: walletPublicKeyHash, + } as NewWalletRegisteredEvent, + ] + + // Prepare wallet data in the Bridge. Set only relevant fields. + tbtcContracts.bridge.setWallet(walletPublicKeyHash.toPrefixedString(), { + state: WalletState.Live, + walletPublicKey: Hex.from(walletPublicKey), + pendingRedemptionsValue: BigNumber.from(0), + mainUtxoHash: tbtcContracts.bridge.buildUtxoHash(mainUtxo), + } as Wallet) + + const walletAddress = BitcoinAddressConverter.publicKeyHashToAddress( + walletPublicKeyHash.toString(), + true, + BitcoinNetwork.Testnet + ) + + // Prepare wallet transaction history for main UTXO lookup. + // Set only relevant fields. + const transactionHistory = new Map() + transactionHistory.set(walletAddress, [ + { + transactionHash: mainUtxo.transactionHash, + outputs: [ + { + outputIndex: mainUtxo.outputIndex, + value: mainUtxo.value, + scriptPubKey: + BitcoinAddressConverter.addressToOutputScript(walletAddress), + }, + ], + } as BitcoinTx, + ]) + bitcoinClient.transactionHistory = transactionHistory + + const redemptionsService = new RedemptionsService( + tbtcContracts, + bitcoinClient + ) + + await redemptionsService.requestRedemption( + BitcoinAddressConverter.outputScriptToAddress( + Hex.from(redeemerOutputScript), + BitcoinNetwork.Testnet + ), + amount + ) + }) + + it("should submit redemption request with correct arguments", () => { + const tokenLog = tbtcContracts.tbtcToken.requestRedemptionLog + + expect(tokenLog.length).to.equal(1) + expect(tokenLog[0]).to.deep.equal({ + walletPublicKey, + mainUtxo, + redeemerOutputScript, + amount, + }) + }) + }) + + describe("getRedemptionRequest", () => { + context("when asked for a pending request", () => { + const { redemptionKey, pendingRedemption: redemptionRequest } = + multipleRedemptionsWithWitnessChange.pendingRedemptions[0] + + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + let redemptionsService: RedemptionsService + + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + + const pendingRedemptions = new Map() + pendingRedemptions.set(redemptionKey, redemptionRequest) + + tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) + + redemptionsService = new RedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + it("should return the expected redemption request", async () => { + const actualRedemptionRequest = + await redemptionsService.getRedemptionRequests( + BitcoinAddressConverter.outputScriptToAddress( + Hex.from(redemptionRequest.redeemerOutputScript), + BitcoinNetwork.Testnet + ), + walletPublicKey, + "pending" + ) + + expect(actualRedemptionRequest).to.be.eql(redemptionRequest) + }) + }) + + context("when asked for a timed-out request", () => { + const { redemptionKey, pendingRedemption: redemptionRequest } = + multipleRedemptionsWithWitnessChange.pendingRedemptions[0] + + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + let redemptionsService: RedemptionsService + + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + + const timedOutRedemptions = new Map() + timedOutRedemptions.set(redemptionKey, redemptionRequest) + + tbtcContracts.bridge.setTimedOutRedemptions(timedOutRedemptions) + + redemptionsService = new RedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + it("should return the expected redemption request", async () => { + const actualRedemptionRequest = + await redemptionsService.getRedemptionRequests( + BitcoinAddressConverter.outputScriptToAddress( + Hex.from(redemptionRequest.redeemerOutputScript), + BitcoinNetwork.Testnet + ), + walletPublicKey, + "timedOut" + ) + + expect(actualRedemptionRequest).to.be.eql(redemptionRequest) + }) + }) + }) + + describe("findWalletForRedemption", () => { + class TestRedemptionsService extends RedemptionsService { + public async findWalletForRedemption( + redeemerOutputScript: string, + amount: BigNumber + ): Promise<{ + walletPublicKey: string + mainUtxo: BitcoinUtxo + }> { + return super.findWalletForRedemption(redeemerOutputScript, amount) + } + } + + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + let redemptionsService: TestRedemptionsService + // script for testnet P2WSH address + // tb1qau95mxzh2249aa3y8exx76ltc2sq0e7kw8hj04936rdcmnynhswqqz02vv + const redeemerOutputScript = + "0x220020ef0b4d985752aa5ef6243e4c6f6bebc2a007e7d671ef27d4b1d0db8dcc93bc1c" + + context( + "when there are no wallets in the network that can handle redemption", + () => { + const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC + beforeEach(() => { + bitcoinClient = new MockBitcoinClient() + tbtcContracts = new MockTBTCContracts() + tbtcContracts.bridge.newWalletRegisteredEvents = [] + redemptionsService = new TestRedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + it("should throw an error", async () => { + await expect( + redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + ).to.be.rejectedWith( + "Currently, there are no live wallets in the network." + ) + }) + } ) + + context("when there are registered wallets in the network", () => { + let result: Awaited | never> + const walletsOrder = [ + findWalletForRedemptionData.nonLiveWallet, + findWalletForRedemptionData.walletWithoutUtxo, + findWalletForRedemptionData.walletWithPendingRedemption, + findWalletForRedemptionData.liveWallet, + ] + + beforeEach(async () => { + bitcoinClient = new MockBitcoinClient() + tbtcContracts = new MockTBTCContracts() + + tbtcContracts.bridge.newWalletRegisteredEvents = walletsOrder.map( + (wallet) => wallet.event + ) + + const walletsTransactionHistory = new Map() + + walletsOrder.forEach((wallet) => { + const { + state, + mainUtxoHash, + walletPublicKey, + btcAddress, + transactions, + pendingRedemptionsValue, + } = wallet.data + + walletsTransactionHistory.set(btcAddress, transactions) + tbtcContracts.bridge.setWallet( + wallet.event.walletPublicKeyHash.toPrefixedString(), + { + state, + mainUtxoHash, + walletPublicKey, + pendingRedemptionsValue, + } as Wallet + ) + }) + + bitcoinClient.transactionHistory = walletsTransactionHistory + + redemptionsService = new TestRedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + context( + "when there is a wallet that can handle the redemption request", + () => { + const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC + beforeEach(async () => { + result = await redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + }) + + it("should get all registered wallets", () => { + const bridgeQueryEventsLog = + tbtcContracts.bridge.newWalletRegisteredEventsLog + + expect(bridgeQueryEventsLog.length).to.equal(1) + expect(bridgeQueryEventsLog[0]).to.deep.equal({ + options: undefined, + filterArgs: [], + }) + }) + + it("should return the wallet data that can handle redemption request", () => { + const expectedWalletData = + findWalletForRedemptionData.walletWithPendingRedemption.data + + expect(result).to.deep.eq({ + walletPublicKey: expectedWalletData.walletPublicKey.toString(), + mainUtxo: expectedWalletData.mainUtxo, + }) + }) + } + ) + + context( + "when the redemption request amount is too large and no wallet can handle the request", + () => { + const amount = BigNumber.from("10000000000") // 1 000 BTC + const expectedMaxAmount = walletsOrder + .map((wallet) => wallet.data) + .map((wallet) => wallet.mainUtxo) + .map((utxo) => utxo.value) + .sort((a, b) => (b.gt(a) ? 0 : -1))[0] + + it("should throw an error", async () => { + await expect( + redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + ).to.be.rejectedWith( + `Could not find a wallet with enough funds. Maximum redemption amount is ${expectedMaxAmount.toString()} Satoshi.` + ) + }) + } + ) + + context( + "when there is pending redemption request from a given wallet to the same address", + () => { + beforeEach(async () => { + const redeemerOutputScript = + findWalletForRedemptionData.pendingRedemption + .redeemerOutputScript + const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC + + const walletPublicKeyHash = + findWalletForRedemptionData.walletWithPendingRedemption.event + .walletPublicKeyHash + + const pendingRedemptions = new Map< + BigNumberish, + RedemptionRequest + >() + + const key = MockBridge.buildRedemptionKey( + walletPublicKeyHash.toString(), + redeemerOutputScript + ) + + pendingRedemptions.set( + key, + findWalletForRedemptionData.pendingRedemption + ) + tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) + + result = await redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + }) + + it("should get all registered wallets", () => { + const bridgeQueryEventsLog = + tbtcContracts.bridge.newWalletRegisteredEventsLog + + expect(bridgeQueryEventsLog.length).to.equal(1) + expect(bridgeQueryEventsLog[0]).to.deep.equal({ + options: undefined, + filterArgs: [], + }) + }) + + it("should skip the wallet for which there is a pending redemption request to the same redeemer output script and return the wallet data that can handle redemption request", () => { + const expectedWalletData = + findWalletForRedemptionData.liveWallet.data + + expect(result).to.deep.eq({ + walletPublicKey: expectedWalletData.walletPublicKey.toString(), + mainUtxo: expectedWalletData.mainUtxo, + }) + }) + } + ) + + context( + "when wallet has pending redemptions and the requested amount is greater than possible", + () => { + beforeEach(async () => { + const wallet = + findWalletForRedemptionData.walletWithPendingRedemption + const walletBTCBalance = wallet.data.mainUtxo.value + + const amount: BigNumber = walletBTCBalance + .sub(wallet.data.pendingRedemptionsValue) + .add(BigNumber.from(500000)) // 0.005 BTC + + console.log("amount", amount.toString()) + + result = await redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + }) + + it("should skip the wallet wallet with pending redemptions and return the wallet data that can handle redemption request ", () => { + const expectedWalletData = + findWalletForRedemptionData.liveWallet.data + + expect(result).to.deep.eq({ + walletPublicKey: expectedWalletData.walletPublicKey.toString(), + mainUtxo: expectedWalletData.mainUtxo, + }) + }) + } + ) + + context( + "when all active wallets has pending redemption for a given Bitcoin address", + () => { + const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC + const redeemerOutputScript = + findWalletForRedemptionData.pendingRedemption.redeemerOutputScript + + beforeEach(async () => { + const walletPublicKeyHash = + findWalletForRedemptionData.walletWithPendingRedemption.event + .walletPublicKeyHash + + const pendingRedemptions = new Map< + BigNumberish, + RedemptionRequest + >() + + const pendingRedemption1 = MockBridge.buildRedemptionKey( + walletPublicKeyHash.toString(), + redeemerOutputScript + ) + + const pendingRedemption2 = MockBridge.buildRedemptionKey( + findWalletForRedemptionData.liveWallet.event.walletPublicKeyHash.toString(), + redeemerOutputScript + ) + + pendingRedemptions.set( + pendingRedemption1, + findWalletForRedemptionData.pendingRedemption + ) + + pendingRedemptions.set( + pendingRedemption2, + findWalletForRedemptionData.pendingRedemption + ) + tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) + }) + + it("should throw an error", async () => { + await expect( + redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + ).to.be.rejectedWith( + "All live wallets in the network have the pending redemption for a given Bitcoin address. Please use another Bitcoin address." + ) + }) + } + ) + }) }) - it("should submit redemption proof with correct arguments", () => { - const tokenLog = token.requestRedemptionLog + describe("determineWalletMainUtxo", () => { + class TestRedemptionsService extends RedemptionsService { + public async determineWalletMainUtxo( + walletPublicKeyHash: Hex, + bitcoinNetwork: BitcoinNetwork + ): Promise { + return super.determineWalletMainUtxo( + walletPublicKeyHash, + bitcoinNetwork + ) + } + } - expect(tokenLog.length).to.equal(1) - expect(tokenLog[0]).to.deep.equal({ - walletPublicKey, - mainUtxo, - redeemerOutputScript, - amount, + // Just an arbitrary 20-byte wallet public key hash. + const walletPublicKeyHash = Hex.from( + "e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0" + ) + + // Helper function facilitating creation of mock transactions. + const mockTransaction = ( + hash: string, + outputs: Record // key: locking script, value: amount of locked satoshis + ): BitcoinTx => { + return { + transactionHash: Hex.from(hash), + inputs: [], // not relevant in this test scenario + outputs: Object.entries(outputs).map( + ([scriptPubKey, value], index) => ({ + outputIndex: index, + value: BigNumber.from(value), + scriptPubKey: Hex.from(scriptPubKey), + }) + ), + } + } + + // Create a fake wallet witness transaction history that consists of 6 transactions. + const walletWitnessTransactionHistory: BitcoinTx[] = [ + mockTransaction( + "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1", + { + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "4c6b33b7c0550e0e536a5d119ac7189d71e1296fcb0c258e0c115356895bc0e6", + { + "00140000000000000000000000000000000000000001": 100000, + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 200000, // wallet witness output + } + ), + mockTransaction( + "44863a79ce2b8fec9792403d5048506e50ffa7338191db0e6c30d3d3358ea2f6", + { + "00140000000000000000000000000000000000000001": 100000, + "00140000000000000000000000000000000000000002": 200000, + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 300000, // wallet witness output + } + ), + mockTransaction( + "f65bc5029251f0042aedb37f90dbb2bfb63a2e81694beef9cae5ec62e954c22e", + { + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "2724545276df61f43f1e92c4b9f1dd3c9109595c022dbd9dc003efbad8ded38b", + { + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214", + { + "00140000000000000000000000000000000000000001": 100000, + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 200000, // wallet witness output + } + ), + ] + + // Create a fake wallet legacy transaction history that consists of 6 transactions. + const walletLegacyTransactionHistory: BitcoinTx[] = [ + mockTransaction( + "230a19d8867ff3f5b409e924d9dd6413188e215f9bb52f1c47de6154dac42267", + { + "00140000000000000000000000000000000000000001": 100000, + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 200000, // wallet legacy output + } + ), + mockTransaction( + "b11bfc481b95769b8488bd661d5f61a35f7c3c757160494d63f6e04e532dfcb9", + { + "00140000000000000000000000000000000000000001": 100000, + "00140000000000000000000000000000000000000002": 200000, + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 300000, // wallet legacy output + } + ), + mockTransaction( + "7e91580d989f8541489a37431381ff9babd596111232f1bc7a1a1ba503c27dee", + { + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "5404e339ba82e6e52fcc24cb40029bed8425baa4c7f869626ef9de956186f910", + { + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94", + { + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "00cc0cd13fc4de7a15cb41ab6d58f8b31c75b6b9b4194958c381441a67d09b08", + { + "00140000000000000000000000000000000000000001": 100000, + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 200000, // wallet legacy output + } + ), + ] + + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + let bitcoinNetwork: BitcoinNetwork + let redemptionsService: TestRedemptionsService + + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + redemptionsService = new TestRedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + context("when wallet main UTXO is not set in the Bridge", () => { + beforeEach(async () => { + tbtcContracts.bridge.setWallet( + walletPublicKeyHash.toPrefixedString(), + { + mainUtxoHash: Hex.from( + "0x0000000000000000000000000000000000000000000000000000000000000000" + ), + } as Wallet + ) + }) + + it("should return undefined", async () => { + const mainUtxo = await redemptionsService.determineWalletMainUtxo( + walletPublicKeyHash, + bitcoinNetwork + ) + + expect(mainUtxo).to.be.undefined + }) + }) + + context("when wallet main UTXO is set in the Bridge", () => { + const tests = [ + { + testName: "recent witness transaction", + // Set the main UTXO hash based on the latest transaction from walletWitnessTransactionHistory. + actualMainUtxo: { + transactionHash: Hex.from( + "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214" + ), + outputIndex: 1, + value: BigNumber.from(200000), + }, + expectedMainUtxo: { + transactionHash: Hex.from( + "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214" + ), + outputIndex: 1, + value: BigNumber.from(200000), + }, + }, + { + testName: "recent legacy transaction", + // Set the main UTXO hash based on the second last transaction from walletLegacyTransactionHistory. + actualMainUtxo: { + transactionHash: Hex.from( + "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94" + ), + outputIndex: 0, + value: BigNumber.from(100000), + }, + expectedMainUtxo: { + transactionHash: Hex.from( + "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94" + ), + outputIndex: 0, + value: BigNumber.from(100000), + }, + }, + { + testName: "old witness transaction", + // Set the main UTXO hash based on the oldest transaction from walletWitnessTransactionHistory. + actualMainUtxo: { + transactionHash: Hex.from( + "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1" + ), + outputIndex: 0, + value: BigNumber.from(100000), + }, + expectedMainUtxo: undefined, + }, + { + testName: "old legacy transaction", + // Set the main UTXO hash based on the oldest transaction from walletLegacyTransactionHistory. + actualMainUtxo: { + transactionHash: Hex.from( + "230a19d8867ff3f5b409e924d9dd6413188e215f9bb52f1c47de6154dac42267" + ), + outputIndex: 1, + value: BigNumber.from(200000), + }, + expectedMainUtxo: undefined, + }, + ] + + tests.forEach(({ testName, actualMainUtxo, expectedMainUtxo }) => { + context(`with main UTXO coming from ${testName}`, () => { + const networkTests = [ + { + networkTestName: "bitcoin testnet", + network: BitcoinNetwork.Testnet, + }, + { + networkTestName: "bitcoin mainnet", + network: BitcoinNetwork.Mainnet, + }, + ] + + networkTests.forEach(({ networkTestName, network }) => { + context(`with ${networkTestName} network`, () => { + beforeEach(async () => { + bitcoinNetwork = network + + const walletWitnessAddress = + BitcoinAddressConverter.publicKeyHashToAddress( + walletPublicKeyHash.toString(), + true, + bitcoinNetwork + ) + const walletLegacyAddress = + BitcoinAddressConverter.publicKeyHashToAddress( + walletPublicKeyHash.toString(), + false, + bitcoinNetwork + ) + + // Record the fake transaction history for both address types. + const transactionHistory = new Map() + transactionHistory.set( + walletWitnessAddress, + walletWitnessTransactionHistory + ) + transactionHistory.set( + walletLegacyAddress, + walletLegacyTransactionHistory + ) + bitcoinClient.transactionHistory = transactionHistory + + tbtcContracts.bridge.setWallet( + walletPublicKeyHash.toPrefixedString(), + { + mainUtxoHash: + tbtcContracts.bridge.buildUtxoHash(actualMainUtxo), + } as Wallet + ) + }) + + it("should return the expected main UTXO", async () => { + const mainUtxo = + await redemptionsService.determineWalletMainUtxo( + walletPublicKeyHash, + bitcoinNetwork + ) + + expect(mainUtxo).to.be.eql(expectedMainUtxo) + }) + }) + }) + }) + }) }) }) }) @@ -437,9 +1178,7 @@ describe("Redemption", () => { redeemerOutputScripts, data.witness ) - ).to.be.rejectedWith( - "Provided redeemer output script and wallet public key do not identify a redemption request" - ) + ).to.be.rejectedWith("Redemption request does not exist") }) } ) @@ -1383,351 +2122,6 @@ describe("Redemption", () => { ) }) }) - - describe("getRedemptionRequest", () => { - context("when asked for a pending request", () => { - const { redemptionKey, pendingRedemption: redemptionRequest } = - multipleRedemptionsWithWitnessChange.pendingRedemptions[0] - - let bridge: MockBridge - - beforeEach(async () => { - const pendingRedemptions = new Map() - pendingRedemptions.set(redemptionKey, redemptionRequest) - - bridge = new MockBridge() - bridge.setPendingRedemptions(pendingRedemptions) - }) - - it("should return the expected redemption request", async () => { - const actualRedemptionRequest = await getRedemptionRequest( - walletPublicKey, - redemptionRequest.redeemerOutputScript, - "pending", - bridge - ) - - expect(actualRedemptionRequest).to.be.eql(redemptionRequest) - }) - }) - - context("when asked for a timed-out request", () => { - const { redemptionKey, pendingRedemption: redemptionRequest } = - multipleRedemptionsWithWitnessChange.pendingRedemptions[0] - - let bridge: MockBridge - - beforeEach(async () => { - const pendingRedemptions = new Map() - pendingRedemptions.set(redemptionKey, redemptionRequest) - - bridge = new MockBridge() - bridge.setTimedOutRedemptions(pendingRedemptions) - }) - - it("should return the expected redemption request", async () => { - const actualRedemptionRequest = await getRedemptionRequest( - walletPublicKey, - redemptionRequest.redeemerOutputScript, - "timedOut", - bridge - ) - - expect(actualRedemptionRequest).to.be.eql(redemptionRequest) - }) - }) - }) - - describe("findWalletForRedemption", () => { - let bridge: MockBridge - let bitcoinClient: MockBitcoinClient - // script for testnet P2WSH address - // tb1qau95mxzh2249aa3y8exx76ltc2sq0e7kw8hj04936rdcmnynhswqqz02vv - const redeemerOutputScript = - "0x220020ef0b4d985752aa5ef6243e4c6f6bebc2a007e7d671ef27d4b1d0db8dcc93bc1c" - - context( - "when there are no wallets in the network that can handle redemption", - () => { - const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC - beforeEach(() => { - bitcoinClient = new MockBitcoinClient() - bridge = new MockBridge() - bridge.newWalletRegisteredEvents = [] - }) - - it("should throw an error", async () => { - await expect( - findWalletForRedemption( - amount, - redeemerOutputScript, - BitcoinNetwork.Testnet, - bridge, - bitcoinClient - ) - ).to.be.rejectedWith( - "Currently, there are no live wallets in the network." - ) - }) - } - ) - - context("when there are registered wallets in the network", () => { - let result: Awaited | never> - const walletsOrder = [ - findWalletForRedemptionData.nonLiveWallet, - findWalletForRedemptionData.walletWithoutUtxo, - findWalletForRedemptionData.walletWithPendingRedemption, - findWalletForRedemptionData.liveWallet, - ] - - beforeEach(async () => { - bitcoinClient = new MockBitcoinClient() - bridge = new MockBridge() - - bridge.newWalletRegisteredEvents = walletsOrder.map( - (wallet) => wallet.event - ) - - const walletsTransactionHistory = new Map() - - walletsOrder.forEach((wallet) => { - const { - state, - mainUtxoHash, - walletPublicKey, - btcAddress, - transactions, - pendingRedemptionsValue, - } = wallet.data - - walletsTransactionHistory.set(btcAddress, transactions) - bridge.setWallet( - wallet.event.walletPublicKeyHash.toPrefixedString(), - { - state, - mainUtxoHash, - walletPublicKey, - pendingRedemptionsValue, - } as Wallet - ) - }) - - bitcoinClient.transactionHistory = walletsTransactionHistory - }) - - context( - "when there is a wallet that can handle the redemption request", - () => { - const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC - beforeEach(async () => { - result = await findWalletForRedemption( - amount, - redeemerOutputScript, - BitcoinNetwork.Testnet, - bridge, - bitcoinClient - ) - }) - - it("should get all registered wallets", () => { - const bridgeQueryEventsLog = bridge.newWalletRegisteredEventsLog - - expect(bridgeQueryEventsLog.length).to.equal(1) - expect(bridgeQueryEventsLog[0]).to.deep.equal({ - options: undefined, - filterArgs: [], - }) - }) - - it("should return the wallet data that can handle redemption request", () => { - const expectedWalletData = - findWalletForRedemptionData.walletWithPendingRedemption.data - - expect(result).to.deep.eq({ - walletPublicKey: expectedWalletData.walletPublicKey.toString(), - mainUtxo: expectedWalletData.mainUtxo, - }) - }) - } - ) - - context( - "when the redemption request amount is too large and no wallet can handle the request", - () => { - const amount = BigNumber.from("10000000000") // 1 000 BTC - const expectedMaxAmount = walletsOrder - .map((wallet) => wallet.data) - .map((wallet) => wallet.mainUtxo) - .map((utxo) => utxo.value) - .sort((a, b) => (b.gt(a) ? 0 : -1))[0] - - it("should throw an error", async () => { - await expect( - findWalletForRedemption( - amount, - redeemerOutputScript, - BitcoinNetwork.Testnet, - bridge, - bitcoinClient - ) - ).to.be.rejectedWith( - `Could not find a wallet with enough funds. Maximum redemption amount is ${expectedMaxAmount.toString()} Satoshi.` - ) - }) - } - ) - - context( - "when there is pending redemption request from a given wallet to the same address", - () => { - beforeEach(async () => { - const redeemerOutputScript = - findWalletForRedemptionData.pendingRedemption.redeemerOutputScript - const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC - - const walletPublicKeyHash = - findWalletForRedemptionData.walletWithPendingRedemption.event - .walletPublicKeyHash - - const pendingRedemptions = new Map< - BigNumberish, - RedemptionRequest - >() - - const key = MockBridge.buildRedemptionKey( - walletPublicKeyHash.toString(), - redeemerOutputScript - ) - - pendingRedemptions.set( - key, - findWalletForRedemptionData.pendingRedemption - ) - bridge.setPendingRedemptions(pendingRedemptions) - - result = await findWalletForRedemption( - amount, - redeemerOutputScript, - BitcoinNetwork.Testnet, - bridge, - bitcoinClient - ) - }) - - it("should get all registered wallets", () => { - const bridgeQueryEventsLog = bridge.newWalletRegisteredEventsLog - - expect(bridgeQueryEventsLog.length).to.equal(1) - expect(bridgeQueryEventsLog[0]).to.deep.equal({ - options: undefined, - filterArgs: [], - }) - }) - - it("should skip the wallet for which there is a pending redemption request to the same redeemer output script and return the wallet data that can handle redemption request", () => { - const expectedWalletData = - findWalletForRedemptionData.liveWallet.data - - expect(result).to.deep.eq({ - walletPublicKey: expectedWalletData.walletPublicKey.toString(), - mainUtxo: expectedWalletData.mainUtxo, - }) - }) - } - ) - - context( - "when wallet has pending redemptions and the requested amount is greater than possible", - () => { - beforeEach(async () => { - const wallet = - findWalletForRedemptionData.walletWithPendingRedemption - const walletBTCBalance = wallet.data.mainUtxo.value - - const amount: BigNumber = walletBTCBalance - .sub(wallet.data.pendingRedemptionsValue) - .add(BigNumber.from(500000)) // 0.005 BTC - - console.log("amount", amount.toString()) - - result = await findWalletForRedemption( - amount, - redeemerOutputScript, - BitcoinNetwork.Testnet, - bridge, - bitcoinClient - ) - }) - - it("should skip the wallet wallet with pending redemptions and return the wallet data that can handle redemption request ", () => { - const expectedWalletData = - findWalletForRedemptionData.liveWallet.data - - expect(result).to.deep.eq({ - walletPublicKey: expectedWalletData.walletPublicKey.toString(), - mainUtxo: expectedWalletData.mainUtxo, - }) - }) - } - ) - - context( - "when all active wallets has pending redemption for a given Bitcoin address", - () => { - const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC - const redeemerOutputScript = - findWalletForRedemptionData.pendingRedemption.redeemerOutputScript - - beforeEach(async () => { - const walletPublicKeyHash = - findWalletForRedemptionData.walletWithPendingRedemption.event - .walletPublicKeyHash - - const pendingRedemptions = new Map< - BigNumberish, - RedemptionRequest - >() - - const pendingRedemption1 = MockBridge.buildRedemptionKey( - walletPublicKeyHash.toString(), - redeemerOutputScript - ) - - const pendingRedemption2 = MockBridge.buildRedemptionKey( - findWalletForRedemptionData.liveWallet.event.walletPublicKeyHash.toString(), - redeemerOutputScript - ) - - pendingRedemptions.set( - pendingRedemption1, - findWalletForRedemptionData.pendingRedemption - ) - - pendingRedemptions.set( - pendingRedemption2, - findWalletForRedemptionData.pendingRedemption - ) - bridge.setPendingRedemptions(pendingRedemptions) - }) - - it("should throw an error", async () => { - await expect( - findWalletForRedemption( - amount, - redeemerOutputScript, - BitcoinNetwork.Testnet, - bridge, - bitcoinClient - ) - ).to.be.rejectedWith( - "All live wallets in the network have the pending redemption for a given Bitcoin address. Please use another Bitcoin address." - ) - }) - } - ) - }) - }) }) async function runRedemptionScenario( diff --git a/typescript/test/wallet.test.ts b/typescript/test/wallet.test.ts deleted file mode 100644 index 5cbd48fce..000000000 --- a/typescript/test/wallet.test.ts +++ /dev/null @@ -1,291 +0,0 @@ -import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import { MockBridge } from "./utils/mock-bridge" -import { Hex } from "../src" -import { determineWalletMainUtxo } from "../src/wallet" -import { expect } from "chai" -import { - BitcoinNetwork, - BitcoinAddressConverter, - BitcoinTx, -} from "../src/lib/bitcoin" -import { Wallet } from "../src/lib/contracts" -import { BigNumber } from "ethers" - -describe("Wallet", () => { - describe("determineWalletMainUtxo", () => { - // Just an arbitrary 20-byte wallet public key hash. - const walletPublicKeyHash = Hex.from( - "e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0" - ) - - // Helper function facilitating creation of mock transactions. - const mockTransaction = ( - hash: string, - outputs: Record // key: locking script, value: amount of locked satoshis - ): BitcoinTx => { - return { - transactionHash: Hex.from(hash), - inputs: [], // not relevant in this test scenario - outputs: Object.entries(outputs).map( - ([scriptPubKey, value], index) => ({ - outputIndex: index, - value: BigNumber.from(value), - scriptPubKey: Hex.from(scriptPubKey), - }) - ), - } - } - - // Create a fake wallet witness transaction history that consists of 6 transactions. - const walletWitnessTransactionHistory: BitcoinTx[] = [ - mockTransaction( - "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1", - { - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "4c6b33b7c0550e0e536a5d119ac7189d71e1296fcb0c258e0c115356895bc0e6", - { - "00140000000000000000000000000000000000000001": 100000, - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 200000, // wallet witness output - } - ), - mockTransaction( - "44863a79ce2b8fec9792403d5048506e50ffa7338191db0e6c30d3d3358ea2f6", - { - "00140000000000000000000000000000000000000001": 100000, - "00140000000000000000000000000000000000000002": 200000, - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 300000, // wallet witness output - } - ), - mockTransaction( - "f65bc5029251f0042aedb37f90dbb2bfb63a2e81694beef9cae5ec62e954c22e", - { - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "2724545276df61f43f1e92c4b9f1dd3c9109595c022dbd9dc003efbad8ded38b", - { - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214", - { - "00140000000000000000000000000000000000000001": 100000, - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 200000, // wallet witness output - } - ), - ] - - // Create a fake wallet legacy transaction history that consists of 6 transactions. - const walletLegacyTransactionHistory: BitcoinTx[] = [ - mockTransaction( - "230a19d8867ff3f5b409e924d9dd6413188e215f9bb52f1c47de6154dac42267", - { - "00140000000000000000000000000000000000000001": 100000, - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 200000, // wallet legacy output - } - ), - mockTransaction( - "b11bfc481b95769b8488bd661d5f61a35f7c3c757160494d63f6e04e532dfcb9", - { - "00140000000000000000000000000000000000000001": 100000, - "00140000000000000000000000000000000000000002": 200000, - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 300000, // wallet legacy output - } - ), - mockTransaction( - "7e91580d989f8541489a37431381ff9babd596111232f1bc7a1a1ba503c27dee", - { - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "5404e339ba82e6e52fcc24cb40029bed8425baa4c7f869626ef9de956186f910", - { - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94", - { - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "00cc0cd13fc4de7a15cb41ab6d58f8b31c75b6b9b4194958c381441a67d09b08", - { - "00140000000000000000000000000000000000000001": 100000, - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 200000, // wallet legacy output - } - ), - ] - - let bridge: MockBridge - let bitcoinClient: MockBitcoinClient - let bitcoinNetwork: BitcoinNetwork - - beforeEach(async () => { - bridge = new MockBridge() - bitcoinClient = new MockBitcoinClient() - }) - - context("when wallet main UTXO is not set in the Bridge", () => { - beforeEach(async () => { - bridge.setWallet(walletPublicKeyHash.toPrefixedString(), { - mainUtxoHash: Hex.from( - "0x0000000000000000000000000000000000000000000000000000000000000000" - ), - } as Wallet) - }) - - it("should return undefined", async () => { - const mainUtxo = await determineWalletMainUtxo( - walletPublicKeyHash, - bridge, - bitcoinClient, - bitcoinNetwork - ) - - expect(mainUtxo).to.be.undefined - }) - }) - - context("when wallet main UTXO is set in the Bridge", () => { - const tests = [ - { - testName: "recent witness transaction", - // Set the main UTXO hash based on the latest transaction from walletWitnessTransactionHistory. - actualMainUtxo: { - transactionHash: Hex.from( - "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214" - ), - outputIndex: 1, - value: BigNumber.from(200000), - }, - expectedMainUtxo: { - transactionHash: Hex.from( - "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214" - ), - outputIndex: 1, - value: BigNumber.from(200000), - }, - }, - { - testName: "recent legacy transaction", - // Set the main UTXO hash based on the second last transaction from walletLegacyTransactionHistory. - actualMainUtxo: { - transactionHash: Hex.from( - "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94" - ), - outputIndex: 0, - value: BigNumber.from(100000), - }, - expectedMainUtxo: { - transactionHash: Hex.from( - "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94" - ), - outputIndex: 0, - value: BigNumber.from(100000), - }, - }, - { - testName: "old witness transaction", - // Set the main UTXO hash based on the oldest transaction from walletWitnessTransactionHistory. - actualMainUtxo: { - transactionHash: Hex.from( - "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1" - ), - outputIndex: 0, - value: BigNumber.from(100000), - }, - expectedMainUtxo: undefined, - }, - { - testName: "old legacy transaction", - // Set the main UTXO hash based on the oldest transaction from walletLegacyTransactionHistory. - actualMainUtxo: { - transactionHash: Hex.from( - "230a19d8867ff3f5b409e924d9dd6413188e215f9bb52f1c47de6154dac42267" - ), - outputIndex: 1, - value: BigNumber.from(200000), - }, - expectedMainUtxo: undefined, - }, - ] - - tests.forEach(({ testName, actualMainUtxo, expectedMainUtxo }) => { - context(`with main UTXO coming from ${testName}`, () => { - const networkTests = [ - { - networkTestName: "bitcoin testnet", - network: BitcoinNetwork.Testnet, - }, - { - networkTestName: "bitcoin mainnet", - network: BitcoinNetwork.Mainnet, - }, - ] - - networkTests.forEach(({ networkTestName, network }) => { - context(`with ${networkTestName} network`, () => { - beforeEach(async () => { - bitcoinNetwork = network - - const walletWitnessAddress = - BitcoinAddressConverter.publicKeyHashToAddress( - walletPublicKeyHash.toString(), - true, - bitcoinNetwork - ) - const walletLegacyAddress = - BitcoinAddressConverter.publicKeyHashToAddress( - walletPublicKeyHash.toString(), - false, - bitcoinNetwork - ) - - // Record the fake transaction history for both address types. - const transactionHistory = new Map() - transactionHistory.set( - walletWitnessAddress, - walletWitnessTransactionHistory - ) - transactionHistory.set( - walletLegacyAddress, - walletLegacyTransactionHistory - ) - bitcoinClient.transactionHistory = transactionHistory - - bridge.setWallet(walletPublicKeyHash.toPrefixedString(), { - mainUtxoHash: bridge.buildUtxoHash(actualMainUtxo), - } as Wallet) - }) - - it("should return the expected main UTXO", async () => { - const mainUtxo = await determineWalletMainUtxo( - walletPublicKeyHash, - bridge, - bitcoinClient, - bitcoinNetwork - ) - - expect(mainUtxo).to.be.eql(expectedMainUtxo) - }) - }) - }) - }) - }) - }) - }) -}) From f0f7c1505262563779b915854232712662d8d0a7 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 29 Sep 2023 14:11:34 +0200 Subject: [PATCH 175/205] Move remaining code to the `./services/maintenance` feature module The code left is purely related to system maintainers or is helper tooling empowering internal operations like system testing. We are moving it to a dedicated module. By the way, we are arranging the main `index.ts` and adjust all imports to use the base path and not dive into specific directories. --- typescript/src/deposit-sweep.ts | 417 ---- typescript/src/index.ts | 64 +- typescript/src/optimistic-minting.ts | 76 - typescript/src/redemption.ts | 256 -- typescript/src/services/deposits/index.ts | 1 + typescript/src/services/maintenance/index.ts | 4 + .../maintenance/maintenance-service.ts | 25 + .../maintenance/optimistic-minting.ts | 80 + typescript/src/services/maintenance/spv.ts | 96 + .../src/services/maintenance/wallet-tx.ts | 663 ++++++ typescript/test/bitcoin-network.test.ts | 6 +- typescript/test/bitcoin.test.ts | 4 +- typescript/test/data/deposit-refund.ts | 6 +- typescript/test/data/deposit-sweep.ts | 8 +- typescript/test/data/deposit.ts | 2 +- typescript/test/data/electrum.ts | 4 +- typescript/test/data/proof.ts | 4 +- typescript/test/data/redemption.ts | 9 +- typescript/test/deposit-sweep.test.ts | 1713 +++++++------- typescript/test/deposit.test.ts | 14 +- typescript/test/electrum.test.ts | 4 +- typescript/test/ethereum.test.ts | 7 +- typescript/test/hex.test.ts | 2 +- typescript/test/proof.test.ts | 4 +- typescript/test/redemption.test.ts | 2068 +++++++++-------- 25 files changed, 2904 insertions(+), 2633 deletions(-) delete mode 100644 typescript/src/deposit-sweep.ts delete mode 100644 typescript/src/optimistic-minting.ts delete mode 100644 typescript/src/redemption.ts create mode 100644 typescript/src/services/maintenance/index.ts create mode 100644 typescript/src/services/maintenance/maintenance-service.ts create mode 100644 typescript/src/services/maintenance/optimistic-minting.ts create mode 100644 typescript/src/services/maintenance/spv.ts create mode 100644 typescript/src/services/maintenance/wallet-tx.ts diff --git a/typescript/src/deposit-sweep.ts b/typescript/src/deposit-sweep.ts deleted file mode 100644 index 440bfa219..000000000 --- a/typescript/src/deposit-sweep.ts +++ /dev/null @@ -1,417 +0,0 @@ -import bcoin from "bcoin" -import { BigNumber } from "ethers" -import { - assembleBitcoinSpvProof, - BitcoinRawTx, - BitcoinUtxo, - BitcoinClient, - extractBitcoinRawTxVectors, - BitcoinPublicKeyUtils, - BitcoinPrivateKeyUtils, - BitcoinTxHash, - BitcoinHashUtils, -} from "./lib/bitcoin" -import { Bridge, ChainIdentifier, DepositReceipt } from "./lib/contracts" -import { DepositScript } from "./services/deposits" - -/** - * Submits a deposit sweep by combining all the provided P2(W)SH UTXOs and - * broadcasting a Bitcoin P2(W)PKH deposit sweep transaction. - * @dev The caller is responsible for ensuring the provided UTXOs are correctly - * formed, can be spent by the wallet and their combined value is greater - * then the fee. Note that broadcasting transaction may fail silently (e.g. - * when the provided UTXOs are not spendable) and no error will be returned. - * @param bitcoinClient - Bitcoin client used to interact with the network. - * @param fee - the value that should be subtracted from the sum of the UTXOs - * values and used as the transaction fee. - * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. - * @param witness - The parameter used to decide about the type of the new main - * UTXO output. P2WPKH if `true`, P2PKH if `false`. - * @param utxos - P2(W)SH UTXOs to be combined into one output. - * @param deposits - Array of deposits. Each element corresponds to UTXO. - * The number of UTXOs and deposit elements must equal. - * @param mainUtxo - main UTXO of the wallet, which is a P2WKH UTXO resulting - * from the previous wallet transaction (optional). - * @returns The outcome consisting of: - * - the sweep transaction hash, - * - the new wallet's main UTXO produced by this transaction. - */ -export async function submitDepositSweepTransaction( - bitcoinClient: BitcoinClient, - fee: BigNumber, - walletPrivateKey: string, - witness: boolean, - utxos: BitcoinUtxo[], - deposits: DepositReceipt[], - mainUtxo?: BitcoinUtxo -): Promise<{ - transactionHash: BitcoinTxHash - newMainUtxo: BitcoinUtxo -}> { - const utxosWithRaw: (BitcoinUtxo & BitcoinRawTx)[] = [] - for (const utxo of utxos) { - const utxoRawTransaction = await bitcoinClient.getRawTransaction( - utxo.transactionHash - ) - - utxosWithRaw.push({ - ...utxo, - transactionHex: utxoRawTransaction.transactionHex, - }) - } - - let mainUtxoWithRaw - - if (mainUtxo) { - const mainUtxoRawTransaction = await bitcoinClient.getRawTransaction( - mainUtxo.transactionHash - ) - mainUtxoWithRaw = { - ...mainUtxo, - transactionHex: mainUtxoRawTransaction.transactionHex, - } - } - - const { transactionHash, newMainUtxo, rawTransaction } = - await assembleDepositSweepTransaction( - fee, - walletPrivateKey, - witness, - utxosWithRaw, - deposits, - mainUtxoWithRaw - ) - - // Note that `broadcast` may fail silently (i.e. no error will be returned, - // even if the transaction is rejected by other nodes and does not enter the - // mempool, for example due to an UTXO being already spent). - await bitcoinClient.broadcast(rawTransaction) - - return { transactionHash, newMainUtxo } -} - -/** - * Assembles a Bitcoin P2WPKH deposit sweep transaction. - * @dev The caller is responsible for ensuring the provided UTXOs are correctly - * formed, can be spent by the wallet and their combined value is greater - * then the fee. - * @param fee - the value that should be subtracted from the sum of the UTXOs - * values and used as the transaction fee. - * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. - * @param witness - The parameter used to decide about the type of the new main - * UTXO output. P2WPKH if `true`, P2PKH if `false`. - * @param utxos - UTXOs from new deposit transactions. Must be P2(W)SH. - * @param deposits - Array of deposits. Each element corresponds to UTXO. - * The number of UTXOs and deposit elements must equal. - * @param mainUtxo - main UTXO of the wallet, which is a P2WKH UTXO resulting - * from the previous wallet transaction (optional). - * @returns The outcome consisting of: - * - the sweep transaction hash, - * - the new wallet's main UTXO produced by this transaction. - * - the sweep transaction in the raw format - */ -export async function assembleDepositSweepTransaction( - fee: BigNumber, - walletPrivateKey: string, - witness: boolean, - utxos: (BitcoinUtxo & BitcoinRawTx)[], - deposits: DepositReceipt[], - mainUtxo?: BitcoinUtxo & BitcoinRawTx -): Promise<{ - transactionHash: BitcoinTxHash - newMainUtxo: BitcoinUtxo - rawTransaction: BitcoinRawTx -}> { - if (utxos.length < 1) { - throw new Error("There must be at least one deposit UTXO to sweep") - } - - if (utxos.length != deposits.length) { - throw new Error("Number of UTXOs must equal the number of deposit elements") - } - - const walletKeyRing = BitcoinPrivateKeyUtils.createKeyRing( - walletPrivateKey, - witness - ) - const walletAddress = walletKeyRing.getAddress("string") - - const inputCoins = [] - let totalInputValue = BigNumber.from(0) - - if (mainUtxo) { - inputCoins.push( - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), - mainUtxo.outputIndex, - -1 - ) - ) - totalInputValue = totalInputValue.add(mainUtxo.value) - } - - for (const utxo of utxos) { - inputCoins.push( - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), - utxo.outputIndex, - -1 - ) - ) - totalInputValue = totalInputValue.add(utxo.value) - } - - const transaction = new bcoin.MTX() - - transaction.addOutput({ - script: bcoin.Script.fromAddress(walletAddress), - value: totalInputValue.toNumber(), - }) - - await transaction.fund(inputCoins, { - changeAddress: walletAddress, - hardFee: fee.toNumber(), - subtractFee: true, - }) - - if (transaction.outputs.length != 1) { - throw new Error("Deposit sweep transaction must have only one output") - } - - // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any - // order - const utxosWithDeposits: (BitcoinUtxo & BitcoinRawTx & DepositReceipt)[] = - utxos.map((utxo, index) => ({ - ...utxo, - ...deposits[index], - })) - - for (let i = 0; i < transaction.inputs.length; i++) { - const previousOutpoint = transaction.inputs[i].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - const previousScript = previousOutput.script - - // P2(W)PKH (main UTXO) - if (previousScript.isPubkeyhash() || previousScript.isWitnessPubkeyhash()) { - await signMainUtxoInput(transaction, i, walletKeyRing) - continue - } - - const utxoWithDeposit = utxosWithDeposits.find( - (u) => - u.transactionHash.toString() === previousOutpoint.txid() && - u.outputIndex == previousOutpoint.index - ) - if (!utxoWithDeposit) { - throw new Error("Unknown input") - } - - if (previousScript.isScripthash()) { - // P2SH (deposit UTXO) - await signP2SHDepositInput(transaction, i, utxoWithDeposit, walletKeyRing) - } else if (previousScript.isWitnessScripthash()) { - // P2WSH (deposit UTXO) - await signP2WSHDepositInput( - transaction, - i, - utxoWithDeposit, - walletKeyRing - ) - } else { - throw new Error("Unsupported UTXO script type") - } - } - - const transactionHash = BitcoinTxHash.from(transaction.txid()) - - return { - transactionHash, - newMainUtxo: { - transactionHash, - outputIndex: 0, // There is only one output. - value: BigNumber.from(transaction.outputs[0].value), - }, - rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), - }, - } -} - -/** - * Creates script for the transaction input at the given index and signs the - * input. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Empty promise. - */ -async function signMainUtxoInput( - transaction: any, - inputIndex: number, - walletKeyRing: any -) { - const previousOutpoint = transaction.inputs[inputIndex].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - if (!walletKeyRing.ownOutput(previousOutput)) { - throw new Error("UTXO does not belong to the wallet") - } - // Build script and set it as input's witness - transaction.scriptInput(inputIndex, previousOutput, walletKeyRing) - // Build signature and add it in front of script in input's witness - transaction.signInput(inputIndex, previousOutput, walletKeyRing) -} - -/** - * Creates and sets `scriptSig` for the transaction input at the given index by - * combining signature, wallet public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Empty promise. - */ -async function signP2SHDepositInput( - transaction: any, - inputIndex: number, - deposit: DepositReceipt, - walletKeyRing: any -): Promise { - const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData(transaction, inputIndex, deposit, walletKeyRing) - - const signature: Buffer = transaction.signature( - inputIndex, - depositScript, - previousOutputValue, - walletKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 0 // legacy sighash version - ) - const scriptSig = new bcoin.Script() - scriptSig.clear() - scriptSig.pushData(signature) - scriptSig.pushData(Buffer.from(walletPublicKey, "hex")) - scriptSig.pushData(depositScript.toRaw()) - scriptSig.compile() - - transaction.inputs[inputIndex].script = scriptSig -} - -/** - * Creates and sets witness script for the transaction input at the given index - * by combining signature, wallet public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Empty promise. - */ -async function signP2WSHDepositInput( - transaction: any, - inputIndex: number, - deposit: DepositReceipt, - walletKeyRing: any -): Promise { - const { walletPublicKey, depositScript, previousOutputValue } = - await prepareInputSignData(transaction, inputIndex, deposit, walletKeyRing) - - const signature: Buffer = transaction.signature( - inputIndex, - depositScript, - previousOutputValue, - walletKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 1 // segwit sighash version - ) - - const witness = new bcoin.Witness() - witness.clear() - witness.pushData(signature) - witness.pushData(Buffer.from(walletPublicKey, "hex")) - witness.pushData(depositScript.toRaw()) - witness.compile() - - transaction.inputs[inputIndex].witness = witness -} - -/** - * Creates data needed to sign a deposit input. - * @param transaction - Mutable transaction containing the input. - * @param inputIndex - Index that points to the input. - * @param deposit - Data of the deposit. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Data needed to sign the input. - */ -async function prepareInputSignData( - transaction: any, - inputIndex: number, - deposit: DepositReceipt, - walletKeyRing: any -): Promise<{ - walletPublicKey: string - depositScript: any - previousOutputValue: number -}> { - const previousOutpoint = transaction.inputs[inputIndex].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - - const walletPublicKey = walletKeyRing.getPublicKey("hex") - if ( - BitcoinHashUtils.computeHash160(walletKeyRing.getPublicKey("hex")) != - deposit.walletPublicKeyHash - ) { - throw new Error( - "Wallet public key does not correspond to wallet private key" - ) - } - - if (!BitcoinPublicKeyUtils.isCompressedPublicKey(walletPublicKey)) { - throw new Error("Wallet public key must be compressed") - } - - const depositScript = bcoin.Script.fromRaw( - Buffer.from(await DepositScript.fromReceipt(deposit).getPlainText(), "hex") - ) - - return { - walletPublicKey, - depositScript: depositScript, - previousOutputValue: previousOutput.value, - } -} - -/** - * Prepares the proof of a deposit sweep transaction and submits it to the - * Bridge on-chain contract. - * @param transactionHash - Hash of the transaction being proven. - * @param mainUtxo - Recent main UTXO of the wallet as currently known on-chain. - * @param bridge - Handle to the Bridge on-chain contract. - * @param bitcoinClient - Bitcoin client used to interact with the network. - * @param vault - (Optional) The vault pointed by swept deposits. - * @returns Empty promise. - */ -export async function submitDepositSweepProof( - transactionHash: BitcoinTxHash, - mainUtxo: BitcoinUtxo, - bridge: Bridge, - bitcoinClient: BitcoinClient, - vault?: ChainIdentifier -): Promise { - const confirmations = await bridge.txProofDifficultyFactor() - const proof = await assembleBitcoinSpvProof( - transactionHash, - confirmations, - bitcoinClient - ) - // TODO: Write a converter and use it to convert the transaction part of the - // proof to the decomposed transaction data (version, inputs, outputs, locktime). - // Use raw transaction data for now. - const rawTransaction = await bitcoinClient.getRawTransaction(transactionHash) - const rawTransactionVectors = extractBitcoinRawTxVectors(rawTransaction) - await bridge.submitDepositSweepProof( - rawTransactionVectors, - proof, - mainUtxo, - vault - ) -} diff --git a/typescript/src/index.ts b/typescript/src/index.ts index 1c50e4168..197a34d8f 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -1,55 +1,9 @@ -// TODO: Consider exports refactoring as per discussion https://github.com/keep-network/tbtc-v2/pull/460#discussion_r1084530007 - -import { validateBitcoinSpvProof } from "./lib/bitcoin" - -import { submitDepositSweepProof } from "./deposit-sweep" - -import { submitRedemptionProof } from "./redemption" - -import { - requestOptimisticMint, - cancelOptimisticMint, - finalizeOptimisticMint, - getOptimisticMintingRequest, -} from "./optimistic-minting" - -export const SpvMaintainer = { - submitDepositSweepProof, - submitRedemptionProof, -} - -export const OptimisticMinting = { - requestOptimisticMint, - cancelOptimisticMint, - finalizeOptimisticMint, - getOptimisticMintingRequest, -} - -export const Bitcoin = { - validateBitcoinSpvProof, -} - -export { - BitcoinTxHash, - BitcoinTx, - BitcoinTxOutput, - BitcoinLocktimeUtils, - BitcoinNetwork, -} from "./lib/bitcoin" - -export { ElectrumClient } from "./lib/electrum" - -export { - EthereumBridge, - EthereumWalletRegistry, - EthereumAddress, - EthereumTBTCVault, - EthereumTBTCToken, -} from "./lib/ethereum" - -export { Hex } from "./lib/utils" - -export { - OptimisticMintingRequest, - OptimisticMintingRequestedEvent, -} from "./lib/contracts" +export * from "./lib/bitcoin" +export * from "./lib/contracts" +export * from "./lib/electrum" +export * from "./lib/ethereum" +export * from "./lib/utils" + +export * from "./services/deposits" +export * from "./services/maintenance" +export * from "./services/redemptions" diff --git a/typescript/src/optimistic-minting.ts b/typescript/src/optimistic-minting.ts deleted file mode 100644 index 3f884e8ab..000000000 --- a/typescript/src/optimistic-minting.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { BitcoinTxHash } from "./lib/bitcoin" -import { TBTCVault, OptimisticMintingRequest } from "./lib/contracts" -import { Hex } from "./lib/utils" - -/** - * Requests optimistic minting for a deposit on chain. - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @param tbtcVault Handle to the TBTCVault on-chain contract - * @returns Transaction hash of the optimistic mint request transaction. - */ -export async function requestOptimisticMint( - depositTxHash: BitcoinTxHash, - depositOutputIndex: number, - tbtcVault: TBTCVault -): Promise { - return await tbtcVault.requestOptimisticMint( - depositTxHash, - depositOutputIndex - ) -} - -/** - * Cancels optimistic minting for a deposit on chain. - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @param tbtcVault Handle to the TBTCVault on-chain contract - * @returns Transaction hash of the optimistic mint cancel transaction. - */ -export async function cancelOptimisticMint( - depositTxHash: BitcoinTxHash, - depositOutputIndex: number, - tbtcVault: TBTCVault -): Promise { - return await tbtcVault.cancelOptimisticMint(depositTxHash, depositOutputIndex) -} - -/** - * Finalizes optimistic minting for a deposit on chain. - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @param tbtcVault Handle to the TBTCVault on-chain contract - * @returns Transaction hash of the optimistic mint finalize transaction. - */ -export async function finalizeOptimisticMint( - depositTxHash: BitcoinTxHash, - depositOutputIndex: number, - tbtcVault: TBTCVault -): Promise { - return await tbtcVault.finalizeOptimisticMint( - depositTxHash, - depositOutputIndex - ) -} - -/** - * Gets optimistic minting request for a deposit from chain. - * @param depositTxHash The revealed deposit transaction's hash. - * @param depositOutputIndex Index of the deposit transaction output that - * funds the revealed deposit. - * @param tbtcVault Handle to the TBTCVault on-chain contract - * @returns Optimistic minting request. - */ -export async function getOptimisticMintingRequest( - depositTxHash: BitcoinTxHash, - depositOutputIndex: number, - tbtcVault: TBTCVault -): Promise { - return await tbtcVault.optimisticMintingRequests( - depositTxHash, - depositOutputIndex - ) -} diff --git a/typescript/src/redemption.ts b/typescript/src/redemption.ts deleted file mode 100644 index 5c1696812..000000000 --- a/typescript/src/redemption.ts +++ /dev/null @@ -1,256 +0,0 @@ -import bcoin from "bcoin" -import { BigNumber } from "ethers" -import { - assembleBitcoinSpvProof, - BitcoinPrivateKeyUtils, - extractBitcoinRawTxVectors, - BitcoinRawTx, - BitcoinUtxo, - BitcoinClient, - BitcoinTxHash, -} from "./lib/bitcoin" -import { Bridge, RedemptionRequest } from "./lib/contracts" - -/** - * Handles pending redemption requests by creating a redemption transaction - * transferring Bitcoins from the wallet's main UTXO to the provided redeemer - * output scripts and broadcasting it. The change UTXO resulting from the - * transaction becomes the new main UTXO of the wallet. - * @dev It is up to the caller to ensure the wallet key and each of the redeemer - * output scripts represent a valid pending redemption request in the Bridge. - * If this is not the case, an exception will be thrown. - * @param bitcoinClient - The Bitcoin client used to interact with the network - * @param bridge - The handle to the Bridge on-chain contract - * @param walletPrivateKey - The private kay of the wallet in the WIF format - * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO - * held by the on-chain Bridge contract - * @param redeemerOutputScripts - The list of output scripts that the redeemed - * funds will be locked to. The output scripts must be un-prefixed and - * not prepended with length - * @param witness - The parameter used to decide about the type of the change - * output. P2WPKH if `true`, P2PKH if `false` - * @returns The outcome consisting of: - * - the redemption transaction hash, - * - the optional new wallet's main UTXO produced by this transaction. - */ -export async function submitRedemptionTransaction( - bitcoinClient: BitcoinClient, - bridge: Bridge, - walletPrivateKey: string, - mainUtxo: BitcoinUtxo, - redeemerOutputScripts: string[], - witness: boolean -): Promise<{ - transactionHash: BitcoinTxHash - newMainUtxo?: BitcoinUtxo -}> { - const mainUtxoRawTransaction = await bitcoinClient.getRawTransaction( - mainUtxo.transactionHash - ) - - const mainUtxoWithRaw: BitcoinUtxo & BitcoinRawTx = { - ...mainUtxo, - transactionHex: mainUtxoRawTransaction.transactionHex, - } - - const walletPublicKey = BitcoinPrivateKeyUtils.createKeyRing(walletPrivateKey) - .getPublicKey() - .toString("hex") - - const redemptionRequests: RedemptionRequest[] = [] - - for (const redeemerOutputScript of redeemerOutputScripts) { - const redemptionRequest = await bridge.pendingRedemptions( - walletPublicKey, - redeemerOutputScript - ) - - if (redemptionRequest.requestedAt == 0) { - throw new Error("Redemption request does not exist") - } - - redemptionRequests.push({ - ...redemptionRequest, - redeemerOutputScript: redeemerOutputScript, - }) - } - - const { transactionHash, newMainUtxo, rawTransaction } = - await assembleRedemptionTransaction( - walletPrivateKey, - mainUtxoWithRaw, - redemptionRequests, - witness - ) - - // Note that `broadcast` may fail silently (i.e. no error will be returned, - // even if the transaction is rejected by other nodes and does not enter the - // mempool, for example due to an UTXO being already spent). - await bitcoinClient.broadcast(rawTransaction) - - return { transactionHash, newMainUtxo } -} - -/** - * Assembles a Bitcoin redemption transaction. - * The transaction will have a single input (main UTXO of the wallet making - * the redemption), an output for each redemption request provided, and a change - * output if the redemption requests do not consume the entire amount of the - * single input. - * @dev The caller is responsible for ensuring the redemption request list is - * correctly formed: - * - there is at least one redemption - * - the `requestedAmount` in each redemption request is greater than - * the sum of its `txFee` and `treasuryFee` - * @param walletPrivateKey - The private key of the wallet in the WIF format - * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO held - * by the on-chain Bridge contract - * @param redemptionRequests - The list of redemption requests - * @param witness - The parameter used to decide the type of the change output. - * P2WPKH if `true`, P2PKH if `false` - * @returns The outcome consisting of: - * - the redemption transaction hash, - * - the optional new wallet's main UTXO produced by this transaction. - * - the redemption transaction in the raw format - */ -export async function assembleRedemptionTransaction( - walletPrivateKey: string, - mainUtxo: BitcoinUtxo & BitcoinRawTx, - redemptionRequests: RedemptionRequest[], - witness: boolean -): Promise<{ - transactionHash: BitcoinTxHash - newMainUtxo?: BitcoinUtxo - rawTransaction: BitcoinRawTx -}> { - if (redemptionRequests.length < 1) { - throw new Error("There must be at least one request to redeem") - } - - const walletKeyRing = BitcoinPrivateKeyUtils.createKeyRing( - walletPrivateKey, - witness - ) - const walletAddress = walletKeyRing.getAddress("string") - - // Use the main UTXO as the single transaction input - const inputCoins = [ - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), - mainUtxo.outputIndex, - -1 - ), - ] - - const transaction = new bcoin.MTX() - - let txTotalFee = BigNumber.from(0) - let totalOutputsValue = BigNumber.from(0) - - // Process the requests - for (const request of redemptionRequests) { - // Calculate the value of the output by subtracting tx fee and treasury - // fee for this particular output from the requested amount - const outputValue = request.requestedAmount - .sub(request.txMaxFee) - .sub(request.treasuryFee) - - // Add the output value to the total output value - totalOutputsValue = totalOutputsValue.add(outputValue) - - // Add the fee for this particular request to the overall transaction fee - // TODO: Using the maximum allowed transaction fee for the request (`txMaxFee`) - // as the transaction fee for now. In the future allow the caller to - // propose the value of the transaction fee. If the proposed transaction - // fee is smaller than the sum of fee shares from all the outputs then - // use the proposed fee and add the difference to outputs proportionally. - txTotalFee = txTotalFee.add(request.txMaxFee) - - transaction.addOutput({ - script: bcoin.Script.fromRaw( - Buffer.from(request.redeemerOutputScript, "hex") - ), - value: outputValue.toNumber(), - }) - } - - // If there is a change output, add it explicitly to the transaction. - // If we did not add this output explicitly, the bcoin library would add it - // anyway during funding, but if the value of the change output was very low, - // the library would consider it "dust" and add it to the fee rather than - // create a new output. - const changeOutputValue = mainUtxo.value - .sub(totalOutputsValue) - .sub(txTotalFee) - if (changeOutputValue.gt(0)) { - transaction.addOutput({ - script: bcoin.Script.fromAddress(walletAddress), - value: changeOutputValue.toNumber(), - }) - } - - await transaction.fund(inputCoins, { - changeAddress: walletAddress, - hardFee: txTotalFee.toNumber(), - subtractFee: false, - }) - - transaction.sign(walletKeyRing) - - const transactionHash = BitcoinTxHash.from(transaction.txid()) - // If there is a change output, it will be the new wallet's main UTXO. - const newMainUtxo = changeOutputValue.gt(0) - ? { - transactionHash, - // It was the last output added to the transaction. - outputIndex: transaction.outputs.length - 1, - value: changeOutputValue, - } - : undefined - - return { - transactionHash, - newMainUtxo, - rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), - }, - } -} - -/** - * Prepares the proof of a redemption transaction and submits it to the - * Bridge on-chain contract. - * @param transactionHash - Hash of the transaction being proven. - * @param mainUtxo - Recent main UTXO of the wallet as currently known on-chain. - * @param walletPublicKey - Bitcoin public key of the wallet. Must be in the - * compressed form (33 bytes long with 02 or 03 prefix). - * @param bridge - Handle to the Bridge on-chain contract. - * @param bitcoinClient - Bitcoin client used to interact with the network. - * @returns Empty promise. - */ -export async function submitRedemptionProof( - transactionHash: BitcoinTxHash, - mainUtxo: BitcoinUtxo, - walletPublicKey: string, - bridge: Bridge, - bitcoinClient: BitcoinClient -): Promise { - const confirmations = await bridge.txProofDifficultyFactor() - const proof = await assembleBitcoinSpvProof( - transactionHash, - confirmations, - bitcoinClient - ) - // TODO: Write a converter and use it to convert the transaction part of the - // proof to the decomposed transaction data (version, inputs, outputs, locktime). - // Use raw transaction data for now. - const rawTransaction = await bitcoinClient.getRawTransaction(transactionHash) - const rawTransactionVectors = extractBitcoinRawTxVectors(rawTransaction) - - await bridge.submitRedemptionProof( - rawTransactionVectors, - proof, - mainUtxo, - walletPublicKey - ) -} diff --git a/typescript/src/services/deposits/index.ts b/typescript/src/services/deposits/index.ts index f75596a11..d326e4023 100644 --- a/typescript/src/services/deposits/index.ts +++ b/typescript/src/services/deposits/index.ts @@ -1,3 +1,4 @@ export * from "./deposit" export * from "./deposits-service" export * from "./funding" +export * from "./refund" diff --git a/typescript/src/services/maintenance/index.ts b/typescript/src/services/maintenance/index.ts new file mode 100644 index 000000000..ee3f28e26 --- /dev/null +++ b/typescript/src/services/maintenance/index.ts @@ -0,0 +1,4 @@ +export * from "./maintenance-service" +export * from "./optimistic-minting" +export * from "./spv" +export * from "./wallet-tx" diff --git a/typescript/src/services/maintenance/maintenance-service.ts b/typescript/src/services/maintenance/maintenance-service.ts new file mode 100644 index 000000000..01c55637e --- /dev/null +++ b/typescript/src/services/maintenance/maintenance-service.ts @@ -0,0 +1,25 @@ +import { TBTCContracts } from "../../lib/contracts" +import { BitcoinClient } from "../../lib/bitcoin" +import { OptimisticMinting } from "./optimistic-minting" +import { Spv } from "./spv" +import {WalletTx} from "./wallet-tx"; + +/** + * Service exposing features relevant to authorized maintainers and + * operators of the tBTC v2 system. + */ +export class MaintenanceService { + /** + * Features for optimistic minting maintainers. + */ + public readonly optimisticMinting: OptimisticMinting + /** + * Features for SPV proof maintainers. + */ + public readonly spv: Spv + + constructor(tbtcContracts: TBTCContracts, bitcoinClient: BitcoinClient) { + this.optimisticMinting = new OptimisticMinting(tbtcContracts) + this.spv = new Spv(tbtcContracts, bitcoinClient) + } +} diff --git a/typescript/src/services/maintenance/optimistic-minting.ts b/typescript/src/services/maintenance/optimistic-minting.ts new file mode 100644 index 000000000..56c072a46 --- /dev/null +++ b/typescript/src/services/maintenance/optimistic-minting.ts @@ -0,0 +1,80 @@ +import { BitcoinTxHash } from "../../lib/bitcoin" +import { OptimisticMintingRequest } from "../../lib/contracts" +import { Hex } from "../../lib/utils" +import { TBTCContracts } from "../../lib/contracts" + +export class OptimisticMinting { + private readonly tbtcContracts: TBTCContracts + + constructor(tbtcContracts: TBTCContracts) { + this.tbtcContracts = tbtcContracts + } + + /** + * Requests optimistic minting for a deposit on chain. + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Transaction hash of the optimistic mint request transaction. + */ + async requestMint( + depositTxHash: BitcoinTxHash, + depositOutputIndex: number + ): Promise { + return this.tbtcContracts.tbtcVault.requestOptimisticMint( + depositTxHash, + depositOutputIndex + ) + } + + /** + * Cancels optimistic minting for a deposit on chain. + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Transaction hash of the optimistic mint cancel transaction. + */ + async cancelMint( + depositTxHash: BitcoinTxHash, + depositOutputIndex: number + ): Promise { + return this.tbtcContracts.tbtcVault.cancelOptimisticMint( + depositTxHash, + depositOutputIndex + ) + } + + /** + * Finalizes optimistic minting for a deposit on chain. + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Transaction hash of the optimistic mint finalize transaction. + */ + async finalizeMint( + depositTxHash: BitcoinTxHash, + depositOutputIndex: number + ): Promise { + return this.tbtcContracts.tbtcVault.finalizeOptimisticMint( + depositTxHash, + depositOutputIndex + ) + } + + /** + * Gets optimistic minting request for a deposit from chain. + * @param depositTxHash The revealed deposit transaction's hash. + * @param depositOutputIndex Index of the deposit transaction output that + * funds the revealed deposit. + * @returns Optimistic minting request. + */ + async getMintingRequest( + depositTxHash: BitcoinTxHash, + depositOutputIndex: number + ): Promise { + return this.tbtcContracts.tbtcVault.optimisticMintingRequests( + depositTxHash, + depositOutputIndex + ) + } +} diff --git a/typescript/src/services/maintenance/spv.ts b/typescript/src/services/maintenance/spv.ts new file mode 100644 index 000000000..d64fef5b9 --- /dev/null +++ b/typescript/src/services/maintenance/spv.ts @@ -0,0 +1,96 @@ +import { + assembleBitcoinSpvProof, + BitcoinClient, + BitcoinTxHash, + BitcoinUtxo, + extractBitcoinRawTxVectors, +} from "../../lib/bitcoin" +import { ChainIdentifier, TBTCContracts } from "../../lib/contracts" + +export class Spv { + /** + * Handle to tBTC contracts. + */ + private readonly tbtcContracts: TBTCContracts + /** + * Bitcoin client handle. + */ + private readonly bitcoinClient: BitcoinClient + + constructor(tbtcContracts: TBTCContracts, bitcoinClient: BitcoinClient) { + this.tbtcContracts = tbtcContracts + this.bitcoinClient = bitcoinClient + } + + /** + * Prepares the proof of a deposit sweep transaction and submits it to the + * Bridge on-chain contract. + * @param transactionHash - Hash of the transaction being proven. + * @param mainUtxo - Recent main UTXO of the wallet as currently known on-chain. + * @param vault - (Optional) The vault pointed by swept deposits. + * @returns Empty promise. + */ + async submitDepositSweepProof( + transactionHash: BitcoinTxHash, + mainUtxo: BitcoinUtxo, + vault?: ChainIdentifier + ): Promise { + const confirmations = + await this.tbtcContracts.bridge.txProofDifficultyFactor() + const proof = await assembleBitcoinSpvProof( + transactionHash, + confirmations, + this.bitcoinClient + ) + // TODO: Write a converter and use it to convert the transaction part of the + // proof to the decomposed transaction data (version, inputs, outputs, locktime). + // Use raw transaction data for now. + const rawTransaction = await this.bitcoinClient.getRawTransaction( + transactionHash + ) + const rawTransactionVectors = extractBitcoinRawTxVectors(rawTransaction) + await this.tbtcContracts.bridge.submitDepositSweepProof( + rawTransactionVectors, + proof, + mainUtxo, + vault + ) + } + + /** + * Prepares the proof of a redemption transaction and submits it to the + * Bridge on-chain contract. + * @param transactionHash - Hash of the transaction being proven. + * @param mainUtxo - Recent main UTXO of the wallet as currently known on-chain. + * @param walletPublicKey - Bitcoin public key of the wallet. Must be in the + * compressed form (33 bytes long with 02 or 03 prefix). + * @returns Empty promise. + */ + async submitRedemptionProof( + transactionHash: BitcoinTxHash, + mainUtxo: BitcoinUtxo, + walletPublicKey: string + ): Promise { + const confirmations = + await this.tbtcContracts.bridge.txProofDifficultyFactor() + const proof = await assembleBitcoinSpvProof( + transactionHash, + confirmations, + this.bitcoinClient + ) + // TODO: Write a converter and use it to convert the transaction part of the + // proof to the decomposed transaction data (version, inputs, outputs, locktime). + // Use raw transaction data for now. + const rawTransaction = await this.bitcoinClient.getRawTransaction( + transactionHash + ) + const rawTransactionVectors = extractBitcoinRawTxVectors(rawTransaction) + + await this.tbtcContracts.bridge.submitRedemptionProof( + rawTransactionVectors, + proof, + mainUtxo, + walletPublicKey + ) + } +} diff --git a/typescript/src/services/maintenance/wallet-tx.ts b/typescript/src/services/maintenance/wallet-tx.ts new file mode 100644 index 000000000..4c2522e98 --- /dev/null +++ b/typescript/src/services/maintenance/wallet-tx.ts @@ -0,0 +1,663 @@ +import { + BitcoinClient, + BitcoinHashUtils, + BitcoinPrivateKeyUtils, + BitcoinPublicKeyUtils, + BitcoinRawTx, + BitcoinTxHash, + BitcoinUtxo, +} from "../../lib/bitcoin" +import { BigNumber } from "ethers" +import { + DepositReceipt, + RedemptionRequest, + TBTCContracts, +} from "../../lib/contracts" +import bcoin from "bcoin" +import { DepositScript } from "../deposits" + +/** + * Wallet transactions builder. This feature set is supposed to be used only + * for internal purposes like system tests. In real world, tBTC v2 wallets + * are formed by peer-to-peer network participants that sign transactions + * using threshold signature schemes. + * + * @experimental THIS IS EXPERIMENTAL CODE THAT CAN BE CHANGED OR REMOVED + * IN FUTURE RELEASES. IT SHOULD BE USED ONLY FOR INTERNAL + * PURPOSES AND EXTERNAL APPLICATIONS SHOULD NOT DEPEND ON IT. + */ +// TODO: Abstract away transaction signing so there is no need to deal with +// private key directly. +export class WalletTx { + public readonly depositSweep: DepositSweep + public readonly redemption: Redemption + + constructor( + tbtcContracts: TBTCContracts, + bitcoinClient: BitcoinClient, + witness: boolean = true + ) { + this.depositSweep = new DepositSweep(bitcoinClient, witness) + this.redemption = new Redemption(tbtcContracts, bitcoinClient, witness) + } +} + +class DepositSweep { + /** + * Bitcoin client handle. + */ + private readonly bitcoinClient: BitcoinClient + /** + * Flag indicating whether the generated Bitcoin deposit sweep transaction + * should be a witness one. + */ + private readonly witness: boolean + + constructor(bitcoinClient: BitcoinClient, witness: boolean = true) { + this.bitcoinClient = bitcoinClient + this.witness = witness + } + + /** + * Submits a deposit sweep by combining all the provided P2(W)SH UTXOs and + * broadcasting a Bitcoin P2(W)PKH deposit sweep transaction. + * @dev The caller is responsible for ensuring the provided UTXOs are correctly + * formed, can be spent by the wallet and their combined value is greater + * than the fee. Note that broadcasting transaction may fail silently (e.g. + * when the provided UTXOs are not spendable) and no error will be returned. + * @param fee - the value that should be subtracted from the sum of the UTXOs + * values and used as the transaction fee. + * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. + * @param utxos - P2(W)SH UTXOs to be combined into one output. + * @param deposits - Array of deposits. Each element corresponds to UTXO. + * The number of UTXOs and deposit elements must equal. + * @param mainUtxo - main UTXO of the wallet, which is a P2WKH UTXO resulting + * from the previous wallet transaction (optional). + * @returns The outcome consisting of: + * - the sweep transaction hash, + * - the new wallet's main UTXO produced by this transaction. + */ + async submitTransaction( + fee: BigNumber, + walletPrivateKey: string, + utxos: BitcoinUtxo[], + deposits: DepositReceipt[], + mainUtxo?: BitcoinUtxo + ): Promise<{ + transactionHash: BitcoinTxHash + newMainUtxo: BitcoinUtxo + }> { + const utxosWithRaw: (BitcoinUtxo & BitcoinRawTx)[] = [] + for (const utxo of utxos) { + const utxoRawTransaction = await this.bitcoinClient.getRawTransaction( + utxo.transactionHash + ) + + utxosWithRaw.push({ + ...utxo, + transactionHex: utxoRawTransaction.transactionHex, + }) + } + + let mainUtxoWithRaw + + if (mainUtxo) { + const mainUtxoRawTransaction = await this.bitcoinClient.getRawTransaction( + mainUtxo.transactionHash + ) + mainUtxoWithRaw = { + ...mainUtxo, + transactionHex: mainUtxoRawTransaction.transactionHex, + } + } + + const { transactionHash, newMainUtxo, rawTransaction } = + await this.assembleTransaction( + fee, + walletPrivateKey, + utxosWithRaw, + deposits, + mainUtxoWithRaw + ) + + // Note that `broadcast` may fail silently (i.e. no error will be returned, + // even if the transaction is rejected by other nodes and does not enter the + // mempool, for example due to an UTXO being already spent). + await this.bitcoinClient.broadcast(rawTransaction) + + return { transactionHash, newMainUtxo } + } + + /** + * Assembles a Bitcoin P2WPKH deposit sweep transaction. + * @dev The caller is responsible for ensuring the provided UTXOs are correctly + * formed, can be spent by the wallet and their combined value is greater + * then the fee. + * @param fee - the value that should be subtracted from the sum of the UTXOs + * values and used as the transaction fee. + * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. + * @param utxos - UTXOs from new deposit transactions. Must be P2(W)SH. + * @param deposits - Array of deposits. Each element corresponds to UTXO. + * The number of UTXOs and deposit elements must equal. + * @param mainUtxo - main UTXO of the wallet, which is a P2WKH UTXO resulting + * from the previous wallet transaction (optional). + * @returns The outcome consisting of: + * - the sweep transaction hash, + * - the new wallet's main UTXO produced by this transaction. + * - the sweep transaction in the raw format + */ + async assembleTransaction( + fee: BigNumber, + walletPrivateKey: string, + utxos: (BitcoinUtxo & BitcoinRawTx)[], + deposits: DepositReceipt[], + mainUtxo?: BitcoinUtxo & BitcoinRawTx + ): Promise<{ + transactionHash: BitcoinTxHash + newMainUtxo: BitcoinUtxo + rawTransaction: BitcoinRawTx + }> { + if (utxos.length < 1) { + throw new Error("There must be at least one deposit UTXO to sweep") + } + + if (utxos.length != deposits.length) { + throw new Error( + "Number of UTXOs must equal the number of deposit elements" + ) + } + + const walletKeyRing = BitcoinPrivateKeyUtils.createKeyRing( + walletPrivateKey, + this.witness + ) + const walletAddress = walletKeyRing.getAddress("string") + + const inputCoins = [] + let totalInputValue = BigNumber.from(0) + + if (mainUtxo) { + inputCoins.push( + bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), + mainUtxo.outputIndex, + -1 + ) + ) + totalInputValue = totalInputValue.add(mainUtxo.value) + } + + for (const utxo of utxos) { + inputCoins.push( + bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), + utxo.outputIndex, + -1 + ) + ) + totalInputValue = totalInputValue.add(utxo.value) + } + + const transaction = new bcoin.MTX() + + transaction.addOutput({ + script: bcoin.Script.fromAddress(walletAddress), + value: totalInputValue.toNumber(), + }) + + await transaction.fund(inputCoins, { + changeAddress: walletAddress, + hardFee: fee.toNumber(), + subtractFee: true, + }) + + if (transaction.outputs.length != 1) { + throw new Error("Deposit sweep transaction must have only one output") + } + + // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any + // order + const utxosWithDeposits: (BitcoinUtxo & BitcoinRawTx & DepositReceipt)[] = + utxos.map((utxo, index) => ({ + ...utxo, + ...deposits[index], + })) + + for (let i = 0; i < transaction.inputs.length; i++) { + const previousOutpoint = transaction.inputs[i].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) + const previousScript = previousOutput.script + + // P2(W)PKH (main UTXO) + if ( + previousScript.isPubkeyhash() || + previousScript.isWitnessPubkeyhash() + ) { + await this.signMainUtxoInput(transaction, i, walletKeyRing) + continue + } + + const utxoWithDeposit = utxosWithDeposits.find( + (u) => + u.transactionHash.toString() === previousOutpoint.txid() && + u.outputIndex == previousOutpoint.index + ) + if (!utxoWithDeposit) { + throw new Error("Unknown input") + } + + if (previousScript.isScripthash()) { + // P2SH (deposit UTXO) + await this.signP2SHDepositInput( + transaction, + i, + utxoWithDeposit, + walletKeyRing + ) + } else if (previousScript.isWitnessScripthash()) { + // P2WSH (deposit UTXO) + await this.signP2WSHDepositInput( + transaction, + i, + utxoWithDeposit, + walletKeyRing + ) + } else { + throw new Error("Unsupported UTXO script type") + } + } + + const transactionHash = BitcoinTxHash.from(transaction.txid()) + + return { + transactionHash, + newMainUtxo: { + transactionHash, + outputIndex: 0, // There is only one output. + value: BigNumber.from(transaction.outputs[0].value), + }, + rawTransaction: { + transactionHex: transaction.toRaw().toString("hex"), + }, + } + } + + /** + * Creates script for the transaction input at the given index and signs the + * input. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param walletKeyRing - Key ring created using the wallet's private key. + * @returns Empty promise. + */ + private async signMainUtxoInput( + transaction: any, + inputIndex: number, + walletKeyRing: any + ) { + const previousOutpoint = transaction.inputs[inputIndex].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) + if (!walletKeyRing.ownOutput(previousOutput)) { + throw new Error("UTXO does not belong to the wallet") + } + // Build script and set it as input's witness + transaction.scriptInput(inputIndex, previousOutput, walletKeyRing) + // Build signature and add it in front of script in input's witness + transaction.signInput(inputIndex, previousOutput, walletKeyRing) + } + + /** + * Creates and sets `scriptSig` for the transaction input at the given index by + * combining signature, wallet public key and deposit script. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param deposit - Data of the deposit. + * @param walletKeyRing - Key ring created using the wallet's private key. + * @returns Empty promise. + */ + private async signP2SHDepositInput( + transaction: any, + inputIndex: number, + deposit: DepositReceipt, + walletKeyRing: any + ): Promise { + const { walletPublicKey, depositScript, previousOutputValue } = + await this.prepareInputSignData( + transaction, + inputIndex, + deposit, + walletKeyRing + ) + + const signature: Buffer = transaction.signature( + inputIndex, + depositScript, + previousOutputValue, + walletKeyRing.privateKey, + bcoin.Script.hashType.ALL, + 0 // legacy sighash version + ) + const scriptSig = new bcoin.Script() + scriptSig.clear() + scriptSig.pushData(signature) + scriptSig.pushData(Buffer.from(walletPublicKey, "hex")) + scriptSig.pushData(depositScript.toRaw()) + scriptSig.compile() + + transaction.inputs[inputIndex].script = scriptSig + } + + /** + * Creates and sets witness script for the transaction input at the given index + * by combining signature, wallet public key and deposit script. + * @param transaction - Mutable transaction containing the input to be signed. + * @param inputIndex - Index that points to the input to be signed. + * @param deposit - Data of the deposit. + * @param walletKeyRing - Key ring created using the wallet's private key. + * @returns Empty promise. + */ + private async signP2WSHDepositInput( + transaction: any, + inputIndex: number, + deposit: DepositReceipt, + walletKeyRing: any + ): Promise { + const { walletPublicKey, depositScript, previousOutputValue } = + await this.prepareInputSignData( + transaction, + inputIndex, + deposit, + walletKeyRing + ) + + const signature: Buffer = transaction.signature( + inputIndex, + depositScript, + previousOutputValue, + walletKeyRing.privateKey, + bcoin.Script.hashType.ALL, + 1 // segwit sighash version + ) + + const witness = new bcoin.Witness() + witness.clear() + witness.pushData(signature) + witness.pushData(Buffer.from(walletPublicKey, "hex")) + witness.pushData(depositScript.toRaw()) + witness.compile() + + transaction.inputs[inputIndex].witness = witness + } + + /** + * Creates data needed to sign a deposit input. + * @param transaction - Mutable transaction containing the input. + * @param inputIndex - Index that points to the input. + * @param deposit - Data of the deposit. + * @param walletKeyRing - Key ring created using the wallet's private key. + * @returns Data needed to sign the input. + */ + private async prepareInputSignData( + transaction: any, + inputIndex: number, + deposit: DepositReceipt, + walletKeyRing: any + ): Promise<{ + walletPublicKey: string + depositScript: any + previousOutputValue: number + }> { + const previousOutpoint = transaction.inputs[inputIndex].prevout + const previousOutput = transaction.view.getOutput(previousOutpoint) + + const walletPublicKey = walletKeyRing.getPublicKey("hex") + if ( + BitcoinHashUtils.computeHash160(walletKeyRing.getPublicKey("hex")) != + deposit.walletPublicKeyHash + ) { + throw new Error( + "Wallet public key does not correspond to wallet private key" + ) + } + + if (!BitcoinPublicKeyUtils.isCompressedPublicKey(walletPublicKey)) { + throw new Error("Wallet public key must be compressed") + } + + const depositScript = bcoin.Script.fromRaw( + Buffer.from( + await DepositScript.fromReceipt(deposit).getPlainText(), + "hex" + ) + ) + + return { + walletPublicKey, + depositScript: depositScript, + previousOutputValue: previousOutput.value, + } + } +} + +class Redemption { + /** + * Handle to tBTC contracts. + */ + private readonly tbtcContracts: TBTCContracts + /** + * Bitcoin client handle. + */ + private readonly bitcoinClient: BitcoinClient + /** + * Flag indicating whether the generated Bitcoin redemption transaction + * should be a witness one. + */ + private readonly witness: boolean + + constructor( + tbtcContracts: TBTCContracts, + bitcoinClient: BitcoinClient, + witness: boolean = true + ) { + this.tbtcContracts = tbtcContracts + this.bitcoinClient = bitcoinClient + this.witness = witness + } + /** + * Handles pending redemption requests by creating a redemption transaction + * transferring Bitcoins from the wallet's main UTXO to the provided redeemer + * output scripts and broadcasting it. The change UTXO resulting from the + * transaction becomes the new main UTXO of the wallet. + * @dev It is up to the caller to ensure the wallet key and each of the redeemer + * output scripts represent a valid pending redemption request in the Bridge. + * If this is not the case, an exception will be thrown. + * @param walletPrivateKey - The private kay of the wallet in the WIF format + * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO + * held by the on-chain Bridge contract + * @param redeemerOutputScripts - The list of output scripts that the redeemed + * funds will be locked to. The output scripts must be un-prefixed and + * not prepended with length + * @returns The outcome consisting of: + * - the redemption transaction hash, + * - the optional new wallet's main UTXO produced by this transaction. + */ + async submitTransaction( + walletPrivateKey: string, + mainUtxo: BitcoinUtxo, + redeemerOutputScripts: string[] + ): Promise<{ + transactionHash: BitcoinTxHash + newMainUtxo?: BitcoinUtxo + }> { + const mainUtxoRawTransaction = await this.bitcoinClient.getRawTransaction( + mainUtxo.transactionHash + ) + + const mainUtxoWithRaw: BitcoinUtxo & BitcoinRawTx = { + ...mainUtxo, + transactionHex: mainUtxoRawTransaction.transactionHex, + } + + const walletPublicKey = BitcoinPrivateKeyUtils.createKeyRing( + walletPrivateKey + ) + .getPublicKey() + .toString("hex") + + const redemptionRequests: RedemptionRequest[] = [] + + for (const redeemerOutputScript of redeemerOutputScripts) { + const redemptionRequest = + await this.tbtcContracts.bridge.pendingRedemptions( + walletPublicKey, + redeemerOutputScript + ) + + if (redemptionRequest.requestedAt == 0) { + throw new Error("Redemption request does not exist") + } + + redemptionRequests.push({ + ...redemptionRequest, + redeemerOutputScript: redeemerOutputScript, + }) + } + + const { transactionHash, newMainUtxo, rawTransaction } = + await this.assembleTransaction( + walletPrivateKey, + mainUtxoWithRaw, + redemptionRequests + ) + + // Note that `broadcast` may fail silently (i.e. no error will be returned, + // even if the transaction is rejected by other nodes and does not enter the + // mempool, for example due to an UTXO being already spent). + await this.bitcoinClient.broadcast(rawTransaction) + + return { transactionHash, newMainUtxo } + } + + /** + * Assembles a Bitcoin redemption transaction. + * The transaction will have a single input (main UTXO of the wallet making + * the redemption), an output for each redemption request provided, and a change + * output if the redemption requests do not consume the entire amount of the + * single input. + * @dev The caller is responsible for ensuring the redemption request list is + * correctly formed: + * - there is at least one redemption + * - the `requestedAmount` in each redemption request is greater than + * the sum of its `txFee` and `treasuryFee` + * @param walletPrivateKey - The private key of the wallet in the WIF format + * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO held + * by the on-chain Bridge contract + * @param redemptionRequests - The list of redemption requests + * @returns The outcome consisting of: + * - the redemption transaction hash, + * - the optional new wallet's main UTXO produced by this transaction. + * - the redemption transaction in the raw format + */ + async assembleTransaction( + walletPrivateKey: string, + mainUtxo: BitcoinUtxo & BitcoinRawTx, + redemptionRequests: RedemptionRequest[] + ): Promise<{ + transactionHash: BitcoinTxHash + newMainUtxo?: BitcoinUtxo + rawTransaction: BitcoinRawTx + }> { + if (redemptionRequests.length < 1) { + throw new Error("There must be at least one request to redeem") + } + + const walletKeyRing = BitcoinPrivateKeyUtils.createKeyRing( + walletPrivateKey, + this.witness + ) + const walletAddress = walletKeyRing.getAddress("string") + + // Use the main UTXO as the single transaction input + const inputCoins = [ + bcoin.Coin.fromTX( + bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), + mainUtxo.outputIndex, + -1 + ), + ] + + const transaction = new bcoin.MTX() + + let txTotalFee = BigNumber.from(0) + let totalOutputsValue = BigNumber.from(0) + + // Process the requests + for (const request of redemptionRequests) { + // Calculate the value of the output by subtracting tx fee and treasury + // fee for this particular output from the requested amount + const outputValue = request.requestedAmount + .sub(request.txMaxFee) + .sub(request.treasuryFee) + + // Add the output value to the total output value + totalOutputsValue = totalOutputsValue.add(outputValue) + + // Add the fee for this particular request to the overall transaction fee + // TODO: Using the maximum allowed transaction fee for the request (`txMaxFee`) + // as the transaction fee for now. In the future allow the caller to + // propose the value of the transaction fee. If the proposed transaction + // fee is smaller than the sum of fee shares from all the outputs then + // use the proposed fee and add the difference to outputs proportionally. + txTotalFee = txTotalFee.add(request.txMaxFee) + + transaction.addOutput({ + script: bcoin.Script.fromRaw( + Buffer.from(request.redeemerOutputScript, "hex") + ), + value: outputValue.toNumber(), + }) + } + + // If there is a change output, add it explicitly to the transaction. + // If we did not add this output explicitly, the bcoin library would add it + // anyway during funding, but if the value of the change output was very low, + // the library would consider it "dust" and add it to the fee rather than + // create a new output. + const changeOutputValue = mainUtxo.value + .sub(totalOutputsValue) + .sub(txTotalFee) + if (changeOutputValue.gt(0)) { + transaction.addOutput({ + script: bcoin.Script.fromAddress(walletAddress), + value: changeOutputValue.toNumber(), + }) + } + + await transaction.fund(inputCoins, { + changeAddress: walletAddress, + hardFee: txTotalFee.toNumber(), + subtractFee: false, + }) + + transaction.sign(walletKeyRing) + + const transactionHash = BitcoinTxHash.from(transaction.txid()) + // If there is a change output, it will be the new wallet's main UTXO. + const newMainUtxo = changeOutputValue.gt(0) + ? { + transactionHash, + // It was the last output added to the transaction. + outputIndex: transaction.outputs.length - 1, + value: changeOutputValue, + } + : undefined + + return { + transactionHash, + newMainUtxo, + rawTransaction: { + transactionHex: transaction.toRaw().toString("hex"), + }, + } + } +} diff --git a/typescript/test/bitcoin-network.test.ts b/typescript/test/bitcoin-network.test.ts index aa87a5c0c..db4555b74 100644 --- a/typescript/test/bitcoin-network.test.ts +++ b/typescript/test/bitcoin-network.test.ts @@ -1,9 +1,5 @@ import { expect } from "chai" -import { - BitcoinTxHash, - BitcoinNetwork, - toBcoinNetwork, -} from "../src/lib/bitcoin" +import { BitcoinTxHash, BitcoinNetwork, toBcoinNetwork } from "../src" describe("BitcoinNetwork", () => { const testData = [ diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 6b03fff4b..785875480 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -9,8 +9,8 @@ import { BitcoinTargetConverter, BitcoinCompactSizeUint, BitcoinAddressConverter, -} from "../src/lib/bitcoin" -import { Hex } from "../src/lib/utils" + Hex, +} from "../src" import { BigNumber } from "ethers" import { btcAddresses } from "./data/bitcoin" diff --git a/typescript/test/data/deposit-refund.ts b/typescript/test/data/deposit-refund.ts index 57a41762d..ff0782a2a 100644 --- a/typescript/test/data/deposit-refund.ts +++ b/typescript/test/data/deposit-refund.ts @@ -4,9 +4,9 @@ import { BitcoinUtxo, BitcoinTxHash, BitcoinLocktimeUtils, -} from "../../src/lib/bitcoin" -import { DepositReceipt } from "../../src/lib/contracts" -import { EthereumAddress } from "../../src/lib/ethereum" + DepositReceipt, + EthereumAddress, +} from "../../src" /** * Testnet private key that can be used to refund the deposits used in tests. diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index 14251228b..0c962b841 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -7,11 +7,11 @@ import { BitcoinTxMerkleBranch, BitcoinTxHash, BitcoinLocktimeUtils, -} from "../../src/lib/bitcoin" -import { DepositReceipt } from "../../src/lib/contracts" + DepositReceipt, + EthereumAddress, + Hex, +} from "../../src" import { BigNumber } from "ethers" -import { EthereumAddress } from "../../src/lib/ethereum" -import { Hex } from "../../src" export const NO_MAIN_UTXO = { transactionHash: BitcoinTxHash.from(""), diff --git a/typescript/test/data/deposit.ts b/typescript/test/data/deposit.ts index 241c6e4bd..16a2e1d00 100644 --- a/typescript/test/data/deposit.ts +++ b/typescript/test/data/deposit.ts @@ -1,4 +1,4 @@ -import { BitcoinRawTx, BitcoinTxHash, BitcoinUtxo } from "../../src/lib/bitcoin" +import { BitcoinRawTx, BitcoinTxHash, BitcoinUtxo } from "../../src" import { BigNumber } from "ethers" /** diff --git a/typescript/test/data/electrum.ts b/typescript/test/data/electrum.ts index 374fe9c14..22d930672 100644 --- a/typescript/test/data/electrum.ts +++ b/typescript/test/data/electrum.ts @@ -4,9 +4,9 @@ import { BitcoinUtxo, BitcoinTxMerkleBranch, BitcoinTxHash, -} from "../../src/lib/bitcoin" + Hex, +} from "../../src" import { BigNumber } from "ethers" -import { Hex } from "../../src" /** * Bitcoin testnet address used for Electrum client tests. diff --git a/typescript/test/data/proof.ts b/typescript/test/data/proof.ts index ec212b497..bbd94a853 100644 --- a/typescript/test/data/proof.ts +++ b/typescript/test/data/proof.ts @@ -4,9 +4,9 @@ import { BitcoinTx, BitcoinTxHash, BitcoinTxMerkleBranch, -} from "../../src/lib/bitcoin" + Hex, +} from "../../src" import { BigNumber } from "ethers" -import { Hex } from "../../src" /** * Represents a set of data used for given proof scenario. diff --git a/typescript/test/data/redemption.ts b/typescript/test/data/redemption.ts index c66863c50..9ff50845d 100644 --- a/typescript/test/data/redemption.ts +++ b/typescript/test/data/redemption.ts @@ -8,10 +8,11 @@ import { BitcoinTxMerkleBranch, BitcoinTxHash, BitcoinAddressConverter, -} from "../../src/lib/bitcoin" -import { RedemptionRequest, WalletState } from "../../src/lib/contracts" -import { EthereumAddress } from "../../src/lib/ethereum" -import { Hex } from "../../src" + RedemptionRequest, + WalletState, + EthereumAddress, + Hex, +} from "../../src" /** * Private key (testnet) of the wallet. diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index b92c63b84..403d56020 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -4,7 +4,9 @@ import { BitcoinTxHash, BitcoinUtxo, BitcoinTx, -} from "../src/lib/bitcoin" + MaintenanceService, + WalletTx, +} from "../src" import { testnetDepositScripthashAddress, testnetDepositWitnessScripthashAddress, @@ -20,99 +22,299 @@ import { NO_MAIN_UTXO, } from "./data/deposit-sweep" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import { MockBridge } from "./utils/mock-bridge" import bcoin from "bcoin" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) import { expect } from "chai" -import { - assembleDepositSweepTransaction, - submitDepositSweepProof, - submitDepositSweepTransaction, -} from "../src/deposit-sweep" +import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" describe("Sweep", () => { const fee = BigNumber.from(1600) - describe("submitDepositSweepTransaction", () => { - let bitcoinClient: MockBitcoinClient + describe("WalletTx", () => { + describe("DepositSweep", () => { + describe("submitTransaction", () => { + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient - beforeEach(async () => { - bcoin.set("testnet") + beforeEach(async () => { + bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() - }) + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + }) - context("when the new main UTXO is requested to be witness", () => { - context("when there is no main UTXO from previous deposit sweep", () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo + context("when the new main UTXO is requested to be witness", () => { + context( + "when there is no main UTXO from previous deposit sweep", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + + beforeEach(async () => { + // Map transaction hashes for UTXOs to transactions in hexadecimal and + // set the mapping in the mock Bitcoin client + const rawTransactions = new Map() + for (const deposit of depositSweepWithNoMainUtxoAndWitnessOutput.deposits) { + rawTransactions.set(deposit.utxo.transactionHash.toString(), { + transactionHex: deposit.utxo.transactionHex, + }) + } + bitcoinClient.rawTransactions = rawTransactions + + const utxos: BitcoinUtxo[] = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( + (data) => { + return data.utxo + } + ) + + const deposit = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + const witness = + depositSweepWithNoMainUtxoAndWitnessOutput.witness + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) - beforeEach(async () => { - // Map transaction hashes for UTXOs to transactions in hexadecimal and - // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() - for (const deposit of depositSweepWithNoMainUtxoAndWitnessOutput.deposits) { - rawTransactions.set(deposit.utxo.transactionHash.toString(), { - transactionHex: deposit.utxo.transactionHex, - }) - } - bitcoinClient.rawTransactions = rawTransactions + ;({ transactionHash, newMainUtxo } = + await walletTx.depositSweep.submitTransaction( + fee, + testnetWalletPrivateKey, + utxos, + deposit + )) + }) - const utxos: BitcoinUtxo[] = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map((data) => { - return data.utxo - }) + it("should broadcast sweep transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transaction + ) + }) - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.data + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transactionHash, + outputIndex: 0, + value: BigNumber.from(35400), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + + context("when there is main UTXO from previous deposit sweep", () => { + context( + "when main UTXO from previous deposit sweep is witness", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + + beforeEach(async () => { + // Map transaction hashes for UTXOs to transactions in hexadecimal and + // set the mapping in the mock Bitcoin client + const rawTransactions = new Map() + for (const deposit of depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits) { + rawTransactions.set( + deposit.utxo.transactionHash.toString(), + { + transactionHex: deposit.utxo.transactionHex, + } + ) + } + // The main UTXO resulting from another data set was used as input. + // Set raw data of that main UTXO as well. + rawTransactions.set( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString(), + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transaction + ) + bitcoinClient.rawTransactions = rawTransactions + + const utxos: BitcoinUtxo[] = + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.utxo + } + ) + + const deposit = + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + + const witness = + depositSweepWithWitnessMainUtxoAndWitnessOutput.witness + + const mainUtxo = + depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) + + ;({ transactionHash, newMainUtxo } = + await walletTx.depositSweep.submitTransaction( + fee, + testnetWalletPrivateKey, + utxos, + deposit, + mainUtxo + )) + }) + + it("should broadcast sweep transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash, + outputIndex: 0, + value: BigNumber.from(60800), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) } ) - const witness = depositSweepWithNoMainUtxoAndWitnessOutput.witness - ;({ transactionHash, newMainUtxo } = - await submitDepositSweepTransaction( - bitcoinClient, - fee, - testnetWalletPrivateKey, - witness, - utxos, - deposit - )) - }) + context( + "when main UTXO from previous deposit sweep is non-witness", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + + beforeEach(async () => { + // Map transaction hashes for UTXOs to transactions in hexadecimal and + // set the mapping in the mock Bitcoin client + const rawTransactions = new Map() + for (const deposit of depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits) { + rawTransactions.set( + deposit.utxo.transactionHash.toString(), + { + transactionHex: deposit.utxo.transactionHex, + } + ) + } + rawTransactions.set( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString(), + { + transactionHex: + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .mainUtxo.transactionHex, + } + ) + bitcoinClient.rawTransactions = rawTransactions + + const utxos: BitcoinUtxo[] = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.utxo + } + ) + + const deposit = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + + const witness = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.witness + + const mainUtxo = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo - it("should broadcast sweep transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transaction - ) - }) + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) + + ;({ transactionHash, newMainUtxo } = + await walletTx.depositSweep.submitTransaction( + fee, + testnetWalletPrivateKey, + utxos, + deposit, + mainUtxo + )) + }) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transactionHash - ) - }) + it("should broadcast sweep transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transaction + ) + }) - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transactionHash, - outputIndex: 0, - value: BigNumber.from(35400), - } + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash + ) + }) - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash, + outputIndex: 0, + value: BigNumber.from(33800), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + }) }) - }) - context("when there is main UTXO from previous deposit sweep", () => { - context("when main UTXO from previous deposit sweep is witness", () => { + context("when the new main UTXO is requested to be non-witness", () => { + // The only difference between deposit sweep transactions with witness and + // non-witness output is the output type itself. + // Therefore only one test case was added for non-witness transactions. let transactionHash: BitcoinTxHash let newMainUtxo: BitcoinUtxo @@ -120,63 +322,51 @@ describe("Sweep", () => { // Map transaction hashes for UTXOs to transactions in hexadecimal and // set the mapping in the mock Bitcoin client const rawTransactions = new Map() - for (const deposit of depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits) { + for (const deposit of depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits) { rawTransactions.set(deposit.utxo.transactionHash.toString(), { transactionHex: deposit.utxo.transactionHex, }) } - // The main UTXO resulting from another data set was used as input. - // Set raw data of that main UTXO as well. - rawTransactions.set( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString(), - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transaction - ) bitcoinClient.rawTransactions = rawTransactions - const utxos: BitcoinUtxo[] = - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.utxo + const utxos = + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( + (data) => { + return data.utxo } ) - const deposit = - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + const deposits = + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( (deposit) => { return deposit.data } ) - const witness = - depositSweepWithWitnessMainUtxoAndWitnessOutput.witness + depositSweepWithNoMainUtxoAndNonWitnessOutput.witness - const mainUtxo = - depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo + const walletTx = new WalletTx(tbtcContracts, bitcoinClient, witness) ;({ transactionHash, newMainUtxo } = - await submitDepositSweepTransaction( - bitcoinClient, + await walletTx.depositSweep.submitTransaction( fee, testnetWalletPrivateKey, - witness, utxos, - deposit, - mainUtxo + deposits )) }) it("should broadcast sweep transaction with proper structure", async () => { expect(bitcoinClient.broadcastLog.length).to.be.equal(1) expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep .transaction ) }) it("should return the proper transaction hash", async () => { expect(transactionHash).to.be.deep.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep .transactionHash ) }) @@ -184,343 +374,503 @@ describe("Sweep", () => { it("should return the proper new main UTXO", () => { const expectedNewMainUtxo = { transactionHash: - depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep .transactionHash, outputIndex: 0, - value: BigNumber.from(60800), + value: BigNumber.from(13400), } expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) }) }) + }) - context( - "when main UTXO from previous deposit sweep is non-witness", - () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - - beforeEach(async () => { - // Map transaction hashes for UTXOs to transactions in hexadecimal and - // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() - for (const deposit of depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits) { - rawTransactions.set(deposit.utxo.transactionHash.toString(), { - transactionHex: deposit.utxo.transactionHex, - }) - } - rawTransactions.set( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString(), - { - transactionHex: - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo - .transactionHex, - } - ) - bitcoinClient.rawTransactions = rawTransactions + describe("assembleTransaction", () => { + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient - const utxos: BitcoinUtxo[] = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.utxo + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + }) + + context("when the new main UTXO is requested to be witness", () => { + context( + "when there is no main UTXO from previous deposit sweep", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx + + const utxosWithRaw = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( + (data) => { + return data.utxo } ) const deposit = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( (deposit) => { return deposit.data } ) - const witness = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.witness + const witness = depositSweepWithNoMainUtxoAndWitnessOutput.witness - const mainUtxo = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) - ;({ transactionHash, newMainUtxo } = - await submitDepositSweepTransaction( - bitcoinClient, + beforeEach(async () => { + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.depositSweep.assembleTransaction( fee, testnetWalletPrivateKey, - witness, - utxos, - deposit, - mainUtxo + utxosWithRaw, + deposit )) - }) - - it("should broadcast sweep transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep - .transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep - .transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash, - outputIndex: 0, - value: BigNumber.from(33800), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - }) - }) + }) - context("when the new main UTXO is requested to be non-witness", () => { - // The only difference between deposit sweep transactions with witness and - // non-witness output is the output type itself. - // Therefore only one test case was added for non-witness transactions. - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo + it("should return sweep transaction with proper structure", () => { + // Compare HEXes. + expect(transaction).to.be.eql( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transaction + ) - beforeEach(async () => { - // Map transaction hashes for UTXOs to transactions in hexadecimal and - // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() - for (const deposit of depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits) { - rawTransactions.set(deposit.utxo.transactionHash.toString(), { - transactionHex: deposit.utxo.transactionHex, - }) - } - bitcoinClient.rawTransactions = rawTransactions + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - const utxos = - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map((data) => { - return data.utxo - }) + expect(txJSON.hash).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) - const deposits = - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) - const witness = depositSweepWithNoMainUtxoAndNonWitnessOutput.witness - - ;({ transactionHash, newMainUtxo } = - await submitDepositSweepTransaction( - bitcoinClient, - fee, - testnetWalletPrivateKey, - witness, - utxos, - deposits - )) - }) + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(2) - it("should broadcast sweep transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transaction - ) - }) + const p2shInput = txJSON.inputs[0] + expect(p2shInput.prevout.hash).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() + ) + expect(p2shInput.prevout.index).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo + .outputIndex + ) + // Transaction should be signed. As it's not SegWit input, the `witness` + // field should be empty, while the `script` field should be filled. + expect(p2shInput.witness).to.be.equal("00") + expect(p2shInput.script.length).to.be.greaterThan(0) + // Input's address should be set to the address generated from deposit + // script hash + expect(p2shInput.address).to.be.equal( + testnetDepositScripthashAddress + ) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transactionHash - ) - }) + const p2wshInput = txJSON.inputs[1] + expect(p2wshInput.prevout.hash).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() + ) + expect(p2wshInput.prevout.index).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo + .outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wshInput.witness.length).to.be.greaterThan(0) + expect(p2wshInput.script.length).to.be.equal(0) + // Input's address should be set to the address generated from deposit + // witness script hash + expect(p2wshInput.address).to.be.equal( + testnetDepositWitnessScripthashAddress + ) - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transactionHash, - outputIndex: 0, - value: BigNumber.from(13400), - } + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(1) + const sweepOutput = txJSON.outputs[0] - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - }) - }) + // Should be OP_0 . Public key corresponds to the + // wallet BTC address. + expect(sweepOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The output's address should be the wallet's address + expect(sweepOutput.address).to.be.equal(testnetWalletAddress) + // The output's value should be equal to the sum of all input values + // minus fee (25000 + 12000 - 1600) + expect(sweepOutput.value).to.be.equal(35400) + }) - describe("assembleDepositSweepTransaction", () => { - context("when the new main UTXO is requested to be witness", () => { - context("when there is no main UTXO from previous deposit sweep", () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - let transaction: BitcoinRawTx + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transactionHash + ) + }) - const utxosWithRaw = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map((data) => { - return data.utxo - }) + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transactionHash, + outputIndex: 0, + value: BigNumber.from(35400), + } - const deposit = depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) - const witness = depositSweepWithNoMainUtxoAndWitnessOutput.witness + context("when there is main UTXO from previous deposit sweep", () => { + context( + "when main UTXO prom previous deposit sweep is witness", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx + + const utxosWithRaw = + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.utxo + } + ) + + const deposit = + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + + // P2WPKH + const mainUtxoWithRaw = + depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo + + const witness = + depositSweepWithWitnessMainUtxoAndWitnessOutput.witness + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) - beforeEach(async () => { - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await assembleDepositSweepTransaction( - fee, - testnetWalletPrivateKey, - witness, - utxosWithRaw, - deposit - )) - }) + beforeEach(async () => { + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.depositSweep.assembleTransaction( + fee, + testnetWalletPrivateKey, + utxosWithRaw, + deposit, + mainUtxoWithRaw + )) + }) - it("should return sweep transaction with proper structure", () => { - // Compare HEXes. - expect(transaction).to.be.eql( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transaction - ) + it("should return sweep transaction with proper structure", () => { + // Compare HEXes. + expect(transaction).to.be.eql( + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transaction + ) + + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + + expect(txJSON.hash).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) + + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(3) + + const p2wkhInput = txJSON.inputs[0] + expect(p2wkhInput.prevout.hash).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() + ) + expect(p2wkhInput.prevout.index).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo + .outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wkhInput.witness.length).to.be.greaterThan(0) + expect(p2wkhInput.script.length).to.be.equal(0) + // The input comes from the main UTXO so the input should be the + // wallet's address + expect(p2wkhInput.address).to.be.equal(testnetWalletAddress) + + const p2shInput = txJSON.inputs[1] + expect(p2shInput.prevout.hash).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() + ) + expect(p2shInput.prevout.index).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0] + .utxo.outputIndex + ) + // Transaction should be signed. As it's not SegWit input, the `witness` + // field should be empty, while the `script` field should be filled. + expect(p2shInput.witness).to.be.equal("00") + expect(p2shInput.script.length).to.be.greaterThan(0) + // Input's address should be set to the address generated from deposit + // script hash + expect(p2shInput.address).to.be.equal( + testnetDepositScripthashAddress + ) + + const p2wshInput = txJSON.inputs[2] + expect(p2wshInput.prevout.hash).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() + ) + expect(p2wshInput.prevout.index).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1] + .utxo.outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wshInput.witness.length).to.be.greaterThan(0) + expect(p2wshInput.script.length).to.be.equal(0) + // Input's address should be set to the address generated from deposit + // witness script hash + expect(p2wshInput.address).to.be.equal( + testnetDepositWitnessScripthashAddress + ) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(1) + + const sweepOutput = txJSON.outputs[0] + // Should be OP_0 . Public key corresponds to the + // wallet BTC address. + expect(sweepOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The output's address should be the wallet's address + expect(sweepOutput.address).to.be.equal(testnetWalletAddress) + // The output's value should be equal to the sum of all input values + // minus fee (17000 + 10000 + 35400 - 1600) + expect(sweepOutput.value).to.be.equal(60800) + }) - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash + ) + }) - expect(txJSON.hash).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash, + outputIndex: 0, + value: BigNumber.from(60800), + } - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(2) + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) - const p2shInput = txJSON.inputs[0] - expect(p2shInput.prevout.hash).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() - ) - expect(p2shInput.prevout.index).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo - .outputIndex - ) - // Transaction should be signed. As it's not SegWit input, the `witness` - // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.equal("00") - expect(p2shInput.script.length).to.be.greaterThan(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2shInput.address).to.be.equal(testnetDepositScripthashAddress) - - const p2wshInput = txJSON.inputs[1] - expect(p2wshInput.prevout.hash).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() - ) - expect(p2wshInput.prevout.index).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo - .outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wshInput.witness.length).to.be.greaterThan(0) - expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // witness script hash - expect(p2wshInput.address).to.be.equal( - testnetDepositWitnessScripthashAddress - ) + context( + "when main UTXO from previous deposit sweep is non-witness", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx + + const utxosWithRaw = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.utxo + } + ) + + const deposit = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + + // P2WPKH + const mainUtxoWithRaw = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo + + const witness = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.witness + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(1) - const sweepOutput = txJSON.outputs[0] + beforeEach(async () => { + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.depositSweep.assembleTransaction( + fee, + testnetWalletPrivateKey, + utxosWithRaw, + deposit, + mainUtxoWithRaw + )) + }) - // Should be OP_0 . Public key corresponds to the - // wallet BTC address. - expect(sweepOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - // The output's address should be the wallet's address - expect(sweepOutput.address).to.be.equal(testnetWalletAddress) - // The output's value should be equal to the sum of all input values - // minus fee (25000 + 12000 - 1600) - expect(sweepOutput.value).to.be.equal(35400) - }) + it("should return sweep transaction with proper structure", () => { + // Compare HEXes. + expect(transaction).to.be.eql( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transaction + ) + + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + + expect(txJSON.hash).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) + + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(2) + + const p2wshInput = txJSON.inputs[0] + expect(p2wshInput.prevout.hash).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() + ) + expect(p2wshInput.prevout.index).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .deposits[0].utxo.outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wshInput.witness.length).to.be.greaterThan(0) + expect(p2wshInput.script.length).to.be.equal(0) + // Input's address should be set to the address generated from deposit + // script hash + expect(p2wshInput.address).to.be.equal( + "tb1qk8urugnf08wfle6wslmdxq7mkz9z0gw8e6gkvspn7dx87tfpfntshdm7qr" + ) + + const p2pkhInput = txJSON.inputs[1] // main UTXO + expect(p2pkhInput.prevout.hash).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() + ) + expect(p2pkhInput.prevout.index).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo + .outputIndex + ) + // Transaction should be signed. As it's not SegWit input, the `witness` + // field should be empty, while the `script` field should be filled. + expect(p2pkhInput.witness).to.be.equal("00") + expect(p2pkhInput.script.length).to.be.greaterThan(0) + // The input comes from the main UTXO so the input should be the + // wallet's address + expect(p2pkhInput.address).to.be.equal( + "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" + ) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(1) + + const sweepOutput = txJSON.outputs[0] + // Should be OP_0 . Public key corresponds to the + // wallet BTC address. + expect(sweepOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The output's address should be the wallet's address + expect(sweepOutput.address).to.be.equal(testnetWalletAddress) + // The output's value should be equal to the sum of all input values + // minus fee (16400 + 19000 - 1600) + expect(sweepOutput.value).to.be.equal(33800) + }) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transactionHash - ) - }) + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash + ) + }) - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transactionHash, - outputIndex: 0, - value: BigNumber.from(35400), - } + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash, + outputIndex: 0, + value: BigNumber.from(33800), + } - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + }) }) - }) - context("when there is main UTXO from previous deposit sweep", () => { - context("when main UTXO prom previous deposit sweep is witness", () => { + context("when the new main UTXO is requested to be non-witness", () => { + // The only difference between deposit sweep transactions with witness and + // non-witness output is the output type itself. + // Therefore only one test case was added for non-witness transactions. let transactionHash: BitcoinTxHash let newMainUtxo: BitcoinUtxo let transaction: BitcoinRawTx const utxosWithRaw = - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( (deposit) => { return deposit.utxo } ) const deposit = - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( (deposit) => { return deposit.data } ) - // P2WPKH - const mainUtxoWithRaw = - depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo + const witness = depositSweepWithNoMainUtxoAndNonWitnessOutput.witness - const witness = - depositSweepWithWitnessMainUtxoAndWitnessOutput.witness + const walletTx = new WalletTx(tbtcContracts, bitcoinClient, witness) beforeEach(async () => { ;({ transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleDepositSweepTransaction( + } = await walletTx.depositSweep.assembleTransaction( fee, testnetWalletPrivateKey, - witness, utxosWithRaw, - deposit, - mainUtxoWithRaw + deposit )) }) it("should return sweep transaction with proper structure", () => { // Compare HEXes. expect(transaction).to.be.eql( - depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep .transaction ) @@ -529,35 +879,19 @@ describe("Sweep", () => { const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep.transactionHash.toString() ) expect(txJSON.version).to.be.equal(1) // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(3) + expect(txJSON.inputs.length).to.be.equal(1) - const p2wkhInput = txJSON.inputs[0] - expect(p2wkhInput.prevout.hash).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() - ) - expect(p2wkhInput.prevout.index).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo - .outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wkhInput.witness.length).to.be.greaterThan(0) - expect(p2wkhInput.script.length).to.be.equal(0) - // The input comes from the main UTXO so the input should be the - // wallet's address - expect(p2wkhInput.address).to.be.equal(testnetWalletAddress) - - const p2shInput = txJSON.inputs[1] + const p2shInput = txJSON.inputs[0] expect(p2shInput.prevout.hash).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo.transactionHash.toString() ) expect(p2shInput.prevout.index).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` @@ -567,46 +901,30 @@ describe("Sweep", () => { // Input's address should be set to the address generated from deposit // script hash expect(p2shInput.address).to.be.equal( - testnetDepositScripthashAddress - ) - - const p2wshInput = txJSON.inputs[2] - expect(p2wshInput.prevout.hash).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() - ) - expect(p2wshInput.prevout.index).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo - .outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wshInput.witness.length).to.be.greaterThan(0) - expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // witness script hash - expect(p2wshInput.address).to.be.equal( - testnetDepositWitnessScripthashAddress + "2N8iF1pRndihBzgLDna9MfRhmqktwTdHejA" ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) const sweepOutput = txJSON.outputs[0] - // Should be OP_0 . Public key corresponds to the - // wallet BTC address. + // OP_DUP OP_HASH160 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 + // OP_EQUALVERIFY OP_CHECKSIG expect(sweepOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" + "76a9148db50eb52063ea9d98b3eac91489a90f738986f688ac" ) // The output's address should be the wallet's address - expect(sweepOutput.address).to.be.equal(testnetWalletAddress) + expect(sweepOutput.address).to.be.equal( + "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" + ) // The output's value should be equal to the sum of all input values - // minus fee (17000 + 10000 + 35400 - 1600) - expect(sweepOutput.value).to.be.equal(60800) + // minus fee (15000- 1600) + expect(sweepOutput.value).to.be.equal(13400) }) it("should return the proper transaction hash", async () => { expect(transactionHash).to.be.deep.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep .transactionHash ) }) @@ -614,467 +932,238 @@ describe("Sweep", () => { it("should return the proper new main UTXO", () => { const expectedNewMainUtxo = { transactionHash: - depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep .transactionHash, outputIndex: 0, - value: BigNumber.from(60800), + value: BigNumber.from(13400), } - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + expect(newMainUtxo).to.be.deep.equal(expectedNewMainUtxo) }) }) - context( - "when main UTXO from previous deposit sweep is non-witness", - () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - let transaction: BitcoinRawTx + context("when there are no UTXOs", () => { + it("should revert", async () => { + const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - const utxosWithRaw = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.utxo - } + await expect( + walletTx.depositSweep.assembleTransaction( + fee, + testnetWalletPrivateKey, + [], + [] ) + ).to.be.rejectedWith( + "There must be at least one deposit UTXO to sweep" + ) + }) + }) - const deposit = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.data + context( + "when the numbers of UTXOs and deposit elements are not equal", + () => { + const utxosWithRaw = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( + (data) => { + return data.utxo } ) - // P2WPKH - const mainUtxoWithRaw = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo + // Add only one element to the deposit + const deposit = [ + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data, + ] - const witness = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.witness - - beforeEach(async () => { - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await assembleDepositSweepTransaction( - fee, - testnetWalletPrivateKey, - witness, - utxosWithRaw, - deposit, - mainUtxoWithRaw - )) - }) + const witness = depositSweepWithNoMainUtxoAndWitnessOutput.witness - it("should return sweep transaction with proper structure", () => { - // Compare HEXes. - expect(transaction).to.be.eql( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep - .transaction + it("should revert", async () => { + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness ) - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - - expect(txJSON.hash).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() + await expect( + walletTx.depositSweep.assembleTransaction( + fee, + testnetWalletPrivateKey, + utxosWithRaw, + deposit + ) + ).to.be.rejectedWith( + "Number of UTXOs must equal the number of deposit elements" ) - expect(txJSON.version).to.be.equal(1) + }) + } + ) - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(2) + context("when the main UTXO does not belong to the wallet", () => { + const utxoWithRaw = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo + const deposit = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data + + // The UTXO below does not belong to the wallet + const mainUtxoWithRaw = { + transactionHash: BitcoinTxHash.from( + "2f952bdc206bf51bb745b967cb7166149becada878d3191ffe341155ebcd4883" + ), + outputIndex: 1, + value: BigNumber.from(3933200), + transactionHex: + "0100000000010162cae24e74ad64f9f0493b09f3964908b3b3038f4924882d3d" + + "bd853b4c9bc7390100000000ffffffff02102700000000000017a914867120d5" + + "480a9cc0c11c1193fa59b3a92e852da78710043c00000000001600147ac2d937" + + "8a1c47e589dfb8095ca95ed2140d272602483045022100b70bd9b7f5d230444a" + + "542c7971bea79786b4ebde6703cee7b6ee8cd16e115ebf02204d50ea9d1ee08d" + + "e9741498c2cc64266e40d52c4adb9ef68e65aa2727cd4208b5012102ee067a02" + + "73f2e3ba88d23140a24fdb290f27bbcd0f94117a9c65be3911c5c04e00000000", + } - const p2wshInput = txJSON.inputs[0] - expect(p2wshInput.prevout.hash).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() - ) - expect(p2wshInput.prevout.index).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0] - .utxo.outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wshInput.witness.length).to.be.greaterThan(0) - expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2wshInput.address).to.be.equal( - "tb1qk8urugnf08wfle6wslmdxq7mkz9z0gw8e6gkvspn7dx87tfpfntshdm7qr" - ) + it("should revert", async () => { + const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - const p2pkhInput = txJSON.inputs[1] // main UTXO - expect(p2pkhInput.prevout.hash).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() - ) - expect(p2pkhInput.prevout.index).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo - .outputIndex - ) - // Transaction should be signed. As it's not SegWit input, the `witness` - // field should be empty, while the `script` field should be filled. - expect(p2pkhInput.witness).to.be.equal("00") - expect(p2pkhInput.script.length).to.be.greaterThan(0) - // The input comes from the main UTXO so the input should be the - // wallet's address - expect(p2pkhInput.address).to.be.equal( - "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" + await expect( + walletTx.depositSweep.assembleTransaction( + fee, + testnetWalletPrivateKey, + [utxoWithRaw], + [deposit], + mainUtxoWithRaw ) + ).to.be.rejectedWith("UTXO does not belong to the wallet") + }) + }) - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(1) + context( + "when the wallet private does not correspond to the wallet public key", + () => { + const utxoWithRaw = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo + const deposit = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data + const anotherPrivateKey = + "cRJvyxtoggjAm9A94cB86hZ7Y62z2ei5VNJHLksFi2xdnz1GJ6xt" - const sweepOutput = txJSON.outputs[0] - // Should be OP_0 . Public key corresponds to the - // wallet BTC address. - expect(sweepOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - // The output's address should be the wallet's address - expect(sweepOutput.address).to.be.equal(testnetWalletAddress) - // The output's value should be equal to the sum of all input values - // minus fee (16400 + 19000 - 1600) - expect(sweepOutput.value).to.be.equal(33800) - }) + it("should revert", async () => { + const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep - .transactionHash + await expect( + walletTx.depositSweep.assembleTransaction( + fee, + anotherPrivateKey, + [utxoWithRaw], + [deposit] + ) + ).to.be.rejectedWith( + "Wallet public key does not correspond to wallet private key" ) }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash, - outputIndex: 0, - value: BigNumber.from(33800), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) } ) - }) - }) - context("when the new main UTXO is requested to be non-witness", () => { - // The only difference between deposit sweep transactions with witness and - // non-witness output is the output type itself. - // Therefore only one test case was added for non-witness transactions. - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - let transaction: BitcoinRawTx - - const utxosWithRaw = - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( - (deposit) => { - return deposit.utxo - } - ) - - const deposit = - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( - (deposit) => { - return deposit.data + context("when the type of UTXO is unsupported", () => { + // Use coinbase transaction of some block + const utxoWithRaw = { + transactionHash: BitcoinTxHash.from( + "025de155e6f2ffbbf4851493e0d28dad54020db221a3f38bf63c1f65e3d3595b" + ), + outputIndex: 0, + value: BigNumber.from(5000000000), + transactionHex: + "010000000100000000000000000000000000000000000000000000000000000000" + + "00000000ffffffff0e04db07c34f0103062f503253482fffffffff0100f2052a01" + + "000000232102db6a0f2ef2e970eb1d2a84eabb5337f9cac0d85b49f209bffc4ec6" + + "805802e6a5ac00000000", } - ) + const deposit = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data - const witness = depositSweepWithNoMainUtxoAndNonWitnessOutput.witness + it("should revert", async () => { + const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - beforeEach(async () => { - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await assembleDepositSweepTransaction( - fee, - testnetWalletPrivateKey, - witness, - utxosWithRaw, - deposit - )) + await expect( + walletTx.depositSweep.assembleTransaction( + fee, + testnetWalletPrivateKey, + [utxoWithRaw], + [deposit] + ) + ).to.be.rejectedWith("Unsupported UTXO script type") + }) + }) }) + }) + }) - it("should return sweep transaction with proper structure", () => { - // Compare HEXes. - expect(transaction).to.be.eql( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transaction - ) - - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + describe("Spv", () => { + describe("submitDepositSweepProof", () => { + let bitcoinClient: MockBitcoinClient + let tbtcContracts: MockTBTCContracts + let maintenanceService: MaintenanceService - expect(txJSON.hash).to.be.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) + beforeEach(async () => { + bcoin.set("testnet") - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(1) + bitcoinClient = new MockBitcoinClient() + tbtcContracts = new MockTBTCContracts() - const p2shInput = txJSON.inputs[0] - expect(p2shInput.prevout.hash).to.be.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo.transactionHash.toString() - ) - expect(p2shInput.prevout.index).to.be.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo - .outputIndex + maintenanceService = new MaintenanceService( + tbtcContracts, + bitcoinClient ) - // Transaction should be signed. As it's not SegWit input, the `witness` - // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.equal("00") - expect(p2shInput.script.length).to.be.greaterThan(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2shInput.address).to.be.equal( - "2N8iF1pRndihBzgLDna9MfRhmqktwTdHejA" + + const transactionHash = + depositSweepProof.bitcoinChainData.transaction.transactionHash + const transactions = new Map() + transactions.set( + transactionHash.toString(), + depositSweepProof.bitcoinChainData.transaction ) + bitcoinClient.transactions = transactions - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(1) + const rawTransactions = new Map() + rawTransactions.set( + transactionHash.toString(), + depositSweepProof.bitcoinChainData.rawTransaction + ) + bitcoinClient.rawTransactions = rawTransactions - const sweepOutput = txJSON.outputs[0] - // OP_DUP OP_HASH160 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 - // OP_EQUALVERIFY OP_CHECKSIG - expect(sweepOutput.script).to.be.equal( - "76a9148db50eb52063ea9d98b3eac91489a90f738986f688ac" + bitcoinClient.latestHeight = + depositSweepProof.bitcoinChainData.latestBlockHeight + bitcoinClient.headersChain = + depositSweepProof.bitcoinChainData.headersChain + bitcoinClient.transactionMerkle = + depositSweepProof.bitcoinChainData.transactionMerkleBranch + const confirmations = new Map() + confirmations.set( + transactionHash.toString(), + depositSweepProof.bitcoinChainData.accumulatedTxConfirmations ) - // The output's address should be the wallet's address - expect(sweepOutput.address).to.be.equal( - "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" + bitcoinClient.confirmations = confirmations + await maintenanceService.spv.submitDepositSweepProof( + transactionHash, + NO_MAIN_UTXO ) - // The output's value should be equal to the sum of all input values - // minus fee (15000- 1600) - expect(sweepOutput.value).to.be.equal(13400) }) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transactionHash + it("should submit deposit sweep proof with correct arguments", () => { + const bridgeLog = tbtcContracts.bridge.depositSweepProofLog + expect(bridgeLog.length).to.equal(1) + expect(bridgeLog[0].mainUtxo).to.equal(NO_MAIN_UTXO) + expect(bridgeLog[0].sweepTx).to.deep.equal( + depositSweepProof.expectedSweepProof.sweepTx + ) + expect(bridgeLog[0].sweepProof.txIndexInBlock).to.deep.equal( + depositSweepProof.expectedSweepProof.sweepProof.txIndexInBlock + ) + expect(bridgeLog[0].sweepProof.merkleProof).to.deep.equal( + depositSweepProof.expectedSweepProof.sweepProof.merkleProof + ) + expect(bridgeLog[0].sweepProof.bitcoinHeaders).to.deep.equal( + depositSweepProof.expectedSweepProof.sweepProof.bitcoinHeaders ) }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transactionHash, - outputIndex: 0, - value: BigNumber.from(13400), - } - - expect(newMainUtxo).to.be.deep.equal(expectedNewMainUtxo) - }) - }) - - context("when there are no UTXOs", () => { - it("should revert", async () => { - await expect( - assembleDepositSweepTransaction( - fee, - testnetWalletPrivateKey, - true, - [], - [] - ) - ).to.be.rejectedWith("There must be at least one deposit UTXO to sweep") - }) - }) - - context( - "when the numbers of UTXOs and deposit elements are not equal", - () => { - const utxosWithRaw = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map((data) => { - return data.utxo - }) - - // Add only one element to the deposit - const deposit = [ - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data, - ] - - const witness = depositSweepWithNoMainUtxoAndWitnessOutput.witness - - it("should revert", async () => { - await expect( - assembleDepositSweepTransaction( - fee, - testnetWalletPrivateKey, - witness, - utxosWithRaw, - deposit - ) - ).to.be.rejectedWith( - "Number of UTXOs must equal the number of deposit elements" - ) - }) - } - ) - - context("when the main UTXO does not belong to the wallet", () => { - const utxoWithRaw = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data - - // The UTXO below does not belong to the wallet - const mainUtxoWithRaw = { - transactionHash: BitcoinTxHash.from( - "2f952bdc206bf51bb745b967cb7166149becada878d3191ffe341155ebcd4883" - ), - outputIndex: 1, - value: BigNumber.from(3933200), - transactionHex: - "0100000000010162cae24e74ad64f9f0493b09f3964908b3b3038f4924882d3d" + - "bd853b4c9bc7390100000000ffffffff02102700000000000017a914867120d5" + - "480a9cc0c11c1193fa59b3a92e852da78710043c00000000001600147ac2d937" + - "8a1c47e589dfb8095ca95ed2140d272602483045022100b70bd9b7f5d230444a" + - "542c7971bea79786b4ebde6703cee7b6ee8cd16e115ebf02204d50ea9d1ee08d" + - "e9741498c2cc64266e40d52c4adb9ef68e65aa2727cd4208b5012102ee067a02" + - "73f2e3ba88d23140a24fdb290f27bbcd0f94117a9c65be3911c5c04e00000000", - } - - it("should revert", async () => { - await expect( - assembleDepositSweepTransaction( - fee, - testnetWalletPrivateKey, - true, - [utxoWithRaw], - [deposit], - mainUtxoWithRaw - ) - ).to.be.rejectedWith("UTXO does not belong to the wallet") - }) - }) - - context( - "when the wallet private does not correspond to the wallet public key", - () => { - const utxoWithRaw = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data - const anotherPrivateKey = - "cRJvyxtoggjAm9A94cB86hZ7Y62z2ei5VNJHLksFi2xdnz1GJ6xt" - - it("should revert", async () => { - await expect( - assembleDepositSweepTransaction( - fee, - anotherPrivateKey, - true, - [utxoWithRaw], - [deposit] - ) - ).to.be.rejectedWith( - "Wallet public key does not correspond to wallet private key" - ) - }) - } - ) - - context("when the type of UTXO is unsupported", () => { - // Use coinbase transaction of some block - const utxoWithRaw = { - transactionHash: BitcoinTxHash.from( - "025de155e6f2ffbbf4851493e0d28dad54020db221a3f38bf63c1f65e3d3595b" - ), - outputIndex: 0, - value: BigNumber.from(5000000000), - transactionHex: - "010000000100000000000000000000000000000000000000000000000000000000" + - "00000000ffffffff0e04db07c34f0103062f503253482fffffffff0100f2052a01" + - "000000232102db6a0f2ef2e970eb1d2a84eabb5337f9cac0d85b49f209bffc4ec6" + - "805802e6a5ac00000000", - } - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data - - it("should revert", async () => { - await expect( - assembleDepositSweepTransaction( - fee, - testnetWalletPrivateKey, - true, - [utxoWithRaw], - [deposit] - ) - ).to.be.rejectedWith("Unsupported UTXO script type") - }) - }) - }) - - describe("submitDepositSweepProof", () => { - let bitcoinClient: MockBitcoinClient - let bridge: MockBridge - - beforeEach(async () => { - bcoin.set("testnet") - - bitcoinClient = new MockBitcoinClient() - bridge = new MockBridge() - - const transactionHash = - depositSweepProof.bitcoinChainData.transaction.transactionHash - const transactions = new Map() - transactions.set( - transactionHash.toString(), - depositSweepProof.bitcoinChainData.transaction - ) - bitcoinClient.transactions = transactions - - const rawTransactions = new Map() - rawTransactions.set( - transactionHash.toString(), - depositSweepProof.bitcoinChainData.rawTransaction - ) - bitcoinClient.rawTransactions = rawTransactions - - bitcoinClient.latestHeight = - depositSweepProof.bitcoinChainData.latestBlockHeight - bitcoinClient.headersChain = - depositSweepProof.bitcoinChainData.headersChain - bitcoinClient.transactionMerkle = - depositSweepProof.bitcoinChainData.transactionMerkleBranch - const confirmations = new Map() - confirmations.set( - transactionHash.toString(), - depositSweepProof.bitcoinChainData.accumulatedTxConfirmations - ) - bitcoinClient.confirmations = confirmations - await submitDepositSweepProof( - transactionHash, - NO_MAIN_UTXO, - bridge, - bitcoinClient - ) - }) - - it("should submit deposit sweep proof with correct arguments", () => { - const bridgeLog = bridge.depositSweepProofLog - expect(bridgeLog.length).to.equal(1) - expect(bridgeLog[0].mainUtxo).to.equal(NO_MAIN_UTXO) - expect(bridgeLog[0].sweepTx).to.deep.equal( - depositSweepProof.expectedSweepProof.sweepTx - ) - expect(bridgeLog[0].sweepProof.txIndexInBlock).to.deep.equal( - depositSweepProof.expectedSweepProof.sweepProof.txIndexInBlock - ) - expect(bridgeLog[0].sweepProof.merkleProof).to.deep.equal( - depositSweepProof.expectedSweepProof.sweepProof.merkleProof - ) - expect(bridgeLog[0].sweepProof.bitcoinHeaders).to.deep.equal( - depositSweepProof.expectedSweepProof.sweepProof.bitcoinHeaders - ) }) }) }) diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index 3b179c4c5..45887102d 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -13,17 +13,15 @@ import { BitcoinTxHash, BitcoinUtxo, extractBitcoinRawTxVectors, -} from "../src/lib/bitcoin" -import { DepositReceipt } from "../src/lib/contracts" -import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import bcoin from "bcoin" -import { EthereumAddress } from "../src/lib/ethereum" -import { BitcoinNetwork } from "../src" -import { + DepositReceipt, + EthereumAddress, + BitcoinNetwork, DepositFunding, DepositScript, Deposit, -} from "../src/services/deposits" +} from "../src" +import { MockBitcoinClient } from "./utils/mock-bitcoin-client" +import bcoin from "bcoin" import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" describe("Deposit", () => { diff --git a/typescript/test/electrum.test.ts b/typescript/test/electrum.test.ts index 0775f4b5e..6d8d80020 100644 --- a/typescript/test/electrum.test.ts +++ b/typescript/test/electrum.test.ts @@ -1,9 +1,9 @@ import { + BitcoinNetwork, ElectrumCredentials, ElectrumClient, computeElectrumScriptHash, -} from "../src/lib/electrum" -import { BitcoinNetwork } from "../src/lib/bitcoin" +} from "../src" import { testnetAddress, testnetHeadersChain, diff --git a/typescript/test/ethereum.test.ts b/typescript/test/ethereum.test.ts index 1a9c9f1ba..45e248a0f 100644 --- a/typescript/test/ethereum.test.ts +++ b/typescript/test/ethereum.test.ts @@ -1,8 +1,11 @@ import { + BitcoinTxHash, + BitcoinHashUtils, EthereumAddress, EthereumBridge, EthereumTBTCToken, -} from "../src/lib/ethereum" + Hex, +} from "../src" import { deployMockContract, MockContract, @@ -14,8 +17,6 @@ import { abi as TBTCTokenABI } from "@keep-network/tbtc-v2/artifacts/TBTC.json" import { abi as WalletRegistryABI } from "@keep-network/ecdsa/artifacts/WalletRegistry.json" import { MockProvider } from "@ethereum-waffle/provider" import { waffleChai } from "@ethereum-waffle/chai" -import { BitcoinTxHash, BitcoinHashUtils } from "../src/lib/bitcoin" -import { Hex } from "../src/lib/utils" chai.use(waffleChai) diff --git a/typescript/test/hex.test.ts b/typescript/test/hex.test.ts index 1f8e538e3..252f1a93d 100644 --- a/typescript/test/hex.test.ts +++ b/typescript/test/hex.test.ts @@ -1,5 +1,5 @@ import { assert } from "chai" -import { Hex } from "../src/lib/utils" +import { Hex } from "../src" describe("Hex", () => { const stringUnprefixed = diff --git a/typescript/test/proof.test.ts b/typescript/test/proof.test.ts index 9f499ac1e..fc52d7bc2 100644 --- a/typescript/test/proof.test.ts +++ b/typescript/test/proof.test.ts @@ -6,8 +6,8 @@ import { BitcoinSpvProof, assembleBitcoinSpvProof, validateBitcoinSpvProof, -} from "../src/lib/bitcoin" -import { Hex } from "../src/lib/utils" + Hex, +} from "../src" import { singleInputProofTestData, multipleInputsProofTestData, diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index f9a3a5c68..468360684 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -6,7 +6,14 @@ import { BitcoinTx, BitcoinTxHash, BitcoinUtxo, -} from "../src/lib/bitcoin" + NewWalletRegisteredEvent, + RedemptionRequest, + Wallet, + WalletState, + RedemptionsService, + WalletTx, + MaintenanceService, +} from "../src" import bcoin from "bcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { @@ -25,23 +32,11 @@ import { walletPrivateKey, walletPublicKey, } from "./data/redemption" -import { - NewWalletRegisteredEvent, - RedemptionRequest, - Wallet, - WalletState, -} from "../src/lib/contracts" -import { - assembleRedemptionTransaction, - submitRedemptionProof, - submitRedemptionTransaction, -} from "../src/redemption" import { MockBridge } from "./utils/mock-bridge" import * as chai from "chai" import { expect } from "chai" import chaiAsPromised from "chai-as-promised" import { BigNumber, BigNumberish } from "ethers" -import { RedemptionsService } from "../src/services/redemptions" import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" import { Hex } from "../src" @@ -816,28 +811,218 @@ describe("Redemption", () => { }) }) - describe("submitRedemptionTransaction", () => { - let bitcoinClient: MockBitcoinClient - let bridge: MockBridge + describe("WalletTx", () => { + describe("Redemption", () => { + describe("submitTransaction", () => { + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient - beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() - bridge = new MockBridge() - }) + beforeEach(async () => { + bcoin.set("testnet") - context("when there are redemption requests provided", () => { - context( - "when all redeemer output scripts identify pending redemptions", - () => { - context("when there is a change created", () => { - context("when the change output is P2WPKH", () => { - context("when there is a single redeemer", () => { - context( - "when the redeemer output script is derived from a P2PKH address", - () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + }) + + context("when there are redemption requests provided", () => { + context( + "when all redeemer output scripts identify pending redemptions", + () => { + context("when there is a change created", () => { + context("when the change output is P2WPKH", () => { + context("when there is a single redeemer", () => { + context( + "when the redeemer output script is derived from a P2PKH address", + () => { + const data: RedemptionTestData = + singleP2PKHRedemptionWithWitnessChange + + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + + beforeEach(async () => { + ;({ transactionHash, newMainUtxo } = + await runRedemptionScenario( + walletPrivateKey, + bitcoinClient, + tbtcContracts, + data + )) + }) + + it("should broadcast redemption transaction with proper structure", () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal( + 1 + ) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + data.expectedRedemption.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + data.expectedRedemption.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + data.expectedRedemption.transactionHash, + outputIndex: 1, + value: BigNumber.from(1472680), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + + context( + "when the redeemer output script is derived from a P2WPKH address", + () => { + const data: RedemptionTestData = + singleP2WPKHRedemptionWithWitnessChange + + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + + beforeEach(async () => { + ;({ transactionHash, newMainUtxo } = + await runRedemptionScenario( + walletPrivateKey, + bitcoinClient, + tbtcContracts, + data + )) + }) + + it("should broadcast redemption transaction with proper structure", () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal( + 1 + ) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + data.expectedRedemption.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + data.expectedRedemption.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + data.expectedRedemption.transactionHash, + outputIndex: 1, + value: BigNumber.from(1458780), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + + context( + "when the redeemer output script is derived from a P2SH address", + () => { + const data: RedemptionTestData = + singleP2SHRedemptionWithWitnessChange + + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + + beforeEach(async () => { + ;({ transactionHash, newMainUtxo } = + await runRedemptionScenario( + walletPrivateKey, + bitcoinClient, + tbtcContracts, + data + )) + }) + + it("should broadcast redemption transaction with proper structure", () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal( + 1 + ) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + data.expectedRedemption.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + data.expectedRedemption.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + data.expectedRedemption.transactionHash, + outputIndex: 1, + value: BigNumber.from(1446580), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + + context( + "when the redeemer output script is derived from a P2WSH address", + () => { + const data: RedemptionTestData = + singleP2WSHRedemptionWithWitnessChange + + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + + beforeEach(async () => { + ;({ transactionHash, newMainUtxo } = + await runRedemptionScenario( + walletPrivateKey, + bitcoinClient, + tbtcContracts, + data + )) + }) + + it("should broadcast redemption transaction with proper structure", () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal( + 1 + ) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + data.expectedRedemption.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + data.expectedRedemption.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + data.expectedRedemption.transactionHash, + outputIndex: 1, + value: BigNumber.from(1429580), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + }) + + context("when there are multiple redeemers", () => { const data: RedemptionTestData = - singleP2PKHRedemptionWithWitnessChange + multipleRedemptionsWithWitnessChange let transactionHash: BitcoinTxHash let newMainUtxo: BitcoinUtxo | undefined @@ -847,7 +1032,7 @@ describe("Redemption", () => { await runRedemptionScenario( walletPrivateKey, bitcoinClient, - bridge, + tbtcContracts, data )) }) @@ -869,39 +1054,301 @@ describe("Redemption", () => { const expectedNewMainUtxo = { transactionHash: data.expectedRedemption.transactionHash, - outputIndex: 1, - value: BigNumber.from(1472680), + outputIndex: 4, + value: BigNumber.from(1375180), } expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) }) - } + }) + }) + + context("when the change output is P2PKH", () => { + // The only difference between redemption transactions with P2PKH and + // P2WPKH change is the output type. + // Therefore only one test case was added for P2PKH transactions. + const data: RedemptionTestData = + singleP2SHRedemptionWithNonWitnessChange + + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + + beforeEach(async () => { + ;({ transactionHash, newMainUtxo } = + await runRedemptionScenario( + walletPrivateKey, + bitcoinClient, + tbtcContracts, + data + )) + }) + + it("should broadcast redemption transaction with proper structure", () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + data.expectedRedemption.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + data.expectedRedemption.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: data.expectedRedemption.transactionHash, + outputIndex: 1, + value: BigNumber.from(1364180), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + }) + }) + + context("when there is no change UTXO created", () => { + // Use test data with the treasury fees of all the redemption requests + // set to 0. This is the only situation that the redemption transaction + // will not contain the change output. + const data: RedemptionTestData = + multipleRedemptionsWithoutChange + + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + + beforeEach(async () => { + ;({ transactionHash, newMainUtxo } = + await runRedemptionScenario( + walletPrivateKey, + bitcoinClient, + tbtcContracts, + data + )) + }) + + it("should broadcast redemption transaction with proper structure", () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + data.expectedRedemption.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + data.expectedRedemption.transactionHash + ) + }) + + it("should not return the new main UTXO", () => { + expect(newMainUtxo).to.be.undefined + }) + }) + } + ) + + context( + "when not all redeemer output scripts identify pending redemptions", + () => { + const data: RedemptionTestData = + multipleRedemptionsWithWitnessChange + + beforeEach(async () => { + const rawTransactions = new Map() + rawTransactions.set(data.mainUtxo.transactionHash.toString(), { + transactionHex: data.mainUtxo.transactionHex, + }) + bitcoinClient.rawTransactions = rawTransactions + + const pendingRedemptions = new Map< + BigNumberish, + RedemptionRequest + >( + data.pendingRedemptions.map((redemption) => [ + redemption.redemptionKey, + redemption.pendingRedemption, + ]) + ) + + // Before setting the pending redemption map in the Bridge, delete + // one element to simulate absence of that redemption + pendingRedemptions.delete( + data.pendingRedemptions[2].redemptionKey ) + tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) + }) + + it("should revert", async () => { + const redeemerOutputScripts = data.pendingRedemptions.map( + (redemption) => + redemption.pendingRedemption.redeemerOutputScript + ) + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + data.witness + ) + + await expect( + walletTx.redemption.submitTransaction( + walletPrivateKey, + data.mainUtxo, + redeemerOutputScripts + ) + ).to.be.rejectedWith("Redemption request does not exist") + }) + } + ) + }) + + context("when there are no redemption requests provided", () => { + const data: RedemptionTestData = + singleP2WPKHRedemptionWithWitnessChange + + beforeEach(async () => { + const rawTransactions = new Map() + rawTransactions.set(data.mainUtxo.transactionHash.toString(), { + transactionHex: data.mainUtxo.transactionHex, + }) + bitcoinClient.rawTransactions = rawTransactions + }) + + it("should revert", async () => { + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + data.witness + ) + + await expect( + walletTx.redemption.submitTransaction( + walletPrivateKey, + data.mainUtxo, + [] // empty redeemer output script list + ) + ).to.be.rejectedWith("There must be at least one request to redeem") + }) + }) + }) + + describe("assembleTransaction", () => { + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + }) + context("when there are redemption requests provided", () => { + context("when there is a change UTXO created", () => { + describe("when the change output is P2WPKH", () => { + context("when there is a single redeemer", () => { context( - "when the redeemer output script is derived from a P2WPKH address", + "when the redeemer output script is derived from a P2PKH address", () => { const data: RedemptionTestData = - singleP2WPKHRedemptionWithWitnessChange + singleP2PKHRedemptionWithWitnessChange let transactionHash: BitcoinTxHash let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { - ;({ transactionHash, newMainUtxo } = - await runRedemptionScenario( - walletPrivateKey, - bitcoinClient, - bridge, - data - )) + const redemptionRequests = data.pendingRedemptions.map( + (redemption) => redemption.pendingRedemption + ) + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + data.witness + ) + + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.redemption.assembleTransaction( + walletPrivateKey, + data.mainUtxo, + redemptionRequests + )) }) - it("should broadcast redemption transaction with proper structure", () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( + it("should return transaction with proper structure", async () => { + // Compare HEXes. + expect(transaction).to.be.eql( data.expectedRedemption.transaction ) + + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from( + transaction.transactionHex, + "hex" + ) + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + + expect(txJSON.hash).to.be.equal( + data.expectedRedemption.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) + + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(1) + + const input = txJSON.inputs[0] + + expect(input.prevout.hash).to.be.equal( + data.mainUtxo.transactionHash.toString() + ) + expect(input.prevout.index).to.be.equal( + data.mainUtxo.outputIndex + ) + // Transaction should be signed but this is SegWit input so the `script` + // field should be empty and the `witness` field should be filled instead. + expect(input.script.length).to.be.equal(0) + expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(2) + + const p2pkhOutput = txJSON.outputs[0] + const changeOutput = txJSON.outputs[1] + + // P2PKH output + // The output value should be `requestedAmount` - `txFee` - `treasuryFee` + // which is 10000 - 1600 - 1000 = 7400 + expect(p2pkhOutput.value).to.be.equal(7400) + // The output script should correspond to: + // OP_DUP OP_HASH160 0x14 0x4130879211c54df460e484ddf9aac009cb38ee74 + // OP_EQUALVERIFY OP_CHECKSIG + expect(p2pkhOutput.script).to.be.equal( + "76a9144130879211c54df460e484ddf9aac009cb38ee7488ac" + ) + // The output address should be P2PKH + expect(p2pkhOutput.address).to.be.equal( + "mmTeMR8RKu6QzMGTG4ipA71uewm3EuJng5" + ) + + // P2WPKH output (change) + // The value of fee should be the fee share of the (only) redeem output + // which is 1600 + // The output value should be main UTXO input value - fee - the + // value of the output, which is 1472680 = 1481680 - 1600 - 7400 + expect(changeOutput.value).to.be.equal(1472680) + // The output script should correspond to: + // OP_0 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 + expect(changeOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The change output address should be the P2WPKH address of the wallet + expect(changeOutput.address).to.be.equal( + p2wpkhWalletAddress + ) }) it("should return the proper transaction hash", async () => { @@ -915,7 +1362,7 @@ describe("Redemption", () => { transactionHash: data.expectedRedemption.transactionHash, outputIndex: 1, - value: BigNumber.from(1458780), + value: BigNumber.from(1472680), } expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) @@ -924,29 +1371,107 @@ describe("Redemption", () => { ) context( - "when the redeemer output script is derived from a P2SH address", + "when the redeemer output script is derived from a P2WPKH address", () => { const data: RedemptionTestData = - singleP2SHRedemptionWithWitnessChange + singleP2WPKHRedemptionWithWitnessChange let transactionHash: BitcoinTxHash let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { - ;({ transactionHash, newMainUtxo } = - await runRedemptionScenario( - walletPrivateKey, - bitcoinClient, - bridge, - data - )) + const redemptionRequests = data.pendingRedemptions.map( + (redemption) => redemption.pendingRedemption + ) + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + data.witness + ) + + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.redemption.assembleTransaction( + walletPrivateKey, + data.mainUtxo, + redemptionRequests + )) }) - it("should broadcast redemption transaction with proper structure", () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( + it("should return transaction with proper structure", async () => { + // Compare HEXes. + expect(transaction).to.be.eql( data.expectedRedemption.transaction ) + + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from( + transaction.transactionHex, + "hex" + ) + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + + expect(txJSON.hash).to.be.equal( + data.expectedRedemption.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) + + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(1) + + const input = txJSON.inputs[0] + + expect(input.prevout.hash).to.be.equal( + data.mainUtxo.transactionHash.toString() + ) + expect(input.prevout.index).to.be.equal( + data.mainUtxo.outputIndex + ) + // Transaction should be signed but this is SegWit input so the `script` + // field should be empty and the `witness` field should be filled instead. + expect(input.script.length).to.be.equal(0) + expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(2) + + const p2wpkhOutput = txJSON.outputs[0] + const changeOutput = txJSON.outputs[1] + + // P2WPKH output + // The output value should be `requestedAmount` - `txFee` - `treasuryFee` + // which is 15000 - 1700 - 1100 = 12200 + expect(p2wpkhOutput.value).to.be.equal(12200) + // The output script should correspond to: + // OP_0 0x14 0x4130879211c54df460e484ddf9aac009cb38ee74 + expect(p2wpkhOutput.script).to.be.equal( + "00144130879211c54df460e484ddf9aac009cb38ee74" + ) + // The output address should be P2WPKH + expect(p2wpkhOutput.address).to.be.equal( + "tb1qgycg0ys3c4xlgc8ysnwln2kqp89n3mn5ts7z3l" + ) + + // P2WPKH output (change) + // The value of fee should be the fee share of the (only) redeem output + // which is 1700 + // The output value should be main UTXO input value - fee - the + // value of the output, which is 1458780 = 1472680 - 1700 - 12200 + expect(changeOutput.value).to.be.equal(1458780) + // The output script should correspond to: + // OP_0 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 + expect(changeOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The change output address should be the P2WPKH address of the wallet + expect(changeOutput.address).to.be.equal( + p2wpkhWalletAddress + ) }) it("should return the proper transaction hash", async () => { @@ -960,7 +1485,7 @@ describe("Redemption", () => { transactionHash: data.expectedRedemption.transactionHash, outputIndex: 1, - value: BigNumber.from(1446580), + value: BigNumber.from(1458780), } expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) @@ -969,29 +1494,107 @@ describe("Redemption", () => { ) context( - "when the redeemer output script is derived from a P2WSH address", + "when the redeemer output script is derived from a P2SH address", () => { const data: RedemptionTestData = - singleP2WSHRedemptionWithWitnessChange + singleP2SHRedemptionWithWitnessChange let transactionHash: BitcoinTxHash let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx beforeEach(async () => { - ;({ transactionHash, newMainUtxo } = - await runRedemptionScenario( - walletPrivateKey, - bitcoinClient, - bridge, - data - )) + const redemptionRequests = data.pendingRedemptions.map( + (redemption) => redemption.pendingRedemption + ) + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + data.witness + ) + + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.redemption.assembleTransaction( + walletPrivateKey, + data.mainUtxo, + redemptionRequests + )) }) - it("should broadcast redemption transaction with proper structure", () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( + it("should return transaction with proper structure", async () => { + // Compare HEXes. + expect(transaction).to.be.eql( data.expectedRedemption.transaction ) + + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from( + transaction.transactionHex, + "hex" + ) + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + + expect(txJSON.hash).to.be.equal( + data.expectedRedemption.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) + + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(1) + + const input = txJSON.inputs[0] + + expect(input.prevout.hash).to.be.equal( + data.mainUtxo.transactionHash.toString() + ) + expect(input.prevout.index).to.be.equal( + data.mainUtxo.outputIndex + ) + // Transaction should be signed but this is SegWit input so the `script` + // field should be empty and the `witness` field should be filled instead. + expect(input.script.length).to.be.equal(0) + expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(2) + + const p2shOutput = txJSON.outputs[0] + const changeOutput = txJSON.outputs[1] + + // P2SH output + // The output value should be `requestedAmount` - `txFee` - `treasuryFee` + // which is 13000 - 1700 - 800 = 10500 + expect(p2shOutput.value).to.be.equal(10500) + // The output script should correspond to: + // OP_HASH160 0x14 0x3ec459d0f3c29286ae5df5fcc421e2786024277e OP_EQUAL + expect(p2shOutput.script).to.be.equal( + "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87" + ) + // The output address should be P2SH + expect(p2shOutput.address).to.be.equal( + "2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C" + ) + + // P2WPKH output (change) + // The value of fee should be the fee share of the (only) redeem output + // which is 1700 + // The output value should be main UTXO input value - fee - the + // value of the output, which is 1446580 = 1458780 - 1700 - 10500 + expect(changeOutput.value).to.be.equal(1446580) + // The output script should correspond to: + // OP_0 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 + expect(changeOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The change output address should be the P2WPKH address of the wallet + expect(changeOutput.address).to.be.equal( + p2wpkhWalletAddress + ) }) it("should return the proper transaction hash", async () => { @@ -1005,558 +1608,141 @@ describe("Redemption", () => { transactionHash: data.expectedRedemption.transactionHash, outputIndex: 1, - value: BigNumber.from(1429580), + value: BigNumber.from(1446580), } expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) }) } ) - }) - context("when there are multiple redeemers", () => { - const data: RedemptionTestData = - multipleRedemptionsWithWitnessChange + context( + "when the redeemer output script is derived from a P2WSH address", + () => { + const data: RedemptionTestData = + singleP2WSHRedemptionWithWitnessChange - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo | undefined + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx - beforeEach(async () => { - ;({ transactionHash, newMainUtxo } = - await runRedemptionScenario( - walletPrivateKey, - bitcoinClient, - bridge, - data - )) - }) + beforeEach(async () => { + const redemptionRequests = data.pendingRedemptions.map( + (redemption) => redemption.pendingRedemption + ) - it("should broadcast redemption transaction with proper structure", () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - data.expectedRedemption.transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - data.expectedRedemption.transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: data.expectedRedemption.transactionHash, - outputIndex: 4, - value: BigNumber.from(1375180), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - }) - }) - - context("when the change output is P2PKH", () => { - // The only difference between redemption transactions with P2PKH and - // P2WPKH change is the output type. - // Therefore only one test case was added for P2PKH transactions. - const data: RedemptionTestData = - singleP2SHRedemptionWithNonWitnessChange - - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo | undefined - - beforeEach(async () => { - ;({ transactionHash, newMainUtxo } = - await runRedemptionScenario( - walletPrivateKey, - bitcoinClient, - bridge, - data - )) - }) - - it("should broadcast redemption transaction with proper structure", () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - data.expectedRedemption.transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - data.expectedRedemption.transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: data.expectedRedemption.transactionHash, - outputIndex: 1, - value: BigNumber.from(1364180), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - }) - }) - - context("when there is no change UTXO created", () => { - // Use test data with the treasury fees of all the redemption requests - // set to 0. This is the only situation that the redemption transaction - // will not contain the change output. - const data: RedemptionTestData = multipleRedemptionsWithoutChange - - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo | undefined - - beforeEach(async () => { - ;({ transactionHash, newMainUtxo } = await runRedemptionScenario( - walletPrivateKey, - bitcoinClient, - bridge, - data - )) - }) - - it("should broadcast redemption transaction with proper structure", () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - data.expectedRedemption.transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - data.expectedRedemption.transactionHash - ) - }) - - it("should not return the new main UTXO", () => { - expect(newMainUtxo).to.be.undefined - }) - }) - } - ) - - context( - "when not all redeemer output scripts identify pending redemptions", - () => { - const data: RedemptionTestData = multipleRedemptionsWithWitnessChange - - beforeEach(async () => { - const rawTransactions = new Map() - rawTransactions.set(data.mainUtxo.transactionHash.toString(), { - transactionHex: data.mainUtxo.transactionHex, - }) - bitcoinClient.rawTransactions = rawTransactions - - const pendingRedemptions = new Map( - data.pendingRedemptions.map((redemption) => [ - redemption.redemptionKey, - redemption.pendingRedemption, - ]) - ) - - // Before setting the pending redemption map in the Bridge, delete - // one element to simulate absence of that redemption - pendingRedemptions.delete(data.pendingRedemptions[2].redemptionKey) - bridge.setPendingRedemptions(pendingRedemptions) - }) - - it("should revert", async () => { - const redeemerOutputScripts = data.pendingRedemptions.map( - (redemption) => redemption.pendingRedemption.redeemerOutputScript - ) - - await expect( - submitRedemptionTransaction( - bitcoinClient, - bridge, - walletPrivateKey, - data.mainUtxo, - redeemerOutputScripts, - data.witness - ) - ).to.be.rejectedWith("Redemption request does not exist") - }) - } - ) - }) - - context("when there are no redemption requests provided", () => { - const data: RedemptionTestData = singleP2WPKHRedemptionWithWitnessChange - - beforeEach(async () => { - const rawTransactions = new Map() - rawTransactions.set(data.mainUtxo.transactionHash.toString(), { - transactionHex: data.mainUtxo.transactionHex, - }) - bitcoinClient.rawTransactions = rawTransactions - }) - - it("should revert", async () => { - await expect( - submitRedemptionTransaction( - bitcoinClient, - bridge, - walletPrivateKey, - data.mainUtxo, - [], // empty redeemer output script list - data.witness - ) - ).to.be.rejectedWith("There must be at least one request to redeem") - }) - }) - }) - - describe("assembleRedemptionTransaction", () => { - context("when there are redemption requests provided", () => { - context("when there is a change UTXO created", () => { - describe("when the change output is P2WPKH", () => { - context("when there is a single redeemer", () => { - context( - "when the redeemer output script is derived from a P2PKH address", - () => { - const data: RedemptionTestData = - singleP2PKHRedemptionWithWitnessChange - - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo | undefined - let transaction: BitcoinRawTx - - beforeEach(async () => { - const redemptionRequests = data.pendingRedemptions.map( - (redemption) => redemption.pendingRedemption - ) - - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await assembleRedemptionTransaction( - walletPrivateKey, - data.mainUtxo, - redemptionRequests, - data.witness - )) - }) - - it("should return transaction with proper structure", async () => { - // Compare HEXes. - expect(transaction).to.be.eql( - data.expectedRedemption.transaction - ) - - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - - expect(txJSON.hash).to.be.equal( - data.expectedRedemption.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) - - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(1) - - const input = txJSON.inputs[0] - - expect(input.prevout.hash).to.be.equal( - data.mainUtxo.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) - // Transaction should be signed but this is SegWit input so the `script` - // field should be empty and the `witness` field should be filled instead. - expect(input.script.length).to.be.equal(0) - expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(2) - - const p2pkhOutput = txJSON.outputs[0] - const changeOutput = txJSON.outputs[1] - - // P2PKH output - // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 10000 - 1600 - 1000 = 7400 - expect(p2pkhOutput.value).to.be.equal(7400) - // The output script should correspond to: - // OP_DUP OP_HASH160 0x14 0x4130879211c54df460e484ddf9aac009cb38ee74 - // OP_EQUALVERIFY OP_CHECKSIG - expect(p2pkhOutput.script).to.be.equal( - "76a9144130879211c54df460e484ddf9aac009cb38ee7488ac" - ) - // The output address should be P2PKH - expect(p2pkhOutput.address).to.be.equal( - "mmTeMR8RKu6QzMGTG4ipA71uewm3EuJng5" - ) - - // P2WPKH output (change) - // The value of fee should be the fee share of the (only) redeem output - // which is 1600 - // The output value should be main UTXO input value - fee - the - // value of the output, which is 1472680 = 1481680 - 1600 - 7400 - expect(changeOutput.value).to.be.equal(1472680) - // The output script should correspond to: - // OP_0 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 - expect(changeOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - // The change output address should be the P2WPKH address of the wallet - expect(changeOutput.address).to.be.equal(p2wpkhWalletAddress) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - data.expectedRedemption.transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: data.expectedRedemption.transactionHash, - outputIndex: 1, - value: BigNumber.from(1472680), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - - context( - "when the redeemer output script is derived from a P2WPKH address", - () => { - const data: RedemptionTestData = - singleP2WPKHRedemptionWithWitnessChange - - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo | undefined - let transaction: BitcoinRawTx - - beforeEach(async () => { - const redemptionRequests = data.pendingRedemptions.map( - (redemption) => redemption.pendingRedemption - ) - - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await assembleRedemptionTransaction( - walletPrivateKey, - data.mainUtxo, - redemptionRequests, - data.witness - )) - }) - - it("should return transaction with proper structure", async () => { - // Compare HEXes. - expect(transaction).to.be.eql( - data.expectedRedemption.transaction - ) - - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - - expect(txJSON.hash).to.be.equal( - data.expectedRedemption.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) - - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(1) - - const input = txJSON.inputs[0] - - expect(input.prevout.hash).to.be.equal( - data.mainUtxo.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) - // Transaction should be signed but this is SegWit input so the `script` - // field should be empty and the `witness` field should be filled instead. - expect(input.script.length).to.be.equal(0) - expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(2) - - const p2wpkhOutput = txJSON.outputs[0] - const changeOutput = txJSON.outputs[1] - - // P2WPKH output - // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 15000 - 1700 - 1100 = 12200 - expect(p2wpkhOutput.value).to.be.equal(12200) - // The output script should correspond to: - // OP_0 0x14 0x4130879211c54df460e484ddf9aac009cb38ee74 - expect(p2wpkhOutput.script).to.be.equal( - "00144130879211c54df460e484ddf9aac009cb38ee74" - ) - // The output address should be P2WPKH - expect(p2wpkhOutput.address).to.be.equal( - "tb1qgycg0ys3c4xlgc8ysnwln2kqp89n3mn5ts7z3l" - ) - - // P2WPKH output (change) - // The value of fee should be the fee share of the (only) redeem output - // which is 1700 - // The output value should be main UTXO input value - fee - the - // value of the output, which is 1458780 = 1472680 - 1700 - 12200 - expect(changeOutput.value).to.be.equal(1458780) - // The output script should correspond to: - // OP_0 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 - expect(changeOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - // The change output address should be the P2WPKH address of the wallet - expect(changeOutput.address).to.be.equal(p2wpkhWalletAddress) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - data.expectedRedemption.transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: data.expectedRedemption.transactionHash, - outputIndex: 1, - value: BigNumber.from(1458780), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - - context( - "when the redeemer output script is derived from a P2SH address", - () => { - const data: RedemptionTestData = - singleP2SHRedemptionWithWitnessChange - - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo | undefined - let transaction: BitcoinRawTx - - beforeEach(async () => { - const redemptionRequests = data.pendingRedemptions.map( - (redemption) => redemption.pendingRedemption - ) - - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await assembleRedemptionTransaction( - walletPrivateKey, - data.mainUtxo, - redemptionRequests, - data.witness - )) - }) - - it("should return transaction with proper structure", async () => { - // Compare HEXes. - expect(transaction).to.be.eql( - data.expectedRedemption.transaction - ) + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + data.witness + ) - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.redemption.assembleTransaction( + walletPrivateKey, + data.mainUtxo, + redemptionRequests + )) + }) - expect(txJSON.hash).to.be.equal( - data.expectedRedemption.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) + it("should return transaction with proper structure", async () => { + // Compare HEXes. + expect(transaction).to.be.eql( + data.expectedRedemption.transaction + ) - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(1) + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from( + transaction.transactionHex, + "hex" + ) + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - const input = txJSON.inputs[0] + expect(txJSON.hash).to.be.equal( + data.expectedRedemption.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) - expect(input.prevout.hash).to.be.equal( - data.mainUtxo.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) - // Transaction should be signed but this is SegWit input so the `script` - // field should be empty and the `witness` field should be filled instead. - expect(input.script.length).to.be.equal(0) - expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(1) - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(2) + const input = txJSON.inputs[0] - const p2shOutput = txJSON.outputs[0] - const changeOutput = txJSON.outputs[1] + expect(input.prevout.hash).to.be.equal( + data.mainUtxo.transactionHash.toString() + ) + expect(input.prevout.index).to.be.equal( + data.mainUtxo.outputIndex + ) + // Transaction should be signed but this is SegWit input so the `script` + // field should be empty and the `witness` field should be filled instead. + expect(input.script.length).to.be.equal(0) + expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(2) + + const p2wshOutput = txJSON.outputs[0] + const changeOutput = txJSON.outputs[1] + + // P2WSH output + // The output value should be `requestedAmount` - `txFee` - `treasuryFee` + // which is 18000 - 1400 - 1000 = 15600 + expect(p2wshOutput.value).to.be.equal(15600) + // The output script should correspond to: + // OP_0 0x20 0x86a303cdd2e2eab1d1679f1a813835dc5a1b65321077cdccaf08f98cbf04ca96 + expect(p2wshOutput.script).to.be.equal( + "002086a303cdd2e2eab1d1679f1a813835dc5a1b65321077cdccaf08f98cbf04ca96" + ) + // The output address should be P2WSH + expect(p2wshOutput.address).to.be.equal( + "tb1qs63s8nwjut4tr5t8nudgzwp4m3dpkefjzpmumn90pruce0cye2tq2jkq0y" + ) - // P2SH output - // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 13000 - 1700 - 800 = 10500 - expect(p2shOutput.value).to.be.equal(10500) - // The output script should correspond to: - // OP_HASH160 0x14 0x3ec459d0f3c29286ae5df5fcc421e2786024277e OP_EQUAL - expect(p2shOutput.script).to.be.equal( - "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87" - ) - // The output address should be P2SH - expect(p2shOutput.address).to.be.equal( - "2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C" - ) + // P2WPKH output (change) + // The value of fee should be the fee share of the (only) redeem output + // which is 1400 + // The output value should be main UTXO input value - fee - the + // value of the output, which is 1429580 = 1446580 - 1400 - 15600 + expect(changeOutput.value).to.be.equal(1429580) + // The output script should correspond to: + // OP_0 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 + expect(changeOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The change output address should be the P2WPKH address of the wallet + expect(changeOutput.address).to.be.equal( + p2wpkhWalletAddress + ) + }) - // P2WPKH output (change) - // The value of fee should be the fee share of the (only) redeem output - // which is 1700 - // The output value should be main UTXO input value - fee - the - // value of the output, which is 1446580 = 1458780 - 1700 - 10500 - expect(changeOutput.value).to.be.equal(1446580) - // The output script should correspond to: - // OP_0 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 - expect(changeOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - // The change output address should be the P2WPKH address of the wallet - expect(changeOutput.address).to.be.equal(p2wpkhWalletAddress) - }) + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + data.expectedRedemption.transactionHash + ) + }) - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - data.expectedRedemption.transactionHash - ) - }) + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + data.expectedRedemption.transactionHash, + outputIndex: 1, + value: BigNumber.from(1429580), + } - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: data.expectedRedemption.transactionHash, - outputIndex: 1, - value: BigNumber.from(1446580), + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) } + ) + }) - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - - context( - "when the redeemer output script is derived from a P2WSH address", - () => { + context("when there are multiple redeemers", () => { const data: RedemptionTestData = - singleP2WSHRedemptionWithWitnessChange + multipleRedemptionsWithWitnessChange let transactionHash: BitcoinTxHash let newMainUtxo: BitcoinUtxo | undefined @@ -1567,15 +1753,20 @@ describe("Redemption", () => { (redemption) => redemption.pendingRedemption ) + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + data.witness + ) + ;({ transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransaction( + } = await walletTx.redemption.assembleTransaction( walletPrivateKey, data.mainUtxo, - redemptionRequests, - data.witness + redemptionRequests )) }) @@ -1612,15 +1803,61 @@ describe("Redemption", () => { expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(2) + expect(txJSON.outputs.length).to.be.equal(5) + + const p2pkhOutput = txJSON.outputs[0] + const p2wpkhOutput = txJSON.outputs[1] + const p2shOutput = txJSON.outputs[2] + const p2wshOutput = txJSON.outputs[3] + const changeOutput = txJSON.outputs[4] + + // P2PKH output + // The output value should be `requestedAmount` - `txFee` - `treasuryFee` + // which is 18000 - 1100 - 1000 = 15900 + expect(p2pkhOutput.value).to.be.equal(15900) + // The output script should correspond to: + // OP_DUP OP_HASH160 0x14 0x4130879211c54df460e484ddf9aac009cb38ee74 + // OP_EQUALVERIFY OP_CHECKSIG + expect(p2pkhOutput.script).to.be.equal( + "76a9144130879211c54df460e484ddf9aac009cb38ee7488ac" + ) + // The output address should be P2PKH + expect(p2pkhOutput.address).to.be.equal( + "mmTeMR8RKu6QzMGTG4ipA71uewm3EuJng5" + ) + + // P2WPKH output + // The output value should be `requestedAmount` - `txFee` - `treasuryFee` + // which is 13000 - 900 - 800 = 11300 + expect(p2wpkhOutput.value).to.be.equal(11300) + // The output script should correspond to: + // OP_0 0x14 0x4130879211c54df460e484ddf9aac009cb38ee74 + expect(p2wpkhOutput.script).to.be.equal( + "00144130879211c54df460e484ddf9aac009cb38ee74" + ) + // The output address should be P2WPKH + expect(p2wpkhOutput.address).to.be.equal( + "tb1qgycg0ys3c4xlgc8ysnwln2kqp89n3mn5ts7z3l" + ) - const p2wshOutput = txJSON.outputs[0] - const changeOutput = txJSON.outputs[1] + // P2SH output + // The output value should be `requestedAmount` - `txFee` - `treasuryFee` + // which is 12000 - 1000 - 1100 = 9900 + expect(p2shOutput.value).to.be.equal(9900) + // The output script should correspond to: + // OP_HASH160 0x14 0x3ec459d0f3c29286ae5df5fcc421e2786024277e OP_EQUAL + expect(p2shOutput.script).to.be.equal( + "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87" + ) + // The output address should be P2SH + expect(p2shOutput.address).to.be.equal( + "2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C" + ) // P2WSH output // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 18000 - 1400 - 1000 = 15600 - expect(p2wshOutput.value).to.be.equal(15600) + // which is 15000 - 1400 - 700 = 12900 + expect(p2wshOutput.value).to.be.equal(12900) // The output script should correspond to: // OP_0 0x20 0x86a303cdd2e2eab1d1679f1a813835dc5a1b65321077cdccaf08f98cbf04ca96 expect(p2wshOutput.script).to.be.equal( @@ -1632,11 +1869,11 @@ describe("Redemption", () => { ) // P2WPKH output (change) - // The value of fee should be the fee share of the (only) redeem output - // which is 1400 - // The output value should be main UTXO input value - fee - the - // value of the output, which is 1429580 = 1446580 - 1400 - 15600 - expect(changeOutput.value).to.be.equal(1429580) + // The value of fee should be the sum of fee share of all redeem outputs + // which is 1100 + 900 + 1000 + 1400 = 4400 + // The output value should be main UTXO input value - fee - sum of all + // outputs, which is 1375180 = 1429580 - 4400 - (15900 + 11300 + 9900 + 12900) + expect(changeOutput.value).to.be.equal(1375180) // The output script should correspond to: // OP_0 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 expect(changeOutput.script).to.be.equal( @@ -1655,19 +1892,138 @@ describe("Redemption", () => { it("should return the proper new main UTXO", () => { const expectedNewMainUtxo = { transactionHash: data.expectedRedemption.transactionHash, - outputIndex: 1, - value: BigNumber.from(1429580), + outputIndex: 4, + value: BigNumber.from(1375180), } - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + expect(newMainUtxo).to.be.deep.equal(expectedNewMainUtxo) }) - } - ) + }) + }) + + describe("when the change output is P2PKH", () => { + // The only difference between redemption transactions with P2PKH + // change outputs and P2WPKH change outputs is the output type itself. + // Therefore the tests for creating transactions with P2PKH are + // limited to one single test case as more complicated scenarios are + // covered for P2WPKH change output tests. + const data: RedemptionTestData = + singleP2SHRedemptionWithNonWitnessChange + + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo | undefined + let transaction: BitcoinRawTx + + beforeEach(async () => { + const redemptionRequests = data.pendingRedemptions.map( + (redemption) => redemption.pendingRedemption + ) + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + data.witness + ) + + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.redemption.assembleTransaction( + walletPrivateKey, + data.mainUtxo, + redemptionRequests + )) + }) + + it("should return transaction with proper structure", async () => { + // Compare HEXes. + expect(transaction).to.be.eql( + data.expectedRedemption.transaction + ) + + // Convert raw transaction to JSON to make detailed comparison. + const buffer = Buffer.from(transaction.transactionHex, "hex") + const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + + expect(txJSON.hash).to.be.equal( + data.expectedRedemption.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) + + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(1) + + const input = txJSON.inputs[0] + + expect(input.prevout.hash).to.be.equal( + data.mainUtxo.transactionHash.toString() + ) + expect(input.prevout.index).to.be.equal( + data.mainUtxo.outputIndex + ) + // Transaction should be signed but this is SegWit input so the `script` + // field should be empty and the `witness` field should be filled instead. + expect(input.script.length).to.be.equal(0) + expect(input.witness.length).to.be.greaterThan(0) + expect(input.address).to.be.equal(p2wpkhWalletAddress) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(2) + + const p2shOutput = txJSON.outputs[0] + const changeOutput = txJSON.outputs[1] + + // P2SH output + // The output value should be `requestedAmount` - `txFee` - `treasuryFee` + // which is 12000 - 1200 - 1000 = 9800 + expect(p2shOutput.value).to.be.equal(9800) + // The output script should correspond to: + // OP_HASH160 0x14 0x3ec459d0f3c29286ae5df5fcc421e2786024277e OP_EQUAL + expect(p2shOutput.script).to.be.equal( + "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87" + ) + // The output address should be P2SH + expect(p2shOutput.address).to.be.equal( + "2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C" + ) + + // P2PKH output (change) + // The value of fee should be the fee share of the (only) redeem output + // which is 1200 + // The output value should be main UTXO input value - fee - the value + // of the redeem output, which is 1364180 = 1375180 - 1200 - 9800 + expect(changeOutput.value).to.be.equal(1364180) + // The output script should correspond to: + // OP_DUP OP_HASH160 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 + // OP_EQUALVERIFY OP_CHECKSIG + expect(changeOutput.script).to.be.equal( + "76a9148db50eb52063ea9d98b3eac91489a90f738986f688ac" + ) + // The change output address should be the P2PKH address of the wallet + expect(changeOutput.address).to.be.equal(p2pkhWalletAddress) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + data.expectedRedemption.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: data.expectedRedemption.transactionHash, + outputIndex: 1, + value: BigNumber.from(1364180), + } + + expect(newMainUtxo).to.be.deep.equal(expectedNewMainUtxo) + }) + }) }) - context("when there are multiple redeemers", () => { - const data: RedemptionTestData = - multipleRedemptionsWithWitnessChange + context("when there is no change UTXO created", () => { + const data: RedemptionTestData = multipleRedemptionsWithoutChange let transactionHash: BitcoinTxHash let newMainUtxo: BitcoinUtxo | undefined @@ -1678,15 +2034,20 @@ describe("Redemption", () => { (redemption) => redemption.pendingRedemption ) + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + data.witness + ) + ;({ transactionHash, newMainUtxo, rawTransaction: transaction, - } = await assembleRedemptionTransaction( + } = await walletTx.redemption.assembleTransaction( walletPrivateKey, data.mainUtxo, - redemptionRequests, - data.witness + redemptionRequests )) }) @@ -1719,84 +2080,39 @@ describe("Redemption", () => { expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(5) + expect(txJSON.outputs.length).to.be.equal(2) const p2pkhOutput = txJSON.outputs[0] const p2wpkhOutput = txJSON.outputs[1] - const p2shOutput = txJSON.outputs[2] - const p2wshOutput = txJSON.outputs[3] - const changeOutput = txJSON.outputs[4] // P2PKH output // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 18000 - 1100 - 1000 = 15900 - expect(p2pkhOutput.value).to.be.equal(15900) + // which is 6000 - 800 - 0 = 5200 + expect(p2pkhOutput.value).to.be.equal(5200) // The output script should correspond to: // OP_DUP OP_HASH160 0x14 0x4130879211c54df460e484ddf9aac009cb38ee74 // OP_EQUALVERIFY OP_CHECKSIG expect(p2pkhOutput.script).to.be.equal( "76a9144130879211c54df460e484ddf9aac009cb38ee7488ac" ) - // The output address should be P2PKH + // The output address should be P2PK expect(p2pkhOutput.address).to.be.equal( "mmTeMR8RKu6QzMGTG4ipA71uewm3EuJng5" ) // P2WPKH output // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 13000 - 900 - 800 = 11300 - expect(p2wpkhOutput.value).to.be.equal(11300) + // which is 4000 - 900 - 0 = 3100 + expect(p2wpkhOutput.value).to.be.equal(3100) // The output script should correspond to: - // OP_0 0x14 0x4130879211c54df460e484ddf9aac009cb38ee74 + // OP_0 0x14 0x4bf9ffb7ae0f8b0f5a622b154aca829126f6e769 expect(p2wpkhOutput.script).to.be.equal( - "00144130879211c54df460e484ddf9aac009cb38ee74" + "00144bf9ffb7ae0f8b0f5a622b154aca829126f6e769" ) - // The output address should be P2WPKH + // The output address should be P2PKH expect(p2wpkhOutput.address).to.be.equal( - "tb1qgycg0ys3c4xlgc8ysnwln2kqp89n3mn5ts7z3l" - ) - - // P2SH output - // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 12000 - 1000 - 1100 = 9900 - expect(p2shOutput.value).to.be.equal(9900) - // The output script should correspond to: - // OP_HASH160 0x14 0x3ec459d0f3c29286ae5df5fcc421e2786024277e OP_EQUAL - expect(p2shOutput.script).to.be.equal( - "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87" - ) - // The output address should be P2SH - expect(p2shOutput.address).to.be.equal( - "2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C" - ) - - // P2WSH output - // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 15000 - 1400 - 700 = 12900 - expect(p2wshOutput.value).to.be.equal(12900) - // The output script should correspond to: - // OP_0 0x20 0x86a303cdd2e2eab1d1679f1a813835dc5a1b65321077cdccaf08f98cbf04ca96 - expect(p2wshOutput.script).to.be.equal( - "002086a303cdd2e2eab1d1679f1a813835dc5a1b65321077cdccaf08f98cbf04ca96" + "tb1qf0ulldawp79s7knz9v254j5zjyn0demfx2d0xx" ) - // The output address should be P2WSH - expect(p2wshOutput.address).to.be.equal( - "tb1qs63s8nwjut4tr5t8nudgzwp4m3dpkefjzpmumn90pruce0cye2tq2jkq0y" - ) - - // P2WPKH output (change) - // The value of fee should be the sum of fee share of all redeem outputs - // which is 1100 + 900 + 1000 + 1400 = 4400 - // The output value should be main UTXO input value - fee - sum of all - // outputs, which is 1375180 = 1429580 - 4400 - (15900 + 11300 + 9900 + 12900) - expect(changeOutput.value).to.be.equal(1375180) - // The output script should correspond to: - // OP_0 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 - expect(changeOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - // The change output address should be the P2WPKH address of the wallet - expect(changeOutput.address).to.be.equal(p2wpkhWalletAddress) }) it("should return the proper transaction hash", async () => { @@ -1805,329 +2121,126 @@ describe("Redemption", () => { ) }) - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: data.expectedRedemption.transactionHash, - outputIndex: 4, - value: BigNumber.from(1375180), - } - - expect(newMainUtxo).to.be.deep.equal(expectedNewMainUtxo) + it("should not return the new main UTXO", () => { + expect(newMainUtxo).to.be.undefined }) }) }) - describe("when the change output is P2PKH", () => { - // The only difference between redemption transactions with P2PKH - // change outputs and P2WPKH change outputs is the output type itself. - // Therefore the tests for creating transactions with P2PKH are - // limited to one single test case as more complicated scenarios are - // covered for P2WPKH change output tests. + context("when there are no redemption requests provided", () => { const data: RedemptionTestData = - singleP2SHRedemptionWithNonWitnessChange - - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo | undefined - let transaction: BitcoinRawTx + singleP2PKHRedemptionWithWitnessChange - beforeEach(async () => { - const redemptionRequests = data.pendingRedemptions.map( - (redemption) => redemption.pendingRedemption - ) - - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await assembleRedemptionTransaction( - walletPrivateKey, - data.mainUtxo, - redemptionRequests, + it("should revert", async () => { + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, data.witness - )) - }) - - it("should return transaction with proper structure", async () => { - // Compare HEXes. - expect(transaction).to.be.eql(data.expectedRedemption.transaction) - - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") - - expect(txJSON.hash).to.be.equal( - data.expectedRedemption.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) - - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(1) - - const input = txJSON.inputs[0] - - expect(input.prevout.hash).to.be.equal( - data.mainUtxo.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal(data.mainUtxo.outputIndex) - // Transaction should be signed but this is SegWit input so the `script` - // field should be empty and the `witness` field should be filled instead. - expect(input.script.length).to.be.equal(0) - expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(2) - - const p2shOutput = txJSON.outputs[0] - const changeOutput = txJSON.outputs[1] - - // P2SH output - // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 12000 - 1200 - 1000 = 9800 - expect(p2shOutput.value).to.be.equal(9800) - // The output script should correspond to: - // OP_HASH160 0x14 0x3ec459d0f3c29286ae5df5fcc421e2786024277e OP_EQUAL - expect(p2shOutput.script).to.be.equal( - "a9143ec459d0f3c29286ae5df5fcc421e2786024277e87" - ) - // The output address should be P2SH - expect(p2shOutput.address).to.be.equal( - "2Mxy76sc1qAxiJ1fXMXDXqHvVcPLh6Lf12C" - ) - - // P2PKH output (change) - // The value of fee should be the fee share of the (only) redeem output - // which is 1200 - // The output value should be main UTXO input value - fee - the value - // of the redeem output, which is 1364180 = 1375180 - 1200 - 9800 - expect(changeOutput.value).to.be.equal(1364180) - // The output script should correspond to: - // OP_DUP OP_HASH160 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 - // OP_EQUALVERIFY OP_CHECKSIG - expect(changeOutput.script).to.be.equal( - "76a9148db50eb52063ea9d98b3eac91489a90f738986f688ac" - ) - // The change output address should be the P2PKH address of the wallet - expect(changeOutput.address).to.be.equal(p2pkhWalletAddress) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - data.expectedRedemption.transactionHash ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: data.expectedRedemption.transactionHash, - outputIndex: 1, - value: BigNumber.from(1364180), - } - expect(newMainUtxo).to.be.deep.equal(expectedNewMainUtxo) + await expect( + walletTx.redemption.assembleTransaction( + walletPrivateKey, + data.mainUtxo, + [] // empty list of redemption requests + ) + ).to.be.rejectedWith("There must be at least one request to redeem") }) }) }) + }) + }) - context("when there is no change UTXO created", () => { - const data: RedemptionTestData = multipleRedemptionsWithoutChange - - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo | undefined - let transaction: BitcoinRawTx - - beforeEach(async () => { - const redemptionRequests = data.pendingRedemptions.map( - (redemption) => redemption.pendingRedemption - ) - - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await assembleRedemptionTransaction( - walletPrivateKey, - data.mainUtxo, - redemptionRequests, - data.witness - )) - }) + describe("Spv", () => { + describe("submitRedemptionProof", () => { + const mainUtxo = { + transactionHash: BitcoinTxHash.from( + "3d28bb5bf73379da51bc683f4d0ed31d7b024466c619d80ebd9378077d900be3" + ), + outputIndex: 1, + value: BigNumber.from(1429580), + } - it("should return transaction with proper structure", async () => { - // Compare HEXes. - expect(transaction).to.be.eql(data.expectedRedemption.transaction) + let bitcoinClient: MockBitcoinClient + let tbtcContracts: MockTBTCContracts + let maintenanceService: MaintenanceService - // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + beforeEach(async () => { + bcoin.set("testnet") - expect(txJSON.hash).to.be.equal( - data.expectedRedemption.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) + bitcoinClient = new MockBitcoinClient() + tbtcContracts = new MockTBTCContracts() - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(1) + maintenanceService = new MaintenanceService( + tbtcContracts, + bitcoinClient + ) - const input = txJSON.inputs[0] + const transactionHash = + redemptionProof.bitcoinChainData.transaction.transactionHash - expect(input.prevout.hash).to.be.equal( - data.mainUtxo.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal(data.mainUtxo.outputIndex) - // Transaction should be signed but this is SegWit input so the `script` - // field should be empty and the `witness` field should be filled instead. - expect(input.script.length).to.be.equal(0) - expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(2) - - const p2pkhOutput = txJSON.outputs[0] - const p2wpkhOutput = txJSON.outputs[1] - - // P2PKH output - // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 6000 - 800 - 0 = 5200 - expect(p2pkhOutput.value).to.be.equal(5200) - // The output script should correspond to: - // OP_DUP OP_HASH160 0x14 0x4130879211c54df460e484ddf9aac009cb38ee74 - // OP_EQUALVERIFY OP_CHECKSIG - expect(p2pkhOutput.script).to.be.equal( - "76a9144130879211c54df460e484ddf9aac009cb38ee7488ac" - ) - // The output address should be P2PK - expect(p2pkhOutput.address).to.be.equal( - "mmTeMR8RKu6QzMGTG4ipA71uewm3EuJng5" - ) + const transactions = new Map() + transactions.set( + transactionHash.toString(), + redemptionProof.bitcoinChainData.transaction + ) + bitcoinClient.transactions = transactions - // P2WPKH output - // The output value should be `requestedAmount` - `txFee` - `treasuryFee` - // which is 4000 - 900 - 0 = 3100 - expect(p2wpkhOutput.value).to.be.equal(3100) - // The output script should correspond to: - // OP_0 0x14 0x4bf9ffb7ae0f8b0f5a622b154aca829126f6e769 - expect(p2wpkhOutput.script).to.be.equal( - "00144bf9ffb7ae0f8b0f5a622b154aca829126f6e769" - ) - // The output address should be P2PKH - expect(p2wpkhOutput.address).to.be.equal( - "tb1qf0ulldawp79s7knz9v254j5zjyn0demfx2d0xx" - ) - }) + const rawTransactions = new Map() + rawTransactions.set( + transactionHash.toString(), + redemptionProof.bitcoinChainData.rawTransaction + ) + bitcoinClient.rawTransactions = rawTransactions - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - data.expectedRedemption.transactionHash - ) - }) + bitcoinClient.latestHeight = + redemptionProof.bitcoinChainData.latestBlockHeight + bitcoinClient.headersChain = + redemptionProof.bitcoinChainData.headersChain + bitcoinClient.transactionMerkle = + redemptionProof.bitcoinChainData.transactionMerkleBranch + const confirmations = new Map() + confirmations.set( + transactionHash.toString(), + redemptionProof.bitcoinChainData.accumulatedTxConfirmations + ) + bitcoinClient.confirmations = confirmations - it("should not return the new main UTXO", () => { - expect(newMainUtxo).to.be.undefined - }) + await maintenanceService.spv.submitRedemptionProof( + transactionHash, + mainUtxo, + walletPublicKey + ) }) - }) - - context("when there are no redemption requests provided", () => { - const data: RedemptionTestData = singleP2PKHRedemptionWithWitnessChange - it("should revert", async () => { - await expect( - assembleRedemptionTransaction( - walletPrivateKey, - data.mainUtxo, - [], // empty list of redemption requests - data.witness - ) - ).to.be.rejectedWith("There must be at least one request to redeem") + it("should submit redemption proof with correct arguments", () => { + const bridgeLog = tbtcContracts.bridge.redemptionProofLog + expect(bridgeLog.length).to.equal(1) + expect(bridgeLog[0].mainUtxo).to.equal(mainUtxo) + expect(bridgeLog[0].walletPublicKey).to.equal( + redemptionProof.expectedRedemptionProof.walletPublicKey + ) + expect(bridgeLog[0].redemptionTx).to.deep.equal( + redemptionProof.expectedRedemptionProof.redemptionTx + ) + expect(bridgeLog[0].redemptionProof.txIndexInBlock).to.deep.equal( + redemptionProof.expectedRedemptionProof.redemptionProof.txIndexInBlock + ) + expect(bridgeLog[0].redemptionProof.merkleProof).to.deep.equal( + redemptionProof.expectedRedemptionProof.redemptionProof.merkleProof + ) + expect(bridgeLog[0].redemptionProof.bitcoinHeaders).to.deep.equal( + redemptionProof.expectedRedemptionProof.redemptionProof.bitcoinHeaders + ) }) }) }) - - describe("submitRedemptionProof", () => { - const mainUtxo = { - transactionHash: BitcoinTxHash.from( - "3d28bb5bf73379da51bc683f4d0ed31d7b024466c619d80ebd9378077d900be3" - ), - outputIndex: 1, - value: BigNumber.from(1429580), - } - - let bitcoinClient: MockBitcoinClient - let bridge: MockBridge - - beforeEach(async () => { - bcoin.set("testnet") - - bitcoinClient = new MockBitcoinClient() - bridge = new MockBridge() - - const transactionHash = - redemptionProof.bitcoinChainData.transaction.transactionHash - - const transactions = new Map() - transactions.set( - transactionHash.toString(), - redemptionProof.bitcoinChainData.transaction - ) - bitcoinClient.transactions = transactions - - const rawTransactions = new Map() - rawTransactions.set( - transactionHash.toString(), - redemptionProof.bitcoinChainData.rawTransaction - ) - bitcoinClient.rawTransactions = rawTransactions - - bitcoinClient.latestHeight = - redemptionProof.bitcoinChainData.latestBlockHeight - bitcoinClient.headersChain = redemptionProof.bitcoinChainData.headersChain - bitcoinClient.transactionMerkle = - redemptionProof.bitcoinChainData.transactionMerkleBranch - const confirmations = new Map() - confirmations.set( - transactionHash.toString(), - redemptionProof.bitcoinChainData.accumulatedTxConfirmations - ) - bitcoinClient.confirmations = confirmations - - await submitRedemptionProof( - transactionHash, - mainUtxo, - walletPublicKey, - bridge, - bitcoinClient - ) - }) - - it("should submit redemption proof with correct arguments", () => { - const bridgeLog = bridge.redemptionProofLog - expect(bridgeLog.length).to.equal(1) - expect(bridgeLog[0].mainUtxo).to.equal(mainUtxo) - expect(bridgeLog[0].walletPublicKey).to.equal( - redemptionProof.expectedRedemptionProof.walletPublicKey - ) - expect(bridgeLog[0].redemptionTx).to.deep.equal( - redemptionProof.expectedRedemptionProof.redemptionTx - ) - expect(bridgeLog[0].redemptionProof.txIndexInBlock).to.deep.equal( - redemptionProof.expectedRedemptionProof.redemptionProof.txIndexInBlock - ) - expect(bridgeLog[0].redemptionProof.merkleProof).to.deep.equal( - redemptionProof.expectedRedemptionProof.redemptionProof.merkleProof - ) - expect(bridgeLog[0].redemptionProof.bitcoinHeaders).to.deep.equal( - redemptionProof.expectedRedemptionProof.redemptionProof.bitcoinHeaders - ) - }) - }) }) async function runRedemptionScenario( walletPrivKey: string, bitcoinClient: MockBitcoinClient, - bridge: MockBridge, + tbtcContracts: MockTBTCContracts, data: RedemptionTestData ): Promise<{ transactionHash: BitcoinTxHash @@ -2139,7 +2252,7 @@ async function runRedemptionScenario( }) bitcoinClient.rawTransactions = rawTransactions - bridge.setPendingRedemptions( + tbtcContracts.bridge.setPendingRedemptions( new Map( data.pendingRedemptions.map((redemption) => [ redemption.redemptionKey, @@ -2152,12 +2265,11 @@ async function runRedemptionScenario( (redemption) => redemption.pendingRedemption.redeemerOutputScript ) - return submitRedemptionTransaction( - bitcoinClient, - bridge, + const walletTx = new WalletTx(tbtcContracts, bitcoinClient, data.witness) + + return walletTx.redemption.submitTransaction( walletPrivKey, data.mainUtxo, - redeemerOutputScripts, - data.witness + redeemerOutputScripts ) } From 550486d419d2f31ca4d2c82cb6612ed351667445 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 29 Sep 2023 14:12:52 +0200 Subject: [PATCH 176/205] Skip Electrum test suite This test suite depends on external Electrum servers and is prone to their health fluctuations. We observed such fluctuations now, and we are temporarily skipping their default run to avoid loosing time. --- typescript/test/electrum.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/test/electrum.test.ts b/typescript/test/electrum.test.ts index 6d8d80020..eccfe1056 100644 --- a/typescript/test/electrum.test.ts +++ b/typescript/test/electrum.test.ts @@ -84,7 +84,7 @@ const testnetCredentials: ElectrumCredentials[] = [ * out of scope of this suite. The `broadcast` function was tested manually * though. */ -describe("Electrum", () => { +describe.skip("Electrum", () => { testnetCredentials.forEach((credentials) => { describe(`${credentials.protocol}://${credentials.host}:${credentials.port}`, async () => { let electrumClient: ElectrumClient From 6628c09f00709497598736c1f969267aa82bdba1 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Fri, 29 Sep 2023 17:20:43 +0200 Subject: [PATCH 177/205] Add `TBTC` entrypoint component and embed chain configs Here we add the `TBTC` entrypoint component allowing to easily set up the SDK to work with supported Ethereum-based and Bitcoin networks. --- typescript/src/index.ts | 5 + typescript/src/lib/contracts/bridge.ts | 5 + typescript/src/lib/contracts/tbtc-token.ts | 6 + .../src/lib/contracts/wallet-registry.ts | 5 + typescript/src/lib/electrum/client.ts | 25 + typescript/src/lib/electrum/urls/mainnet.json | 8 + typescript/src/lib/electrum/urls/testnet.json | 3 + .../lib/ethereum/artifacts/goerli/Bridge.json | 2637 +++++++++++++++++ .../ethereum/artifacts/goerli/TBTCToken.json | 763 +++++ .../ethereum/artifacts/goerli/TBTCVault.json | 1606 ++++++++++ .../artifacts/goerli/WalletRegistry.json | 1962 ++++++++++++ .../ethereum/artifacts/mainnet/Bridge.json | 2624 ++++++++++++++++ .../ethereum/artifacts/mainnet/TBTCToken.json | 762 +++++ .../ethereum/artifacts/mainnet/TBTCVault.json | 1606 ++++++++++ .../artifacts/mainnet/WalletRegistry.json | 1962 ++++++++++++ typescript/src/lib/ethereum/bridge.ts | 37 +- typescript/src/lib/ethereum/index.ts | 90 + typescript/src/lib/ethereum/tbtc-token.ts | 39 +- typescript/src/lib/ethereum/tbtc-vault.ts | 29 +- .../src/lib/ethereum/wallet-registry.ts | 43 +- .../maintenance/maintenance-service.ts | 1 - typescript/src/services/tbtc.ts | 96 + typescript/test/utils/mock-bridge.ts | 4 + typescript/test/utils/mock-tbtc-token.ts | 7 +- typescript/test/utils/mock-wallet-registry.ts | 6 + 25 files changed, 14315 insertions(+), 16 deletions(-) create mode 100644 typescript/src/lib/electrum/urls/mainnet.json create mode 100644 typescript/src/lib/electrum/urls/testnet.json create mode 100644 typescript/src/lib/ethereum/artifacts/goerli/Bridge.json create mode 100644 typescript/src/lib/ethereum/artifacts/goerli/TBTCToken.json create mode 100644 typescript/src/lib/ethereum/artifacts/goerli/TBTCVault.json create mode 100644 typescript/src/lib/ethereum/artifacts/goerli/WalletRegistry.json create mode 100644 typescript/src/lib/ethereum/artifacts/mainnet/Bridge.json create mode 100644 typescript/src/lib/ethereum/artifacts/mainnet/TBTCToken.json create mode 100644 typescript/src/lib/ethereum/artifacts/mainnet/TBTCVault.json create mode 100644 typescript/src/lib/ethereum/artifacts/mainnet/WalletRegistry.json create mode 100644 typescript/src/services/tbtc.ts diff --git a/typescript/src/index.ts b/typescript/src/index.ts index 197a34d8f..2ee4bcafd 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -1,9 +1,14 @@ +// Export shared library modules. export * from "./lib/bitcoin" export * from "./lib/contracts" export * from "./lib/electrum" export * from "./lib/ethereum" export * from "./lib/utils" +// Export feature modules (services). export * from "./services/deposits" export * from "./services/maintenance" export * from "./services/redemptions" + +// Export the entrypoint module. +export * from "./services/tbtc" diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index 52c06f3bd..d78499c55 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -14,6 +14,11 @@ import { WalletRegistry } from "./wallet-registry" * Interface for communication with the Bridge on-chain contract. */ export interface Bridge { + /** + * Gets the chain-specific identifier of this contract. + */ + getChainIdentifier(): ChainIdentifier + /** * Get emitted DepositRevealed events. * @see GetEventsFunction diff --git a/typescript/src/lib/contracts/tbtc-token.ts b/typescript/src/lib/contracts/tbtc-token.ts index 7770510dd..b78ef1823 100644 --- a/typescript/src/lib/contracts/tbtc-token.ts +++ b/typescript/src/lib/contracts/tbtc-token.ts @@ -1,11 +1,17 @@ import { BigNumber } from "ethers" import { BitcoinUtxo } from "../bitcoin" import { Hex } from "../utils" +import { ChainIdentifier } from "./chain-identifier" /** * Interface for communication with the TBTC v2 token on-chain contract. */ export interface TBTCToken { + /** + * Gets the chain-specific identifier of this contract. + */ + getChainIdentifier(): ChainIdentifier + /** * Gets the total supply of the TBTC v2 token. The returned value is in * ERC 1e18 precision, it has to be converted before using as Bitcoin value diff --git a/typescript/src/lib/contracts/wallet-registry.ts b/typescript/src/lib/contracts/wallet-registry.ts index 417e9c745..bd18cde29 100644 --- a/typescript/src/lib/contracts/wallet-registry.ts +++ b/typescript/src/lib/contracts/wallet-registry.ts @@ -7,6 +7,11 @@ import { ChainIdentifier } from "./chain-identifier" * Interface for communication with the WalletRegistry on-chain contract. */ export interface WalletRegistry { + /** + * Gets the chain-specific identifier of this contract. + */ + getChainIdentifier(): ChainIdentifier + /** * Gets the public key for the given wallet. * @param walletID ID of the wallet. diff --git a/typescript/src/lib/electrum/client.ts b/typescript/src/lib/electrum/client.ts index c24b68d57..dd0b10aab 100644 --- a/typescript/src/lib/electrum/client.ts +++ b/typescript/src/lib/electrum/client.ts @@ -17,6 +17,9 @@ import { BigNumber, utils } from "ethers" import { URL } from "url" import { backoffRetrier, Hex, RetrierFn } from "../utils" +import MainnetElectrumUrls from "./urls/mainnet.json" +import TestnetElectrumUrls from "./urls/testnet.json" + /** * Represents a set of credentials required to establish an Electrum connection. */ @@ -110,6 +113,28 @@ export class ElectrumClient implements BitcoinClient { ) } + /** + * Creates an Electrum client instance using a default config for the given + * Bitcoin network. + * @param network Bitcoin network the instance should be created for. + * @returns Electrum client instance. + */ + static fromDefaultConfig(network: BitcoinNetwork): ElectrumClient { + let file + switch (network) { + case BitcoinNetwork.Mainnet: + file = MainnetElectrumUrls + break + case BitcoinNetwork.Testnet: + file = TestnetElectrumUrls + break + default: + throw new Error("No default Electrum for given network") + } + + return ElectrumClient.fromUrl(file.urls) + } + /** * Create Electrum credentials by parsing an URL. * @param url - URL to be parsed. diff --git a/typescript/src/lib/electrum/urls/mainnet.json b/typescript/src/lib/electrum/urls/mainnet.json new file mode 100644 index 000000000..8c36cb6f0 --- /dev/null +++ b/typescript/src/lib/electrum/urls/mainnet.json @@ -0,0 +1,8 @@ +{ + "urls": [ + "wss://electrumx-server.tbtc.network:8443", + "wss://electrum.boar.network:2083", + "wss://bitcoin.threshold.p2p.org:50004", + "wss://electrumx.prod-utility-eks-us-west-2.staked.cloud:443" + ] +} diff --git a/typescript/src/lib/electrum/urls/testnet.json b/typescript/src/lib/electrum/urls/testnet.json new file mode 100644 index 000000000..fb50c0bed --- /dev/null +++ b/typescript/src/lib/electrum/urls/testnet.json @@ -0,0 +1,3 @@ +{ + "urls": ["wss://electrumx-server.test.tbtc.network:8443"] +} diff --git a/typescript/src/lib/ethereum/artifacts/goerli/Bridge.json b/typescript/src/lib/ethereum/artifacts/goerli/Bridge.json new file mode 100644 index 000000000..20fa37e56 --- /dev/null +++ b/typescript/src/lib/ethereum/artifacts/goerli/Bridge.json @@ -0,0 +1,2637 @@ +{ + "address": "0x0Cad3257C4B7ec6de1f6926Fbf5714255a6632c3", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "depositDustThreshold", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "depositTreasuryFeeDivisor", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "depositTxMaxFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "depositRevealAheadPeriod", + "type": "uint32" + } + ], + "name": "DepositParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "amount", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bytes8", + "name": "blindingFactor", + "type": "bytes8" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes20", + "name": "refundPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes4", + "name": "refundLocktime", + "type": "bytes4" + }, + { + "indexed": false, + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "name": "DepositRevealed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sweepTxHash", + "type": "bytes32" + } + ], + "name": "DepositsSwept", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sighash", + "type": "bytes32" + } + ], + "name": "FraudChallengeDefeatTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sighash", + "type": "bytes32" + } + ], + "name": "FraudChallengeDefeated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sighash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "FraudChallengeSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint96", + "name": "fraudChallengeDepositAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "fraudChallengeDefeatTimeout", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "fraudSlashingAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "fraudNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "FraudParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldGovernance", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "GovernanceTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "movingFundsTxHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movingFundsTxOutputIndex", + "type": "uint32" + } + ], + "name": "MovedFundsSweepTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sweepTxHash", + "type": "bytes32" + } + ], + "name": "MovedFundsSwept", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "MovingFundsBelowDustReported", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes20[]", + "name": "targetWallets", + "type": "bytes20[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "submitter", + "type": "address" + } + ], + "name": "MovingFundsCommitmentSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "movingFundsTxHash", + "type": "bytes32" + } + ], + "name": "MovingFundsCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "movingFundsTxMaxTotalFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "movingFundsDustThreshold", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movingFundsTimeoutResetDelay", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movingFundsTimeout", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "movingFundsTimeoutSlashingAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movingFundsTimeoutNotifierRewardMultiplier", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "movingFundsCommitmentGasOffset", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "movedFundsSweepTxMaxTotalFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movedFundsSweepTimeout", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "movedFundsSweepTimeoutSlashingAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movedFundsSweepTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "MovingFundsParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "MovingFundsTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "MovingFundsTimeoutReset", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "NewWalletRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "NewWalletRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "redemptionDustThreshold", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "redemptionTreasuryFeeDivisor", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "redemptionTxMaxFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "redemptionTxMaxTotalFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "redemptionTimeout", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "redemptionTimeoutSlashingAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "redemptionTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "RedemptionParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "redeemerOutputScript", + "type": "bytes" + }, + { + "indexed": true, + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "requestedAmount", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "treasuryFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "txMaxFee", + "type": "uint64" + } + ], + "name": "RedemptionRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "redeemerOutputScript", + "type": "bytes" + } + ], + "name": "RedemptionTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "redemptionTxHash", + "type": "bytes32" + } + ], + "name": "RedemptionsCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "spvMaintainer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isTrusted", + "type": "bool" + } + ], + "name": "SpvMaintainerStatusUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "treasury", + "type": "address" + } + ], + "name": "TreasuryUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "vault", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isTrusted", + "type": "bool" + } + ], + "name": "VaultStatusUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "WalletClosed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "WalletClosing", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "WalletMovingFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "walletCreationPeriod", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "walletCreationMinBtcBalance", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "walletCreationMaxBtcBalance", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "walletClosureMinBtcBalance", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "walletMaxAge", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "walletMaxBtcTransfer", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "walletClosingPeriod", + "type": "uint32" + } + ], + "name": "WalletParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "WalletTerminated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyX", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyY", + "type": "bytes32" + } + ], + "name": "__ecdsaWalletCreatedCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyX", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyY", + "type": "bytes32" + } + ], + "name": "__ecdsaWalletHeartbeatFailedCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "activeWalletPubKeyHash", + "outputs": [ + { + "internalType": "bytes20", + "name": "", + "type": "bytes20" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "contractReferences", + "outputs": [ + { + "internalType": "contract Bank", + "name": "bank", + "type": "address" + }, + { + "internalType": "contract IRelay", + "name": "relay", + "type": "address" + }, + { + "internalType": "contract IWalletRegistry", + "name": "ecdsaWalletRegistry", + "type": "address" + }, + { + "internalType": "contract ReimbursementPool", + "name": "reimbursementPool", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "walletPublicKey", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "preimage", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "witness", + "type": "bool" + } + ], + "name": "defeatFraudChallenge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "walletPublicKey", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "heartbeatMessage", + "type": "bytes" + } + ], + "name": "defeatFraudChallengeWithHeartbeat", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "depositParameters", + "outputs": [ + { + "internalType": "uint64", + "name": "depositDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "depositTreasuryFeeDivisor", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "depositTxMaxFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "depositRevealAheadPeriod", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "deposits", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "internalType": "uint64", + "name": "amount", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "revealedAt", + "type": "uint32" + }, + { + "internalType": "address", + "name": "vault", + "type": "address" + }, + { + "internalType": "uint64", + "name": "treasuryFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "sweptAt", + "type": "uint32" + } + ], + "internalType": "struct Deposit.DepositRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "challengeKey", + "type": "uint256" + } + ], + "name": "fraudChallenges", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "challenger", + "type": "address" + }, + { + "internalType": "uint256", + "name": "depositAmount", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "reportedAt", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "resolved", + "type": "bool" + } + ], + "internalType": "struct Fraud.FraudChallenge", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "fraudParameters", + "outputs": [ + { + "internalType": "uint96", + "name": "fraudChallengeDepositAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "fraudChallengeDefeatTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "fraudSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "fraudNotifierRewardMultiplier", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governance", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_bank", + "type": "address" + }, + { + "internalType": "address", + "name": "_relay", + "type": "address" + }, + { + "internalType": "address", + "name": "_treasury", + "type": "address" + }, + { + "internalType": "address", + "name": "_ecdsaWalletRegistry", + "type": "address" + }, + { + "internalType": "address payable", + "name": "_reimbursementPool", + "type": "address" + }, + { + "internalType": "uint96", + "name": "_txProofDifficultyFactor", + "type": "uint96" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "name": "isVaultTrusted", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "liveWalletsCount", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "requestKey", + "type": "uint256" + } + ], + "name": "movedFundsSweepRequests", + "outputs": [ + { + "components": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "uint64", + "name": "value", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "createdAt", + "type": "uint32" + }, + { + "internalType": "enum MovingFunds.MovedFundsSweepRequestState", + "name": "state", + "type": "uint8" + } + ], + "internalType": "struct MovingFunds.MovedFundsSweepRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "movingFundsParameters", + "outputs": [ + { + "internalType": "uint64", + "name": "movingFundsTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "movingFundsDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeoutResetDelay", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "movingFundsTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeoutNotifierRewardMultiplier", + "type": "uint32" + }, + { + "internalType": "uint16", + "name": "movingFundsCommitmentGasOffset", + "type": "uint16" + }, + { + "internalType": "uint64", + "name": "movedFundsSweepTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "movedFundsSweepTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "movedFundsSweepTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "movedFundsSweepTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "walletPublicKey", + "type": "bytes" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + }, + { + "internalType": "bytes", + "name": "preimageSha256", + "type": "bytes" + } + ], + "name": "notifyFraudChallengeDefeatTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "movingFundsTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "movingFundsTxOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + } + ], + "name": "notifyMovedFundsSweepTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + } + ], + "name": "notifyMovingFundsBelowDust", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + } + ], + "name": "notifyMovingFundsTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + }, + { + "internalType": "bytes", + "name": "redeemerOutputScript", + "type": "bytes" + } + ], + "name": "notifyRedemptionTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "walletMainUtxo", + "type": "tuple" + } + ], + "name": "notifyWalletCloseable", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "notifyWalletClosingPeriodElapsed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redemptionKey", + "type": "uint256" + } + ], + "name": "pendingRedemptions", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint64", + "name": "requestedAmount", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "treasuryFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "txMaxFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "requestedAt", + "type": "uint32" + } + ], + "internalType": "struct Redemption.RedemptionRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "balanceOwner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "redemptionData", + "type": "bytes" + } + ], + "name": "receiveBalanceApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "redemptionParameters", + "outputs": [ + { + "internalType": "uint64", + "name": "redemptionDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTreasuryFeeDivisor", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTxMaxFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "redemptionTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "redemptionTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "redemptionTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "activeWalletMainUtxo", + "type": "tuple" + } + ], + "name": "requestNewWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "redeemerOutputScript", + "type": "bytes" + }, + { + "internalType": "uint64", + "name": "amount", + "type": "uint64" + } + ], + "name": "requestRedemption", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "resetMovingFundsTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "fundingTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + }, + { + "internalType": "bytes8", + "name": "blindingFactor", + "type": "bytes8" + }, + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "bytes20", + "name": "refundPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "bytes4", + "name": "refundLocktime", + "type": "bytes4" + }, + { + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "internalType": "struct Deposit.DepositRevealInfo", + "name": "reveal", + "type": "tuple" + } + ], + "name": "revealDeposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spvMaintainer", + "type": "address" + }, + { + "internalType": "bool", + "name": "isTrusted", + "type": "bool" + } + ], + "name": "setSpvMaintainerStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vault", + "type": "address" + }, + { + "internalType": "bool", + "name": "isTrusted", + "type": "bool" + } + ], + "name": "setVaultStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "utxoKey", + "type": "uint256" + } + ], + "name": "spentMainUTXOs", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "sweepTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "merkleProof", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "txIndexInBlock", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "bitcoinHeaders", + "type": "bytes" + } + ], + "internalType": "struct BitcoinTx.Proof", + "name": "sweepProof", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + }, + { + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "name": "submitDepositSweepProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "walletPublicKey", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "preimageSha256", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + } + ], + "internalType": "struct BitcoinTx.RSVSignature", + "name": "signature", + "type": "tuple" + } + ], + "name": "submitFraudChallenge", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "sweepTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "merkleProof", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "txIndexInBlock", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "bitcoinHeaders", + "type": "bytes" + } + ], + "internalType": "struct BitcoinTx.Proof", + "name": "sweepProof", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + } + ], + "name": "submitMovedFundsSweepProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "walletMainUtxo", + "type": "tuple" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + }, + { + "internalType": "uint256", + "name": "walletMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes20[]", + "name": "targetWallets", + "type": "bytes20[]" + } + ], + "name": "submitMovingFundsCommitment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "movingFundsTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "merkleProof", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "txIndexInBlock", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "bitcoinHeaders", + "type": "bytes" + } + ], + "internalType": "struct BitcoinTx.Proof", + "name": "movingFundsProof", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + }, + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "submitMovingFundsProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "redemptionTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "merkleProof", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "txIndexInBlock", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "bitcoinHeaders", + "type": "bytes" + } + ], + "internalType": "struct BitcoinTx.Proof", + "name": "redemptionProof", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + }, + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "submitRedemptionProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redemptionKey", + "type": "uint256" + } + ], + "name": "timedOutRedemptions", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint64", + "name": "requestedAmount", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "treasuryFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "txMaxFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "requestedAt", + "type": "uint32" + } + ], + "internalType": "struct Redemption.RedemptionRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "treasury", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "txProofDifficultyFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "depositDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "depositTreasuryFeeDivisor", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "depositTxMaxFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "depositRevealAheadPeriod", + "type": "uint32" + } + ], + "name": "updateDepositParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint96", + "name": "fraudChallengeDepositAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "fraudChallengeDefeatTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "fraudSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "fraudNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "updateFraudParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "movingFundsTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "movingFundsDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeoutResetDelay", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "movingFundsTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeoutNotifierRewardMultiplier", + "type": "uint32" + }, + { + "internalType": "uint16", + "name": "movingFundsCommitmentGasOffset", + "type": "uint16" + }, + { + "internalType": "uint64", + "name": "movedFundsSweepTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "movedFundsSweepTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "movedFundsSweepTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "movedFundsSweepTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "updateMovingFundsParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "redemptionDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTreasuryFeeDivisor", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTxMaxFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "redemptionTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "redemptionTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "redemptionTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "updateRedemptionParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRelay", + "name": "relay", + "type": "address" + } + ], + "name": "updateRelay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "treasury", + "type": "address" + } + ], + "name": "updateTreasury", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "walletCreationPeriod", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "walletCreationMinBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "walletCreationMaxBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "walletClosureMinBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "walletMaxAge", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "walletMaxBtcTransfer", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "walletClosingPeriod", + "type": "uint32" + } + ], + "name": "updateWalletParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "walletParameters", + "outputs": [ + { + "internalType": "uint32", + "name": "walletCreationPeriod", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "walletCreationMinBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "walletCreationMaxBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "walletClosureMinBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "walletMaxAge", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "walletMaxBtcTransfer", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "walletClosingPeriod", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "wallets", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "mainUtxoHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "pendingRedemptionsValue", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "createdAt", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "movingFundsRequestedAt", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "closingStartedAt", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "pendingMovedFundsSweepRequestsCount", + "type": "uint32" + }, + { + "internalType": "enum Wallets.WalletState", + "name": "state", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "movingFundsTargetWalletsCommitmentHash", + "type": "bytes32" + } + ], + "internalType": "struct Wallets.Wallet", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x0c3003c638a0a8b590f118e99c0112f6d9e0b6b816bd26e8902f3208429f5e92", + "receipt": { + "to": "0x47439cddBEeb66834D07C84dfa16a3F53E7166DB", + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": null, + "transactionIndex": 7, + "gasUsed": "38760", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000200000000000000000000000060000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000080000", + "blockHash": "0x42f642f6d86665c26d412806fa7afd2aa048a8abceaa458990d83ab61406dcd4", + "transactionHash": "0x0c3003c638a0a8b590f118e99c0112f6d9e0b6b816bd26e8902f3208429f5e92", + "logs": [ + { + "transactionIndex": 7, + "blockNumber": 8981331, + "transactionHash": "0x0c3003c638a0a8b590f118e99c0112f6d9e0b6b816bd26e8902f3208429f5e92", + "address": "0x0Cad3257C4B7ec6de1f6926Fbf5714255a6632c3", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x00000000000000000000000003d47483486c1d1dfd99faa4b943363d07eafddc" + ], + "data": "0x", + "logIndex": 11, + "blockHash": "0x42f642f6d86665c26d412806fa7afd2aa048a8abceaa458990d83ab61406dcd4" + } + ], + "blockNumber": 8981331, + "cumulativeGasUsed": "1188482", + "status": 1, + "byzantium": true + }, + "numDeployments": 3, + "libraries": { + "Deposit": "0xc6911F875E58513B3471678Bf804f56ea78639d1", + "DepositSweep": "0x0e8DE6422034B3E26e23FB201F510af783719699", + "Redemption": "0x9c7f623879aD9CC197A615DccDa2Ef5128B8b8F0", + "Wallets": "0xE4Bc89b7aB1cFD7827D2b9A101546fCcBC599b1C", + "Fraud": "0x64E8AeA9b1dF57df4e53e762ffd45Be1C7F1e211", + "MovingFunds": "0xa572224301529Ea81AC11d2aF07514F1AD647Fd4" + }, + "implementation": "0x03d47483486c1d1DFD99FaA4B943363D07EAFDDC", + "devdoc": "Contract deployed as upgradable proxy" +} diff --git a/typescript/src/lib/ethereum/artifacts/goerli/TBTCToken.json b/typescript/src/lib/ethereum/artifacts/goerli/TBTCToken.json new file mode 100644 index 000000000..d56505e19 --- /dev/null +++ b/typescript/src/lib/ethereum/artifacts/goerli/TBTCToken.json @@ -0,0 +1,763 @@ +{ + "address": "0x679874fBE6D4E7Cc54A59e315FF1eB266686a937", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "approveAndCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cachedChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cachedDomainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "recoverERC721", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xc84cbf9e28bd17faf747312883a91aea795c6e07dc66e5fe8b7339a3963e368d", + "receipt": { + "to": null, + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0x679874fBE6D4E7Cc54A59e315FF1eB266686a937", + "transactionIndex": 29, + "gasUsed": "1656167", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000200000200000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000010", + "blockHash": "0x3dfc22aef2e4511f80b1c99fc8c2301313ad753baaf4c6f9946569abb8ebbb49", + "transactionHash": "0xc84cbf9e28bd17faf747312883a91aea795c6e07dc66e5fe8b7339a3963e368d", + "logs": [ + { + "transactionIndex": 29, + "blockNumber": 8364943, + "transactionHash": "0xc84cbf9e28bd17faf747312883a91aea795c6e07dc66e5fe8b7339a3963e368d", + "address": "0x679874fBE6D4E7Cc54A59e315FF1eB266686a937", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc" + ], + "data": "0x", + "logIndex": 48, + "blockHash": "0x3dfc22aef2e4511f80b1c99fc8c2301313ad753baaf4c6f9946569abb8ebbb49" + } + ], + "blockNumber": 8364943, + "cumulativeGasUsed": "5222559", + "status": 1, + "byzantium": true + }, + "args": [], + "numDeployments": 1, + "solcInputHash": "f862bd134ddc06352fa5be0644481600", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burnFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cachedChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cachedDomainSeparator\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC721\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recoverERC721\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address,uint256)\":{\"details\":\"If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\",\"returns\":{\"_0\":\"True if the operation succeeded.\"}},\"approveAndCall(address,uint256,bytes)\":{\"details\":\"If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.\",\"returns\":{\"_0\":\"True if both approval and `receiveApproval` calls succeeded.\"}},\"burn(uint256)\":{\"details\":\"Requirements: - the caller must have a balance of at least `amount`.\"},\"burnFrom(address,uint256)\":{\"details\":\"Requirements: - `account` must have a balance of at least `amount`, - the caller must have allowance for `account`'s tokens of at least `amount`.\"},\"mint(address,uint256)\":{\"details\":\"Requirements: - `recipient` cannot be the zero address.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"details\":\"The deadline argument can be set to `type(uint256).max to create permits that effectively never expire. If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transfer(address,uint256)\":{\"details\":\"Requirements: - `recipient` cannot be the zero address, - the caller must have a balance of at least `amount`.\",\"returns\":{\"_0\":\"True if the operation succeeded, reverts otherwise.\"}},\"transferFrom(address,address,uint256)\":{\"details\":\"Requirements: - `spender` and `recipient` cannot be the zero address, - `spender` must have a balance of at least `amount`, - the caller must have allowance for `spender`'s tokens of at least `amount`.\",\"returns\":{\"_0\":\"True if the operation succeeded, reverts otherwise.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"DOMAIN_SEPARATOR()\":{\"notice\":\"Returns hash of EIP712 Domain struct with the token name as a signing domain and token contract as a verifying contract. Used to construct EIP2612 signature provided to `permit` function.\"},\"PERMIT_TYPEHASH()\":{\"notice\":\"Returns EIP2612 Permit message hash. Used to construct EIP2612 signature provided to `permit` function.\"},\"allowance(address,address)\":{\"notice\":\"The remaining number of tokens that spender will be allowed to spend on behalf of owner through `transferFrom` and `burnFrom`. This is zero by default.\"},\"approve(address,uint256)\":{\"notice\":\"Sets `amount` as the allowance of `spender` over the caller's tokens.\"},\"approveAndCall(address,uint256,bytes)\":{\"notice\":\"Calls `receiveApproval` function on spender previously approving the spender to withdraw from the caller multiple times, up to the `amount` amount. If this function is called again, it overwrites the current allowance with `amount`. Reverts if the approval reverted or if `receiveApproval` call on the spender reverted.\"},\"balanceOf(address)\":{\"notice\":\"The amount of tokens owned by the given account.\"},\"burn(uint256)\":{\"notice\":\"Destroys `amount` tokens from the caller.\"},\"burnFrom(address,uint256)\":{\"notice\":\"Destroys `amount` of tokens from `account` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`.\"},\"decimals()\":{\"notice\":\"The decimals places of the token.\"},\"mint(address,uint256)\":{\"notice\":\"Creates `amount` tokens and assigns them to `account`, increasing the total supply.\"},\"name()\":{\"notice\":\"The name of the token.\"},\"nonce(address)\":{\"notice\":\"Returns the current nonce for EIP2612 permission for the provided token owner for a replay protection. Used to construct EIP2612 signature provided to `permit` function.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their tokens with a signature conforming EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, paying gas fees, and possibly performing other actions in the same transaction.\"},\"symbol()\":{\"notice\":\"The symbol of the token.\"},\"totalSupply()\":{\"notice\":\"The amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"notice\":\"Moves `amount` tokens from the caller's account to `recipient`.\"},\"transferFrom(address,address,uint256)\":{\"notice\":\"Moves `amount` tokens from `spender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/token/TBTC.sol\":\"TBTC\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x0d4de01fe5360c38b4ad2b0822a12722958428f5138a7ff47c1720eb6fa52bba\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonce;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `spender` and `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `spender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(spender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(spender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonce[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(spender, recipient, amount);\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[spender] = spenderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(spender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x1e1bf4ec5c9d6fe70f6f834316482aeff3f122ff4ffaa7178099e7ae71a0b16d\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonce(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xdac9a5086c19a7128b505a7be1ab0ac1aa314f6989cb88d2417e9d7383f89fa9\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\n/// @title MisfundRecovery\\n/// @notice Allows the owner of the token contract extending MisfundRecovery\\n/// to recover any ERC20 and ERC721 sent mistakenly to the token\\n/// contract address.\\ncontract MisfundRecovery is Ownable {\\n using SafeERC20 for IERC20;\\n\\n function recoverERC20(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n token.safeTransfer(recipient, amount);\\n }\\n\\n function recoverERC721(\\n IERC721 token,\\n address recipient,\\n uint256 tokenId,\\n bytes calldata data\\n ) external onlyOwner {\\n token.safeTransferFrom(address(this), recipient, tokenId, data);\\n }\\n}\\n\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"contracts/token/TBTC.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\\\";\\n\\ncontract TBTC is ERC20WithPermit, MisfundRecovery {\\n constructor() ERC20WithPermit(\\\"tBTC v2\\\", \\\"tBTC\\\") {}\\n}\\n\",\"keccak256\":\"0x4542aaa48f7682005b815253768b6433c811daff5d2727db256d5f1879f5ccbf\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60c06040523480156200001157600080fd5b50604051806040016040528060078152602001663a212a21903b1960c91b815250604051806040016040528060048152602001637442544360e01b8152506200006962000063620000a160201b60201c565b620000a5565b60056200007783826200024b565b5060066200008682826200024b565b504660805262000095620000f5565b60a05250620003959050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600560405162000129919062000317565b60408051918290038220828201825260018352603160f81b6020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b634e487b7160e01b600052604160045260246000fd5b600181811c90821680620001d157607f821691505b602082108103620001f257634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200024657600081815260208120601f850160051c81016020861015620002215750805b601f850160051c820191505b8181101562000242578281556001016200022d565b5050505b505050565b81516001600160401b03811115620002675762000267620001a6565b6200027f81620002788454620001bc565b84620001f8565b602080601f831160018114620002b757600084156200029e5750858301515b600019600386901b1c1916600185901b17855562000242565b600085815260208120601f198616915b82811015620002e857888601518255948401946001909101908401620002c7565b5085821015620003075787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008083546200032781620001bc565b60018281168015620003425760018114620003585762000389565b60ff198416875282151583028701945062000389565b8760005260208060002060005b85811015620003805781548a82015290840190820162000365565b50505082870194505b50929695505050505050565b60805160a051611b92620003c96000396000818161034901526105fa0152600081816102d901526105d20152611b926000f3fe608060405234801561001057600080fd5b50600436106101985760003560e01c8063715018a6116100e3578063b4f94b2e1161008c578063dd62ed3e11610066578063dd62ed3e14610391578063f2fde38b146103bc578063fc4e51f6146103cf57600080fd5b8063b4f94b2e14610344578063cae9ca511461036b578063d505accf1461037e57600080fd5b80638da5cb5b116100bd5780638da5cb5b1461030e57806395d89b4114610329578063a9059cbb1461033157600080fd5b8063715018a6146102cc578063771da5c5146102d457806379cc6790146102fb57600080fd5b8063313ce5671161014557806342966c681161011f57806342966c681461027957806370a082311461028c57806370ae92d2146102ac57600080fd5b8063313ce567146102445780633644e5151461025e57806340c10f191461026657600080fd5b806318160ddd1161017657806318160ddd146101f357806323b872dd1461020a57806330adf81f1461021d57600080fd5b806306fdde031461019d578063095ea7b3146101bb5780631171bda9146101de575b600080fd5b6101a56103e2565b6040516101b29190611663565b60405180910390f35b6101ce6101c936600461168b565b610470565b60405190151581526020016101b2565b6101f16101ec3660046116b7565b610487565b005b6101fc60045481565b6040519081526020016101b2565b6101ce6102183660046116b7565b6104ff565b6101fc7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b61024c601281565b60405160ff90911681526020016101b2565b6101fc6105ce565b6101f161027436600461168b565b610629565b6101f16102873660046116f8565b610762565b6101fc61029a366004611711565b60016020526000908152604090205481565b6101fc6102ba366004611711565b60036020526000908152604090205481565b6101f161076f565b6101fc7f000000000000000000000000000000000000000000000000000000000000000081565b6101f161030936600461168b565b6107d5565b6000546040516001600160a01b0390911681526020016101b2565b6101a561086b565b6101ce61033f36600461168b565b610878565b6101fc7f000000000000000000000000000000000000000000000000000000000000000081565b6101ce610379366004611744565b610885565b6101f161038c366004611811565b610926565b6101fc61039f366004611888565b600260209081526000928352604080842090915290825290205481565b6101f16103ca366004611711565b610c36565b6101f16103dd3660046118c1565b610d15565b600580546103ef90611960565b80601f016020809104026020016040519081016040528092919081815260200182805461041b90611960565b80156104685780601f1061043d57610100808354040283529160200191610468565b820191906000526020600020905b81548152906001019060200180831161044b57829003601f168201915b505050505081565b600061047d338484610dea565b5060015b92915050565b6000546001600160a01b031633146104e65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6104fa6001600160a01b0384168383610ef8565b505050565b6001600160a01b038316600090815260026020908152604080832033845290915281205460001981146105b657828110156105a25760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360448201527f650000000000000000000000000000000000000000000000000000000000000060648201526084016104dd565b6105b685336105b186856119b0565b610dea565b6105c1858585610f78565b60019150505b9392505050565b60007f0000000000000000000000000000000000000000000000000000000000000000460361061c57507f000000000000000000000000000000000000000000000000000000000000000090565b61062461117f565b905090565b6000546001600160a01b031633146106835760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104dd565b6001600160a01b0382166106d95760405162461bcd60e51b815260206004820152601860248201527f4d696e7420746f20746865207a65726f2061646472657373000000000000000060448201526064016104dd565b80600460008282546106eb91906119c3565b90915550506001600160a01b038216600090815260016020526040812080548392906107189084906119c3565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b61076c338261124a565b50565b6000546001600160a01b031633146107c95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104dd565b6107d3600061132e565b565b6001600160a01b0382166000908152600260209081526040808320338452909152902054600019811461086157818110156108525760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e636500000060448201526064016104dd565b61086183336105b185856119b0565b6104fa838361124a565b600680546103ef90611960565b600061047d338484610f78565b60006108918484610470565b1561091c576040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081526001600160a01b03851690638f4ffcb1906108e19033908790309088906004016119d6565b600060405180830381600087803b1580156108fb57600080fd5b505af115801561090f573d6000803e3d6000fd5b50505050600190506105c7565b5060009392505050565b428410156109765760405162461bcd60e51b815260206004820152601260248201527f5065726d697373696f6e2065787069726564000000000000000000000000000060448201526064016104dd565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08111156109e65760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202773272076616c7565000000000060448201526064016104dd565b8260ff16601b14806109fb57508260ff16601c145b610a475760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202776272076616c7565000000000060448201526064016104dd565b6000610a516105ce565b6001600160a01b038916600090815260036020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928c928c928c92909190610a9f83611a12565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e00160405160208183030381529060405280519060200120604051602001610b339291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610b9e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610bd45750886001600160a01b0316816001600160a01b0316145b610c205760405162461bcd60e51b815260206004820152601160248201527f496e76616c6964207369676e617475726500000000000000000000000000000060448201526064016104dd565b610c2b898989610dea565b505050505050505050565b6000546001600160a01b03163314610c905760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104dd565b6001600160a01b038116610d0c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104dd565b61076c8161132e565b6000546001600160a01b03163314610d6f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104dd565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde90610dbc9030908890889088908890600401611a2b565b600060405180830381600087803b158015610dd657600080fd5b505af1158015610c2b573d6000803e3d6000fd5b6001600160a01b038316610e405760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f206164647265737300000060448201526064016104dd565b6001600160a01b038216610e965760405162461bcd60e51b815260206004820152601b60248201527f417070726f766520746f20746865207a65726f2061646472657373000000000060448201526064016104dd565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526104fa908490611396565b6001600160a01b038316610fce5760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f2061646472657373000060448201526064016104dd565b6001600160a01b0382166110245760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016104dd565b306001600160a01b0383160361107c5760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e206164647265737300000060448201526064016104dd565b6001600160a01b038316600090815260016020526040902054818110156110e55760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e63650060448201526064016104dd565b6110ef82826119b0565b6001600160a01b0380861660009081526001602052604080822093909355908516815290812080548492906111259084906119c3565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161117191815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60056040516111b19190611a7f565b604080519182900382208282018252600183527f31000000000000000000000000000000000000000000000000000000000000006020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b038216600090815260016020526040902054818110156112b35760405162461bcd60e51b815260206004820152601b60248201527f4275726e20616d6f756e7420657863656564732062616c616e6365000000000060448201526064016104dd565b6112bd82826119b0565b6001600160a01b038416600090815260016020526040812091909155600480548492906112eb9084906119b0565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610eeb565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006113eb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661147b9092919063ffffffff16565b8051909150156104fa57808060200190518101906114099190611b1e565b6104fa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104dd565b606061148a8484600085611492565b949350505050565b60608247101561150a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016104dd565b6001600160a01b0385163b6115615760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104dd565b600080866001600160a01b0316858760405161157d9190611b40565b60006040518083038185875af1925050503d80600081146115ba576040519150601f19603f3d011682016040523d82523d6000602084013e6115bf565b606091505b50915091506115cf8282866115da565b979650505050505050565b606083156115e95750816105c7565b8251156115f95782518084602001fd5b8160405162461bcd60e51b81526004016104dd9190611663565b60005b8381101561162e578181015183820152602001611616565b50506000910152565b6000815180845261164f816020860160208601611613565b601f01601f19169290920160200192915050565b6020815260006105c76020830184611637565b6001600160a01b038116811461076c57600080fd5b6000806040838503121561169e57600080fd5b82356116a981611676565b946020939093013593505050565b6000806000606084860312156116cc57600080fd5b83356116d781611676565b925060208401356116e781611676565b929592945050506040919091013590565b60006020828403121561170a57600080fd5b5035919050565b60006020828403121561172357600080fd5b81356105c781611676565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561175957600080fd5b833561176481611676565b925060208401359150604084013567ffffffffffffffff8082111561178857600080fd5b818601915086601f83011261179c57600080fd5b8135818111156117ae576117ae61172e565b604051601f8201601f19908116603f011681019083821181831017156117d6576117d661172e565b816040528281528960208487010111156117ef57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a03121561182c57600080fd5b873561183781611676565b9650602088013561184781611676565b95506040880135945060608801359350608088013560ff8116811461186b57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561189b57600080fd5b82356118a681611676565b915060208301356118b681611676565b809150509250929050565b6000806000806000608086880312156118d957600080fd5b85356118e481611676565b945060208601356118f481611676565b935060408601359250606086013567ffffffffffffffff8082111561191857600080fd5b818801915088601f83011261192c57600080fd5b81358181111561193b57600080fd5b89602082850101111561194d57600080fd5b9699959850939650602001949392505050565b600181811c9082168061197457607f821691505b60208210810361199457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156104815761048161199a565b808201808211156104815761048161199a565b60006001600160a01b03808716835285602084015280851660408401525060806060830152611a086080830184611637565b9695505050505050565b600060018201611a2457611a2461199a565b5060010190565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b600080835481600182811c915080831680611a9b57607f831692505b60208084108203611aba57634e487b7160e01b86526022600452602486fd5b818015611ace5760018114611ae357611b10565b60ff1986168952841515850289019650611b10565b60008a81526020902060005b86811015611b085781548b820152908501908301611aef565b505084890196505b509498975050505050505050565b600060208284031215611b3057600080fd5b815180151581146105c757600080fd5b60008251611b52818460208701611613565b919091019291505056fea264697066735822122014ba9a6dc40cd5a66877a573c7b8d56d9c3914d7f5b45a829d543c5233bd296664736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101985760003560e01c8063715018a6116100e3578063b4f94b2e1161008c578063dd62ed3e11610066578063dd62ed3e14610391578063f2fde38b146103bc578063fc4e51f6146103cf57600080fd5b8063b4f94b2e14610344578063cae9ca511461036b578063d505accf1461037e57600080fd5b80638da5cb5b116100bd5780638da5cb5b1461030e57806395d89b4114610329578063a9059cbb1461033157600080fd5b8063715018a6146102cc578063771da5c5146102d457806379cc6790146102fb57600080fd5b8063313ce5671161014557806342966c681161011f57806342966c681461027957806370a082311461028c57806370ae92d2146102ac57600080fd5b8063313ce567146102445780633644e5151461025e57806340c10f191461026657600080fd5b806318160ddd1161017657806318160ddd146101f357806323b872dd1461020a57806330adf81f1461021d57600080fd5b806306fdde031461019d578063095ea7b3146101bb5780631171bda9146101de575b600080fd5b6101a56103e2565b6040516101b29190611663565b60405180910390f35b6101ce6101c936600461168b565b610470565b60405190151581526020016101b2565b6101f16101ec3660046116b7565b610487565b005b6101fc60045481565b6040519081526020016101b2565b6101ce6102183660046116b7565b6104ff565b6101fc7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b61024c601281565b60405160ff90911681526020016101b2565b6101fc6105ce565b6101f161027436600461168b565b610629565b6101f16102873660046116f8565b610762565b6101fc61029a366004611711565b60016020526000908152604090205481565b6101fc6102ba366004611711565b60036020526000908152604090205481565b6101f161076f565b6101fc7f000000000000000000000000000000000000000000000000000000000000000081565b6101f161030936600461168b565b6107d5565b6000546040516001600160a01b0390911681526020016101b2565b6101a561086b565b6101ce61033f36600461168b565b610878565b6101fc7f000000000000000000000000000000000000000000000000000000000000000081565b6101ce610379366004611744565b610885565b6101f161038c366004611811565b610926565b6101fc61039f366004611888565b600260209081526000928352604080842090915290825290205481565b6101f16103ca366004611711565b610c36565b6101f16103dd3660046118c1565b610d15565b600580546103ef90611960565b80601f016020809104026020016040519081016040528092919081815260200182805461041b90611960565b80156104685780601f1061043d57610100808354040283529160200191610468565b820191906000526020600020905b81548152906001019060200180831161044b57829003601f168201915b505050505081565b600061047d338484610dea565b5060015b92915050565b6000546001600160a01b031633146104e65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b6104fa6001600160a01b0384168383610ef8565b505050565b6001600160a01b038316600090815260026020908152604080832033845290915281205460001981146105b657828110156105a25760405162461bcd60e51b815260206004820152602160248201527f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360448201527f650000000000000000000000000000000000000000000000000000000000000060648201526084016104dd565b6105b685336105b186856119b0565b610dea565b6105c1858585610f78565b60019150505b9392505050565b60007f0000000000000000000000000000000000000000000000000000000000000000460361061c57507f000000000000000000000000000000000000000000000000000000000000000090565b61062461117f565b905090565b6000546001600160a01b031633146106835760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104dd565b6001600160a01b0382166106d95760405162461bcd60e51b815260206004820152601860248201527f4d696e7420746f20746865207a65726f2061646472657373000000000000000060448201526064016104dd565b80600460008282546106eb91906119c3565b90915550506001600160a01b038216600090815260016020526040812080548392906107189084906119c3565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b61076c338261124a565b50565b6000546001600160a01b031633146107c95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104dd565b6107d3600061132e565b565b6001600160a01b0382166000908152600260209081526040808320338452909152902054600019811461086157818110156108525760405162461bcd60e51b815260206004820152601d60248201527f4275726e20616d6f756e74206578636565647320616c6c6f77616e636500000060448201526064016104dd565b61086183336105b185856119b0565b6104fa838361124a565b600680546103ef90611960565b600061047d338484610f78565b60006108918484610470565b1561091c576040517f8f4ffcb10000000000000000000000000000000000000000000000000000000081526001600160a01b03851690638f4ffcb1906108e19033908790309088906004016119d6565b600060405180830381600087803b1580156108fb57600080fd5b505af115801561090f573d6000803e3d6000fd5b50505050600190506105c7565b5060009392505050565b428410156109765760405162461bcd60e51b815260206004820152601260248201527f5065726d697373696f6e2065787069726564000000000000000000000000000060448201526064016104dd565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08111156109e65760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202773272076616c7565000000000060448201526064016104dd565b8260ff16601b14806109fb57508260ff16601c145b610a475760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964207369676e6174757265202776272076616c7565000000000060448201526064016104dd565b6000610a516105ce565b6001600160a01b038916600090815260036020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928c928c928c92909190610a9f83611a12565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e00160405160208183030381529060405280519060200120604051602001610b339291907f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015610b9e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811615801590610bd45750886001600160a01b0316816001600160a01b0316145b610c205760405162461bcd60e51b815260206004820152601160248201527f496e76616c6964207369676e617475726500000000000000000000000000000060448201526064016104dd565b610c2b898989610dea565b505050505050505050565b6000546001600160a01b03163314610c905760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104dd565b6001600160a01b038116610d0c5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104dd565b61076c8161132e565b6000546001600160a01b03163314610d6f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104dd565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde90610dbc9030908890889088908890600401611a2b565b600060405180830381600087803b158015610dd657600080fd5b505af1158015610c2b573d6000803e3d6000fd5b6001600160a01b038316610e405760405162461bcd60e51b815260206004820152601d60248201527f417070726f76652066726f6d20746865207a65726f206164647265737300000060448201526064016104dd565b6001600160a01b038216610e965760405162461bcd60e51b815260206004820152601b60248201527f417070726f766520746f20746865207a65726f2061646472657373000000000060448201526064016104dd565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001790526104fa908490611396565b6001600160a01b038316610fce5760405162461bcd60e51b815260206004820152601e60248201527f5472616e736665722066726f6d20746865207a65726f2061646472657373000060448201526064016104dd565b6001600160a01b0382166110245760405162461bcd60e51b815260206004820152601c60248201527f5472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016104dd565b306001600160a01b0383160361107c5760405162461bcd60e51b815260206004820152601d60248201527f5472616e7366657220746f2074686520746f6b656e206164647265737300000060448201526064016104dd565b6001600160a01b038316600090815260016020526040902054818110156110e55760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657220616d6f756e7420657863656564732062616c616e63650060448201526064016104dd565b6110ef82826119b0565b6001600160a01b0380861660009081526001602052604080822093909355908516815290812080548492906111259084906119c3565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161117191815260200190565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60056040516111b19190611a7f565b604080519182900382208282018252600183527f31000000000000000000000000000000000000000000000000000000000000006020938401528151928301939093528101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6001600160a01b038216600090815260016020526040902054818110156112b35760405162461bcd60e51b815260206004820152601b60248201527f4275726e20616d6f756e7420657863656564732062616c616e6365000000000060448201526064016104dd565b6112bd82826119b0565b6001600160a01b038416600090815260016020526040812091909155600480548492906112eb9084906119b0565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90602001610eeb565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006113eb826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661147b9092919063ffffffff16565b8051909150156104fa57808060200190518101906114099190611b1e565b6104fa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104dd565b606061148a8484600085611492565b949350505050565b60608247101561150a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016104dd565b6001600160a01b0385163b6115615760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104dd565b600080866001600160a01b0316858760405161157d9190611b40565b60006040518083038185875af1925050503d80600081146115ba576040519150601f19603f3d011682016040523d82523d6000602084013e6115bf565b606091505b50915091506115cf8282866115da565b979650505050505050565b606083156115e95750816105c7565b8251156115f95782518084602001fd5b8160405162461bcd60e51b81526004016104dd9190611663565b60005b8381101561162e578181015183820152602001611616565b50506000910152565b6000815180845261164f816020860160208601611613565b601f01601f19169290920160200192915050565b6020815260006105c76020830184611637565b6001600160a01b038116811461076c57600080fd5b6000806040838503121561169e57600080fd5b82356116a981611676565b946020939093013593505050565b6000806000606084860312156116cc57600080fd5b83356116d781611676565b925060208401356116e781611676565b929592945050506040919091013590565b60006020828403121561170a57600080fd5b5035919050565b60006020828403121561172357600080fd5b81356105c781611676565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561175957600080fd5b833561176481611676565b925060208401359150604084013567ffffffffffffffff8082111561178857600080fd5b818601915086601f83011261179c57600080fd5b8135818111156117ae576117ae61172e565b604051601f8201601f19908116603f011681019083821181831017156117d6576117d661172e565b816040528281528960208487010111156117ef57600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600080600080600080600060e0888a03121561182c57600080fd5b873561183781611676565b9650602088013561184781611676565b95506040880135945060608801359350608088013560ff8116811461186b57600080fd5b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561189b57600080fd5b82356118a681611676565b915060208301356118b681611676565b809150509250929050565b6000806000806000608086880312156118d957600080fd5b85356118e481611676565b945060208601356118f481611676565b935060408601359250606086013567ffffffffffffffff8082111561191857600080fd5b818801915088601f83011261192c57600080fd5b81358181111561193b57600080fd5b89602082850101111561194d57600080fd5b9699959850939650602001949392505050565b600181811c9082168061197457607f821691505b60208210810361199457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b818103818111156104815761048161199a565b808201808211156104815761048161199a565b60006001600160a01b03808716835285602084015280851660408401525060806060830152611a086080830184611637565b9695505050505050565b600060018201611a2457611a2461199a565b5060010190565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f85011683010190509695505050505050565b600080835481600182811c915080831680611a9b57607f831692505b60208084108203611aba57634e487b7160e01b86526022600452602486fd5b818015611ace5760018114611ae357611b10565b60ff1986168952841515850289019650611b10565b60008a81526020902060005b86811015611b085781548b820152908501908301611aef565b505084890196505b509498975050505050505050565b600060208284031215611b3057600080fd5b815180151581146105c757600080fd5b60008251611b52818460208701611613565b919091019291505056fea264697066735822122014ba9a6dc40cd5a66877a573c7b8d56d9c3914d7f5b45a829d543c5233bd296664736f6c63430008110033", + "devdoc": { + "kind": "dev", + "methods": { + "approve(address,uint256)": { + "details": "If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729", + "returns": { + "_0": "True if the operation succeeded." + } + }, + "approveAndCall(address,uint256,bytes)": { + "details": "If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.", + "returns": { + "_0": "True if both approval and `receiveApproval` calls succeeded." + } + }, + "burn(uint256)": { + "details": "Requirements: - the caller must have a balance of at least `amount`." + }, + "burnFrom(address,uint256)": { + "details": "Requirements: - `account` must have a balance of at least `amount`, - the caller must have allowance for `account`'s tokens of at least `amount`." + }, + "mint(address,uint256)": { + "details": "Requirements: - `recipient` cannot be the zero address." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": { + "details": "The deadline argument can be set to `type(uint256).max to create permits that effectively never expire. If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transfer(address,uint256)": { + "details": "Requirements: - `recipient` cannot be the zero address, - the caller must have a balance of at least `amount`.", + "returns": { + "_0": "True if the operation succeeded, reverts otherwise." + } + }, + "transferFrom(address,address,uint256)": { + "details": "Requirements: - `spender` and `recipient` cannot be the zero address, - `spender` must have a balance of at least `amount`, - the caller must have allowance for `spender`'s tokens of at least `amount`.", + "returns": { + "_0": "True if the operation succeeded, reverts otherwise." + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "DOMAIN_SEPARATOR()": { + "notice": "Returns hash of EIP712 Domain struct with the token name as a signing domain and token contract as a verifying contract. Used to construct EIP2612 signature provided to `permit` function." + }, + "PERMIT_TYPEHASH()": { + "notice": "Returns EIP2612 Permit message hash. Used to construct EIP2612 signature provided to `permit` function." + }, + "allowance(address,address)": { + "notice": "The remaining number of tokens that spender will be allowed to spend on behalf of owner through `transferFrom` and `burnFrom`. This is zero by default." + }, + "approve(address,uint256)": { + "notice": "Sets `amount` as the allowance of `spender` over the caller's tokens." + }, + "approveAndCall(address,uint256,bytes)": { + "notice": "Calls `receiveApproval` function on spender previously approving the spender to withdraw from the caller multiple times, up to the `amount` amount. If this function is called again, it overwrites the current allowance with `amount`. Reverts if the approval reverted or if `receiveApproval` call on the spender reverted." + }, + "balanceOf(address)": { + "notice": "The amount of tokens owned by the given account." + }, + "burn(uint256)": { + "notice": "Destroys `amount` tokens from the caller." + }, + "burnFrom(address,uint256)": { + "notice": "Destroys `amount` of tokens from `account` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`." + }, + "decimals()": { + "notice": "The decimals places of the token." + }, + "mint(address,uint256)": { + "notice": "Creates `amount` tokens and assigns them to `account`, increasing the total supply." + }, + "name()": { + "notice": "The name of the token." + }, + "nonce(address)": { + "notice": "Returns the current nonce for EIP2612 permission for the provided token owner for a replay protection. Used to construct EIP2612 signature provided to `permit` function." + }, + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": { + "notice": "EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their tokens with a signature conforming EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, paying gas fees, and possibly performing other actions in the same transaction." + }, + "symbol()": { + "notice": "The symbol of the token." + }, + "totalSupply()": { + "notice": "The amount of tokens in existence." + }, + "transfer(address,uint256)": { + "notice": "Moves `amount` tokens from the caller's account to `recipient`." + }, + "transferFrom(address,address,uint256)": { + "notice": "Moves `amount` tokens from `spender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 13249, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 16610, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "balanceOf", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 16618, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "allowance", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 16624, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "nonce", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 16639, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "totalSupply", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 16643, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "name", + "offset": 0, + "slot": "5", + "type": "t_string_storage" + }, + { + "astId": 16647, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "symbol", + "offset": 0, + "slot": "6", + "type": "t_string_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} diff --git a/typescript/src/lib/ethereum/artifacts/goerli/TBTCVault.json b/typescript/src/lib/ethereum/artifacts/goerli/TBTCVault.json new file mode 100644 index 000000000..c55369319 --- /dev/null +++ b/typescript/src/lib/ethereum/artifacts/goerli/TBTCVault.json @@ -0,0 +1,1606 @@ +{ + "address": "0x65eB0562FCe858f8328858c76E689aBedB78621F", + "abi": [ + { + "inputs": [ + { + "internalType": "contract Bank", + "name": "_bank", + "type": "address" + }, + { + "internalType": "contract TBTC", + "name": "_tbtcToken", + "type": "address" + }, + { + "internalType": "contract Bridge", + "name": "_bridge", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "GuardianAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "GuardianRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Minted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "MinterAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "MinterRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "OptimisticMintingCancelled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "optimisticMintingDebt", + "type": "uint256" + } + ], + "name": "OptimisticMintingDebtRepaid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "newOptimisticMintingDelay", + "type": "uint32" + } + ], + "name": "OptimisticMintingDelayUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "newOptimisticMintingDelay", + "type": "uint32" + } + ], + "name": "OptimisticMintingDelayUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "newOptimisticMintingFeeDivisor", + "type": "uint32" + } + ], + "name": "OptimisticMintingFeeUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "newOptimisticMintingFeeDivisor", + "type": "uint32" + } + ], + "name": "OptimisticMintingFeeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "optimisticMintingDebt", + "type": "uint256" + } + ], + "name": "OptimisticMintingFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "OptimisticMintingPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "OptimisticMintingRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "OptimisticMintingUnpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Unminted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newVault", + "type": "address" + } + ], + "name": "UpgradeFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newVault", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "UpgradeInitiated", + "type": "event" + }, + { + "inputs": [], + "name": "GOVERNANCE_DELAY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SATOSHI_MULTIPLIER", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "addGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "addMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "amountToSatoshis", + "outputs": [ + { + "internalType": "uint256", + "name": "convertibleAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "remainder", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "satoshis", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bank", + "outputs": [ + { + "internalType": "contract Bank", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_newOptimisticMintingDelay", + "type": "uint32" + } + ], + "name": "beginOptimisticMintingDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_newOptimisticMintingFeeDivisor", + "type": "uint32" + } + ], + "name": "beginOptimisticMintingFeeUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "bridge", + "outputs": [ + { + "internalType": "contract Bridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "calculateDepositKey", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "cancelOptimisticMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "finalizeOptimisticMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeOptimisticMintingDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeOptimisticMintingFeeUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getMinters", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newVault", + "type": "address" + } + ], + "name": "initiateUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isGuardian", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isMinter", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isOptimisticMintingPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "minters", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newOptimisticMintingDelay", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newOptimisticMintingFeeDivisor", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "optimisticMintingDebt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "optimisticMintingDelay", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "optimisticMintingDelayUpdateInitiatedTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "optimisticMintingFeeDivisor", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "optimisticMintingFeeUpdateInitiatedTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "optimisticMintingRequests", + "outputs": [ + { + "internalType": "uint64", + "name": "requestedAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "finalizedAt", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseOptimisticMinting", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "receiveApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "satoshis", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "receiveBalanceApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "depositors", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "depositedSatoshiAmounts", + "type": "uint256[]" + } + ], + "name": "receiveBalanceIncrease", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20FromToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "recoverERC721", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "recoverERC721FromToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "removeGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "removeMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "requestOptimisticMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "tbtcToken", + "outputs": [ + { + "internalType": "contract TBTC", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "unmint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "redemptionData", + "type": "bytes" + } + ], + "name": "unmintAndRedeem", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpauseOptimisticMinting", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "upgradeInitiatedTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x8bcb0534a00a776fc21229184663ac39368db772ee2ba692dcf889265a7e8370", + "receipt": { + "to": null, + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0x65eB0562FCe858f8328858c76E689aBedB78621F", + "transactionIndex": 15, + "gasUsed": "3340784", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000200000001000000000000000000000000000000000000020000000000000000000800000000000000000000040000000000400000000200000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x487502d84725255efc9d9892c338cc0916437ebe118c95ebf566864efcce2d5f", + "transactionHash": "0x8bcb0534a00a776fc21229184663ac39368db772ee2ba692dcf889265a7e8370", + "logs": [ + { + "transactionIndex": 15, + "blockNumber": 8364960, + "transactionHash": "0x8bcb0534a00a776fc21229184663ac39368db772ee2ba692dcf889265a7e8370", + "address": "0x65eB0562FCe858f8328858c76E689aBedB78621F", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc" + ], + "data": "0x", + "logIndex": 19, + "blockHash": "0x487502d84725255efc9d9892c338cc0916437ebe118c95ebf566864efcce2d5f" + } + ], + "blockNumber": 8364960, + "cumulativeGasUsed": "7425600", + "status": 1, + "byzantium": true + }, + "args": [ + "0xd5040917dA4f297Fa20a2F3A4fF91416C08bfB39", + "0x679874fBE6D4E7Cc54A59e315FF1eB266686a937", + "0x0Cad3257C4B7ec6de1f6926Fbf5714255a6632c3" + ], + "numDeployments": 1, + "solcInputHash": "f862bd134ddc06352fa5be0644481600", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract Bank\",\"name\":\"_bank\",\"type\":\"address\"},{\"internalType\":\"contract TBTC\",\"name\":\"_tbtcToken\",\"type\":\"address\"},{\"internalType\":\"contract Bridge\",\"name\":\"_bridge\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"GuardianAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"GuardianRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Minted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"MinterAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"MinterRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"OptimisticMintingCancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticMintingDebt\",\"type\":\"uint256\"}],\"name\":\"OptimisticMintingDebtRepaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingDelay\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingDelayUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingDelay\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingDelayUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingFeeDivisor\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingFeeUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingFeeDivisor\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticMintingDebt\",\"type\":\"uint256\"}],\"name\":\"OptimisticMintingFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"OptimisticMintingPaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"OptimisticMintingUnpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Unminted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newVault\",\"type\":\"address\"}],\"name\":\"UpgradeFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newVault\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"UpgradeInitiated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GOVERNANCE_DELAY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SATOSHI_MULTIPLIER\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"addGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"addMinter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"amountToSatoshis\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"convertibleAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"remainder\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"satoshis\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bank\",\"outputs\":[{\"internalType\":\"contract Bank\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_newOptimisticMintingDelay\",\"type\":\"uint32\"}],\"name\":\"beginOptimisticMintingDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_newOptimisticMintingFeeDivisor\",\"type\":\"uint32\"}],\"name\":\"beginOptimisticMintingFeeUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contract Bridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"calculateDepositKey\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"cancelOptimisticMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"finalizeOptimisticMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeOptimisticMintingDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeOptimisticMintingFeeUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinters\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newVault\",\"type\":\"address\"}],\"name\":\"initiateUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isGuardian\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isMinter\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isOptimisticMintingPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"minters\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newOptimisticMintingDelay\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newOptimisticMintingFeeDivisor\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newVault\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"optimisticMintingDebt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingDelay\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingDelayUpdateInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingFeeDivisor\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingFeeUpdateInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"optimisticMintingRequests\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"requestedAt\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"finalizedAt\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseOptimisticMinting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"extraData\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"satoshis\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"receiveBalanceApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"depositors\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"depositedSatoshiAmounts\",\"type\":\"uint256[]\"}],\"name\":\"receiveBalanceIncrease\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverERC20FromToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC721\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recoverERC721\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC721\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recoverERC721FromToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"removeGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"removeMinter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"requestOptimisticMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcToken\",\"outputs\":[{\"internalType\":\"contract TBTC\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"unmint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"redemptionData\",\"type\":\"bytes\"}],\"name\":\"unmintAndRedeem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpauseOptimisticMinting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"upgradeInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"TBTC Vault is the owner of TBTC token contract and is the only contract minting the token.\",\"kind\":\"dev\",\"methods\":{\"amountToSatoshis(uint256)\":{\"returns\":{\"convertibleAmount\":\"Amount of TBTC to be minted/unminted.\",\"remainder\":\"Not convertible remainder if amount is not divisible by SATOSHI_MULTIPLIER.\",\"satoshis\":\"Amount in satoshis - the Bank balance to be transferred for the given mint/unmint\"}},\"beginOptimisticMintingFeeUpdate(uint32)\":{\"details\":\"See the documentation for optimisticMintingFeeDivisor.\"},\"cancelOptimisticMint(bytes32,uint32)\":{\"details\":\"Guardians must validate the following conditions for every deposit for which the optimistic minting was requested: - The deposit happened on Bitcoin side and it has enough confirmations. - The optimistic minting has been requested early enough so that the wallet has enough time to sweep the deposit. - The wallet is an active one and it does perform sweeps or it will perform sweeps once the sweeps are activated.\"},\"initiateUpgrade(address)\":{\"params\":{\"_newVault\":\"The new vault address.\"}},\"mint(uint256)\":{\"details\":\"TBTC Vault must have an allowance for caller's balance in the Bank for at least `amount / SATOSHI_MULTIPLIER`.\",\"params\":{\"amount\":\"Amount of TBTC to mint.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"details\":\"This function is doing the same as `unmint` or `unmintAndRedeem` (depending on `extraData` parameter) but it allows to execute unminting without a separate approval transaction. The function can be called only via `approveAndCall` of TBTC token.\",\"params\":{\"amount\":\"Amount of TBTC to unmint.\",\"extraData\":\"Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function. If empty, `receiveApproval` is not requesting a redemption of Bank balance but is instead performing just TBTC unminting to a Bank balance.\",\"from\":\"TBTC token holder executing unminting.\",\"token\":\"TBTC token address.\"}},\"receiveBalanceApproval(address,uint256,bytes)\":{\"details\":\"Can only be called by the Bank via `approveBalanceAndCall`.\",\"params\":{\"owner\":\"The owner who approved their Bank balance.\",\"satoshis\":\"Amount of satoshis used to mint TBTC.\"}},\"receiveBalanceIncrease(address[],uint256[])\":{\"details\":\"Fails if `depositors` array is empty. Expects the length of `depositors` and `depositedSatoshiAmounts` is the same.\"},\"recoverERC20(address,address,uint256)\":{\"params\":{\"amount\":\"Recovered amount.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC20 token contract.\"}},\"recoverERC20FromToken(address,address,uint256)\":{\"params\":{\"amount\":\"Recovered amount.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC20 token contract.\"}},\"recoverERC721(address,address,uint256,bytes)\":{\"params\":{\"data\":\"Additional data.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC721 token contract.\",\"tokenId\":\"Identifier of the recovered token.\"}},\"recoverERC721FromToken(address,address,uint256,bytes)\":{\"params\":{\"data\":\"Additional data.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC721 token contract.\",\"tokenId\":\"Identifier of the recovered token.\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"requestOptimisticMint(bytes32,uint32)\":{\"details\":\"The deposit done on the Bitcoin side must be revealed early enough to the Bridge on Ethereum to pass the Bridge's validation. The validation passes successfully only if the deposit reveal is done respectively earlier than the moment when the deposit refund locktime is reached, i.e. the deposit becomes refundable. It may happen that the wallet does not sweep a revealed deposit and one of the Minters requests an optimistic mint for that deposit just before the locktime is reached. Guardians must cancel optimistic minting for this deposit because the wallet will not be able to sweep it. The on-chain optimistic minting code does not perform any validation for gas efficiency: it would have to perform the same validation as `validateDepositRefundLocktime` and expect the entire `DepositRevealInfo` to be passed to assemble the expected script hash on-chain. Guardians must validate if the deposit happened on Bitcoin, that the script hash has the expected format, and that the wallet is an active one so they can also validate the time left for the refund.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"unmint(uint256)\":{\"details\":\"Caller must have at least `amount` of TBTC approved to TBTC Vault.\",\"params\":{\"amount\":\"Amount of TBTC to unmint.\"}},\"unmintAndRedeem(uint256,bytes)\":{\"details\":\"Caller must have at least `amount` of TBTC approved to TBTC Vault.\",\"params\":{\"amount\":\"Amount of TBTC to unmint and request to redeem in Bridge.\",\"redemptionData\":\"Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function.\"}}},\"title\":\"TBTC application vault\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"GOVERNANCE_DELAY()\":{\"notice\":\"The time delay that needs to pass between initializing and finalizing the upgrade of governable parameters.\"},\"SATOSHI_MULTIPLIER()\":{\"notice\":\"Multiplier to convert satoshi to TBTC token units.\"},\"addGuardian(address)\":{\"notice\":\"Adds the address to the Guardian set.\"},\"addMinter(address)\":{\"notice\":\"Adds the address to the Minter list.\"},\"amountToSatoshis(uint256)\":{\"notice\":\"Returns the amount of TBTC to be minted/unminted, the remainder, and the Bank balance to be transferred for the given mint/unmint. Note that if the `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account when minting or unminting.\"},\"beginOptimisticMintingDelayUpdate(uint32)\":{\"notice\":\"Begins the process of updating optimistic minting delay.\"},\"beginOptimisticMintingFeeUpdate(uint32)\":{\"notice\":\"Begins the process of updating optimistic minting fee. The fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2% of each deposit, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`.\"},\"calculateDepositKey(bytes32,uint32)\":{\"notice\":\"Calculates deposit key the same way as the Bridge contract. The deposit key is computed as `keccak256(fundingTxHash | fundingOutputIndex)`.\"},\"cancelOptimisticMint(bytes32,uint32)\":{\"notice\":\"Allows a Guardian to cancel optimistic minting request. The following conditions must be met: - The optimistic minting request for the given deposit exists. - The optimistic minting request for the given deposit has not been finalized yet. Optimistic minting request is removed. It is possible to request optimistic minting again for the same deposit later.\"},\"finalizeOptimisticMint(bytes32,uint32)\":{\"notice\":\"Allows a Minter to finalize previously requested optimistic minting. The following conditions must be met: - The optimistic minting has been requested for the given deposit. - The deposit has not been swept yet. - At least `optimisticMintingDelay` passed since the optimistic minting was requested for the given deposit. - The optimistic minting has not been finalized earlier for the given deposit. - The optimistic minting request for the given deposit has not been canceled by a Guardian. - The optimistic minting is not paused. This function mints TBTC and increases `optimisticMintingDebt` for the given depositor. The optimistic minting request is marked as finalized.\"},\"finalizeOptimisticMintingDelayUpdate()\":{\"notice\":\"Finalizes the update process of the optimistic minting delay.\"},\"finalizeOptimisticMintingFeeUpdate()\":{\"notice\":\"Finalizes the update process of the optimistic minting fee.\"},\"finalizeUpgrade()\":{\"notice\":\"Allows the governance to finalize vault upgrade process. The upgrade process needs to be first initiated with a call to `initiateUpgrade` and the `GOVERNANCE_DELAY` needs to pass. Once the upgrade is finalized, the new vault becomes the owner of the TBTC token and receives the whole Bank balance of this vault.\"},\"getMinters()\":{\"notice\":\"Allows to fetch a list of all Minters.\"},\"initiateUpgrade(address)\":{\"notice\":\"Initiates vault upgrade process. The upgrade process needs to be finalized with a call to `finalizeUpgrade` function after the `UPGRADE_GOVERNANCE_DELAY` passes. Only the governance can initiate the upgrade.\"},\"isGuardian(address)\":{\"notice\":\"Indicates if the given address is a Guardian. Only Guardians can cancel requested optimistic minting.\"},\"isMinter(address)\":{\"notice\":\"Indicates if the given address is a Minter. Only Minters can request optimistic minting.\"},\"isOptimisticMintingPaused()\":{\"notice\":\"Indicates if the optimistic minting has been paused. Only the Governance can pause optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits.\"},\"mint(uint256)\":{\"notice\":\"Mints the given `amount` of TBTC to the caller previously transferring `amount / SATOSHI_MULTIPLIER` of the Bank balance from caller to TBTC Vault. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's Bank balance.\"},\"minters(uint256)\":{\"notice\":\"List of all Minters.\"},\"newOptimisticMintingDelay()\":{\"notice\":\"New optimistic minting delay value. Set only when the parameter update process is pending. Once the update gets finalized, this\"},\"newOptimisticMintingFeeDivisor()\":{\"notice\":\"New optimistic minting fee divisor value. Set only when the parameter update process is pending. Once the update gets\"},\"newVault()\":{\"notice\":\"The address of a new TBTC vault. Set only when the upgrade process is pending. Once the upgrade gets finalized, the new TBTC vault will become an owner of TBTC token.\"},\"optimisticMintingDebt(address)\":{\"notice\":\"Optimistic minting debt value per depositor's address. The debt represents the total value of all depositor's deposits revealed to the Bridge that has not been yet swept and led to the optimistic minting of TBTC. When `TBTCVault` sweeps a deposit, the debt is fully or partially paid off, no matter if that particular swept deposit was used for the optimistic minting or not. The values are in 1e18 Ethereum precision.\"},\"optimisticMintingDelay()\":{\"notice\":\"The time that needs to pass between the moment the optimistic minting is requested and the moment optimistic minting is finalized with minting TBTC.\"},\"optimisticMintingDelayUpdateInitiatedTimestamp()\":{\"notice\":\"The timestamp at which the update of the optimistic minting delay started. Zero if update is not in progress.\"},\"optimisticMintingFeeDivisor()\":{\"notice\":\"Divisor used to compute the treasury fee taken from each optimistically minted deposit and transferred to the treasury upon finalization of the optimistic mint. This fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2%, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`. The optimistic minting fee does not replace the deposit treasury fee cut by the Bridge. The optimistic fee is a percentage AFTER the treasury fee is cut: `optimisticMintingFee = (depositAmount - treasuryFee) / optimisticMintingFeeDivisor`\"},\"optimisticMintingFeeUpdateInitiatedTimestamp()\":{\"notice\":\"The timestamp at which the update of the optimistic minting fee divisor started. Zero if update is not in progress.\"},\"optimisticMintingRequests(uint256)\":{\"notice\":\"Collection of all revealed deposits for which the optimistic minting was requested. Indexed by a deposit key computed as `keccak256(fundingTxHash | fundingOutputIndex)`.\"},\"pauseOptimisticMinting()\":{\"notice\":\"Pauses the optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Burns `amount` of TBTC from the caller's balance. If `extraData` is empty, transfers `amount` back to the caller's balance in the Bank. If `extraData` is not empty, requests redemption in the Bridge using the `extraData` as a `redemptionData` parameter to Bridge's `receiveBalanceApproval` function. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account. Note that it may left a token approval equal to the remainder.\"},\"receiveBalanceApproval(address,uint256,bytes)\":{\"notice\":\"Transfers `satoshis` of the Bank balance from the caller to TBTC Vault and mints `satoshis * SATOSHI_MULTIPLIER` of TBTC to the caller.\"},\"receiveBalanceIncrease(address[],uint256[])\":{\"notice\":\"Mints the same amount of TBTC as the deposited satoshis amount multiplied by SATOSHI_MULTIPLIER for each depositor in the array. Can only be called by the Bank after the Bridge swept deposits and Bank increased balance for the vault.\"},\"recoverERC20(address,address,uint256)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC20 token sent - mistakenly or not - to the vault address. This function should be used to withdraw TBTC v1 tokens transferred to TBTCVault as a result of VendingMachine > TBTCVault upgrade.\"},\"recoverERC20FromToken(address,address,uint256)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC20 token sent mistakenly to the TBTC token contract address.\"},\"recoverERC721(address,address,uint256,bytes)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the vault address.\"},\"recoverERC721FromToken(address,address,uint256,bytes)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the TBTC token contract address.\"},\"removeGuardian(address)\":{\"notice\":\"Removes the address from the Guardian set.\"},\"removeMinter(address)\":{\"notice\":\"Removes the address from the Minter list.\"},\"requestOptimisticMint(bytes32,uint32)\":{\"notice\":\"Allows a Minter to request for an optimistic minting of TBTC. The following conditions must be met: - There is no optimistic minting request for the deposit, finalized or not. - The deposit with the given Bitcoin funding transaction hash and output index has been revealed to the Bridge. - The deposit has not been swept yet. - The deposit is targeted into the TBTCVault. - The optimistic minting is not paused. After calling this function, the Minter has to wait for `optimisticMintingDelay` before finalizing the mint with a call to finalizeOptimisticMint.\"},\"unmint(uint256)\":{\"notice\":\"Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` back to the caller's balance in the Bank. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account.\"},\"unmintAndRedeem(uint256,bytes)\":{\"notice\":\"Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` of Bank balance to the Bridge requesting redemption based on the provided `redemptionData`. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account.\"},\"unpauseOptimisticMinting()\":{\"notice\":\"Unpauses the optimistic minting.\"},\"upgradeInitiatedTimestamp()\":{\"notice\":\"The timestamp at which an upgrade to a new TBTC vault was initiated. Set only when the upgrade process is pending.\"}},\"notice\":\"TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of Bitcoin. It facilitates Bitcoin holders to act on the Ethereum blockchain and access the decentralized finance (DeFi) ecosystem. TBTC Vault mints and unmints TBTC based on Bitcoin balances in the Bank.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/vault/TBTCVault.sol\":\"TBTCVault\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title BitcoinSPV */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\n\\nlibrary BTCUtils {\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n // The target at minimum Difficulty. Also the target of the genesis block\\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\\n\\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\\n\\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n\\n /* ***** */\\n /* UTILS */\\n /* ***** */\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _flag The first byte of a VarInt\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\\n return determineVarIntDataLengthAt(_flag, 0);\\n }\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _b The byte array containing a VarInt\\n /// @param _at The position of the VarInt in the array\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\\n if (uint8(_b[_at]) == 0xff) {\\n return 8; // one-byte flag, 8 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfe) {\\n return 4; // one-byte flag, 4 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfd) {\\n return 2; // one-byte flag, 2 bytes data\\n }\\n\\n return 0; // flag is data\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string starting with a VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\\n return parseVarIntAt(_b, 0);\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string containing a VarInt\\n /// @param _at The position of the VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\\n\\n if (_dataLen == 0) {\\n return (0, uint8(_b[_at]));\\n }\\n if (_b.length < 1 + _dataLen + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n uint256 _number;\\n if (_dataLen == 2) {\\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\\n } else if (_dataLen == 4) {\\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\\n } else if (_dataLen == 8) {\\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\\n }\\n return (_dataLen, _number);\\n }\\n\\n /// @notice Changes the endianness of a byte array\\n /// @dev Returns a new, backwards, bytes\\n /// @param _b The bytes to reverse\\n /// @return The reversed bytes\\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\\n bytes memory _newValue = new bytes(_b.length);\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _newValue[_b.length - i - 1] = _b[i];\\n }\\n\\n return _newValue;\\n }\\n\\n /// @notice Changes the endianness of a uint256\\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\\n // swap 8-byte long pairs\\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\\n // swap 16-byte long pairs\\n v = (v >> 128) | (v << 128);\\n }\\n\\n /// @notice Changes the endianness of a uint64\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = (v >> 32) | (v << 32);\\n }\\n\\n /// @notice Changes the endianness of a uint32\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF) |\\n ((v & 0x00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = (v >> 16) | (v << 16);\\n }\\n\\n /// @notice Changes the endianness of a uint24\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\\n }\\n\\n /// @notice Changes the endianness of a uint16\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\\n v = (_b << 8) | (_b >> 8);\\n }\\n\\n\\n /// @notice Converts big-endian bytes to a uint\\n /// @dev Traverses the byte array and sums the bytes\\n /// @param _b The big-endian bytes-encoded integer\\n /// @return The integer representation\\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\\n uint256 _number;\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\\n }\\n\\n return _number;\\n }\\n\\n /// @notice Get the last _num bytes from a byte array\\n /// @param _b The byte array to slice\\n /// @param _num The number of bytes to extract from the end\\n /// @return The last _num bytes of _b\\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\\n uint256 _start = _b.length.sub(_num);\\n\\n return _b.slice(_start, _num);\\n }\\n\\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\\n }\\n\\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\\n // read from position 12 = 0c\\n res := mload(0x0c)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash256(bytes memory _b) internal pure returns (bytes32) {\\n return sha256(abi.encodePacked(sha256(_b)));\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _a The first bytes32 of the pre-image\\n /// @param _b The second bytes32 of the pre-image\\n /// @return res The digest\\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(0x00, _a)\\n mstore(0x20, _b)\\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The array containing the pre-image\\n /// @param at The start of the pre-image\\n /// @param len The length of the pre-image\\n /// @return res The digest\\n function hash256Slice(\\n bytes memory _b,\\n uint256 at,\\n uint256 len\\n ) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /* ************ */\\n /* Legacy Input */\\n /* ************ */\\n\\n /// @notice Extracts the nth input from the vin (0-indexed)\\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\\n /// @param _vin The vin as a tightly-packed byte array\\n /// @param _index The 0-indexed location of the input to extract\\n /// @return The input as a byte array\\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nIns, \\\"Vin read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n _offset = _offset + _len;\\n }\\n\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _vin.slice(_offset, _len);\\n }\\n\\n /// @notice Determines whether an input is legacy\\n /// @dev False if no scriptSig, otherwise True\\n /// @param _input The input\\n /// @return True for legacy, False for witness\\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\\n return _input[36] != hex\\\"00\\\";\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The LEGACY input\\n /// @return The length of the script sig\\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\\n return extractScriptSigLenAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// starting at the specified position\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The byte array containing the LEGACY input\\n /// @param _at The position of the input in the array\\n /// @return The length of the script sig\\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\\n if (_input.length < 37 + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\\n\\n return (_varIntDataLen, _scriptSigLen);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The input\\n /// @return The length of the input in bytes\\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\\n return determineInputLengthAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig,\\n /// starting at the specified position\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input in the array\\n /// @return The length of the input in bytes\\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\\n }\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The LEGACY input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n /// @notice Extracts the sequence from the input\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The LEGACY input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\\n uint32 _beSequence = reverseUint32(_leSeqence);\\n return _beSequence;\\n }\\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\\n /// @dev Will return hex\\\"00\\\" if passed a witness input\\n /// @param _input The LEGACY input\\n /// @return The length-prepended scriptSig\\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n\\n /* ************* */\\n /* Witness Input */\\n /* ************* */\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The WITNESS input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(37);\\n }\\n\\n /// @notice Extracts the sequence from the input in a tx\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The WITNESS input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\\n uint32 _inputeSequence = reverseUint32(_leSeqence);\\n return _inputeSequence;\\n }\\n\\n /// @notice Extracts the outpoint from the input in a tx\\n /// @dev 32-byte tx id with 4-byte index\\n /// @param _input The input\\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\\n return _input.slice(0, 36);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// @dev 32-byte tx id\\n /// @param _input The input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\\n return _input.slice32(0);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// starting at the specified position\\n /// @dev 32-byte tx id\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\\n return _input.slice32(_at);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// @dev 4-byte tx index\\n /// @param _input The input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(32);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// starting at the specified position\\n /// @dev 4-byte tx index\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\\n return _input.slice4(32 + _at);\\n }\\n\\n /* ****** */\\n /* Output */\\n /* ****** */\\n\\n /// @notice Determines the length of an output\\n /// @dev Works with any properly formatted output\\n /// @param _output The output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\\n return determineOutputLengthAt(_output, 0);\\n }\\n\\n /// @notice Determines the length of an output\\n /// starting at the specified position\\n /// @dev Works with any properly formatted output\\n /// @param _output The byte array containing the output\\n /// @param _at The position of the output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\\n if (_output.length < 9 + _at) {\\n return ERR_BAD_ARG;\\n }\\n uint256 _varIntDataLen;\\n uint256 _scriptPubkeyLength;\\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\\n\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n // 8-byte value, 1-byte for tag itself\\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\\n }\\n\\n /// @notice Extracts the output at a given index in the TxOuts vector\\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\\n /// @param _vout The _vout to extract from\\n /// @param _index The 0-indexed location of the output to extract\\n /// @return The specified output\\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nOuts, \\\"Vout read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n _offset += _len;\\n }\\n\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n return _vout.slice(_offset, _len);\\n }\\n\\n /// @notice Extracts the value bytes from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value as LE bytes\\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\\n return _output.slice8(0);\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value\\n function extractValue(bytes memory _output) internal pure returns (uint64) {\\n uint64 _leValue = uint64(extractValueLE(_output));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output in the array\\n /// @return The output value\\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\\n uint64 _leValue = uint64(_output.slice8(_at));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the data from an op return output\\n /// @dev Returns hex\\\"\\\" if no data or not an op return\\n /// @param _output The output\\n /// @return Any data contained in the opreturn output, null if not an op return\\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\\n if (_output[9] != hex\\\"6a\\\") {\\n return hex\\\"\\\";\\n }\\n bytes1 _dataLen = _output[10];\\n return _output.slice(11, uint256(uint8(_dataLen)));\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The output\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\\n return extractHashAt(_output, 8, _output.length - 8);\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output script in the array\\n /// (output start + 8)\\n /// @param _len The length of the output script\\n /// (output length - 8)\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHashAt(\\n bytes memory _output,\\n uint256 _at,\\n uint256 _len\\n ) internal pure returns (bytes memory) {\\n uint8 _scriptLen = uint8(_output[_at]);\\n\\n // don't have to worry about overflow here.\\n // if _scriptLen + 1 overflows, then output length would have to be < 1\\n // for this check to pass. if it's < 1, then we errored when assigning\\n // _scriptLen\\n if (_scriptLen + 1 != _len) {\\n return hex\\\"\\\";\\n }\\n\\n if (uint8(_output[_at + 1]) == 0) {\\n if (_scriptLen < 2) {\\n return hex\\\"\\\";\\n }\\n uint256 _payloadLen = uint8(_output[_at + 2]);\\n // Check for maliciously formatted witness outputs.\\n // No need to worry about underflow as long b/c of the `< 2` check\\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, _payloadLen);\\n } else {\\n bytes3 _tag = _output.slice3(_at);\\n // p2pkh\\n if (_tag == hex\\\"1976a9\\\") {\\n // Check for maliciously formatted p2pkh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + 3]) != 0x14 ||\\n _output.slice2(_at + _len - 2) != hex\\\"88ac\\\") {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 4, 20);\\n //p2sh\\n } else if (_tag == hex\\\"17a914\\\") {\\n // Check for maliciously formatted p2sh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + _len - 1]) != 0x87) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, 20);\\n }\\n }\\n return hex\\\"\\\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\\n }\\n\\n /* ********** */\\n /* Witness TX */\\n /* ********** */\\n\\n\\n /// @notice Checks that the vin passed up is properly formatted\\n /// @dev Consider a vin with a valid vout in its scriptsig\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @return True if it represents a validly formatted vin\\n function validateVin(bytes memory _vin) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n\\n // Not valid if it says there are too many or no inputs\\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nIns; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vin.length) {\\n return false;\\n }\\n\\n // Grab the next input and determine its length.\\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n // Increase the offset by that much\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vin.length;\\n }\\n\\n /// @notice Checks that the vout passed up is properly formatted\\n /// @dev Consider a vout with a valid scriptpubkey\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @return True if it represents a validly formatted vout\\n function validateVout(bytes memory _vout) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n\\n // Not valid if it says there are too many or no outputs\\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nOuts; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vout.length) {\\n return false;\\n }\\n\\n // Grab the next output and determine its length.\\n // Increase the offset by that much\\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vout.length;\\n }\\n\\n\\n\\n /* ************ */\\n /* Block Header */\\n /* ************ */\\n\\n /// @notice Extracts the transaction merkle root from a block header\\n /// @dev Use verifyHash256Merkle to verify proofs with this root\\n /// @param _header The header\\n /// @return The merkle root (little-endian)\\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(36);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The header\\n /// @return The target threshold\\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\\n return extractTargetAt(_header, 0);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The target threshold\\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\\n uint24 _m = uint24(_header.slice3(72 + at));\\n uint8 _e = uint8(_header[75 + at]);\\n uint256 _mantissa = uint256(reverseUint24(_m));\\n uint _exponent = _e - 3;\\n\\n return _mantissa * (256 ** _exponent);\\n }\\n\\n /// @notice Calculate difficulty from the difficulty 1 target and current target\\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _target The current target\\n /// @return The block difficulty (bdiff)\\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\\n // Difficulty 1 calculated from 0x1d00ffff\\n return DIFF1_TARGET.div(_target);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(4);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLEAt(\\n bytes memory _header,\\n uint256 at\\n ) internal pure returns (bytes32) {\\n return _header.slice32(4 + at);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (little-endian bytes)\\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\\n return _header.slice4(68);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (uint)\\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\\n return reverseUint32(uint32(extractTimestampLE(_header)));\\n }\\n\\n /// @notice Extracts the expected difficulty from a block header\\n /// @dev Does NOT verify the work\\n /// @param _header The header\\n /// @return The difficulty as an integer\\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\\n return calculateDifficulty(extractTarget(_header));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\\n return hash256View(abi.encodePacked(_a, _b));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\\n return hash256Pair(_a, _b);\\n }\\n\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Inefficient version.\\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_proof.length % 32 != 0) {\\n return false;\\n }\\n\\n // Special case for coinbase-only blocks\\n if (_proof.length == 32) {\\n return true;\\n }\\n\\n // Should never occur\\n if (_proof.length == 64) {\\n return false;\\n }\\n\\n bytes32 _root = _proof.slice32(_proof.length - 32);\\n bytes32 _current = _proof.slice32(0);\\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\\n\\n return verifyHash256Merkle(_current, _tree, _root, _index);\\n }\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Efficient version.\\n /// @param _leaf The leaf of the proof. LE sha256 hash.\\n /// @param _tree The intermediate nodes in the proof.\\n /// Tightly packed LE sha256 hashes.\\n /// @param _root The root of the proof. LE sha256 hash.\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(\\n bytes32 _leaf,\\n bytes memory _tree,\\n bytes32 _root,\\n uint _index\\n ) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_tree.length % 32 != 0) {\\n return false;\\n }\\n\\n // Should never occur\\n if (_tree.length == 0) {\\n return false;\\n }\\n\\n uint _idx = _index;\\n bytes32 _current = _leaf;\\n\\n // i moves in increments of 32\\n for (uint i = 0; i < _tree.length; i += 32) {\\n if (_idx % 2 == 1) {\\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\\n } else {\\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\\n }\\n _idx = _idx >> 1;\\n }\\n return _current == _root;\\n }\\n\\n /*\\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\\n NB: We get a full-bitlength target from this. For comparison with\\n header-encoded targets we need to mask it with the header target\\n e.g. (full & truncated) == truncated\\n */\\n /// @notice performs the bitcoin difficulty retarget\\n /// @dev implements the Bitcoin algorithm precisely\\n /// @param _previousTarget the target of the previous period\\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\\n /// @return the new period's target threshold\\n function retargetAlgorithm(\\n uint256 _previousTarget,\\n uint256 _firstTimestamp,\\n uint256 _secondTimestamp\\n ) internal pure returns (uint256) {\\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\\n\\n // Normalize ratio to factor of 4 if very long or very short\\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\\n _elapsedTime = RETARGET_PERIOD.div(4);\\n }\\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\\n _elapsedTime = RETARGET_PERIOD.mul(4);\\n }\\n\\n /*\\n NB: high targets e.g. ffff0020 can cause overflows here\\n so we divide it by 256**2, then multiply by 256**2 later\\n we know the target is evenly divisible by 256**2, so this isn't an issue\\n */\\n\\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\\n }\\n}\\n\",\"keccak256\":\"0x439eaa97e9239705f3d31e8d39dccbad32311f1f119e295d53c65e0ae3c5a5fc\"},\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\n\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\n\\nThis is free and unencumbered software released into the public domain.\\n\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\n\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\n\\nFor more information, please refer to \\n*/\\n\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(0x40, and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n ))\\n }\\n\\n return tempBytes;\\n }\\n\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let mlengthmod := mod(mlength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\\n if (_length == 0) {\\n return hex\\\"\\\";\\n }\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n /// @notice Take a slice of the byte array, overwriting the destination.\\n /// The length of the slice will equal the length of the destination array.\\n /// @dev Make sure the destination array has afterspace if required.\\n /// @param _bytes The source array\\n /// @param _dest The destination array.\\n /// @param _start The location to start in the source array.\\n function sliceInPlace(\\n bytes memory _bytes,\\n bytes memory _dest,\\n uint _start\\n ) internal pure {\\n uint _length = _dest.length;\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let res := add(_dest, 32)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n res := add(res, 32)\\n } {\\n mstore(res, mload(src))\\n }\\n }\\n }\\n\\n // Static slice functions, no bounds checking\\n /// @notice take a 32-byte slice from the specified position\\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\\n assembly {\\n res := mload(add(add(_bytes, 32), _start))\\n }\\n }\\n\\n /// @notice take a 20-byte slice from the specified position\\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\\n return bytes20(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 8-byte slice from the specified position\\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\\n return bytes8(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 4-byte slice from the specified position\\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\\n return bytes4(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 3-byte slice from the specified position\\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\\n return bytes3(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 2-byte slice from the specified position\\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\\n return bytes2(slice32(_bytes, _start));\\n }\\n\\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\\n uint _totalLen = _start + 20;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Address conversion out of bounds.\\\");\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\\n uint _totalLen = _start + 32;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Uint conversion out of bounds.\\\");\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {} eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x43e0f3b3b23c861bd031588bf410dfdd02e2af17941a89aa38d70e534e0380d1\"},\"@keep-network/bitcoin-spv-sol/contracts/CheckBitcoinSigs.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title CheckBitcoinSigs */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {BTCUtils} from \\\"./BTCUtils.sol\\\";\\n\\n\\nlibrary CheckBitcoinSigs {\\n\\n using BytesLib for bytes;\\n using BTCUtils for bytes;\\n\\n /// @notice Derives an Ethereum Account address from a pubkey\\n /// @dev The address is the last 20 bytes of the keccak256 of the address\\n /// @param _pubkey The public key X & Y. Unprefixed, as a 64-byte array\\n /// @return The account address\\n function accountFromPubkey(bytes memory _pubkey) internal pure returns (address) {\\n require(_pubkey.length == 64, \\\"Pubkey must be 64-byte raw, uncompressed key.\\\");\\n\\n // keccak hash of uncompressed unprefixed pubkey\\n bytes32 _digest = keccak256(_pubkey);\\n return address(uint160(uint256(_digest)));\\n }\\n\\n /// @notice Calculates the p2wpkh output script of a pubkey\\n /// @dev Compresses keys to 33 bytes as required by Bitcoin\\n /// @param _pubkey The public key, compressed or uncompressed\\n /// @return The p2wkph output script\\n function p2wpkhFromPubkey(bytes memory _pubkey) internal view returns (bytes memory) {\\n bytes memory _compressedPubkey;\\n uint8 _prefix;\\n\\n if (_pubkey.length == 64) {\\n _prefix = uint8(_pubkey[_pubkey.length - 1]) % 2 == 1 ? 3 : 2;\\n _compressedPubkey = abi.encodePacked(_prefix, _pubkey.slice32(0));\\n } else if (_pubkey.length == 65) {\\n _prefix = uint8(_pubkey[_pubkey.length - 1]) % 2 == 1 ? 3 : 2;\\n _compressedPubkey = abi.encodePacked(_prefix, _pubkey.slice32(1));\\n } else {\\n _compressedPubkey = _pubkey;\\n }\\n\\n require(_compressedPubkey.length == 33, \\\"Witness PKH requires compressed keys\\\");\\n\\n bytes20 _pubkeyHash = _compressedPubkey.hash160View();\\n return abi.encodePacked(hex\\\"0014\\\", _pubkeyHash);\\n }\\n\\n /// @notice checks a signed message's validity under a pubkey\\n /// @dev does this using ecrecover because Ethereum has no soul\\n /// @param _pubkey the public key to check (64 bytes)\\n /// @param _digest the message digest signed\\n /// @param _v the signature recovery value\\n /// @param _r the signature r value\\n /// @param _s the signature s value\\n /// @return true if signature is valid, else false\\n function checkSig(\\n bytes memory _pubkey,\\n bytes32 _digest,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) internal pure returns (bool) {\\n require(_pubkey.length == 64, \\\"Requires uncompressed unprefixed pubkey\\\");\\n address _expected = accountFromPubkey(_pubkey);\\n address _actual = ecrecover(_digest, _v, _r, _s);\\n return _actual == _expected;\\n }\\n\\n /// @notice checks a signed message against a bitcoin p2wpkh output script\\n /// @dev does this my verifying the p2wpkh matches an ethereum account\\n /// @param _p2wpkhOutputScript the bitcoin output script\\n /// @param _pubkey the uncompressed, unprefixed public key to check\\n /// @param _digest the message digest signed\\n /// @param _v the signature recovery value\\n /// @param _r the signature r value\\n /// @param _s the signature s value\\n /// @return true if signature is valid, else false\\n function checkBitcoinSig(\\n bytes memory _p2wpkhOutputScript,\\n bytes memory _pubkey,\\n bytes32 _digest,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) internal view returns (bool) {\\n require(_pubkey.length == 64, \\\"Requires uncompressed unprefixed pubkey\\\");\\n\\n bool _isExpectedSigner = keccak256(p2wpkhFromPubkey(_pubkey)) == keccak256(_p2wpkhOutputScript); // is it the expected signer?\\n if (!_isExpectedSigner) {return false;}\\n\\n bool _sigResult = checkSig(_pubkey, _digest, _v, _r, _s);\\n return _sigResult;\\n }\\n\\n /// @notice checks if a message is the sha256 preimage of a digest\\n /// @dev this is NOT the hash256! this step is necessary for ECDSA security!\\n /// @param _digest the digest\\n /// @param _candidate the purported preimage\\n /// @return true if the preimage matches the digest, else false\\n function isSha256Preimage(\\n bytes memory _candidate,\\n bytes32 _digest\\n ) internal pure returns (bool) {\\n return sha256(_candidate) == _digest;\\n }\\n\\n /// @notice checks if a message is the keccak256 preimage of a digest\\n /// @dev this step is necessary for ECDSA security!\\n /// @param _digest the digest\\n /// @param _candidate the purported preimage\\n /// @return true if the preimage matches the digest, else false\\n function isKeccak256Preimage(\\n bytes memory _candidate,\\n bytes32 _digest\\n ) internal pure returns (bool) {\\n return keccak256(_candidate) == _digest;\\n }\\n\\n /// @notice calculates the signature hash of a Bitcoin transaction with the provided details\\n /// @dev documented in bip143. many values are hardcoded here\\n /// @param _outpoint the bitcoin UTXO id (32-byte txid + 4-byte output index)\\n /// @param _inputPKH the input pubkeyhash (hash160(sender_pubkey))\\n /// @param _inputValue the value of the input in satoshi\\n /// @param _outputValue the value of the output in satoshi\\n /// @param _outputScript the length-prefixed output script\\n /// @return the double-sha256 (hash256) signature hash as defined by bip143\\n function wpkhSpendSighash(\\n bytes memory _outpoint, // 36-byte UTXO id\\n bytes20 _inputPKH, // 20-byte hash160\\n bytes8 _inputValue, // 8-byte LE\\n bytes8 _outputValue, // 8-byte LE\\n bytes memory _outputScript // lenght-prefixed output script\\n ) internal view returns (bytes32) {\\n // Fixes elements to easily make a 1-in 1-out sighash digest\\n // Does not support timelocks\\n // bytes memory _scriptCode = abi.encodePacked(\\n // hex\\\"1976a914\\\", // length, dup, hash160, pkh_length\\n // _inputPKH,\\n // hex\\\"88ac\\\"); // equal, checksig\\n\\n bytes32 _hashOutputs = abi.encodePacked(\\n _outputValue, // 8-byte LE\\n _outputScript).hash256View();\\n\\n bytes memory _sighashPreimage = abi.encodePacked(\\n hex\\\"01000000\\\", // version\\n _outpoint.hash256View(), // hashPrevouts\\n hex\\\"8cb9012517c817fead650287d61bdd9c68803b6bf9c64133dcab3e65b5a50cb9\\\", // hashSequence(00000000)\\n _outpoint, // outpoint\\n // p2wpkh script code\\n hex\\\"1976a914\\\", // length, dup, hash160, pkh_length\\n _inputPKH,\\n hex\\\"88ac\\\", // equal, checksig\\n // end script code\\n _inputValue, // value of the input in 8-byte LE\\n hex\\\"00000000\\\", // input nSequence\\n _hashOutputs, // hash of the single output\\n hex\\\"00000000\\\", // nLockTime\\n hex\\\"01000000\\\" // SIGHASH_ALL\\n );\\n return _sighashPreimage.hash256View();\\n }\\n\\n /// @notice calculates the signature hash of a Bitcoin transaction with the provided details\\n /// @dev documented in bip143. many values are hardcoded here\\n /// @param _outpoint the bitcoin UTXO id (32-byte txid + 4-byte output index)\\n /// @param _inputPKH the input pubkeyhash (hash160(sender_pubkey))\\n /// @param _inputValue the value of the input in satoshi\\n /// @param _outputValue the value of the output in satoshi\\n /// @param _outputPKH the output pubkeyhash (hash160(recipient_pubkey))\\n /// @return the double-sha256 (hash256) signature hash as defined by bip143\\n function wpkhToWpkhSighash(\\n bytes memory _outpoint, // 36-byte UTXO id\\n bytes20 _inputPKH, // 20-byte hash160\\n bytes8 _inputValue, // 8-byte LE\\n bytes8 _outputValue, // 8-byte LE\\n bytes20 _outputPKH // 20-byte hash160\\n ) internal view returns (bytes32) {\\n return wpkhSpendSighash(\\n _outpoint,\\n _inputPKH,\\n _inputValue,\\n _outputValue,\\n abi.encodePacked(\\n hex\\\"160014\\\", // wpkh tag\\n _outputPKH)\\n );\\n }\\n\\n /// @notice Preserved for API compatibility with older version\\n /// @dev documented in bip143. many values are hardcoded here\\n /// @param _outpoint the bitcoin UTXO id (32-byte txid + 4-byte output index)\\n /// @param _inputPKH the input pubkeyhash (hash160(sender_pubkey))\\n /// @param _inputValue the value of the input in satoshi\\n /// @param _outputValue the value of the output in satoshi\\n /// @param _outputPKH the output pubkeyhash (hash160(recipient_pubkey))\\n /// @return the double-sha256 (hash256) signature hash as defined by bip143\\n function oneInputOneOutputSighash(\\n bytes memory _outpoint, // 36-byte UTXO id\\n bytes20 _inputPKH, // 20-byte hash160\\n bytes8 _inputValue, // 8-byte LE\\n bytes8 _outputValue, // 8-byte LE\\n bytes20 _outputPKH // 20-byte hash160\\n ) internal view returns (bytes32) {\\n return wpkhToWpkhSighash(_outpoint, _inputPKH, _inputValue, _outputValue, _outputPKH);\\n }\\n\\n}\\n\",\"keccak256\":\"0xfffbd5486af77058fe9385d63d433da914a043994b1affdfcb87248aa10a234c\"},\"@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\nThe MIT License (MIT)\\n\\nCopyright (c) 2016 Smart Contract Solutions, Inc.\\n\\nPermission is hereby granted, free of charge, to any person obtaining\\na copy of this software and associated documentation files (the\\n\\\"Software\\\"), to deal in the Software without restriction, including\\nwithout limitation the rights to use, copy, modify, merge, publish,\\ndistribute, sublicense, and/or sell copies of the Software, and to\\npermit persons to whom the Software is furnished to do so, subject to\\nthe following conditions:\\n\\nThe above copyright notice and this permission notice shall be included\\nin all copies or substantial portions of the Software.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\\n*/\\n\\n\\n/**\\n * @title SafeMath\\n * @dev Math operations with safety checks that throw on error\\n */\\nlibrary SafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, throws on overflow.\\n */\\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (_a == 0) {\\n return 0;\\n }\\n\\n c = _a * _b;\\n require(c / _a == _b, \\\"Overflow during multiplication.\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\\n // uint256 c = _a / _b;\\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\\n return _a / _b;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n require(_b <= _a, \\\"Underflow during subtraction.\\\");\\n return _a - _b;\\n }\\n\\n /**\\n * @dev Adds two numbers, throws on overflow.\\n */\\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n c = _a + _b;\\n require(c >= _a, \\\"Overflow during addition.\\\");\\n return c;\\n }\\n}\\n\",\"keccak256\":\"0x35930d982394c7ffde439b82e5e696c5b21a6f09699d44861dfe409ef64084a3\"},\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title ValidateSPV*/\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\nimport {BTCUtils} from \\\"./BTCUtils.sol\\\";\\n\\n\\nlibrary ValidateSPV {\\n\\n using BTCUtils for bytes;\\n using BTCUtils for uint256;\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n enum InputTypes { NONE, LEGACY, COMPATIBILITY, WITNESS }\\n enum OutputTypes { NONE, WPKH, WSH, OP_RETURN, PKH, SH, NONSTANDARD }\\n\\n uint256 constant ERR_BAD_LENGTH = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n uint256 constant ERR_INVALID_CHAIN = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe;\\n uint256 constant ERR_LOW_WORK = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd;\\n\\n function getErrBadLength() internal pure returns (uint256) {\\n return ERR_BAD_LENGTH;\\n }\\n\\n function getErrInvalidChain() internal pure returns (uint256) {\\n return ERR_INVALID_CHAIN;\\n }\\n\\n function getErrLowWork() internal pure returns (uint256) {\\n return ERR_LOW_WORK;\\n }\\n\\n /// @notice Validates a tx inclusion in the block\\n /// @dev `index` is not a reliable indicator of location within a block\\n /// @param _txid The txid (LE)\\n /// @param _merkleRoot The merkle root (as in the block header)\\n /// @param _intermediateNodes The proof's intermediate nodes (digests between leaf and root)\\n /// @param _index The leaf's index in the tree (0-indexed)\\n /// @return true if fully valid, false otherwise\\n function prove(\\n bytes32 _txid,\\n bytes32 _merkleRoot,\\n bytes memory _intermediateNodes,\\n uint _index\\n ) internal view returns (bool) {\\n // Shortcut the empty-block case\\n if (_txid == _merkleRoot && _index == 0 && _intermediateNodes.length == 0) {\\n return true;\\n }\\n\\n // If the Merkle proof failed, bubble up error\\n return BTCUtils.verifyHash256Merkle(\\n _txid,\\n _intermediateNodes,\\n _merkleRoot,\\n _index\\n );\\n }\\n\\n /// @notice Hashes transaction to get txid\\n /// @dev Supports Legacy and Witness\\n /// @param _version 4-bytes version\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @param _locktime 4-byte tx locktime\\n /// @return 32-byte transaction id, little endian\\n function calculateTxId(\\n bytes4 _version,\\n bytes memory _vin,\\n bytes memory _vout,\\n bytes4 _locktime\\n ) internal view returns (bytes32) {\\n // Get transaction hash double-Sha256(version + nIns + inputs + nOuts + outputs + locktime)\\n return abi.encodePacked(_version, _vin, _vout, _locktime).hash256View();\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @notice Compares the hash of each header to the prevHash in the next header\\n /// @param headers Raw byte array of header chain\\n /// @return totalDifficulty The total accumulated difficulty of the header chain, or an error code\\n function validateHeaderChain(\\n bytes memory headers\\n ) internal view returns (uint256 totalDifficulty) {\\n\\n // Check header chain length\\n if (headers.length % 80 != 0) {return ERR_BAD_LENGTH;}\\n\\n // Initialize header start index\\n bytes32 digest;\\n\\n totalDifficulty = 0;\\n\\n for (uint256 start = 0; start < headers.length; start += 80) {\\n\\n // After the first header, check that headers are in a chain\\n if (start != 0) {\\n if (!validateHeaderPrevHash(headers, start, digest)) {return ERR_INVALID_CHAIN;}\\n }\\n\\n // ith header target\\n uint256 target = headers.extractTargetAt(start);\\n\\n // Require that the header has sufficient work\\n digest = headers.hash256Slice(start, 80);\\n if(uint256(digest).reverseUint256() > target) {\\n return ERR_LOW_WORK;\\n }\\n\\n // Add ith header difficulty to difficulty sum\\n totalDifficulty = totalDifficulty + target.calculateDifficulty();\\n }\\n }\\n\\n /// @notice Checks validity of header work\\n /// @param digest Header digest\\n /// @param target The target threshold\\n /// @return true if header work is valid, false otherwise\\n function validateHeaderWork(\\n bytes32 digest,\\n uint256 target\\n ) internal pure returns (bool) {\\n if (digest == bytes32(0)) {return false;}\\n return (uint256(digest).reverseUint256() < target);\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @dev Compares current header prevHash to previous header's digest\\n /// @param headers The raw bytes array containing the header\\n /// @param at The position of the header\\n /// @param prevHeaderDigest The previous header's digest\\n /// @return true if the connect is valid, false otherwise\\n function validateHeaderPrevHash(\\n bytes memory headers,\\n uint256 at,\\n bytes32 prevHeaderDigest\\n ) internal pure returns (bool) {\\n\\n // Extract prevHash of current header\\n bytes32 prevHash = headers.extractPrevBlockLEAt(at);\\n\\n // Compare prevHash of current header to previous header's digest\\n if (prevHash != prevHeaderDigest) {return false;}\\n\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0xce3febbf3ad3a7ff8a8effd0c7ccaf7ccfa2719578b537d49ea196f0bae8062b\"},\"@keep-network/ecdsa/contracts/EcdsaDkgValidator.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// Initial version copied from Keep Network Random Beacon:\\n// https://github.com/keep-network/keep-core/blob/5138c7628868dbeed3ae2164f76fccc6c1fbb9e8/solidity/random-beacon/contracts/DKGValidator.sol\\n//\\n// With the following differences:\\n// - group public key length,\\n// - group size and related thresholds,\\n// - documentation.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/libraries/BytesLib.sol\\\";\\nimport \\\"@keep-network/sortition-pools/contracts/SortitionPool.sol\\\";\\nimport \\\"./libraries/EcdsaDkg.sol\\\";\\n\\n/// @title DKG result validator\\n/// @notice EcdsaDkgValidator allows performing a full validation of DKG result,\\n/// including checking the format of fields in the result, declared\\n/// selected group members, and signatures of operators supporting the\\n/// result. The operator submitting the result should perform the\\n/// validation using a free contract call before submitting the result\\n/// to ensure their result is valid and can not be challenged. All other\\n/// network operators should perform validation of the submitted result\\n/// using a free contract call and challenge the result if the\\n/// validation fails.\\ncontract EcdsaDkgValidator {\\n using BytesLib for bytes;\\n using ECDSA for bytes32;\\n\\n /// @dev Size of a group in DKG.\\n uint256 public constant groupSize = 100;\\n\\n /// @dev The minimum number of group members needed to interact according to\\n /// the protocol to produce a signature. The adversary can not learn\\n /// anything about the key as long as it does not break into\\n /// groupThreshold+1 of members.\\n uint256 public constant groupThreshold = 51;\\n\\n /// @dev The minimum number of active and properly behaving group members\\n /// during the DKG needed to accept the result. This number is higher\\n /// than `groupThreshold` to keep a safety margin for members becoming\\n /// inactive after DKG so that the group can still produce signature.\\n uint256 public constant activeThreshold = 90; // 90% of groupSize\\n\\n /// @dev Size in bytes of a public key produced by group members during the\\n /// the DKG. The length assumes uncompressed ECDSA public key.\\n uint256 public constant publicKeyByteSize = 64;\\n\\n /// @dev Size in bytes of a single signature produced by operator supporting\\n /// DKG result.\\n uint256 public constant signatureByteSize = 65;\\n\\n SortitionPool public immutable sortitionPool;\\n\\n constructor(SortitionPool _sortitionPool) {\\n sortitionPool = _sortitionPool;\\n }\\n\\n /// @notice Performs a full validation of DKG result, including checking the\\n /// format of fields in the result, declared selected group members,\\n /// and signatures of operators supporting the result.\\n /// @param seed seed used to start the DKG and select group members\\n /// @param startBlock DKG start block\\n /// @return isValid true if the result is valid, false otherwise\\n /// @return errorMsg validation error message; empty for a valid result\\n function validate(\\n EcdsaDkg.Result calldata result,\\n uint256 seed,\\n uint256 startBlock\\n ) external view returns (bool isValid, string memory errorMsg) {\\n (bool hasValidFields, string memory error) = validateFields(result);\\n if (!hasValidFields) {\\n return (false, error);\\n }\\n\\n if (!validateSignatures(result, startBlock)) {\\n return (false, \\\"Invalid signatures\\\");\\n }\\n\\n if (!validateGroupMembers(result, seed)) {\\n return (false, \\\"Invalid group members\\\");\\n }\\n\\n // At this point all group members and misbehaved members were verified\\n if (!validateMembersHash(result)) {\\n return (false, \\\"Invalid members hash\\\");\\n }\\n\\n return (true, \\\"\\\");\\n }\\n\\n /// @notice Performs a static validation of DKG result fields: lengths,\\n /// ranges, and order of arrays.\\n /// @return isValid true if the result is valid, false otherwise\\n /// @return errorMsg validation error message; empty for a valid result\\n function validateFields(EcdsaDkg.Result calldata result)\\n public\\n pure\\n returns (bool isValid, string memory errorMsg)\\n {\\n if (result.groupPubKey.length != publicKeyByteSize) {\\n return (false, \\\"Malformed group public key\\\");\\n }\\n\\n // The number of misbehaved members can not exceed the threshold.\\n // Misbehaved member indices needs to be unique, between [1, groupSize],\\n // and sorted in ascending order.\\n uint8[] calldata misbehavedMembersIndices = result\\n .misbehavedMembersIndices;\\n if (groupSize - misbehavedMembersIndices.length < activeThreshold) {\\n return (false, \\\"Too many members misbehaving during DKG\\\");\\n }\\n if (misbehavedMembersIndices.length > 1) {\\n if (\\n misbehavedMembersIndices[0] < 1 ||\\n misbehavedMembersIndices[misbehavedMembersIndices.length - 1] >\\n groupSize\\n ) {\\n return (false, \\\"Corrupted misbehaved members indices\\\");\\n }\\n for (uint256 i = 1; i < misbehavedMembersIndices.length; i++) {\\n if (\\n misbehavedMembersIndices[i - 1] >=\\n misbehavedMembersIndices[i]\\n ) {\\n return (false, \\\"Corrupted misbehaved members indices\\\");\\n }\\n }\\n }\\n\\n // Each signature needs to have a correct length and signatures need to\\n // be provided.\\n uint256 signaturesCount = result.signatures.length / signatureByteSize;\\n if (result.signatures.length == 0) {\\n return (false, \\\"No signatures provided\\\");\\n }\\n if (result.signatures.length % signatureByteSize != 0) {\\n return (false, \\\"Malformed signatures array\\\");\\n }\\n\\n // We expect the same amount of signatures as the number of declared\\n // group member indices that signed the result.\\n uint256[] calldata signingMembersIndices = result.signingMembersIndices;\\n if (signaturesCount != signingMembersIndices.length) {\\n return (false, \\\"Unexpected signatures count\\\");\\n }\\n if (signaturesCount < groupThreshold) {\\n return (false, \\\"Too few signatures\\\");\\n }\\n if (signaturesCount > groupSize) {\\n return (false, \\\"Too many signatures\\\");\\n }\\n\\n // Signing member indices needs to be unique, between [1,groupSize],\\n // and sorted in ascending order.\\n if (\\n signingMembersIndices[0] < 1 ||\\n signingMembersIndices[signingMembersIndices.length - 1] > groupSize\\n ) {\\n return (false, \\\"Corrupted signing member indices\\\");\\n }\\n for (uint256 i = 1; i < signingMembersIndices.length; i++) {\\n if (signingMembersIndices[i - 1] >= signingMembersIndices[i]) {\\n return (false, \\\"Corrupted signing member indices\\\");\\n }\\n }\\n\\n return (true, \\\"\\\");\\n }\\n\\n /// @notice Performs validation of group members as declared in DKG\\n /// result against group members selected by the sortition pool.\\n /// @param seed seed used to start the DKG and select group members\\n /// @return true if group members matches; false otherwise\\n function validateGroupMembers(EcdsaDkg.Result calldata result, uint256 seed)\\n public\\n view\\n returns (bool)\\n {\\n uint32[] calldata resultMembers = result.members;\\n uint32[] memory actualGroupMembers = sortitionPool.selectGroup(\\n groupSize,\\n bytes32(seed)\\n );\\n if (resultMembers.length != actualGroupMembers.length) {\\n return false;\\n }\\n for (uint256 i = 0; i < resultMembers.length; i++) {\\n if (resultMembers[i] != actualGroupMembers[i]) {\\n return false;\\n }\\n }\\n return true;\\n }\\n\\n /// @notice Performs validation of signatures supplied in DKG result.\\n /// Note that this function does not check if addresses which\\n /// supplied signatures supporting the result are the ones selected\\n /// to the group by sortition pool. This function should be used\\n /// together with `validateGroupMembers`.\\n /// @param startBlock DKG start block\\n /// @return true if group members matches; false otherwise\\n function validateSignatures(\\n EcdsaDkg.Result calldata result,\\n uint256 startBlock\\n ) public view returns (bool) {\\n bytes32 hash = keccak256(\\n abi.encode(\\n block.chainid,\\n result.groupPubKey,\\n result.misbehavedMembersIndices,\\n startBlock\\n )\\n ).toEthSignedMessageHash();\\n\\n uint256[] calldata signingMembersIndices = result.signingMembersIndices;\\n uint32[] memory signingMemberIds = new uint32[](\\n signingMembersIndices.length\\n );\\n for (uint256 i = 0; i < signingMembersIndices.length; i++) {\\n signingMemberIds[i] = result.members[signingMembersIndices[i] - 1];\\n }\\n\\n address[] memory signingMemberAddresses = sortitionPool.getIDOperators(\\n signingMemberIds\\n );\\n\\n bytes memory current; // Current signature to be checked.\\n\\n uint256 signaturesCount = result.signatures.length / signatureByteSize;\\n for (uint256 i = 0; i < signaturesCount; i++) {\\n current = result.signatures.slice(\\n signatureByteSize * i,\\n signatureByteSize\\n );\\n address recoveredAddress = hash.recover(current);\\n\\n if (signingMemberAddresses[i] != recoveredAddress) {\\n return false;\\n }\\n }\\n\\n return true;\\n }\\n\\n /// @notice Performs validation of hashed group members that actively took\\n /// part in DKG.\\n /// @param result DKG result\\n /// @return true if calculated result's group members hash matches with the\\n /// one that is challenged.\\n function validateMembersHash(EcdsaDkg.Result calldata result)\\n public\\n pure\\n returns (bool)\\n {\\n if (result.misbehavedMembersIndices.length > 0) {\\n // members that generated a group signing key\\n uint32[] memory groupMembers = new uint32[](\\n result.members.length - result.misbehavedMembersIndices.length\\n );\\n uint256 k = 0; // misbehaved members counter\\n uint256 j = 0; // group members counter\\n for (uint256 i = 0; i < result.members.length; i++) {\\n // misbehaved member indices start from 1, so we need to -1 on misbehaved\\n if (i != result.misbehavedMembersIndices[k] - 1) {\\n groupMembers[j] = result.members[i];\\n j++;\\n } else if (k < result.misbehavedMembersIndices.length - 1) {\\n k++;\\n }\\n }\\n\\n return keccak256(abi.encode(groupMembers)) == result.membersHash;\\n }\\n\\n return keccak256(abi.encode(result.members)) == result.membersHash;\\n }\\n}\\n\",\"keccak256\":\"0xe8f3d63ef4213ac71d447726be3971c5ed6b0b0eb145763d324faecdce707bf6\",\"license\":\"GPL-3.0-only\"},\"@keep-network/ecdsa/contracts/api/IWalletOwner.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\npragma solidity 0.8.17;\\n\\ninterface IWalletOwner {\\n /// @notice Callback function executed once a new wallet is created.\\n /// @dev Should be callable only by the Wallet Registry.\\n /// @param walletID Wallet's unique identifier.\\n /// @param publicKeyY Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n function __ecdsaWalletCreatedCallback(\\n bytes32 walletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external;\\n\\n /// @notice Callback function executed once a wallet heartbeat failure\\n /// is detected.\\n /// @dev Should be callable only by the Wallet Registry.\\n /// @param walletID Wallet's unique identifier.\\n /// @param publicKeyY Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n function __ecdsaWalletHeartbeatFailedCallback(\\n bytes32 walletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external;\\n}\\n\",\"keccak256\":\"0x8d4654269ab20710e8a729c225c2c69edae7f01ddbd5e037ab591df65e32faa8\",\"license\":\"GPL-3.0-only\"},\"@keep-network/ecdsa/contracts/api/IWalletRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"../libraries/EcdsaDkg.sol\\\";\\n\\ninterface IWalletRegistry {\\n /// @notice Requests a new wallet creation.\\n /// @dev Only the Wallet Owner can call this function.\\n function requestNewWallet() external;\\n\\n /// @notice Closes an existing wallet.\\n /// @param walletID ID of the wallet.\\n /// @dev Only the Wallet Owner can call this function.\\n function closeWallet(bytes32 walletID) external;\\n\\n /// @notice Adds all signing group members of the wallet with the given ID\\n /// to the slashing queue of the staking contract. The notifier will\\n /// receive reward per each group member from the staking contract\\n /// notifiers treasury. The reward is scaled by the\\n /// `rewardMultiplier` provided as a parameter.\\n /// @param amount Amount of tokens to seize from each signing group member\\n /// @param rewardMultiplier Fraction of the staking contract notifiers\\n /// reward the notifier should receive; should be between [0, 100]\\n /// @param notifier Address of the misbehavior notifier\\n /// @param walletID ID of the wallet\\n /// @param walletMembersIDs Identifiers of the wallet signing group members\\n /// @dev Only the Wallet Owner can call this function.\\n /// Requirements:\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events.\\n /// - `rewardMultiplier` must be between [0, 100].\\n /// - This function does revert if staking contract call reverts.\\n /// The calling code needs to handle the potential revert.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n bytes32 walletID,\\n uint32[] calldata walletMembersIDs\\n ) external;\\n\\n /// @notice Gets public key of a wallet with a given wallet ID.\\n /// The public key is returned in an uncompressed format as a 64-byte\\n /// concatenation of X and Y coordinates.\\n /// @param walletID ID of the wallet.\\n /// @return Uncompressed public key of the wallet.\\n function getWalletPublicKey(bytes32 walletID)\\n external\\n view\\n returns (bytes memory);\\n\\n /// @notice Check current wallet creation state.\\n function getWalletCreationState() external view returns (EcdsaDkg.State);\\n\\n /// @notice Checks whether the given operator is a member of the given\\n /// wallet signing group.\\n /// @param walletID ID of the wallet\\n /// @param walletMembersIDs Identifiers of the wallet signing group members\\n /// @param operator Address of the checked operator\\n /// @param walletMemberIndex Position of the operator in the wallet signing\\n /// group members list\\n /// @return True - if the operator is a member of the given wallet signing\\n /// group. False - otherwise.\\n /// @dev Requirements:\\n /// - The `operator` parameter must be an actual sortition pool operator.\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events.\\n /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length]\\n function isWalletMember(\\n bytes32 walletID,\\n uint32[] calldata walletMembersIDs,\\n address operator,\\n uint256 walletMemberIndex\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xb97ece7c12601396fed705386a4e3337ee3a4809dca090a5acb62c2949337c68\",\"license\":\"GPL-3.0-only\"},\"@keep-network/ecdsa/contracts/libraries/EcdsaDkg.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n//\\n\\n// Initial version copied from Keep Network Random Beacon:\\n// https://github.com/keep-network/keep-core/blob/5138c7628868dbeed3ae2164f76fccc6c1fbb9e8/solidity/random-beacon/contracts/libraries/DKG.sol\\n//\\n// With the following differences:\\n// - the group size was set to 100,\\n// - offchainDkgTimeout was removed,\\n// - submission eligibility verification is not performed on-chain,\\n// - submission eligibility delay was replaced with a submission timeout,\\n// - seed timeout notification requires seedTimeout period to pass.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol\\\";\\nimport \\\"@keep-network/sortition-pools/contracts/SortitionPool.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/libraries/BytesLib.sol\\\";\\nimport \\\"../EcdsaDkgValidator.sol\\\";\\n\\nlibrary EcdsaDkg {\\n using BytesLib for bytes;\\n using ECDSAUpgradeable for bytes32;\\n\\n struct Parameters {\\n // Time in blocks during which a seed is expected to be delivered.\\n // DKG starts only after a seed is delivered. The time the contract\\n // awaits for a seed is not included in the DKG timeout.\\n uint256 seedTimeout;\\n // Time in blocks during which a submitted result can be challenged.\\n uint256 resultChallengePeriodLength;\\n // Extra gas required to be left at the end of the challenge DKG result\\n // transaction.\\n uint256 resultChallengeExtraGas;\\n // Time in blocks during which a result is expected to be submitted.\\n uint256 resultSubmissionTimeout;\\n // Time in blocks during which only the result submitter is allowed to\\n // approve it. Once this period ends and the submitter have not approved\\n // the result, anyone can do it.\\n uint256 submitterPrecedencePeriodLength;\\n // This struct doesn't contain `__gap` property as the structure is\\n // stored inside `Data` struct, that already have a gap that can be used\\n // on upgrade.\\n }\\n\\n struct Data {\\n // Address of the Sortition Pool contract.\\n SortitionPool sortitionPool;\\n // Address of the EcdsaDkgValidator contract.\\n EcdsaDkgValidator dkgValidator;\\n // DKG parameters. The parameters should persist between DKG executions.\\n // They should be updated with dedicated set functions only when DKG is not\\n // in progress.\\n Parameters parameters;\\n // Time in block at which DKG state was locked.\\n uint256 stateLockBlock;\\n // Time in blocks at which DKG started.\\n uint256 startBlock;\\n // Seed used to start DKG.\\n uint256 seed;\\n // Time in blocks that should be added to result submission eligibility\\n // delay calculation. It is used in case of a challenge to adjust\\n // DKG timeout calculation.\\n uint256 resultSubmissionStartBlockOffset;\\n // Hash of submitted DKG result.\\n bytes32 submittedResultHash;\\n // Block number from the moment of the DKG result submission.\\n uint256 submittedResultBlock;\\n // Reserved storage space in case we need to add more variables.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[38] __gap;\\n }\\n\\n /// @notice DKG result.\\n struct Result {\\n // Claimed submitter candidate group member index.\\n // Must be in range [1, groupSize].\\n uint256 submitterMemberIndex;\\n // Generated candidate group public key\\n bytes groupPubKey;\\n // Array of misbehaved members indices (disqualified or inactive).\\n // Indices must be in range [1, groupSize], unique, and sorted in ascending\\n // order.\\n uint8[] misbehavedMembersIndices;\\n // Concatenation of signatures from members supporting the result.\\n // The message to be signed by each member is keccak256 hash of the\\n // calculated group public key, misbehaved members indices and DKG\\n // start block. The calculated hash should be prefixed with prefixed with\\n // `\\\\x19Ethereum signed message:\\\\n` before signing, so the message to\\n // sign is:\\n // `\\\\x19Ethereum signed message:\\\\n${keccak256(\\n // groupPubKey, misbehavedMembersIndices, dkgStartBlock\\n // )}`\\n bytes signatures;\\n // Indices of members corresponding to each signature. Indices must be\\n // be in range [1, groupSize], unique, and sorted in ascending order.\\n uint256[] signingMembersIndices;\\n // Identifiers of candidate group members as outputted by the group\\n // selection protocol.\\n uint32[] members;\\n // Keccak256 hash of group members identifiers that actively took part\\n // in DKG (excluding IA/DQ members).\\n bytes32 membersHash;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice States for phases of group creation. The states doesn't include\\n /// timeouts which should be tracked and notified individually.\\n enum State {\\n // Group creation is not in progress. It is a state set after group creation\\n // completion either by timeout or by a result approval.\\n IDLE,\\n // Group creation is awaiting the seed and sortition pool is locked.\\n AWAITING_SEED,\\n // DKG protocol execution is in progress. A result is being calculated\\n // by the clients in this state and the contract awaits a result submission.\\n // This is a state to which group creation returns in case of a result\\n // challenge notification.\\n AWAITING_RESULT,\\n // DKG result was submitted and awaits an approval or a challenge. If a result\\n // gets challenge the state returns to `AWAITING_RESULT`. If a result gets\\n // approval the state changes to `IDLE`.\\n CHALLENGE\\n }\\n\\n /// @dev Size of a group in ECDSA wallet.\\n uint256 public constant groupSize = 100;\\n\\n event DkgStarted(uint256 indexed seed);\\n\\n // To recreate the members that actively took part in dkg, the selected members\\n // array should be filtered out from misbehavedMembersIndices.\\n event DkgResultSubmitted(\\n bytes32 indexed resultHash,\\n uint256 indexed seed,\\n Result result\\n );\\n\\n event DkgTimedOut();\\n\\n event DkgResultApproved(\\n bytes32 indexed resultHash,\\n address indexed approver\\n );\\n\\n event DkgResultChallenged(\\n bytes32 indexed resultHash,\\n address indexed challenger,\\n string reason\\n );\\n\\n event DkgStateLocked();\\n\\n event DkgSeedTimedOut();\\n\\n /// @notice Initializes SortitionPool and EcdsaDkgValidator addresses.\\n /// Can be performed only once.\\n /// @param _sortitionPool Sortition Pool reference\\n /// @param _dkgValidator EcdsaDkgValidator reference\\n function init(\\n Data storage self,\\n SortitionPool _sortitionPool,\\n EcdsaDkgValidator _dkgValidator\\n ) internal {\\n require(\\n address(self.sortitionPool) == address(0),\\n \\\"Sortition Pool address already set\\\"\\n );\\n\\n require(\\n address(self.dkgValidator) == address(0),\\n \\\"DKG Validator address already set\\\"\\n );\\n\\n self.sortitionPool = _sortitionPool;\\n self.dkgValidator = _dkgValidator;\\n }\\n\\n /// @notice Determines the current state of group creation. It doesn't take\\n /// timeouts into consideration. The timeouts should be tracked and\\n /// notified separately.\\n function currentState(Data storage self)\\n internal\\n view\\n returns (State state)\\n {\\n state = State.IDLE;\\n\\n if (self.sortitionPool.isLocked()) {\\n state = State.AWAITING_SEED;\\n\\n if (self.startBlock > 0) {\\n state = State.AWAITING_RESULT;\\n\\n if (self.submittedResultBlock > 0) {\\n state = State.CHALLENGE;\\n }\\n }\\n }\\n }\\n\\n /// @notice Locks the sortition pool and starts awaiting for the\\n /// group creation seed.\\n function lockState(Data storage self) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n emit DkgStateLocked();\\n\\n self.sortitionPool.lock();\\n\\n self.stateLockBlock = block.number;\\n }\\n\\n function start(Data storage self, uint256 seed) internal {\\n require(\\n currentState(self) == State.AWAITING_SEED,\\n \\\"Current state is not AWAITING_SEED\\\"\\n );\\n\\n emit DkgStarted(seed);\\n\\n self.startBlock = block.number;\\n self.seed = seed;\\n }\\n\\n /// @notice Allows to submit a DKG result. The submitted result does not go\\n /// through a validation and before it gets accepted, it needs to\\n /// wait through the challenge period during which everyone has\\n /// a chance to challenge the result as invalid one. Submitter of\\n /// the result needs to be in the sortition pool and if the result\\n /// gets challenged, the submitter will get slashed.\\n function submitResult(Data storage self, Result calldata result) internal {\\n require(\\n currentState(self) == State.AWAITING_RESULT,\\n \\\"Current state is not AWAITING_RESULT\\\"\\n );\\n require(!hasDkgTimedOut(self), \\\"DKG timeout already passed\\\");\\n\\n SortitionPool sortitionPool = self.sortitionPool;\\n\\n // Submitter must be an operator in the sortition pool.\\n // Declared submitter's member index in the DKG result needs to match\\n // the address calling this function.\\n require(\\n sortitionPool.isOperatorInPool(msg.sender),\\n \\\"Submitter not in the sortition pool\\\"\\n );\\n require(\\n sortitionPool.getIDOperator(\\n result.members[result.submitterMemberIndex - 1]\\n ) == msg.sender,\\n \\\"Unexpected submitter index\\\"\\n );\\n\\n self.submittedResultHash = keccak256(abi.encode(result));\\n self.submittedResultBlock = block.number;\\n\\n emit DkgResultSubmitted(self.submittedResultHash, self.seed, result);\\n }\\n\\n /// @notice Checks if awaiting seed timed out.\\n /// @return True if awaiting seed timed out, false otherwise.\\n function hasSeedTimedOut(Data storage self) internal view returns (bool) {\\n return\\n currentState(self) == State.AWAITING_SEED &&\\n block.number > (self.stateLockBlock + self.parameters.seedTimeout);\\n }\\n\\n /// @notice Checks if DKG timed out. The DKG timeout period includes time required\\n /// for off-chain protocol execution and time for the result publication.\\n /// After this time a result cannot be submitted and DKG can be notified\\n /// about the timeout. DKG period is adjusted by result submission\\n /// offset that include blocks that were mined while invalid result\\n /// has been registered until it got challenged.\\n /// @return True if DKG timed out, false otherwise.\\n function hasDkgTimedOut(Data storage self) internal view returns (bool) {\\n return\\n currentState(self) == State.AWAITING_RESULT &&\\n block.number >\\n (self.startBlock +\\n self.resultSubmissionStartBlockOffset +\\n self.parameters.resultSubmissionTimeout);\\n }\\n\\n /// @notice Notifies about the seed was not delivered and restores the\\n /// initial DKG state (IDLE).\\n function notifySeedTimeout(Data storage self) internal {\\n require(hasSeedTimedOut(self), \\\"Awaiting seed has not timed out\\\");\\n\\n emit DkgSeedTimedOut();\\n\\n complete(self);\\n }\\n\\n /// @notice Notifies about DKG timeout.\\n function notifyDkgTimeout(Data storage self) internal {\\n require(hasDkgTimedOut(self), \\\"DKG has not timed out\\\");\\n\\n emit DkgTimedOut();\\n\\n complete(self);\\n }\\n\\n /// @notice Approves DKG result. Can be called when the challenge period for\\n /// the submitted result is finished. Considers the submitted result\\n /// as valid. For the first `submitterPrecedencePeriodLength`\\n /// blocks after the end of the challenge period can be called only\\n /// by the DKG result submitter. After that time, can be called by\\n /// anyone.\\n /// @dev Can be called after a challenge period for the submitted result.\\n /// @param result Result to approve. Must match the submitted result stored\\n /// during `submitResult`.\\n /// @return misbehavedMembers Identifiers of members who misbehaved during DKG.\\n function approveResult(Data storage self, Result calldata result)\\n internal\\n returns (uint32[] memory misbehavedMembers)\\n {\\n require(\\n currentState(self) == State.CHALLENGE,\\n \\\"Current state is not CHALLENGE\\\"\\n );\\n\\n uint256 challengePeriodEnd = self.submittedResultBlock +\\n self.parameters.resultChallengePeriodLength;\\n\\n require(\\n block.number > challengePeriodEnd,\\n \\\"Challenge period has not passed yet\\\"\\n );\\n\\n require(\\n keccak256(abi.encode(result)) == self.submittedResultHash,\\n \\\"Result under approval is different than the submitted one\\\"\\n );\\n\\n // Extract submitter member address. Submitter member index is in\\n // range [1, groupSize] so we need to -1 when fetching identifier from members\\n // array.\\n address submitterMember = self.sortitionPool.getIDOperator(\\n result.members[result.submitterMemberIndex - 1]\\n );\\n\\n require(\\n msg.sender == submitterMember ||\\n block.number >\\n challengePeriodEnd +\\n self.parameters.submitterPrecedencePeriodLength,\\n \\\"Only the DKG result submitter can approve the result at this moment\\\"\\n );\\n\\n // Extract misbehaved members identifiers. Misbehaved members indices\\n // are in range [1, groupSize], so we need to -1 when fetching identifiers from\\n // members array.\\n misbehavedMembers = new uint32[](\\n result.misbehavedMembersIndices.length\\n );\\n for (uint256 i = 0; i < result.misbehavedMembersIndices.length; i++) {\\n misbehavedMembers[i] = result.members[\\n result.misbehavedMembersIndices[i] - 1\\n ];\\n }\\n\\n emit DkgResultApproved(self.submittedResultHash, msg.sender);\\n\\n return misbehavedMembers;\\n }\\n\\n /// @notice Challenges DKG result. If the submitted result is proved to be\\n /// invalid it reverts the DKG back to the result submission phase.\\n /// @dev Can be called during a challenge period for the submitted result.\\n /// @param result Result to challenge. Must match the submitted result\\n /// stored during `submitResult`.\\n /// @return maliciousResultHash Hash of the malicious result.\\n /// @return maliciousSubmitter Identifier of the malicious submitter.\\n function challengeResult(Data storage self, Result calldata result)\\n internal\\n returns (bytes32 maliciousResultHash, uint32 maliciousSubmitter)\\n {\\n require(\\n currentState(self) == State.CHALLENGE,\\n \\\"Current state is not CHALLENGE\\\"\\n );\\n\\n require(\\n block.number <=\\n self.submittedResultBlock +\\n self.parameters.resultChallengePeriodLength,\\n \\\"Challenge period has already passed\\\"\\n );\\n\\n require(\\n keccak256(abi.encode(result)) == self.submittedResultHash,\\n \\\"Result under challenge is different than the submitted one\\\"\\n );\\n\\n // https://github.com/crytic/slither/issues/982\\n // slither-disable-next-line unused-return\\n try\\n self.dkgValidator.validate(result, self.seed, self.startBlock)\\n returns (\\n // slither-disable-next-line uninitialized-local,variable-scope\\n bool isValid,\\n // slither-disable-next-line uninitialized-local,variable-scope\\n string memory errorMsg\\n ) {\\n if (isValid) {\\n revert(\\\"unjustified challenge\\\");\\n }\\n\\n emit DkgResultChallenged(\\n self.submittedResultHash,\\n msg.sender,\\n errorMsg\\n );\\n } catch {\\n // if the validation reverted we consider the DKG result as invalid\\n emit DkgResultChallenged(\\n self.submittedResultHash,\\n msg.sender,\\n \\\"validation reverted\\\"\\n );\\n }\\n\\n // Consider result hash as malicious.\\n maliciousResultHash = self.submittedResultHash;\\n maliciousSubmitter = result.members[result.submitterMemberIndex - 1];\\n\\n // Adjust DKG result submission block start, so submission stage starts\\n // from the beginning.\\n self.resultSubmissionStartBlockOffset = block.number - self.startBlock;\\n\\n submittedResultCleanup(self);\\n\\n return (maliciousResultHash, maliciousSubmitter);\\n }\\n\\n /// @notice Due to EIP150, 1/64 of the gas is not forwarded to the call, and\\n /// will be kept to execute the remaining operations in the function\\n /// after the call inside the try-catch.\\n ///\\n /// To ensure there is no way for the caller to manipulate gas limit\\n /// in such a way that the call inside try-catch fails with out-of-gas\\n /// and the rest of the function is executed with the remaining\\n /// 1/64 of gas, we require an extra gas amount to be left at the\\n /// end of the call to the function challenging DKG result and\\n /// wrapping the call to EcdsaDkgValidator and TokenStaking\\n /// contracts inside a try-catch.\\n function requireChallengeExtraGas(Data storage self) internal view {\\n require(\\n gasleft() >= self.parameters.resultChallengeExtraGas,\\n \\\"Not enough extra gas left\\\"\\n );\\n }\\n\\n /// @notice Checks if DKG result is valid for the current DKG.\\n /// @param result DKG result.\\n /// @return True if the result is valid. If the result is invalid it returns\\n /// false and an error message.\\n function isResultValid(Data storage self, Result calldata result)\\n internal\\n view\\n returns (bool, string memory)\\n {\\n require(self.startBlock > 0, \\\"DKG has not been started\\\");\\n\\n return self.dkgValidator.validate(result, self.seed, self.startBlock);\\n }\\n\\n /// @notice Set setSeedTimeout parameter.\\n function setSeedTimeout(Data storage self, uint256 newSeedTimeout)\\n internal\\n {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(newSeedTimeout > 0, \\\"New value should be greater than zero\\\");\\n\\n self.parameters.seedTimeout = newSeedTimeout;\\n }\\n\\n /// @notice Set resultChallengePeriodLength parameter.\\n function setResultChallengePeriodLength(\\n Data storage self,\\n uint256 newResultChallengePeriodLength\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(\\n newResultChallengePeriodLength > 0,\\n \\\"New value should be greater than zero\\\"\\n );\\n\\n self\\n .parameters\\n .resultChallengePeriodLength = newResultChallengePeriodLength;\\n }\\n\\n /// @notice Set resultChallengeExtraGas parameter.\\n function setResultChallengeExtraGas(\\n Data storage self,\\n uint256 newResultChallengeExtraGas\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n self.parameters.resultChallengeExtraGas = newResultChallengeExtraGas;\\n }\\n\\n /// @notice Set resultSubmissionTimeout parameter.\\n function setResultSubmissionTimeout(\\n Data storage self,\\n uint256 newResultSubmissionTimeout\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(\\n newResultSubmissionTimeout > 0,\\n \\\"New value should be greater than zero\\\"\\n );\\n\\n self.parameters.resultSubmissionTimeout = newResultSubmissionTimeout;\\n }\\n\\n /// @notice Set submitterPrecedencePeriodLength parameter.\\n function setSubmitterPrecedencePeriodLength(\\n Data storage self,\\n uint256 newSubmitterPrecedencePeriodLength\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(\\n newSubmitterPrecedencePeriodLength <\\n self.parameters.resultSubmissionTimeout,\\n \\\"New value should be less than result submission period length\\\"\\n );\\n\\n self\\n .parameters\\n .submitterPrecedencePeriodLength = newSubmitterPrecedencePeriodLength;\\n }\\n\\n /// @notice Completes DKG by cleaning up state.\\n /// @dev Should be called after DKG times out or a result is approved.\\n function complete(Data storage self) internal {\\n delete self.startBlock;\\n delete self.seed;\\n delete self.resultSubmissionStartBlockOffset;\\n submittedResultCleanup(self);\\n self.sortitionPool.unlock();\\n }\\n\\n /// @notice Cleans up submitted result state either after DKG completion\\n /// (as part of `complete` method) or after justified challenge.\\n function submittedResultCleanup(Data storage self) private {\\n delete self.submittedResultHash;\\n delete self.submittedResultBlock;\\n }\\n}\\n\",\"keccak256\":\"0xd6c442e1db2dc95730443fb6496d47889a69bed2fbace466b27f9727484c25ec\",\"license\":\"GPL-3.0-only\"},\"@keep-network/random-beacon/contracts/Governable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\npragma solidity 0.8.17;\\n\\n/// @notice Governable contract.\\n/// @dev A constructor is not defined, which makes the contract compatible with\\n/// upgradable proxies. This requires calling explicitly `_transferGovernance`\\n/// function in a child contract.\\nabstract contract Governable {\\n // Governance of the contract\\n // The variable should be initialized by the implementing contract.\\n // slither-disable-next-line uninitialized-state\\n address public governance;\\n\\n // Reserved storage space in case we need to add more variables,\\n // since there are upgradeable contracts that inherit from this one.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[49] private __gap;\\n\\n event GovernanceTransferred(address oldGovernance, address newGovernance);\\n\\n modifier onlyGovernance() virtual {\\n require(governance == msg.sender, \\\"Caller is not the governance\\\");\\n _;\\n }\\n\\n /// @notice Transfers governance of the contract to `newGovernance`.\\n function transferGovernance(address newGovernance)\\n external\\n virtual\\n onlyGovernance\\n {\\n require(\\n newGovernance != address(0),\\n \\\"New governance is the zero address\\\"\\n );\\n _transferGovernance(newGovernance);\\n }\\n\\n function _transferGovernance(address newGovernance) internal virtual {\\n address oldGovernance = governance;\\n governance = newGovernance;\\n emit GovernanceTransferred(oldGovernance, newGovernance);\\n }\\n}\\n\",\"keccak256\":\"0xcc6a0fe8fdf05a805d2874dc7dd76dede1eb16e3ab77f2d0069dbb92272ab0a3\",\"license\":\"GPL-3.0-only\"},\"@keep-network/random-beacon/contracts/ReimbursementPool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\n\\ncontract ReimbursementPool is Ownable, ReentrancyGuard {\\n /// @notice Authorized contracts that can interact with the reimbursment pool.\\n /// Authorization can be granted and removed by the owner.\\n mapping(address => bool) public isAuthorized;\\n\\n /// @notice Static gas includes:\\n /// - cost of the refund function\\n /// - base transaction cost\\n uint256 public staticGas;\\n\\n /// @notice Max gas price used to reimburse a transaction submitter. Protects\\n /// against malicious operator-miners.\\n uint256 public maxGasPrice;\\n\\n event StaticGasUpdated(uint256 newStaticGas);\\n\\n event MaxGasPriceUpdated(uint256 newMaxGasPrice);\\n\\n event SendingEtherFailed(uint256 refundAmount, address receiver);\\n\\n event AuthorizedContract(address thirdPartyContract);\\n\\n event UnauthorizedContract(address thirdPartyContract);\\n\\n event FundsWithdrawn(uint256 withdrawnAmount, address receiver);\\n\\n constructor(uint256 _staticGas, uint256 _maxGasPrice) {\\n staticGas = _staticGas;\\n maxGasPrice = _maxGasPrice;\\n }\\n\\n /// @notice Receive ETH\\n receive() external payable {}\\n\\n /// @notice Refunds ETH to a spender for executing specific transactions.\\n /// @dev Ignoring the result of sending ETH to a receiver is made on purpose.\\n /// For EOA receiving ETH should always work. If a receiver is a smart\\n /// contract, then we do not want to fail a transaction, because in some\\n /// cases the refund is done at the very end of multiple calls where all\\n /// the previous calls were already paid off. It is a receiver's smart\\n /// contract resposibility to make sure it can receive ETH.\\n /// @dev Only authorized contracts are allowed calling this function.\\n /// @param gasSpent Gas spent on a transaction that needs to be reimbursed.\\n /// @param receiver Address where the reimbursment is sent.\\n function refund(uint256 gasSpent, address receiver) external nonReentrant {\\n require(\\n isAuthorized[msg.sender],\\n \\\"Contract is not authorized for a refund\\\"\\n );\\n require(receiver != address(0), \\\"Receiver's address cannot be zero\\\");\\n\\n uint256 gasPrice = tx.gasprice < maxGasPrice\\n ? tx.gasprice\\n : maxGasPrice;\\n\\n uint256 refundAmount = (gasSpent + staticGas) * gasPrice;\\n\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,unchecked-lowlevel\\n (bool sent, ) = receiver.call{value: refundAmount}(\\\"\\\");\\n /* solhint-enable avoid-low-level-calls */\\n if (!sent) {\\n // slither-disable-next-line reentrancy-events\\n emit SendingEtherFailed(refundAmount, receiver);\\n }\\n }\\n\\n /// @notice Authorize a contract that can interact with this reimbursment pool.\\n /// Can be authorized by the owner only.\\n /// @param _contract Authorized contract.\\n function authorize(address _contract) external onlyOwner {\\n isAuthorized[_contract] = true;\\n\\n emit AuthorizedContract(_contract);\\n }\\n\\n /// @notice Unauthorize a contract that was previously authorized to interact\\n /// with this reimbursment pool. Can be unauthorized by the\\n /// owner only.\\n /// @param _contract Authorized contract.\\n function unauthorize(address _contract) external onlyOwner {\\n delete isAuthorized[_contract];\\n\\n emit UnauthorizedContract(_contract);\\n }\\n\\n /// @notice Setting a static gas cost for executing a transaction. Can be set\\n /// by the owner only.\\n /// @param _staticGas Static gas cost.\\n function setStaticGas(uint256 _staticGas) external onlyOwner {\\n staticGas = _staticGas;\\n\\n emit StaticGasUpdated(_staticGas);\\n }\\n\\n /// @notice Setting a max gas price for transactions. Can be set by the\\n /// owner only.\\n /// @param _maxGasPrice Max gas price used to reimburse tx submitters.\\n function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwner {\\n maxGasPrice = _maxGasPrice;\\n\\n emit MaxGasPriceUpdated(_maxGasPrice);\\n }\\n\\n /// @notice Withdraws all ETH from this pool which are sent to a given\\n /// address. Can be set by the owner only.\\n /// @param receiver An address where ETH is sent.\\n function withdrawAll(address receiver) external onlyOwner {\\n withdraw(address(this).balance, receiver);\\n }\\n\\n /// @notice Withdraws ETH amount from this pool which are sent to a given\\n /// address. Can be set by the owner only.\\n /// @param amount Amount to withdraw from the pool.\\n /// @param receiver An address where ETH is sent.\\n function withdraw(uint256 amount, address receiver) public onlyOwner {\\n require(\\n address(this).balance >= amount,\\n \\\"Insufficient contract balance\\\"\\n );\\n require(receiver != address(0), \\\"Receiver's address cannot be zero\\\");\\n\\n emit FundsWithdrawn(amount, receiver);\\n\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,arbitrary-send\\n (bool sent, ) = receiver.call{value: amount}(\\\"\\\");\\n /* solhint-enable avoid-low-level-calls */\\n require(sent, \\\"Failed to send Ether\\\");\\n }\\n}\\n\",\"keccak256\":\"0xd6c24368cc4c6349b8b614e878ca961cad8254b8e8db1cc0abe452a70022ce50\",\"license\":\"GPL-3.0-only\"},\"@keep-network/random-beacon/contracts/libraries/BytesLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n//\\n\\npragma solidity 0.8.17;\\n\\n/*\\nVersion pulled from keep-core v1:\\nhttps://github.com/keep-network/keep-core/blob/f297202db00c027978ad8e7103a356503de5773c/solidity-v1/contracts/utils/BytesLib.sol\\n\\nTo compile it with solidity 0.8 `_preBytes_slot` was replaced with `_preBytes.slot`.\\n*/\\n\\n/*\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\nThis is free and unencumbered software released into the public domain.\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\nFor more information, please refer to \\n*/\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes)\\n internal\\n {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(\\n and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)),\\n 2\\n )\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes)\\n internal\\n view\\n returns (bool)\\n {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(\\n and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)),\\n 2\\n )\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {\\n\\n } eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function concat(bytes memory _preBytes, bytes memory _postBytes)\\n internal\\n pure\\n returns (bytes memory)\\n {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(\\n 0x40,\\n and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n )\\n )\\n }\\n\\n return tempBytes;\\n }\\n\\n function slice(\\n bytes memory _bytes,\\n uint256 _start,\\n uint256 _length\\n ) internal pure returns (bytes memory res) {\\n uint256 _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n function toAddress(bytes memory _bytes, uint256 _start)\\n internal\\n pure\\n returns (address)\\n {\\n uint256 _totalLen = _start + 20;\\n require(\\n _totalLen > _start && _bytes.length >= _totalLen,\\n \\\"Address conversion out of bounds.\\\"\\n );\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(\\n mload(add(add(_bytes, 0x20), _start)),\\n 0x1000000000000000000000000\\n )\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint8(bytes memory _bytes, uint256 _start)\\n internal\\n pure\\n returns (uint8)\\n {\\n require(\\n _bytes.length >= (_start + 1),\\n \\\"Uint8 conversion out of bounds.\\\"\\n );\\n uint8 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x1), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function toUint(bytes memory _bytes, uint256 _start)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 _totalLen = _start + 32;\\n require(\\n _totalLen > _start && _bytes.length >= _totalLen,\\n \\\"Uint conversion out of bounds.\\\"\\n );\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes)\\n internal\\n pure\\n returns (bool)\\n {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source)\\n internal\\n pure\\n returns (bytes32 result)\\n {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(\\n bytes memory _bytes,\\n uint256 _start,\\n uint256 _length\\n ) internal pure returns (bytes32 result) {\\n uint256 _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3b76e2fe36eb777440250dcf2ea7a689375e8af22f3cc33521095ff6954becdb\",\"license\":\"GPL-3.0-only\"},\"@keep-network/sortition-pools/contracts/Branch.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Constants.sol\\\";\\n\\n/// @notice The implicit 8-ary trees of the sortition pool\\n/// rely on packing 8 \\\"slots\\\" of 32-bit values into each uint256.\\n/// The Branch library permits efficient calculations on these slots.\\nlibrary Branch {\\n /// @notice Calculate the right shift required\\n /// to make the 32 least significant bits of an uint256\\n /// be the bits of the `position`th slot\\n /// when treating the uint256 as a uint32[8].\\n ///\\n /// @dev Not used for efficiency reasons,\\n /// but left to illustrate the meaning of a common pattern.\\n /// I wish solidity had macros, even C macros.\\n function slotShift(uint256 position) internal pure returns (uint256) {\\n unchecked {\\n return position * Constants.SLOT_WIDTH;\\n }\\n }\\n\\n /// @notice Return the `position`th slot of the `node`,\\n /// treating `node` as a uint32[32].\\n function getSlot(uint256 node, uint256 position)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n uint256 shiftBits = position * Constants.SLOT_WIDTH;\\n // Doing a bitwise AND with `SLOT_MAX`\\n // clears all but the 32 least significant bits.\\n // Because of the right shift by `slotShift(position)` bits,\\n // those 32 bits contain the 32 bits in the `position`th slot of `node`.\\n return (node >> shiftBits) & Constants.SLOT_MAX;\\n }\\n }\\n\\n /// @notice Return `node` with the `position`th slot set to zero.\\n function clearSlot(uint256 node, uint256 position)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n uint256 shiftBits = position * Constants.SLOT_WIDTH;\\n // Shifting `SLOT_MAX` left by `slotShift(position)` bits\\n // gives us a number where all bits of the `position`th slot are set,\\n // and all other bits are unset.\\n //\\n // Using a bitwise NOT on this number,\\n // we get a uint256 where all bits are set\\n // except for those of the `position`th slot.\\n //\\n // Bitwise ANDing the original `node` with this number\\n // sets the bits of `position`th slot to zero,\\n // leaving all other bits unchanged.\\n return node & ~(Constants.SLOT_MAX << shiftBits);\\n }\\n }\\n\\n /// @notice Return `node` with the `position`th slot set to `weight`.\\n ///\\n /// @param weight The weight of of the node.\\n /// Safely truncated to a 32-bit number,\\n /// but this should never be called with an overflowing weight regardless.\\n function setSlot(\\n uint256 node,\\n uint256 position,\\n uint256 weight\\n ) internal pure returns (uint256) {\\n unchecked {\\n uint256 shiftBits = position * Constants.SLOT_WIDTH;\\n // Clear the `position`th slot like in `clearSlot()`.\\n uint256 clearedNode = node & ~(Constants.SLOT_MAX << shiftBits);\\n // Bitwise AND `weight` with `SLOT_MAX`\\n // to clear all but the 32 least significant bits.\\n //\\n // Shift this left by `slotShift(position)` bits\\n // to obtain a uint256 with all bits unset\\n // except in the `position`th slot\\n // which contains the 32-bit value of `weight`.\\n uint256 shiftedWeight = (weight & Constants.SLOT_MAX) << shiftBits;\\n // When we bitwise OR these together,\\n // all other slots except the `position`th one come from the left argument,\\n // and the `position`th gets filled with `weight` from the right argument.\\n return clearedNode | shiftedWeight;\\n }\\n }\\n\\n /// @notice Calculate the summed weight of all slots in the `node`.\\n function sumWeight(uint256 node) internal pure returns (uint256 sum) {\\n unchecked {\\n sum = node & Constants.SLOT_MAX;\\n // Iterate through each slot\\n // by shifting `node` right in increments of 32 bits,\\n // and adding the 32 least significant bits to the `sum`.\\n uint256 newNode = node >> Constants.SLOT_WIDTH;\\n while (newNode > 0) {\\n sum += (newNode & Constants.SLOT_MAX);\\n newNode = newNode >> Constants.SLOT_WIDTH;\\n }\\n return sum;\\n }\\n }\\n\\n /// @notice Pick a slot in `node` that corresponds to `index`.\\n /// Treats the node like an array of virtual stakers,\\n /// the number of virtual stakers in each slot corresponding to its weight,\\n /// and picks which slot contains the `index`th virtual staker.\\n ///\\n /// @dev Requires that `index` be lower than `sumWeight(node)`.\\n /// However, this is not enforced for performance reasons.\\n /// If `index` exceeds the permitted range,\\n /// `pickWeightedSlot()` returns the rightmost slot\\n /// and an excessively high `newIndex`.\\n ///\\n /// @return slot The slot of `node` containing the `index`th virtual staker.\\n ///\\n /// @return newIndex The index of the `index`th virtual staker of `node`\\n /// within the returned slot.\\n function pickWeightedSlot(uint256 node, uint256 index)\\n internal\\n pure\\n returns (uint256 slot, uint256 newIndex)\\n {\\n unchecked {\\n newIndex = index;\\n uint256 newNode = node;\\n uint256 currentSlotWeight = newNode & Constants.SLOT_MAX;\\n while (newIndex >= currentSlotWeight) {\\n newIndex -= currentSlotWeight;\\n slot++;\\n newNode = newNode >> Constants.SLOT_WIDTH;\\n currentSlotWeight = newNode & Constants.SLOT_MAX;\\n }\\n return (slot, newIndex);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa7fb1c9c9789f30493e9a40e24a24f46875dc5e7630b4f67478167759f6d1882\"},\"@keep-network/sortition-pools/contracts/Chaosnet.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\n/// @title Chaosnet\\n/// @notice This is a beta staker program for stakers willing to go the extra\\n/// mile with monitoring, share their logs with the dev team, and allow to more\\n/// carefully monitor the bootstrapping network. As the network matures, the\\n/// beta program will be ended.\\ncontract Chaosnet {\\n /// @notice Indicates if the chaosnet is active. The chaosnet is active\\n /// after the contract deployment and can be ended with a call to\\n /// `deactivateChaosnet()`. Once deactivated chaosnet can not be activated\\n /// again.\\n bool public isChaosnetActive;\\n\\n /// @notice Indicates if the given operator is a beta operator for chaosnet.\\n mapping(address => bool) public isBetaOperator;\\n\\n /// @notice Address controlling chaosnet status and beta operator addresses.\\n address public chaosnetOwner;\\n\\n event BetaOperatorsAdded(address[] operators);\\n\\n event ChaosnetOwnerRoleTransferred(\\n address oldChaosnetOwner,\\n address newChaosnetOwner\\n );\\n\\n event ChaosnetDeactivated();\\n\\n constructor() {\\n _transferChaosnetOwner(msg.sender);\\n isChaosnetActive = true;\\n }\\n\\n modifier onlyChaosnetOwner() {\\n require(msg.sender == chaosnetOwner, \\\"Not the chaosnet owner\\\");\\n _;\\n }\\n\\n modifier onlyOnChaosnet() {\\n require(isChaosnetActive, \\\"Chaosnet is not active\\\");\\n _;\\n }\\n\\n /// @notice Adds beta operator to chaosnet. Can be called only by the\\n /// chaosnet owner when the chaosnet is active. Once the operator is added\\n /// as a beta operator, it can not be removed.\\n function addBetaOperators(address[] calldata operators)\\n public\\n onlyOnChaosnet\\n onlyChaosnetOwner\\n {\\n for (uint256 i = 0; i < operators.length; i++) {\\n isBetaOperator[operators[i]] = true;\\n }\\n\\n emit BetaOperatorsAdded(operators);\\n }\\n\\n /// @notice Deactivates the chaosnet. Can be called only by the chaosnet\\n /// owner. Once deactivated chaosnet can not be activated again.\\n function deactivateChaosnet() public onlyOnChaosnet onlyChaosnetOwner {\\n isChaosnetActive = false;\\n emit ChaosnetDeactivated();\\n }\\n\\n /// @notice Transfers the chaosnet owner role to another non-zero address.\\n function transferChaosnetOwnerRole(address newChaosnetOwner)\\n public\\n onlyChaosnetOwner\\n {\\n require(\\n newChaosnetOwner != address(0),\\n \\\"New chaosnet owner must not be zero address\\\"\\n );\\n _transferChaosnetOwner(newChaosnetOwner);\\n }\\n\\n function _transferChaosnetOwner(address newChaosnetOwner) internal {\\n address oldChaosnetOwner = chaosnetOwner;\\n chaosnetOwner = newChaosnetOwner;\\n emit ChaosnetOwnerRoleTransferred(oldChaosnetOwner, newChaosnetOwner);\\n }\\n}\\n\",\"keccak256\":\"0xeaf7bdd5626f88c329793a012621039692ce1b6e1f13013997ddb13d7e3032df\"},\"@keep-network/sortition-pools/contracts/Constants.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nlibrary Constants {\\n ////////////////////////////////////////////////////////////////////////////\\n // Parameters for configuration\\n\\n // How many bits a position uses per level of the tree;\\n // each branch of the tree contains 2**SLOT_BITS slots.\\n uint256 constant SLOT_BITS = 3;\\n uint256 constant LEVELS = 7;\\n ////////////////////////////////////////////////////////////////////////////\\n\\n ////////////////////////////////////////////////////////////////////////////\\n // Derived constants, do not touch\\n uint256 constant SLOT_COUNT = 2**SLOT_BITS;\\n uint256 constant SLOT_WIDTH = 256 / SLOT_COUNT;\\n uint256 constant LAST_SLOT = SLOT_COUNT - 1;\\n uint256 constant SLOT_MAX = (2**SLOT_WIDTH) - 1;\\n uint256 constant POOL_CAPACITY = SLOT_COUNT**LEVELS;\\n\\n uint256 constant ID_WIDTH = SLOT_WIDTH;\\n uint256 constant ID_MAX = SLOT_MAX;\\n\\n uint256 constant BLOCKHEIGHT_WIDTH = 96 - ID_WIDTH;\\n uint256 constant BLOCKHEIGHT_MAX = (2**BLOCKHEIGHT_WIDTH) - 1;\\n\\n uint256 constant SLOT_POINTER_MAX = (2**SLOT_BITS) - 1;\\n uint256 constant LEAF_FLAG = 1 << 255;\\n\\n uint256 constant WEIGHT_WIDTH = 256 / SLOT_COUNT;\\n ////////////////////////////////////////////////////////////////////////////\\n}\\n\",\"keccak256\":\"0xaef690ced707935745ff1482b7bb9bd9eb77bf6a39c717465e64cf12db8a7d39\"},\"@keep-network/sortition-pools/contracts/Leaf.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Constants.sol\\\";\\n\\nlibrary Leaf {\\n function make(\\n address _operator,\\n uint256 _creationBlock,\\n uint256 _id\\n ) internal pure returns (uint256) {\\n assert(_creationBlock <= type(uint64).max);\\n assert(_id <= type(uint32).max);\\n // Converting a bytesX type into a larger type\\n // adds zero bytes on the right.\\n uint256 op = uint256(bytes32(bytes20(_operator)));\\n // Bitwise AND the id to erase\\n // all but the 32 least significant bits\\n uint256 uid = _id & Constants.ID_MAX;\\n // Erase all but the 64 least significant bits,\\n // then shift left by 32 bits to make room for the id\\n uint256 cb = (_creationBlock & Constants.BLOCKHEIGHT_MAX) <<\\n Constants.ID_WIDTH;\\n // Bitwise OR them all together to get\\n // [address operator || uint64 creationBlock || uint32 id]\\n return (op | cb | uid);\\n }\\n\\n function operator(uint256 leaf) internal pure returns (address) {\\n // Converting a bytesX type into a smaller type\\n // truncates it on the right.\\n return address(bytes20(bytes32(leaf)));\\n }\\n\\n /// @notice Return the block number the leaf was created in.\\n function creationBlock(uint256 leaf) internal pure returns (uint256) {\\n return ((leaf >> Constants.ID_WIDTH) & Constants.BLOCKHEIGHT_MAX);\\n }\\n\\n function id(uint256 leaf) internal pure returns (uint32) {\\n // Id is stored in the 32 least significant bits.\\n // Bitwise AND ensures that we only get the contents of those bits.\\n return uint32(leaf & Constants.ID_MAX);\\n }\\n}\\n\",\"keccak256\":\"0xbd107a1a43e48884885e5e966ffcbcd8fa5e89863715d717bb4006e9f89cdc2b\"},\"@keep-network/sortition-pools/contracts/Position.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Constants.sol\\\";\\n\\nlibrary Position {\\n // Return the last 3 bits of a position number,\\n // corresponding to its slot in its parent\\n function slot(uint256 a) internal pure returns (uint256) {\\n return a & Constants.SLOT_POINTER_MAX;\\n }\\n\\n // Return the parent of a position number\\n function parent(uint256 a) internal pure returns (uint256) {\\n return a >> Constants.SLOT_BITS;\\n }\\n\\n // Return the location of the child of a at the given slot\\n function child(uint256 a, uint256 s) internal pure returns (uint256) {\\n return (a << Constants.SLOT_BITS) | (s & Constants.SLOT_POINTER_MAX); // slot(s)\\n }\\n\\n // Return the uint p as a flagged position uint:\\n // the least significant 21 bits contain the position\\n // and the 22nd bit is set as a flag\\n // to distinguish the position 0x000000 from an empty field.\\n function setFlag(uint256 p) internal pure returns (uint256) {\\n return p | Constants.LEAF_FLAG;\\n }\\n\\n // Turn a flagged position into an unflagged position\\n // by removing the flag at the 22nd least significant bit.\\n //\\n // We shouldn't _actually_ need this\\n // as all position-manipulating code should ignore non-position bits anyway\\n // but it's cheap to call so might as well do it.\\n function unsetFlag(uint256 p) internal pure returns (uint256) {\\n return p & (~Constants.LEAF_FLAG);\\n }\\n}\\n\",\"keccak256\":\"0xd3a927908080ac21353a92a6bce3d69e94a5c30f6b51f16b271b6cc679f110e2\"},\"@keep-network/sortition-pools/contracts/RNG.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Leaf.sol\\\";\\nimport \\\"./Constants.sol\\\";\\n\\nlibrary RNG {\\n /// @notice Get an index in the range `[0 .. range-1]`\\n /// and the new state of the RNG,\\n /// using the provided `state` of the RNG.\\n ///\\n /// @param range The upper bound of the index, exclusive.\\n ///\\n /// @param state The previous state of the RNG.\\n /// The initial state needs to be obtained\\n /// from a trusted randomness oracle (the random beacon),\\n /// or from a chain of earlier calls to `RNG.getIndex()`\\n /// on an originally trusted seed.\\n ///\\n /// @dev Calculates the number of bits required for the desired range,\\n /// takes the least significant bits of `state`\\n /// and checks if the obtained index is within the desired range.\\n /// The original state is hashed with `keccak256` to get a new state.\\n /// If the index is outside the range,\\n /// the function retries until it gets a suitable index.\\n ///\\n /// @return index A random integer between `0` and `range - 1`, inclusive.\\n ///\\n /// @return newState The new state of the RNG.\\n /// When `getIndex()` is called one or more times,\\n /// care must be taken to always use the output `state`\\n /// of the most recent call as the input `state` of a subsequent call.\\n /// At the end of a transaction calling `RNG.getIndex()`,\\n /// the previous stored state must be overwritten with the latest output.\\n function getIndex(\\n uint256 range,\\n bytes32 state,\\n uint256 bits\\n ) internal view returns (uint256, bytes32) {\\n bool found = false;\\n uint256 index = 0;\\n bytes32 newState = state;\\n while (!found) {\\n index = truncate(bits, uint256(newState));\\n newState = keccak256(abi.encodePacked(newState, address(this)));\\n if (index < range) {\\n found = true;\\n }\\n }\\n return (index, newState);\\n }\\n\\n /// @notice Calculate how many bits are required\\n /// for an index in the range `[0 .. range-1]`.\\n ///\\n /// @param range The upper bound of the desired range, exclusive.\\n ///\\n /// @return uint The smallest number of bits\\n /// that can contain the number `range-1`.\\n function bitsRequired(uint256 range) internal pure returns (uint256) {\\n unchecked {\\n if (range == 1) {\\n return 0;\\n }\\n\\n uint256 bits = Constants.WEIGHT_WIDTH - 1;\\n\\n // Left shift by `bits`,\\n // so we have a 1 in the (bits + 1)th least significant bit\\n // and 0 in other bits.\\n // If this number is equal or greater than `range`,\\n // the range [0, range-1] fits in `bits` bits.\\n //\\n // Because we loop from high bits to low bits,\\n // we find the highest number of bits that doesn't fit the range,\\n // and return that number + 1.\\n while (1 << bits >= range) {\\n bits--;\\n }\\n\\n return bits + 1;\\n }\\n }\\n\\n /// @notice Truncate `input` to the `bits` least significant bits.\\n function truncate(uint256 bits, uint256 input)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n return input & ((1 << bits) - 1);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x67f87f589cd5123ffa32f883ea2f09b0e56258508bae82b8c655b3c27c71eb5e\"},\"@keep-network/sortition-pools/contracts/Rewards.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\n/// @title Rewards\\n/// @notice Rewards are allocated proportionally to operators\\n/// present in the pool at payout based on their weight in the pool.\\n///\\n/// To facilitate this, we use a global accumulator value\\n/// to track the total rewards one unit of weight would've earned\\n/// since the creation of the pool.\\n///\\n/// Whenever a reward is paid, the accumulator is increased\\n/// by the size of the reward divided by the total weight\\n/// of all eligible operators in the pool.\\n///\\n/// Each operator has an individual accumulator value,\\n/// set to equal the global accumulator when the operator joins the pool.\\n/// This accumulator reflects the amount of rewards\\n/// that have already been accounted for with that operator.\\n///\\n/// Whenever an operator's weight in the pool changes,\\n/// we can update the amount of rewards the operator has earned\\n/// by subtracting the operator's accumulator from the global accumulator.\\n/// This gives us the amount of rewards one unit of weight has earned\\n/// since the last time the operator's rewards have been updated.\\n/// Then we multiply that by the operator's previous (pre-change) weight\\n/// to determine how much rewards in total the operator has earned,\\n/// and add this to the operator's earned rewards.\\n/// Finally, we set the operator's accumulator to the global accumulator value.\\ncontract Rewards {\\n struct OperatorRewards {\\n // The state of the global accumulator\\n // when the operator's rewards were last updated\\n uint96 accumulated;\\n // The amount of rewards collected by the operator after the latest update.\\n // The amount the operator could withdraw may equal `available`\\n // or it may be greater, if more rewards have been paid in since then.\\n // To evaulate the most recent amount including rewards potentially paid\\n // since the last update, use `availableRewards` function.\\n uint96 available;\\n // If nonzero, the operator is ineligible for rewards\\n // and may only re-enable rewards after the specified timestamp.\\n // XXX: unsigned 32-bit integer unix seconds, will break around 2106\\n uint32 ineligibleUntil;\\n // Locally cached weight of the operator,\\n // used to reduce the cost of setting operators ineligible.\\n uint32 weight;\\n }\\n\\n // The global accumulator of how much rewards\\n // a hypothetical operator of weight 1 would have earned\\n // since the creation of the pool.\\n uint96 internal globalRewardAccumulator;\\n // If the amount of reward tokens paid in\\n // does not divide cleanly by pool weight,\\n // the difference is recorded as rounding dust\\n // and added to the next reward.\\n uint96 internal rewardRoundingDust;\\n\\n // The amount of rewards that would've been earned by ineligible operators\\n // had they not been ineligible.\\n uint96 public ineligibleEarnedRewards;\\n\\n // Ineligibility times are calculated from this offset,\\n // set at contract creation.\\n uint256 internal immutable ineligibleOffsetStart;\\n\\n mapping(uint32 => OperatorRewards) internal operatorRewards;\\n\\n constructor() {\\n // solhint-disable-next-line not-rely-on-time\\n ineligibleOffsetStart = block.timestamp;\\n }\\n\\n /// @notice Return whether the operator is eligible for rewards or not.\\n function isEligibleForRewards(uint32 operator) internal view returns (bool) {\\n return operatorRewards[operator].ineligibleUntil == 0;\\n }\\n\\n /// @notice Return the time the operator's reward eligibility can be restored.\\n function rewardsEligibilityRestorableAt(uint32 operator)\\n internal\\n view\\n returns (uint256)\\n {\\n uint32 until = operatorRewards[operator].ineligibleUntil;\\n require(until != 0, \\\"Operator already eligible\\\");\\n return (uint256(until) + ineligibleOffsetStart);\\n }\\n\\n /// @notice Return whether the operator is able to restore their eligibility\\n /// for rewards right away.\\n function canRestoreRewardEligibility(uint32 operator)\\n internal\\n view\\n returns (bool)\\n {\\n // solhint-disable-next-line not-rely-on-time\\n return rewardsEligibilityRestorableAt(operator) <= block.timestamp;\\n }\\n\\n /// @notice Internal function for updating the global state of rewards.\\n function addRewards(uint96 rewardAmount, uint32 currentPoolWeight) internal {\\n require(currentPoolWeight > 0, \\\"No recipients in pool\\\");\\n\\n uint96 totalAmount = rewardAmount + rewardRoundingDust;\\n uint96 perWeightReward = totalAmount / currentPoolWeight;\\n uint96 newRoundingDust = totalAmount % currentPoolWeight;\\n\\n globalRewardAccumulator += perWeightReward;\\n rewardRoundingDust = newRoundingDust;\\n }\\n\\n /// @notice Internal function for updating the operator's reward state.\\n function updateOperatorRewards(uint32 operator, uint32 newWeight) internal {\\n uint96 acc = globalRewardAccumulator;\\n OperatorRewards memory o = operatorRewards[operator];\\n uint96 accruedRewards = (acc - o.accumulated) * uint96(o.weight);\\n if (o.ineligibleUntil == 0) {\\n // If operator is not ineligible, update their earned rewards\\n o.available += accruedRewards;\\n } else {\\n // If ineligible, put the rewards into the ineligible pot\\n ineligibleEarnedRewards += accruedRewards;\\n }\\n // In any case, update their accumulator and weight\\n o.accumulated = acc;\\n o.weight = newWeight;\\n operatorRewards[operator] = o;\\n }\\n\\n /// @notice Set the amount of withdrawable tokens to zero\\n /// and return the previous withdrawable amount.\\n /// @dev Does not update the withdrawable amount,\\n /// but should usually be accompanied by an update.\\n function withdrawOperatorRewards(uint32 operator)\\n internal\\n returns (uint96 withdrawable)\\n {\\n OperatorRewards storage o = operatorRewards[operator];\\n withdrawable = o.available;\\n o.available = 0;\\n }\\n\\n /// @notice Set the amount of ineligible-earned tokens to zero\\n /// and return the previous amount.\\n function withdrawIneligibleRewards() internal returns (uint96 withdrawable) {\\n withdrawable = ineligibleEarnedRewards;\\n ineligibleEarnedRewards = 0;\\n }\\n\\n /// @notice Set the given operators as ineligible for rewards.\\n /// The operators can restore their eligibility at the given time.\\n function setIneligible(uint32[] memory operators, uint256 until) internal {\\n OperatorRewards memory o = OperatorRewards(0, 0, 0, 0);\\n uint96 globalAcc = globalRewardAccumulator;\\n uint96 accrued = 0;\\n // Record ineligibility as seconds after contract creation\\n uint32 _until = uint32(until - ineligibleOffsetStart);\\n\\n for (uint256 i = 0; i < operators.length; i++) {\\n uint32 operator = operators[i];\\n OperatorRewards storage r = operatorRewards[operator];\\n o.available = r.available;\\n o.accumulated = r.accumulated;\\n o.ineligibleUntil = r.ineligibleUntil;\\n o.weight = r.weight;\\n\\n if (o.ineligibleUntil != 0) {\\n // If operator is already ineligible,\\n // don't earn rewards or shorten its ineligibility\\n if (o.ineligibleUntil < _until) {\\n o.ineligibleUntil = _until;\\n }\\n } else {\\n // The operator becomes ineligible -> earn rewards\\n o.ineligibleUntil = _until;\\n accrued = (globalAcc - o.accumulated) * uint96(o.weight);\\n o.available += accrued;\\n }\\n o.accumulated = globalAcc;\\n\\n r.available = o.available;\\n r.accumulated = o.accumulated;\\n r.ineligibleUntil = o.ineligibleUntil;\\n r.weight = o.weight;\\n }\\n }\\n\\n /// @notice Restore the given operator's eligibility for rewards.\\n function restoreEligibility(uint32 operator) internal {\\n // solhint-disable-next-line not-rely-on-time\\n require(canRestoreRewardEligibility(operator), \\\"Operator still ineligible\\\");\\n uint96 acc = globalRewardAccumulator;\\n OperatorRewards memory o = operatorRewards[operator];\\n uint96 accruedRewards = (acc - o.accumulated) * uint96(o.weight);\\n ineligibleEarnedRewards += accruedRewards;\\n o.accumulated = acc;\\n o.ineligibleUntil = 0;\\n operatorRewards[operator] = o;\\n }\\n\\n /// @notice Returns the amount of rewards currently available for withdrawal\\n /// for the given operator.\\n function availableRewards(uint32 operator) internal view returns (uint96) {\\n uint96 acc = globalRewardAccumulator;\\n OperatorRewards memory o = operatorRewards[operator];\\n if (o.ineligibleUntil == 0) {\\n // If operator is not ineligible, calculate newly accrued rewards and add\\n // them to the available ones, calculated during the last update.\\n uint96 accruedRewards = (acc - o.accumulated) * uint96(o.weight);\\n return o.available + accruedRewards;\\n } else {\\n // If ineligible, return only the rewards calculated during the last\\n // update.\\n return o.available;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3a10abb408b44335a092387b2c7ee01db3b27997f1f2c888d9b7a2d92934c4e2\"},\"@keep-network/sortition-pools/contracts/SortitionPool.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./RNG.sol\\\";\\nimport \\\"./SortitionTree.sol\\\";\\nimport \\\"./Rewards.sol\\\";\\nimport \\\"./Chaosnet.sol\\\";\\n\\n/// @title Sortition Pool\\n/// @notice A logarithmic data structure used to store the pool of eligible\\n/// operators weighted by their stakes. It allows to select a group of operators\\n/// based on the provided pseudo-random seed.\\ncontract SortitionPool is\\n SortitionTree,\\n Rewards,\\n Ownable,\\n Chaosnet,\\n IReceiveApproval\\n{\\n using Branch for uint256;\\n using Leaf for uint256;\\n using Position for uint256;\\n\\n IERC20WithPermit public immutable rewardToken;\\n\\n uint256 public immutable poolWeightDivisor;\\n\\n bool public isLocked;\\n\\n event IneligibleForRewards(uint32[] ids, uint256 until);\\n\\n event RewardEligibilityRestored(address indexed operator, uint32 indexed id);\\n\\n /// @notice Reverts if called while pool is locked.\\n modifier onlyUnlocked() {\\n require(!isLocked, \\\"Sortition pool locked\\\");\\n _;\\n }\\n\\n /// @notice Reverts if called while pool is unlocked.\\n modifier onlyLocked() {\\n require(isLocked, \\\"Sortition pool unlocked\\\");\\n _;\\n }\\n\\n constructor(IERC20WithPermit _rewardToken, uint256 _poolWeightDivisor) {\\n rewardToken = _rewardToken;\\n poolWeightDivisor = _poolWeightDivisor;\\n }\\n\\n function receiveApproval(\\n address sender,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(token == address(rewardToken), \\\"Unsupported token\\\");\\n rewardToken.transferFrom(sender, address(this), amount);\\n Rewards.addRewards(uint96(amount), uint32(root.sumWeight()));\\n }\\n\\n /// @notice Withdraws all available rewards for the given operator to the\\n /// given beneficiary.\\n /// @dev Can be called only be the owner. Does not validate if the provided\\n /// beneficiary is associated with the provided operator - this needs to\\n /// be done by the owner calling this function.\\n /// @return The amount of rewards withdrawn in this call.\\n function withdrawRewards(address operator, address beneficiary)\\n public\\n onlyOwner\\n returns (uint96)\\n {\\n uint32 id = getOperatorID(operator);\\n Rewards.updateOperatorRewards(id, uint32(getPoolWeight(operator)));\\n uint96 earned = Rewards.withdrawOperatorRewards(id);\\n rewardToken.transfer(beneficiary, uint256(earned));\\n return earned;\\n }\\n\\n /// @notice Withdraws rewards not allocated to operators marked as ineligible\\n /// to the given recipient address.\\n /// @dev Can be called only by the owner.\\n function withdrawIneligible(address recipient) public onlyOwner {\\n uint96 earned = Rewards.withdrawIneligibleRewards();\\n rewardToken.transfer(recipient, uint256(earned));\\n }\\n\\n /// @notice Locks the sortition pool. In locked state, members cannot be\\n /// inserted and removed from the pool. Members statuses cannot\\n /// be updated as well.\\n /// @dev Can be called only by the contract owner.\\n function lock() public onlyOwner {\\n isLocked = true;\\n }\\n\\n /// @notice Unlocks the sortition pool. Removes all restrictions set by\\n /// the `lock` method.\\n /// @dev Can be called only by the contract owner.\\n function unlock() public onlyOwner {\\n isLocked = false;\\n }\\n\\n /// @notice Inserts an operator to the pool. Reverts if the operator is\\n /// already present. Reverts if the operator is not eligible because of their\\n /// authorized stake. Reverts if the chaosnet is active and the operator is\\n /// not a beta operator.\\n /// @dev Can be called only by the contract owner.\\n /// @param operator Address of the inserted operator.\\n /// @param authorizedStake Inserted operator's authorized stake for the application.\\n function insertOperator(address operator, uint256 authorizedStake)\\n public\\n onlyOwner\\n // TODO: Disabled temporarily for a test environment. This should never be disabled\\n // in normal circumstances.\\n // onlyUnlocked\\n {\\n uint256 weight = getWeight(authorizedStake);\\n require(weight > 0, \\\"Operator not eligible\\\");\\n\\n if (isChaosnetActive) {\\n require(isBetaOperator[operator], \\\"Not beta operator for chaosnet\\\");\\n }\\n\\n _insertOperator(operator, weight);\\n uint32 id = getOperatorID(operator);\\n Rewards.updateOperatorRewards(id, uint32(weight));\\n }\\n\\n /// @notice Update the operator's weight if present and eligible,\\n /// or remove from the pool if present and ineligible.\\n /// @dev Can be called only by the contract owner.\\n /// @param operator Address of the updated operator.\\n /// @param authorizedStake Operator's authorized stake for the application.\\n function updateOperatorStatus(address operator, uint256 authorizedStake)\\n public\\n onlyOwner\\n onlyUnlocked\\n {\\n uint256 weight = getWeight(authorizedStake);\\n\\n uint32 id = getOperatorID(operator);\\n Rewards.updateOperatorRewards(id, uint32(weight));\\n\\n if (weight == 0) {\\n _removeOperator(operator);\\n } else {\\n updateOperator(operator, weight);\\n }\\n }\\n\\n /// @notice Set the given operators as ineligible for rewards.\\n /// The operators can restore their eligibility at the given time.\\n function setRewardIneligibility(uint32[] calldata operators, uint256 until)\\n public\\n onlyOwner\\n {\\n Rewards.setIneligible(operators, until);\\n emit IneligibleForRewards(operators, until);\\n }\\n\\n /// @notice Restores reward eligibility for the operator.\\n function restoreRewardEligibility(address operator) public {\\n uint32 id = getOperatorID(operator);\\n Rewards.restoreEligibility(id);\\n emit RewardEligibilityRestored(operator, id);\\n }\\n\\n /// @notice Returns whether the operator is eligible for rewards or not.\\n function isEligibleForRewards(address operator) public view returns (bool) {\\n uint32 id = getOperatorID(operator);\\n return Rewards.isEligibleForRewards(id);\\n }\\n\\n /// @notice Returns the time the operator's reward eligibility can be restored.\\n function rewardsEligibilityRestorableAt(address operator)\\n public\\n view\\n returns (uint256)\\n {\\n uint32 id = getOperatorID(operator);\\n return Rewards.rewardsEligibilityRestorableAt(id);\\n }\\n\\n /// @notice Returns whether the operator is able to restore their eligibility\\n /// for rewards right away.\\n function canRestoreRewardEligibility(address operator)\\n public\\n view\\n returns (bool)\\n {\\n uint32 id = getOperatorID(operator);\\n return Rewards.canRestoreRewardEligibility(id);\\n }\\n\\n /// @notice Returns the amount of rewards withdrawable for the given operator.\\n function getAvailableRewards(address operator) public view returns (uint96) {\\n uint32 id = getOperatorID(operator);\\n return availableRewards(id);\\n }\\n\\n /// @notice Return whether the operator is present in the pool.\\n function isOperatorInPool(address operator) public view returns (bool) {\\n return getFlaggedLeafPosition(operator) != 0;\\n }\\n\\n /// @notice Return whether the operator's weight in the pool\\n /// matches their eligible weight.\\n function isOperatorUpToDate(address operator, uint256 authorizedStake)\\n public\\n view\\n returns (bool)\\n {\\n return getWeight(authorizedStake) == getPoolWeight(operator);\\n }\\n\\n /// @notice Return the weight of the operator in the pool,\\n /// which may or may not be out of date.\\n function getPoolWeight(address operator) public view returns (uint256) {\\n uint256 flaggedPosition = getFlaggedLeafPosition(operator);\\n if (flaggedPosition == 0) {\\n return 0;\\n } else {\\n uint256 leafPosition = flaggedPosition.unsetFlag();\\n uint256 leafWeight = getLeafWeight(leafPosition);\\n return leafWeight;\\n }\\n }\\n\\n /// @notice Selects a new group of operators of the provided size based on\\n /// the provided pseudo-random seed. At least one operator has to be\\n /// registered in the pool, otherwise the function fails reverting the\\n /// transaction.\\n /// @param groupSize Size of the requested group\\n /// @param seed Pseudo-random number used to select operators to group\\n /// @return selected Members of the selected group\\n function selectGroup(uint256 groupSize, bytes32 seed)\\n public\\n view\\n onlyLocked\\n returns (uint32[] memory)\\n {\\n uint256 _root = root;\\n\\n bytes32 rngState = seed;\\n uint256 rngRange = _root.sumWeight();\\n require(rngRange > 0, \\\"Not enough operators in pool\\\");\\n uint256 currentIndex;\\n\\n uint256 bits = RNG.bitsRequired(rngRange);\\n\\n uint32[] memory selected = new uint32[](groupSize);\\n\\n for (uint256 i = 0; i < groupSize; i++) {\\n (currentIndex, rngState) = RNG.getIndex(rngRange, rngState, bits);\\n\\n uint256 leafPosition = pickWeightedLeaf(currentIndex, _root);\\n\\n uint256 leaf = leaves[leafPosition];\\n selected[i] = leaf.id();\\n }\\n return selected;\\n }\\n\\n function getWeight(uint256 authorization) internal view returns (uint256) {\\n return authorization / poolWeightDivisor;\\n }\\n}\\n\",\"keccak256\":\"0x3c330b682bcb722bba861077a229f0605cda2142c3f0d45aaf2ce6a295e80615\"},\"@keep-network/sortition-pools/contracts/SortitionTree.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Branch.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Leaf.sol\\\";\\nimport \\\"./Constants.sol\\\";\\n\\ncontract SortitionTree {\\n using Branch for uint256;\\n using Position for uint256;\\n using Leaf for uint256;\\n\\n // implicit tree\\n // root 8\\n // level2 64\\n // level3 512\\n // level4 4k\\n // level5 32k\\n // level6 256k\\n // level7 2M\\n uint256 internal root;\\n\\n // A 2-index mapping from layer => (index (0-index) => branch). For example,\\n // to access the 6th branch in the 2nd layer (right below the root node; the\\n // first branch layer), call branches[2][5]. Mappings are used in place of\\n // arrays for efficiency. The root is the first layer, the branches occupy\\n // layers 2 through 7, and layer 8 is for the leaves. Following this\\n // convention, the first index in `branches` is `2`, and the last index is\\n // `7`.\\n mapping(uint256 => mapping(uint256 => uint256)) internal branches;\\n\\n // A 0-index mapping from index => leaf, acting as an array. For example, to\\n // access the 42nd leaf, call leaves[41].\\n mapping(uint256 => uint256) internal leaves;\\n\\n // the flagged (see setFlag() and unsetFlag() in Position.sol) positions\\n // of all operators present in the pool\\n mapping(address => uint256) internal flaggedLeafPosition;\\n\\n // the leaf after the rightmost occupied leaf of each stack\\n uint256 internal rightmostLeaf;\\n\\n // the empty leaves in each stack\\n // between 0 and the rightmost occupied leaf\\n uint256[] internal emptyLeaves;\\n\\n // Each operator has an uint32 ID number\\n // which is allocated when they first join the pool\\n // and remains unchanged even if they leave and rejoin the pool.\\n mapping(address => uint32) internal operatorID;\\n\\n // The idAddress array records the address corresponding to each ID number.\\n // The ID number 0 is initialized with a zero address and is not used.\\n address[] internal idAddress;\\n\\n constructor() {\\n root = 0;\\n rightmostLeaf = 0;\\n idAddress.push();\\n }\\n\\n /// @notice Return the ID number of the given operator address. An ID number\\n /// of 0 means the operator has not been allocated an ID number yet.\\n /// @param operator Address of the operator.\\n /// @return the ID number of the given operator address\\n function getOperatorID(address operator) public view returns (uint32) {\\n return operatorID[operator];\\n }\\n\\n /// @notice Get the operator address corresponding to the given ID number. A\\n /// zero address means the ID number has not been allocated yet.\\n /// @param id ID of the operator\\n /// @return the address of the operator\\n function getIDOperator(uint32 id) public view returns (address) {\\n return idAddress.length > id ? idAddress[id] : address(0);\\n }\\n\\n /// @notice Gets the operator addresses corresponding to the given ID\\n /// numbers. A zero address means the ID number has not been allocated yet.\\n /// This function works just like getIDOperator except that it allows to fetch\\n /// operator addresses for multiple IDs in one call.\\n /// @param ids the array of the operator ids\\n /// @return an array of the associated operator addresses\\n function getIDOperators(uint32[] calldata ids)\\n public\\n view\\n returns (address[] memory)\\n {\\n uint256 idCount = idAddress.length;\\n\\n address[] memory operators = new address[](ids.length);\\n for (uint256 i = 0; i < ids.length; i++) {\\n uint32 id = ids[i];\\n operators[i] = idCount > id ? idAddress[id] : address(0);\\n }\\n return operators;\\n }\\n\\n /// @notice Checks if operator is already registered in the pool.\\n /// @param operator the address of the operator\\n /// @return whether or not the operator is already registered in the pool\\n function isOperatorRegistered(address operator) public view returns (bool) {\\n return getFlaggedLeafPosition(operator) != 0;\\n }\\n\\n /// @notice Sum the number of operators in each trunk.\\n /// @return the number of operators in the pool\\n function operatorsInPool() public view returns (uint256) {\\n // Get the number of leaves that might be occupied;\\n // if `rightmostLeaf` equals `firstLeaf()` the tree must be empty,\\n // otherwise the difference between these numbers\\n // gives the number of leaves that may be occupied.\\n uint256 nPossiblyUsedLeaves = rightmostLeaf;\\n // Get the number of empty leaves\\n // not accounted for by the `rightmostLeaf`\\n uint256 nEmptyLeaves = emptyLeaves.length;\\n\\n return (nPossiblyUsedLeaves - nEmptyLeaves);\\n }\\n\\n /// @notice Convenience method to return the total weight of the pool\\n /// @return the total weight of the pool\\n function totalWeight() public view returns (uint256) {\\n return root.sumWeight();\\n }\\n\\n /// @notice Give the operator a new ID number.\\n /// Does not check if the operator already has an ID number.\\n /// @param operator the address of the operator\\n /// @return a new ID for that operator\\n function allocateOperatorID(address operator) internal returns (uint256) {\\n uint256 id = idAddress.length;\\n\\n require(id <= type(uint32).max, \\\"Pool capacity exceeded\\\");\\n\\n operatorID[operator] = uint32(id);\\n idAddress.push(operator);\\n return id;\\n }\\n\\n /// @notice Inserts an operator into the sortition pool\\n /// @param operator the address of an operator to insert\\n /// @param weight how much weight that operator has in the pool\\n function _insertOperator(address operator, uint256 weight) internal {\\n require(\\n !isOperatorRegistered(operator),\\n \\\"Operator is already registered in the pool\\\"\\n );\\n\\n // Fetch the operator's ID, and if they don't have one, allocate them one.\\n uint256 id = getOperatorID(operator);\\n if (id == 0) {\\n id = allocateOperatorID(operator);\\n }\\n\\n // Determine which leaf to insert them into\\n uint256 position = getEmptyLeafPosition();\\n // Record the block the operator was inserted in\\n uint256 theLeaf = Leaf.make(operator, block.number, id);\\n\\n // Update the leaf, and propagate the weight changes all the way up to the\\n // root.\\n root = setLeaf(position, theLeaf, weight, root);\\n\\n // Without position flags,\\n // the position 0x000000 would be treated as empty\\n flaggedLeafPosition[operator] = position.setFlag();\\n }\\n\\n /// @notice Remove an operator (and their weight) from the pool.\\n /// @param operator the address of the operator to remove\\n function _removeOperator(address operator) internal {\\n uint256 flaggedPosition = getFlaggedLeafPosition(operator);\\n require(flaggedPosition != 0, \\\"Operator is not registered in the pool\\\");\\n uint256 unflaggedPosition = flaggedPosition.unsetFlag();\\n\\n // Update the leaf, and propagate the weight changes all the way up to the\\n // root.\\n root = removeLeaf(unflaggedPosition, root);\\n removeLeafPositionRecord(operator);\\n }\\n\\n /// @notice Update an operator's weight in the pool.\\n /// @param operator the address of the operator to update\\n /// @param weight the new weight\\n function updateOperator(address operator, uint256 weight) internal {\\n require(\\n isOperatorRegistered(operator),\\n \\\"Operator is not registered in the pool\\\"\\n );\\n\\n uint256 flaggedPosition = getFlaggedLeafPosition(operator);\\n uint256 unflaggedPosition = flaggedPosition.unsetFlag();\\n root = updateLeaf(unflaggedPosition, weight, root);\\n }\\n\\n /// @notice Helper method to remove a leaf position record for an operator.\\n /// @param operator the address of the operator to remove the record for\\n function removeLeafPositionRecord(address operator) internal {\\n flaggedLeafPosition[operator] = 0;\\n }\\n\\n /// @notice Removes the data and weight from a particular leaf.\\n /// @param position the leaf index to remove\\n /// @param _root the root node containing the leaf\\n /// @return the updated root node\\n function removeLeaf(uint256 position, uint256 _root)\\n internal\\n returns (uint256)\\n {\\n uint256 rightmostSubOne = rightmostLeaf - 1;\\n bool isRightmost = position == rightmostSubOne;\\n\\n // Clears out the data in the leaf node, and then propagates the weight\\n // changes all the way up to the root.\\n uint256 newRoot = setLeaf(position, 0, 0, _root);\\n\\n // Infer if need to fall back on emptyLeaves yet\\n if (isRightmost) {\\n rightmostLeaf = rightmostSubOne;\\n } else {\\n emptyLeaves.push(position);\\n }\\n return newRoot;\\n }\\n\\n /// @notice Updates the tree to give a particular leaf a new weight.\\n /// @param position the index of the leaf to update\\n /// @param weight the new weight\\n /// @param _root the root node containing the leaf\\n /// @return the updated root node\\n function updateLeaf(\\n uint256 position,\\n uint256 weight,\\n uint256 _root\\n ) internal returns (uint256) {\\n if (getLeafWeight(position) != weight) {\\n return updateTree(position, weight, _root);\\n } else {\\n return _root;\\n }\\n }\\n\\n /// @notice Places a leaf into a particular position, with a given weight and\\n /// propagates that change.\\n /// @param position the index to place the leaf in\\n /// @param theLeaf the new leaf to place in the position\\n /// @param leafWeight the weight of the leaf\\n /// @param _root the root containing the new leaf\\n /// @return the updated root node\\n function setLeaf(\\n uint256 position,\\n uint256 theLeaf,\\n uint256 leafWeight,\\n uint256 _root\\n ) internal returns (uint256) {\\n // set leaf\\n leaves[position] = theLeaf;\\n\\n return (updateTree(position, leafWeight, _root));\\n }\\n\\n /// @notice Propagates a weight change at a position through the tree,\\n /// eventually returning the updated root.\\n /// @param position the index of leaf to update\\n /// @param weight the new weight of the leaf\\n /// @param _root the root node containing the leaf\\n /// @return the updated root node\\n function updateTree(\\n uint256 position,\\n uint256 weight,\\n uint256 _root\\n ) internal returns (uint256) {\\n uint256 childSlot;\\n uint256 treeNode;\\n uint256 newNode;\\n uint256 nodeWeight = weight;\\n\\n uint256 parent = position;\\n // set levels 7 to 2\\n for (uint256 level = Constants.LEVELS; level >= 2; level--) {\\n childSlot = parent.slot();\\n parent = parent.parent();\\n treeNode = branches[level][parent];\\n newNode = treeNode.setSlot(childSlot, nodeWeight);\\n branches[level][parent] = newNode;\\n nodeWeight = newNode.sumWeight();\\n }\\n\\n // set level Root\\n childSlot = parent.slot();\\n return _root.setSlot(childSlot, nodeWeight);\\n }\\n\\n /// @notice Retrieves the next available empty leaf position. Tries to fill\\n /// left to right first, ignoring leaf removals, and then fills\\n /// most-recent-removals first.\\n /// @return the position of the empty leaf\\n function getEmptyLeafPosition() internal returns (uint256) {\\n uint256 rLeaf = rightmostLeaf;\\n bool spaceOnRight = (rLeaf + 1) < Constants.POOL_CAPACITY;\\n if (spaceOnRight) {\\n rightmostLeaf = rLeaf + 1;\\n return rLeaf;\\n } else {\\n uint256 emptyLeafCount = emptyLeaves.length;\\n require(emptyLeafCount > 0, \\\"Pool is full\\\");\\n uint256 emptyLeaf = emptyLeaves[emptyLeafCount - 1];\\n emptyLeaves.pop();\\n return emptyLeaf;\\n }\\n }\\n\\n /// @notice Gets the flagged leaf position for an operator.\\n /// @param operator the address of the operator\\n /// @return the leaf position of that operator\\n function getFlaggedLeafPosition(address operator)\\n internal\\n view\\n returns (uint256)\\n {\\n return flaggedLeafPosition[operator];\\n }\\n\\n /// @notice Gets the weight of a leaf at a particular position.\\n /// @param position the index of the leaf\\n /// @return the weight of the leaf at that position\\n function getLeafWeight(uint256 position) internal view returns (uint256) {\\n uint256 slot = position.slot();\\n uint256 parent = position.parent();\\n\\n // A leaf's weight information is stored a 32-bit slot in the branch layer\\n // directly above the leaf layer. To access it, we calculate that slot and\\n // parent position, and always know the hard-coded layer index.\\n uint256 node = branches[Constants.LEVELS][parent];\\n return node.getSlot(slot);\\n }\\n\\n /// @notice Picks a leaf given a random index.\\n /// @param index a number in `[0, _root.totalWeight())` used to decide\\n /// between leaves\\n /// @param _root the root of the tree\\n function pickWeightedLeaf(uint256 index, uint256 _root)\\n internal\\n view\\n returns (uint256 leafPosition)\\n {\\n uint256 currentIndex = index;\\n uint256 currentNode = _root;\\n uint256 currentPosition = 0;\\n uint256 currentSlot;\\n\\n require(index < currentNode.sumWeight(), \\\"Index exceeds weight\\\");\\n\\n // get root slot\\n (currentSlot, currentIndex) = currentNode.pickWeightedSlot(currentIndex);\\n\\n // get slots from levels 2 to 7\\n for (uint256 level = 2; level <= Constants.LEVELS; level++) {\\n currentPosition = currentPosition.child(currentSlot);\\n currentNode = branches[level][currentPosition];\\n (currentSlot, currentIndex) = currentNode.pickWeightedSlot(currentIndex);\\n }\\n\\n // get leaf position\\n leafPosition = currentPosition.child(currentSlot);\\n }\\n}\\n\",\"keccak256\":\"0x51daeca62ef52be78a1a9de4d2a1c5900c873165f59eda14d5965d7d7da90a03\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = _setInitializedVersion(1);\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n bool isTopLevelCall = _setInitializedVersion(version);\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(version);\\n }\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n _setInitializedVersion(type(uint8).max);\\n }\\n\\n function _setInitializedVersion(uint8 version) private returns (bool) {\\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\\n // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level\\n // of initializers, because in other contexts the contract may have been reentered.\\n if (_initializing) {\\n require(\\n version == 1 && !AddressUpgradeable.isContract(address(this)),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n return false;\\n } else {\\n require(_initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n return true;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7454006cccb737612b00104d2f606d728e2818b778e7e55542f063c614ce46ba\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x55cf2bd9fc76704ddcdc19834cd288b7de00fc0f298a40ea16a954ae8991db2d\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x398d3323c1932a5986bf36be7c57593e121e69d5db5b6574b4ee0d031443de37\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../StringsUpgradeable.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSAUpgradeable {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n // Check the signature length\\n // - case 65: r,s,v signature (standard)\\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else if (signature.length == 64) {\\n bytes32 r;\\n bytes32 vs;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n vs := mload(add(signature, 0x40))\\n }\\n return tryRecover(hash, r, vs);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", StringsUpgradeable.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0x6602a65e0277f31f45cad4c7a15b024fd182f2f0e01eaa1954103b0d57848a27\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128) {\\n require(value >= type(int128).min && value <= type(int128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return int128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64) {\\n require(value >= type(int64).min && value <= type(int64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return int64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32) {\\n require(value >= type(int32).min && value <= type(int32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return int32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16) {\\n require(value >= type(int16).min && value <= type(int16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return int16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8) {\\n require(value >= type(int8).min && value <= type(int8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return int8(value);\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcec885ecdf113b4265ed0856972d7ff167bfeb3802604b18cbb782bf47ecc4ae\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x0e9621f60b2faabe65549f7ed0f24e8853a45c1b7990d47e8160e523683f3935\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x0d4de01fe5360c38b4ad2b0822a12722958428f5138a7ff47c1720eb6fa52bba\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x32c202bd28995dd20c4347b7c6467a6d3241c74c8ad3edcbb610cd9205916c45\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n // Check the signature length\\n // - case 65: r,s,v signature (standard)\\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else if (signature.length == 64) {\\n bytes32 r;\\n bytes32 vs;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n vs := mload(add(signature, 0x40))\\n }\\n return tryRecover(hash, r, vs);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0x3c07f43e60e099b3b157243b3152722e73b80eeb7985c2cd73712828d7f7da29\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a >= b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonce;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `spender` and `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `spender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(spender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(spender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonce[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(spender, recipient, amount);\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[spender] = spenderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(spender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x1e1bf4ec5c9d6fe70f6f834316482aeff3f122ff4ffaa7178099e7ae71a0b16d\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonce(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xdac9a5086c19a7128b505a7be1ab0ac1aa314f6989cb88d2417e9d7383f89fa9\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\n/// @title MisfundRecovery\\n/// @notice Allows the owner of the token contract extending MisfundRecovery\\n/// to recover any ERC20 and ERC721 sent mistakenly to the token\\n/// contract address.\\ncontract MisfundRecovery is Ownable {\\n using SafeERC20 for IERC20;\\n\\n function recoverERC20(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n token.safeTransfer(recipient, amount);\\n }\\n\\n function recoverERC721(\\n IERC721 token,\\n address recipient,\\n uint256 tokenId,\\n bytes calldata data\\n ) external onlyOwner {\\n token.safeTransferFrom(address(this), recipient, tokenId, data);\\n }\\n}\\n\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"contracts/GovernanceUtils.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nlibrary GovernanceUtils {\\n /// @notice Reverts if the governance delay has not passed since\\n /// the change initiated time or if the change has not been\\n /// initiated.\\n /// @param changeInitiatedTimestamp The timestamp at which the change has\\n /// been initiated.\\n /// @param delay Governance delay.\\n function onlyAfterGovernanceDelay(\\n uint256 changeInitiatedTimestamp,\\n uint256 delay\\n ) internal view {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp - changeInitiatedTimestamp >= delay,\\n \\\"Governance delay has not elapsed\\\"\\n );\\n }\\n\\n /// @notice Gets the time remaining until the governable parameter update\\n /// can be committed.\\n /// @param changeInitiatedTimestamp Timestamp indicating the beginning of\\n /// the change.\\n /// @param delay Governance delay.\\n /// @return Remaining time in seconds.\\n function getRemainingGovernanceDelay(\\n uint256 changeInitiatedTimestamp,\\n uint256 delay\\n ) internal view returns (uint256) {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n uint256 elapsed = block.timestamp - changeInitiatedTimestamp;\\n if (elapsed >= delay) {\\n return 0;\\n } else {\\n return delay - elapsed;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9d16501e1b7c368ced397fd2eff0ab1bd1db8d26cc3700d0b7740942ee3c3c31\",\"license\":\"GPL-3.0-only\"},\"contracts/bank/Bank.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IReceiveBalanceApproval.sol\\\";\\nimport \\\"../vault/IVault.sol\\\";\\n\\n/// @title Bitcoin Bank\\n/// @notice Bank is a central component tracking Bitcoin balances. Balances can\\n/// be transferred between balance owners, and balance owners can\\n/// approve their balances to be spent by others. Balances in the Bank\\n/// are updated for depositors who deposited their Bitcoin into the\\n/// Bridge and only the Bridge can increase balances.\\n/// @dev Bank is a governable contract and the Governance can upgrade the Bridge\\n/// address.\\ncontract Bank is Ownable {\\n address public bridge;\\n\\n /// @notice The balance of the given account in the Bank. Zero by default.\\n mapping(address => uint256) public balanceOf;\\n\\n /// @notice The remaining amount of balance a spender will be\\n /// allowed to transfer on behalf of an owner using\\n /// `transferBalanceFrom`. Zero by default.\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /// @notice Returns the current nonce for an EIP2612 permission for the\\n /// provided balance owner to protect against replay attacks. Used\\n /// to construct an EIP2612 signature provided to the `permit`\\n /// function.\\n mapping(address => uint256) public nonces;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns an EIP2612 Permit message hash. Used to construct\\n /// an EIP2612 signature provided to the `permit` function.\\n bytes32 public constant PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n event BalanceTransferred(\\n address indexed from,\\n address indexed to,\\n uint256 amount\\n );\\n\\n event BalanceApproved(\\n address indexed owner,\\n address indexed spender,\\n uint256 amount\\n );\\n\\n event BalanceIncreased(address indexed owner, uint256 amount);\\n\\n event BalanceDecreased(address indexed owner, uint256 amount);\\n\\n event BridgeUpdated(address newBridge);\\n\\n modifier onlyBridge() {\\n require(msg.sender == address(bridge), \\\"Caller is not the bridge\\\");\\n _;\\n }\\n\\n constructor() {\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Allows the Governance to upgrade the Bridge address.\\n /// @dev The function does not implement any governance delay and does not\\n /// check the status of the Bridge. The Governance implementation needs\\n /// to ensure all requirements for the upgrade are satisfied before\\n /// executing this function.\\n /// Requirements:\\n /// - The new Bridge address must not be zero.\\n /// @param _bridge The new Bridge address.\\n function updateBridge(address _bridge) external onlyOwner {\\n require(_bridge != address(0), \\\"Bridge address must not be 0x0\\\");\\n bridge = _bridge;\\n emit BridgeUpdated(_bridge);\\n }\\n\\n /// @notice Moves the given `amount` of balance from the caller to\\n /// `recipient`.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n /// @param recipient The recipient of the balance.\\n /// @param amount The amount of the balance transferred.\\n function transferBalance(address recipient, uint256 amount) external {\\n _transferBalance(msg.sender, recipient, amount);\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// balance. Does not allow updating an existing allowance to\\n /// a value that is non-zero to avoid someone using both the old and\\n /// the new allowance by unfortunate transaction ordering. To update\\n /// an allowance to a non-zero value please set it to zero first or\\n /// use `increaseBalanceAllowance` or `decreaseBalanceAllowance` for\\n /// an atomic update.\\n /// @dev If the `amount` is set to `type(uint256).max`,\\n /// `transferBalanceFrom` will not reduce an allowance.\\n /// @param spender The address that will be allowed to spend the balance.\\n /// @param amount The amount the spender is allowed to spend.\\n function approveBalance(address spender, uint256 amount) external {\\n require(\\n amount == 0 || allowance[msg.sender][spender] == 0,\\n \\\"Non-atomic allowance change not allowed\\\"\\n );\\n _approveBalance(msg.sender, spender, amount);\\n }\\n\\n /// @notice Sets the `amount` as an allowance of a smart contract `spender`\\n /// over the caller's balance and calls the `spender` via\\n /// `receiveBalanceApproval`.\\n /// @dev If the `amount` is set to `type(uint256).max`, the potential\\n /// `transferBalanceFrom` executed in `receiveBalanceApproval` of\\n /// `spender` will not reduce an allowance. Beware that changing an\\n /// allowance with this function brings the risk that `spender` may use\\n /// both the old and the new allowance by unfortunate transaction\\n /// ordering. Please use `increaseBalanceAllowance` and\\n /// `decreaseBalanceAllowance` to eliminate the risk.\\n /// @param spender The smart contract that will be allowed to spend the\\n /// balance.\\n /// @param amount The amount the spender contract is allowed to spend.\\n /// @param extraData Extra data passed to the `spender` contract via\\n /// `receiveBalanceApproval` call.\\n function approveBalanceAndCall(\\n address spender,\\n uint256 amount,\\n bytes calldata extraData\\n ) external {\\n _approveBalance(msg.sender, spender, amount);\\n IReceiveBalanceApproval(spender).receiveBalanceApproval(\\n msg.sender,\\n amount,\\n extraData\\n );\\n }\\n\\n /// @notice Atomically increases the caller's balance allowance granted to\\n /// `spender` by the given `addedValue`.\\n /// @param spender The spender address for which the allowance is increased.\\n /// @param addedValue The amount by which the allowance is increased.\\n function increaseBalanceAllowance(address spender, uint256 addedValue)\\n external\\n {\\n _approveBalance(\\n msg.sender,\\n spender,\\n allowance[msg.sender][spender] + addedValue\\n );\\n }\\n\\n /// @notice Atomically decreases the caller's balance allowance granted to\\n /// `spender` by the given `subtractedValue`.\\n /// @dev Requirements:\\n /// - `spender` must not be the zero address,\\n /// - the current allowance for `spender` must not be lower than\\n /// the `subtractedValue`.\\n /// @param spender The spender address for which the allowance is decreased.\\n /// @param subtractedValue The amount by which the allowance is decreased.\\n function decreaseBalanceAllowance(address spender, uint256 subtractedValue)\\n external\\n {\\n uint256 currentAllowance = allowance[msg.sender][spender];\\n require(\\n currentAllowance >= subtractedValue,\\n \\\"Can not decrease balance allowance below zero\\\"\\n );\\n unchecked {\\n _approveBalance(\\n msg.sender,\\n spender,\\n currentAllowance - subtractedValue\\n );\\n }\\n }\\n\\n /// @notice Moves `amount` of balance from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have an allowance for `spender`'s balance of at\\n /// least `amount`.\\n /// @param spender The address from which the balance is transferred.\\n /// @param recipient The address to which the balance is transferred.\\n /// @param amount The amount of balance that is transferred.\\n function transferBalanceFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n unchecked {\\n _approveBalance(spender, msg.sender, currentAllowance - amount);\\n }\\n }\\n _transferBalance(spender, recipient, amount);\\n }\\n\\n /// @notice An EIP2612 approval made with secp256k1 signature. Users can\\n /// authorize a transfer of their balance with a signature\\n /// conforming to the EIP712 standard, rather than an on-chain\\n /// transaction from their address. Anyone can submit this signature\\n /// on the user's behalf by calling the `permit` function, paying\\n /// gas fees, and possibly performing other actions in the same\\n /// transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferBalanceFrom` will not\\n /// reduce an allowance. Beware that changing an allowance with this\\n /// function brings the risk that someone may use both the old and the\\n /// new allowance by unfortunate transaction ordering. Please use\\n /// `increaseBalanceAllowance` and `decreaseBalanceAllowance` to\\n /// eliminate the risk.\\n /// @param owner The balance owner who signed the permission.\\n /// @param spender The address that will be allowed to spend the balance.\\n /// @param amount The amount the spender is allowed to spend.\\n /// @param deadline The UNIX time until which the permit is valid.\\n /// @param v V part of the permit signature.\\n /// @param r R part of the permit signature.\\n /// @param s S part of the permit signature.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approveBalance(owner, spender, amount);\\n }\\n\\n /// @notice Increases balances of the provided `recipients` by the provided\\n /// `amounts`. Can only be called by the Bridge.\\n /// @dev Requirements:\\n /// - length of `recipients` and `amounts` must be the same,\\n /// - none of `recipients` addresses must point to the Bank.\\n /// @param recipients Balance increase recipients.\\n /// @param amounts Amounts by which balances are increased.\\n function increaseBalances(\\n address[] calldata recipients,\\n uint256[] calldata amounts\\n ) external onlyBridge {\\n require(\\n recipients.length == amounts.length,\\n \\\"Arrays must have the same length\\\"\\n );\\n for (uint256 i = 0; i < recipients.length; i++) {\\n _increaseBalance(recipients[i], amounts[i]);\\n }\\n }\\n\\n /// @notice Increases balance of the provided `recipient` by the provided\\n /// `amount`. Can only be called by the Bridge.\\n /// @dev Requirements:\\n /// - `recipient` address must not point to the Bank.\\n /// @param recipient Balance increase recipient.\\n /// @param amount Amount by which the balance is increased.\\n function increaseBalance(address recipient, uint256 amount)\\n external\\n onlyBridge\\n {\\n _increaseBalance(recipient, amount);\\n }\\n\\n /// @notice Increases the given smart contract `vault`'s balance and\\n /// notifies the `vault` contract about it.\\n /// Can be called only by the Bridge.\\n /// @dev Requirements:\\n /// - `vault` must implement `IVault` interface,\\n /// - length of `recipients` and `amounts` must be the same.\\n /// @param vault Address of `IVault` recipient contract.\\n /// @param recipients Balance increase recipients.\\n /// @param amounts Amounts by which balances are increased.\\n function increaseBalanceAndCall(\\n address vault,\\n address[] calldata recipients,\\n uint256[] calldata amounts\\n ) external onlyBridge {\\n require(\\n recipients.length == amounts.length,\\n \\\"Arrays must have the same length\\\"\\n );\\n uint256 totalAmount = 0;\\n for (uint256 i = 0; i < amounts.length; i++) {\\n totalAmount += amounts[i];\\n }\\n _increaseBalance(vault, totalAmount);\\n IVault(vault).receiveBalanceIncrease(recipients, amounts);\\n }\\n\\n /// @notice Decreases caller's balance by the provided `amount`. There is no\\n /// way to restore the balance so do not call this function unless\\n /// you really know what you are doing!\\n /// @dev Requirements:\\n /// - The caller must have a balance of at least `amount`.\\n /// @param amount The amount by which the balance is decreased.\\n function decreaseBalance(uint256 amount) external {\\n balanceOf[msg.sender] -= amount;\\n emit BalanceDecreased(msg.sender, amount);\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with `TBTC Bank` as\\n /// a signing domain and Bank contract as a verifying contract.\\n /// Used to construct an EIP2612 signature provided to the `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n function _increaseBalance(address recipient, uint256 amount) internal {\\n require(\\n recipient != address(this),\\n \\\"Can not increase balance for Bank\\\"\\n );\\n balanceOf[recipient] += amount;\\n emit BalanceIncreased(recipient, amount);\\n }\\n\\n function _transferBalance(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(\\n recipient != address(0),\\n \\\"Can not transfer to the zero address\\\"\\n );\\n require(\\n recipient != address(this),\\n \\\"Can not transfer to the Bank address\\\"\\n );\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n unchecked {\\n balanceOf[spender] = spenderBalance - amount;\\n }\\n balanceOf[recipient] += amount;\\n emit BalanceTransferred(spender, recipient, amount);\\n }\\n\\n function _approveBalance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Can not approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit BalanceApproved(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(\\\"TBTC Bank\\\")),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x318005485bc8fb8a8fb6091bc4a3ca0e304693d8b372b61835bed2f1f735faf7\",\"license\":\"GPL-3.0-only\"},\"contracts/bank/IReceiveBalanceApproval.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\n/// @title IReceiveBalanceApproval\\n/// @notice `IReceiveBalanceApproval` is an interface for a smart contract\\n/// consuming Bank balances approved to them in the same transaction by\\n/// other contracts or externally owned accounts (EOA).\\ninterface IReceiveBalanceApproval {\\n /// @notice Called by the Bank in `approveBalanceAndCall` function after\\n /// the balance `owner` approved `amount` of their balance in the\\n /// Bank for the contract. This way, the depositor can approve\\n /// balance and call the contract to use the approved balance in\\n /// a single transaction.\\n /// @param owner Address of the Bank balance owner who approved their\\n /// balance to be used by the contract.\\n /// @param amount The amount of the Bank balance approved by the owner\\n /// to be used by the contract.\\n /// @param extraData The `extraData` passed to `Bank.approveBalanceAndCall`.\\n /// @dev The implementation must ensure this function can only be called\\n /// by the Bank. The Bank does _not_ guarantee that the `amount`\\n /// approved by the `owner` currently exists on their balance. That is,\\n /// the `owner` could approve more balance than they currently have.\\n /// This works the same as `Bank.approve` function. The contract must\\n /// ensure the actual balance is checked before performing any action\\n /// based on it.\\n function receiveBalanceApproval(\\n address owner,\\n uint256 amount,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x864f29d54d9d672348520b1f46bbce786994e07d86032987e4374a267a345c2b\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/BitcoinTx.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\nimport {ValidateSPV} from \\\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\\\";\\n\\nimport \\\"./BridgeState.sol\\\";\\n\\n/// @title Bitcoin transaction\\n/// @notice Allows to reference Bitcoin raw transaction in Solidity.\\n/// @dev See https://developer.bitcoin.org/reference/transactions.html#raw-transaction-format\\n///\\n/// Raw Bitcoin transaction data:\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|--------------|------------------------|---------------------------|\\n/// | 4 | version | int32_t (LE) | TX version number |\\n/// | varies | tx_in_count | compactSize uint (LE) | Number of TX inputs |\\n/// | varies | tx_in | txIn[] | TX inputs |\\n/// | varies | tx_out_count | compactSize uint (LE) | Number of TX outputs |\\n/// | varies | tx_out | txOut[] | TX outputs |\\n/// | 4 | lock_time | uint32_t (LE) | Unix time or block number |\\n///\\n//\\n/// Non-coinbase transaction input (txIn):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|------------------|------------------------|---------------------------------------------|\\n/// | 36 | previous_output | outpoint | The previous outpoint being spent |\\n/// | varies | script_bytes | compactSize uint (LE) | The number of bytes in the signature script |\\n/// | varies | signature_script | char[] | The signature script, empty for P2WSH |\\n/// | 4 | sequence | uint32_t (LE) | Sequence number |\\n///\\n///\\n/// The reference to transaction being spent (outpoint):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |-------|-------|---------------|------------------------------------------|\\n/// | 32 | hash | char[32] | Hash of the transaction to spend |\\n/// | 4 | index | uint32_t (LE) | Index of the specific output from the TX |\\n///\\n///\\n/// Transaction output (txOut):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|-----------------|-----------------------|--------------------------------------|\\n/// | 8 | value | int64_t (LE) | Number of satoshis to spend |\\n/// | 1+ | pk_script_bytes | compactSize uint (LE) | Number of bytes in the pubkey script |\\n/// | varies | pk_script | char[] | Pubkey script |\\n///\\n/// compactSize uint format:\\n///\\n/// | Value | Bytes | Format |\\n/// |-----------------------------------------|-------|----------------------------------------------|\\n/// | >= 0 && <= 252 | 1 | uint8_t |\\n/// | >= 253 && <= 0xffff | 3 | 0xfd followed by the number as uint16_t (LE) |\\n/// | >= 0x10000 && <= 0xffffffff | 5 | 0xfe followed by the number as uint32_t (LE) |\\n/// | >= 0x100000000 && <= 0xffffffffffffffff | 9 | 0xff followed by the number as uint64_t (LE) |\\n///\\n/// (*) compactSize uint is often references as VarInt)\\n///\\n/// Coinbase transaction input (txIn):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|------------------|------------------------|---------------------------------------------|\\n/// | 32 | hash | char[32] | A 32-byte 0x0 null (no previous_outpoint) |\\n/// | 4 | index | uint32_t (LE) | 0xffffffff (no previous_outpoint) |\\n/// | varies | script_bytes | compactSize uint (LE) | The number of bytes in the coinbase script |\\n/// | varies | height | char[] | The block height of this block (BIP34) (*) |\\n/// | varies | coinbase_script | none | Arbitrary data, max 100 bytes |\\n/// | 4 | sequence | uint32_t (LE) | Sequence number\\n///\\n/// (*) Uses script language: starts with a data-pushing opcode that indicates how many bytes to push to\\n/// the stack followed by the block height as a little-endian unsigned integer. This script must be as\\n/// short as possible, otherwise it may be rejected. The data-pushing opcode will be 0x03 and the total\\n/// size four bytes until block 16,777,216 about 300 years from now.\\nlibrary BitcoinTx {\\n using BTCUtils for bytes;\\n using BTCUtils for uint256;\\n using BytesLib for bytes;\\n using ValidateSPV for bytes;\\n using ValidateSPV for bytes32;\\n\\n /// @notice Represents Bitcoin transaction data.\\n struct Info {\\n /// @notice Bitcoin transaction version.\\n /// @dev `version` from raw Bitcoin transaction data.\\n /// Encoded as 4-bytes signed integer, little endian.\\n bytes4 version;\\n /// @notice All Bitcoin transaction inputs, prepended by the number of\\n /// transaction inputs.\\n /// @dev `tx_in_count | tx_in` from raw Bitcoin transaction data.\\n ///\\n /// The number of transaction inputs encoded as compactSize\\n /// unsigned integer, little-endian.\\n ///\\n /// Note that some popular block explorers reverse the order of\\n /// bytes from `outpoint`'s `hash` and display it as big-endian.\\n /// Solidity code of Bridge expects hashes in little-endian, just\\n /// like they are represented in a raw Bitcoin transaction.\\n bytes inputVector;\\n /// @notice All Bitcoin transaction outputs prepended by the number of\\n /// transaction outputs.\\n /// @dev `tx_out_count | tx_out` from raw Bitcoin transaction data.\\n ///\\n /// The number of transaction outputs encoded as a compactSize\\n /// unsigned integer, little-endian.\\n bytes outputVector;\\n /// @notice Bitcoin transaction locktime.\\n ///\\n /// @dev `lock_time` from raw Bitcoin transaction data.\\n /// Encoded as 4-bytes unsigned integer, little endian.\\n bytes4 locktime;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents data needed to perform a Bitcoin SPV proof.\\n struct Proof {\\n /// @notice The merkle proof of transaction inclusion in a block.\\n bytes merkleProof;\\n /// @notice Transaction index in the block (0-indexed).\\n uint256 txIndexInBlock;\\n /// @notice Single byte-string of 80-byte bitcoin headers,\\n /// lowest height first.\\n bytes bitcoinHeaders;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents info about an unspent transaction output.\\n struct UTXO {\\n /// @notice Hash of the transaction the output belongs to.\\n /// @dev Byte order corresponds to the Bitcoin internal byte order.\\n bytes32 txHash;\\n /// @notice Index of the transaction output (0-indexed).\\n uint32 txOutputIndex;\\n /// @notice Value of the transaction output.\\n uint64 txOutputValue;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents Bitcoin signature in the R/S/V format.\\n struct RSVSignature {\\n /// @notice Signature r value.\\n bytes32 r;\\n /// @notice Signature s value.\\n bytes32 s;\\n /// @notice Signature recovery value.\\n uint8 v;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Validates the SPV proof of the Bitcoin transaction.\\n /// Reverts in case the validation or proof verification fail.\\n /// @param txInfo Bitcoin transaction data.\\n /// @param proof Bitcoin proof data.\\n /// @return txHash Proven 32-byte transaction hash.\\n function validateProof(\\n BridgeState.Storage storage self,\\n Info calldata txInfo,\\n Proof calldata proof\\n ) internal view returns (bytes32 txHash) {\\n require(\\n txInfo.inputVector.validateVin(),\\n \\\"Invalid input vector provided\\\"\\n );\\n require(\\n txInfo.outputVector.validateVout(),\\n \\\"Invalid output vector provided\\\"\\n );\\n\\n txHash = abi\\n .encodePacked(\\n txInfo.version,\\n txInfo.inputVector,\\n txInfo.outputVector,\\n txInfo.locktime\\n )\\n .hash256View();\\n\\n require(\\n txHash.prove(\\n proof.bitcoinHeaders.extractMerkleRootLE(),\\n proof.merkleProof,\\n proof.txIndexInBlock\\n ),\\n \\\"Tx merkle proof is not valid for provided header and tx hash\\\"\\n );\\n\\n evaluateProofDifficulty(self, proof.bitcoinHeaders);\\n\\n return txHash;\\n }\\n\\n /// @notice Evaluates the given Bitcoin proof difficulty against the actual\\n /// Bitcoin chain difficulty provided by the relay oracle.\\n /// Reverts in case the evaluation fails.\\n /// @param bitcoinHeaders Bitcoin headers chain being part of the SPV\\n /// proof. Used to extract the observed proof difficulty.\\n function evaluateProofDifficulty(\\n BridgeState.Storage storage self,\\n bytes memory bitcoinHeaders\\n ) internal view {\\n IRelay relay = self.relay;\\n uint256 currentEpochDifficulty = relay.getCurrentEpochDifficulty();\\n uint256 previousEpochDifficulty = relay.getPrevEpochDifficulty();\\n\\n uint256 requestedDiff = 0;\\n uint256 firstHeaderDiff = bitcoinHeaders\\n .extractTarget()\\n .calculateDifficulty();\\n\\n if (firstHeaderDiff == currentEpochDifficulty) {\\n requestedDiff = currentEpochDifficulty;\\n } else if (firstHeaderDiff == previousEpochDifficulty) {\\n requestedDiff = previousEpochDifficulty;\\n } else {\\n revert(\\\"Not at current or previous difficulty\\\");\\n }\\n\\n uint256 observedDiff = bitcoinHeaders.validateHeaderChain();\\n\\n require(\\n observedDiff != ValidateSPV.getErrBadLength(),\\n \\\"Invalid length of the headers chain\\\"\\n );\\n require(\\n observedDiff != ValidateSPV.getErrInvalidChain(),\\n \\\"Invalid headers chain\\\"\\n );\\n require(\\n observedDiff != ValidateSPV.getErrLowWork(),\\n \\\"Insufficient work in a header\\\"\\n );\\n\\n require(\\n observedDiff >= requestedDiff * self.txProofDifficultyFactor,\\n \\\"Insufficient accumulated difficulty in header chain\\\"\\n );\\n }\\n\\n /// @notice Extracts public key hash from the provided P2PKH or P2WPKH output.\\n /// Reverts if the validation fails.\\n /// @param output The transaction output.\\n /// @return pubKeyHash 20-byte public key hash the output locks funds on.\\n /// @dev Requirements:\\n /// - The output must be of P2PKH or P2WPKH type and lock the funds\\n /// on a 20-byte public key hash.\\n function extractPubKeyHash(BridgeState.Storage storage, bytes memory output)\\n internal\\n pure\\n returns (bytes20 pubKeyHash)\\n {\\n bytes memory pubKeyHashBytes = output.extractHash();\\n\\n require(\\n pubKeyHashBytes.length == 20,\\n \\\"Output's public key hash must have 20 bytes\\\"\\n );\\n\\n pubKeyHash = pubKeyHashBytes.slice20(0);\\n\\n // The output consists of an 8-byte value and a variable length script.\\n // To extract just the script, we ignore the first 8 bytes.\\n uint256 scriptLen = output.length - 8;\\n\\n // The P2PKH script is 26 bytes long.\\n // The P2WPKH script is 23 bytes long.\\n // A valid script must have one of these lengths,\\n // and we can identify the expected script type by the length.\\n require(\\n scriptLen == 26 || scriptLen == 23,\\n \\\"Output must be P2PKH or P2WPKH\\\"\\n );\\n\\n if (scriptLen == 26) {\\n // Compare to the expected P2PKH script.\\n bytes26 script = bytes26(output.slice32(8));\\n\\n require(\\n script == makeP2PKHScript(pubKeyHash),\\n \\\"Invalid P2PKH script\\\"\\n );\\n }\\n\\n if (scriptLen == 23) {\\n // Compare to the expected P2WPKH script.\\n bytes23 script = bytes23(output.slice32(8));\\n\\n require(\\n script == makeP2WPKHScript(pubKeyHash),\\n \\\"Invalid P2WPKH script\\\"\\n );\\n }\\n\\n return pubKeyHash;\\n }\\n\\n /// @notice Build the P2PKH script from the given public key hash.\\n /// @param pubKeyHash The 20-byte public key hash.\\n /// @return The P2PKH script.\\n /// @dev The P2PKH script has the following byte format:\\n /// <0x1976a914> <20-byte PKH> <0x88ac>. According to\\n /// https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n /// - 0x19: Byte length of the entire script\\n /// - 0x76: OP_DUP\\n /// - 0xa9: OP_HASH160\\n /// - 0x14: Byte length of the public key hash\\n /// - 0x88: OP_EQUALVERIFY\\n /// - 0xac: OP_CHECKSIG\\n /// which matches the P2PKH structure as per:\\n /// https://en.bitcoin.it/wiki/Transaction#Pay-to-PubkeyHash\\n function makeP2PKHScript(bytes20 pubKeyHash)\\n internal\\n pure\\n returns (bytes26)\\n {\\n bytes26 P2PKHScriptMask = hex\\\"1976a914000000000000000000000000000000000000000088ac\\\";\\n\\n return ((bytes26(pubKeyHash) >> 32) | P2PKHScriptMask);\\n }\\n\\n /// @notice Build the P2WPKH script from the given public key hash.\\n /// @param pubKeyHash The 20-byte public key hash.\\n /// @return The P2WPKH script.\\n /// @dev The P2WPKH script has the following format:\\n /// <0x160014> <20-byte PKH>. According to\\n /// https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n /// - 0x16: Byte length of the entire script\\n /// - 0x00: OP_0\\n /// - 0x14: Byte length of the public key hash\\n /// which matches the P2WPKH structure as per:\\n /// https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH\\n function makeP2WPKHScript(bytes20 pubKeyHash)\\n internal\\n pure\\n returns (bytes23)\\n {\\n bytes23 P2WPKHScriptMask = hex\\\"1600140000000000000000000000000000000000000000\\\";\\n\\n return ((bytes23(pubKeyHash) >> 24) | P2WPKHScriptMask);\\n }\\n}\\n\",\"keccak256\":\"0xb087cb5b364bcdcca63772a442c630e858c90555fc691521a212c068b89120a5\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Bridge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@keep-network/random-beacon/contracts/Governable.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/ReimbursementPool.sol\\\";\\nimport {IWalletOwner as EcdsaWalletOwner} from \\\"@keep-network/ecdsa/contracts/api/IWalletOwner.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\n\\nimport \\\"./IRelay.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Deposit.sol\\\";\\nimport \\\"./DepositSweep.sol\\\";\\nimport \\\"./Redemption.sol\\\";\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./EcdsaLib.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\nimport \\\"./Fraud.sol\\\";\\nimport \\\"./MovingFunds.sol\\\";\\n\\nimport \\\"../bank/IReceiveBalanceApproval.sol\\\";\\nimport \\\"../bank/Bank.sol\\\";\\n\\n/// @title Bitcoin Bridge\\n/// @notice Bridge manages BTC deposit and redemption flow and is increasing and\\n/// decreasing balances in the Bank as a result of BTC deposit and\\n/// redemption operations performed by depositors and redeemers.\\n///\\n/// Depositors send BTC funds to the most recently created off-chain\\n/// ECDSA wallet of the bridge using pay-to-script-hash (P2SH) or\\n/// pay-to-witness-script-hash (P2WSH) containing hashed information\\n/// about the depositor\\u2019s Ethereum address. Then, the depositor reveals\\n/// their Ethereum address along with their deposit blinding factor,\\n/// refund public key hash and refund locktime to the Bridge on Ethereum\\n/// chain. The off-chain ECDSA wallet listens for these sorts of\\n/// messages and when it gets one, it checks the Bitcoin network to make\\n/// sure the deposit lines up. If it does, the off-chain ECDSA wallet\\n/// may decide to pick the deposit transaction for sweeping, and when\\n/// the sweep operation is confirmed on the Bitcoin network, the ECDSA\\n/// wallet informs the Bridge about the sweep increasing appropriate\\n/// balances in the Bank.\\n/// @dev Bridge is an upgradeable component of the Bank. The order of\\n/// functionalities in this contract is: deposit, sweep, redemption,\\n/// moving funds, wallet lifecycle, frauds, parameters.\\ncontract Bridge is\\n Governable,\\n EcdsaWalletOwner,\\n Initializable,\\n IReceiveBalanceApproval\\n{\\n using BridgeState for BridgeState.Storage;\\n using Deposit for BridgeState.Storage;\\n using DepositSweep for BridgeState.Storage;\\n using Redemption for BridgeState.Storage;\\n using MovingFunds for BridgeState.Storage;\\n using Wallets for BridgeState.Storage;\\n using Fraud for BridgeState.Storage;\\n\\n BridgeState.Storage internal self;\\n\\n event DepositRevealed(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex,\\n address indexed depositor,\\n uint64 amount,\\n bytes8 blindingFactor,\\n bytes20 indexed walletPubKeyHash,\\n bytes20 refundPubKeyHash,\\n bytes4 refundLocktime,\\n address vault\\n );\\n\\n event DepositsSwept(bytes20 walletPubKeyHash, bytes32 sweepTxHash);\\n\\n event RedemptionRequested(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript,\\n address indexed redeemer,\\n uint64 requestedAmount,\\n uint64 treasuryFee,\\n uint64 txMaxFee\\n );\\n\\n event RedemptionsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 redemptionTxHash\\n );\\n\\n event RedemptionTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript\\n );\\n\\n event WalletMovingFunds(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event MovingFundsCommitmentSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes20[] targetWallets,\\n address submitter\\n );\\n\\n event MovingFundsTimeoutReset(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash\\n );\\n\\n event MovingFundsTimedOut(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsBelowDustReported(bytes20 indexed walletPubKeyHash);\\n\\n event MovedFundsSwept(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sweepTxHash\\n );\\n\\n event MovedFundsSweepTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex\\n );\\n\\n event NewWalletRequested();\\n\\n event NewWalletRegistered(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosing(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosed(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletTerminated(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event FraudChallengeSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n );\\n\\n event FraudChallengeDefeated(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash\\n );\\n\\n event FraudChallengeDefeatTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash\\n );\\n\\n event VaultStatusUpdated(address indexed vault, bool isTrusted);\\n\\n event SpvMaintainerStatusUpdated(\\n address indexed spvMaintainer,\\n bool isTrusted\\n );\\n\\n event DepositParametersUpdated(\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n\\n event RedemptionParametersUpdated(\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n );\\n\\n event MovingFundsParametersUpdated(\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n\\n event WalletParametersUpdated(\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n );\\n\\n event FraudParametersUpdated(\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n );\\n\\n event TreasuryUpdated(address treasury);\\n\\n modifier onlySpvMaintainer() {\\n require(\\n self.isSpvMaintainer[msg.sender],\\n \\\"Caller is not SPV maintainer\\\"\\n );\\n _;\\n }\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /// @dev Initializes upgradable contract on deployment.\\n /// @param _bank Address of the Bank the Bridge belongs to.\\n /// @param _relay Address of the Bitcoin relay providing the current Bitcoin\\n /// network difficulty.\\n /// @param _treasury Address where the deposit and redemption treasury fees\\n /// will be sent to.\\n /// @param _ecdsaWalletRegistry Address of the ECDSA Wallet Registry contract.\\n /// @param _reimbursementPool Address of the Reimbursement Pool contract.\\n /// @param _txProofDifficultyFactor The number of confirmations on the Bitcoin\\n /// chain required to successfully evaluate an SPV proof.\\n function initialize(\\n address _bank,\\n address _relay,\\n address _treasury,\\n address _ecdsaWalletRegistry,\\n address payable _reimbursementPool,\\n uint96 _txProofDifficultyFactor\\n ) external initializer {\\n require(_bank != address(0), \\\"Bank address cannot be zero\\\");\\n self.bank = Bank(_bank);\\n\\n require(_relay != address(0), \\\"Relay address cannot be zero\\\");\\n self.relay = IRelay(_relay);\\n\\n require(\\n _ecdsaWalletRegistry != address(0),\\n \\\"ECDSA Wallet Registry address cannot be zero\\\"\\n );\\n self.ecdsaWalletRegistry = EcdsaWalletRegistry(_ecdsaWalletRegistry);\\n\\n require(\\n _reimbursementPool != address(0),\\n \\\"Reimbursement Pool address cannot be zero\\\"\\n );\\n self.reimbursementPool = ReimbursementPool(_reimbursementPool);\\n\\n require(_treasury != address(0), \\\"Treasury address cannot be zero\\\");\\n self.treasury = _treasury;\\n\\n self.txProofDifficultyFactor = _txProofDifficultyFactor;\\n\\n //\\n // All parameters set in the constructor are initial ones, used at the\\n // moment contracts were deployed for the first time. Parameters are\\n // governable and values assigned in the constructor do not need to\\n // reflect the current ones. Keep in mind the initial parameters are\\n // pretty forgiving and valid only for the early stage of the network.\\n //\\n\\n self.depositDustThreshold = 1000000; // 1000000 satoshi = 0.01 BTC\\n self.depositTxMaxFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.depositRevealAheadPeriod = 15 days;\\n self.depositTreasuryFeeDivisor = 2000; // 1/2000 == 5bps == 0.05% == 0.0005\\n self.redemptionDustThreshold = 1000000; // 1000000 satoshi = 0.01 BTC\\n self.redemptionTreasuryFeeDivisor = 2000; // 1/2000 == 5bps == 0.05% == 0.0005\\n self.redemptionTxMaxFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.redemptionTxMaxTotalFee = 1000000; // 1000000 satoshi = 0.01 BTC\\n self.redemptionTimeout = 5 days;\\n self.redemptionTimeoutSlashingAmount = 100 * 1e18; // 100 T\\n self.redemptionTimeoutNotifierRewardMultiplier = 100; // 100%\\n self.movingFundsTxMaxTotalFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.movingFundsDustThreshold = 200000; // 200000 satoshi = 0.002 BTC\\n self.movingFundsTimeoutResetDelay = 6 days;\\n self.movingFundsTimeout = 7 days;\\n self.movingFundsTimeoutSlashingAmount = 100 * 1e18; // 100 T\\n self.movingFundsTimeoutNotifierRewardMultiplier = 100; //100%\\n self.movingFundsCommitmentGasOffset = 15000;\\n self.movedFundsSweepTxMaxTotalFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.movedFundsSweepTimeout = 7 days;\\n self.movedFundsSweepTimeoutSlashingAmount = 100 * 1e18; // 100 T\\n self.movedFundsSweepTimeoutNotifierRewardMultiplier = 100; //100%\\n self.fraudChallengeDepositAmount = 5 ether;\\n self.fraudChallengeDefeatTimeout = 7 days;\\n self.fraudSlashingAmount = 100 * 1e18; // 100 T\\n self.fraudNotifierRewardMultiplier = 100; // 100%\\n self.walletCreationPeriod = 1 weeks;\\n self.walletCreationMinBtcBalance = 1e8; // 1 BTC\\n self.walletCreationMaxBtcBalance = 100e8; // 100 BTC\\n self.walletClosureMinBtcBalance = 5 * 1e7; // 0.5 BTC\\n self.walletMaxAge = 26 weeks; // ~6 months\\n self.walletMaxBtcTransfer = 10e8; // 10 BTC\\n self.walletClosingPeriod = 40 days;\\n\\n _transferGovernance(msg.sender);\\n }\\n\\n /// @notice Used by the depositor to reveal information about their P2(W)SH\\n /// Bitcoin deposit to the Bridge on Ethereum chain. The off-chain\\n /// wallet listens for revealed deposit events and may decide to\\n /// include the revealed deposit in the next executed sweep.\\n /// Information about the Bitcoin deposit can be revealed before or\\n /// after the Bitcoin transaction with P2(W)SH deposit is mined on\\n /// the Bitcoin chain. Worth noting, the gas cost of this function\\n /// scales with the number of P2(W)SH transaction inputs and\\n /// outputs. The deposit may be routed to one of the trusted vaults.\\n /// When a deposit is routed to a vault, vault gets notified when\\n /// the deposit gets swept and it may execute the appropriate action.\\n /// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`.\\n /// @param reveal Deposit reveal data, see `RevealInfo struct.\\n /// @dev Requirements:\\n /// - This function must be called by the same Ethereum address as the\\n /// one used in the P2(W)SH BTC deposit transaction as a depositor,\\n /// - `reveal.walletPubKeyHash` must identify a `Live` wallet,\\n /// - `reveal.vault` must be 0x0 or point to a trusted vault,\\n /// - `reveal.fundingOutputIndex` must point to the actual P2(W)SH\\n /// output of the BTC deposit transaction,\\n /// - `reveal.blindingFactor` must be the blinding factor used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - `reveal.walletPubKeyHash` must be the wallet pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundPubKeyHash` must be the refund pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundLocktime` must be the refund locktime used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n ///\\n /// If any of these requirements is not met, the wallet _must_ refuse\\n /// to sweep the deposit and the depositor has to wait until the\\n /// deposit script unlocks to receive their BTC back.\\n function revealDeposit(\\n BitcoinTx.Info calldata fundingTx,\\n Deposit.DepositRevealInfo calldata reveal\\n ) external {\\n self.revealDeposit(fundingTx, reveal);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC deposit sweep transaction\\n /// and to update Bank balances accordingly. Sweep is only accepted\\n /// if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by first\\n /// computing the Bitcoin fee for the sweep transaction. The fee is\\n /// divided evenly between all swept deposits. Each depositor\\n /// receives a balance in the bank equal to the amount inferred\\n /// during the reveal transaction, minus their fee share.\\n ///\\n /// It is possible to prove the given sweep only one time.\\n /// @param sweepTx Bitcoin sweep transaction data.\\n /// @param sweepProof Bitcoin sweep proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @param vault Optional address of the vault where all swept deposits\\n /// should be routed to. All deposits swept as part of the transaction\\n /// must have their `vault` parameters set to the same address.\\n /// If this parameter is set to an address of a trusted vault, swept\\n /// deposits are routed to that vault.\\n /// If this parameter is set to the zero address or to an address\\n /// of a non-trusted vault, swept deposits are not routed to a\\n /// vault but depositors' balances are increased in the Bank\\n /// individually.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with 1..n\\n /// inputs. If the wallet has no main UTXO, all n inputs should\\n /// correspond to P2(W)SH revealed deposits UTXOs. If the wallet has\\n /// an existing main UTXO, one of the n inputs must point to that\\n /// main UTXO and remaining n-1 inputs should correspond to P2(W)SH\\n /// revealed deposits UTXOs. That transaction must have only\\n /// one P2(W)PKH output locking funds on the 20-byte wallet public\\n /// key hash,\\n /// - All revealed deposits that are swept by `sweepTx` must have\\n /// their `vault` parameters set to the same address as the address\\n /// passed in the `vault` function parameter,\\n /// - `sweepProof` components must match the expected structure. See\\n /// `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored.\\n function submitDepositSweepProof(\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n address vault\\n ) external onlySpvMaintainer {\\n self.submitDepositSweepProof(sweepTx, sweepProof, mainUtxo, vault);\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script. Handles the\\n /// simplest case in which the redeemer's balance is decreased in\\n /// the Bank.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to process the request,\\n /// - Redeemer must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes calldata redeemerOutputScript,\\n uint64 amount\\n ) external {\\n self.requestRedemption(\\n walletPubKeyHash,\\n mainUtxo,\\n msg.sender,\\n redeemerOutputScript,\\n amount\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script. Used by\\n /// `Bank.approveBalanceAndCall`. Can handle more complex cases\\n /// where balance owner may be someone else than the redeemer.\\n /// For example, vault redeeming its balance for some depositor.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @param redemptionData ABI-encoded redemption data:\\n /// [\\n /// address redeemer,\\n /// bytes20 walletPubKeyHash,\\n /// bytes32 mainUtxoTxHash,\\n /// uint32 mainUtxoTxOutputIndex,\\n /// uint64 mainUtxoTxOutputValue,\\n /// bytes redeemerOutputScript\\n /// ]\\n ///\\n /// - redeemer: The Ethereum address of the redeemer who will be able\\n /// to claim Bank balance if anything goes wrong during the redemption.\\n /// In the most basic case, when someone redeems their balance\\n /// from the Bank, `balanceOwner` is the same as `redeemer`.\\n /// However, when a Vault is redeeming part of its balance for some\\n /// redeemer address (for example, someone who has earlier deposited\\n /// into that Vault), `balanceOwner` is the Vault, and `redeemer` is\\n /// the address for which the vault is redeeming its balance to,\\n /// - walletPubKeyHash: The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key),\\n /// - mainUtxoTxHash: Data of the wallet's main UTXO TX hash, as\\n /// currently known on the Ethereum chain,\\n /// - mainUtxoTxOutputIndex: Data of the wallet's main UTXO output\\n /// index, as currently known on Ethereum chain,\\n /// - mainUtxoTxOutputValue: Data of the wallet's main UTXO output\\n /// value, as currently known on Ethereum chain,\\n /// - redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @dev Requirements:\\n /// - The caller must be the Bank,\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to process the request.\\n ///\\n /// Note on upgradeability:\\n /// Bridge is an upgradeable contract deployed behind\\n /// a TransparentUpgradeableProxy. Accepting redemption data as bytes\\n /// provides great flexibility. The Bridge is just like any other\\n /// contract with a balance approved in the Bank and can be upgraded\\n /// to another version without being bound to a particular interface\\n /// forever. This flexibility comes with the cost - developers\\n /// integrating their vaults and dApps with `Bridge` using\\n /// `approveBalanceAndCall` need to pay extra attention to\\n /// `redemptionData` and adjust the code in case the expected structure\\n /// of `redemptionData` changes.\\n function receiveBalanceApproval(\\n address balanceOwner,\\n uint256 amount,\\n bytes calldata redemptionData\\n ) external override {\\n require(msg.sender == address(self.bank), \\\"Caller is not the bank\\\");\\n\\n self.requestRedemption(\\n balanceOwner,\\n SafeCastUpgradeable.toUint64(amount),\\n redemptionData\\n );\\n }\\n\\n /// @notice Used by the wallet to prove the BTC redemption transaction\\n /// and to make the necessary bookkeeping. Redemption is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by burning\\n /// the total redeemed Bitcoin amount from Bridge balance and\\n /// transferring the treasury fee sum to the treasury address.\\n ///\\n /// It is possible to prove the given redemption only one time.\\n /// @param redemptionTx Bitcoin redemption transaction data.\\n /// @param redemptionProof Bitcoin redemption proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @dev Requirements:\\n /// - `redemptionTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `redemptionTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs handling existing pending\\n /// redemption requests or pointing to reported timed out requests.\\n /// There can be also 1 optional output representing the\\n /// change and pointing back to the 20-byte wallet public key hash.\\n /// The change should be always present if the redeemed value sum\\n /// is lower than the total wallet's BTC balance,\\n /// - `redemptionProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input.\\n /// Other remarks:\\n /// - Putting the change output as the first transaction output can\\n /// save some gas because the output processing loop begins each\\n /// iteration by checking whether the given output is the change\\n /// thus uses some gas for making the comparison. Once the change\\n /// is identified, that check is omitted in further iterations.\\n function submitRedemptionProof(\\n BitcoinTx.Info calldata redemptionTx,\\n BitcoinTx.Proof calldata redemptionProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external onlySpvMaintainer {\\n self.submitRedemptionProof(\\n redemptionTx,\\n redemptionProof,\\n mainUtxo,\\n walletPubKeyHash\\n );\\n }\\n\\n /// @notice Notifies that there is a pending redemption request associated\\n /// with the given wallet, that has timed out. The redemption\\n /// request is identified by the key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The results of calling this function:\\n /// - The pending redemptions value for the wallet will be decreased\\n /// by the requested amount (minus treasury fee),\\n /// - The tokens taken from the redeemer on redemption request will\\n /// be returned to the redeemer,\\n /// - The request will be moved from pending redemptions to\\n /// timed-out redemptions,\\n /// - If the state of the wallet is `Live` or `MovingFunds`, the\\n /// wallet operators will be slashed and the notifier will be\\n /// rewarded,\\n /// - If the state of wallet is `Live`, the wallet will be closed or\\n /// marked as `MovingFunds` (depending on the presence or absence\\n /// of the wallet's main UTXO) and the wallet will no longer be\\n /// marked as the active wallet (if it was marked as such).\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH).\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Terminated state,\\n /// - The redemption request identified by `walletPubKeyHash` and\\n /// `redeemerOutputScript` must exist,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time defined by `redemptionTimeout` must have\\n /// passed since the redemption was requested (the request must be\\n /// timed-out).\\n function notifyRedemptionTimeout(\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs,\\n bytes calldata redeemerOutputScript\\n ) external {\\n self.notifyRedemptionTimeout(\\n walletPubKeyHash,\\n walletMembersIDs,\\n redeemerOutputScript\\n );\\n }\\n\\n /// @notice Submits the moving funds target wallets commitment.\\n /// Once all requirements are met, that function registers the\\n /// target wallets commitment and opens the way for moving funds\\n /// proof submission.\\n /// The caller is reimbursed for the transaction costs.\\n /// @param walletPubKeyHash 20-byte public key hash of the source wallet.\\n /// @param walletMainUtxo Data of the source wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletMembersIDs Identifiers of the source wallet signing group\\n /// members.\\n /// @param walletMemberIndex Position of the caller in the source wallet\\n /// signing group members list.\\n /// @param targetWallets List of 20-byte public key hashes of the target\\n /// wallets that the source wallet commits to move the funds to.\\n /// @dev Requirements:\\n /// - The source wallet must be in the MovingFunds state,\\n /// - The source wallet must not have pending redemption requests,\\n /// - The source wallet must not have pending moved funds sweep requests,\\n /// - The source wallet must not have submitted its commitment already,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given source wallet in the ECDSA registry. Those IDs are\\n /// not directly stored in the contract for gas efficiency purposes\\n /// but they can be read from appropriate `DkgResultSubmitted`\\n /// and `DkgResultApproved` events,\\n /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],\\n /// - The caller must be the member of the source wallet signing group\\n /// at the position indicated by `walletMemberIndex` parameter,\\n /// - The `walletMainUtxo` components must point to the recent main\\n /// UTXO of the source wallet, as currently known on the Ethereum\\n /// chain,\\n /// - Source wallet BTC balance must be greater than zero,\\n /// - At least one Live wallet must exist in the system,\\n /// - Submitted target wallets count must match the expected count\\n /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`\\n /// where `N > 0`,\\n /// - Each target wallet must be not equal to the source wallet,\\n /// - Each target wallet must follow the expected order i.e. all\\n /// target wallets 20-byte public key hashes represented as numbers\\n /// must form a strictly increasing sequence without duplicates,\\n /// - Each target wallet must be in Live state.\\n function submitMovingFundsCommitment(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo,\\n uint32[] calldata walletMembersIDs,\\n uint256 walletMemberIndex,\\n bytes20[] calldata targetWallets\\n ) external {\\n uint256 gasStart = gasleft();\\n\\n self.submitMovingFundsCommitment(\\n walletPubKeyHash,\\n walletMainUtxo,\\n walletMembersIDs,\\n walletMemberIndex,\\n targetWallets\\n );\\n\\n self.reimbursementPool.refund(\\n (gasStart - gasleft()) + self.movingFundsCommitmentGasOffset,\\n msg.sender\\n );\\n }\\n\\n /// @notice Resets the moving funds timeout for the given wallet if the\\n /// target wallet commitment cannot be submitted due to a lack\\n /// of live wallets in the system.\\n /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The target wallets commitment must not be already submitted for\\n /// the given moving funds wallet,\\n /// - Live wallets count must be zero,\\n /// - The moving funds timeout reset delay must be elapsed.\\n function resetMovingFundsTimeout(bytes20 walletPubKeyHash) external {\\n self.resetMovingFundsTimeout(walletPubKeyHash);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moving funds transaction\\n /// and to make the necessary state changes. Moving funds is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the moving funds transaction structure\\n /// by checking if it actually spends the main UTXO of the declared\\n /// wallet and locks the value on the pre-committed target wallets\\n /// using a reasonable transaction fee. If all preconditions are\\n /// met, this functions closes the source wallet.\\n ///\\n /// It is possible to prove the given moving funds transaction only\\n /// one time.\\n /// @param movingFundsTx Bitcoin moving funds transaction data.\\n /// @param movingFundsProof Bitcoin moving funds proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet\\n /// which performed the moving funds transaction.\\n /// @dev Requirements:\\n /// - `movingFundsTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `movingFundsTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs corresponding to the\\n /// pre-committed target wallets. Outputs must be ordered in the\\n /// same way as their corresponding target wallets are ordered\\n /// within the target wallets commitment,\\n /// - `movingFundsProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input,\\n /// - The wallet that `walletPubKeyHash` points to must be in the\\n /// MovingFunds state,\\n /// - The target wallets commitment must be submitted by the wallet\\n /// that `walletPubKeyHash` points to,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movingFundsTxMaxTotalFee` governable parameter.\\n function submitMovingFundsProof(\\n BitcoinTx.Info calldata movingFundsTx,\\n BitcoinTx.Proof calldata movingFundsProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external onlySpvMaintainer {\\n self.submitMovingFundsProof(\\n movingFundsTx,\\n movingFundsProof,\\n mainUtxo,\\n walletPubKeyHash\\n );\\n }\\n\\n /// @notice Notifies about a timed out moving funds process. Terminates\\n /// the wallet and slashes signing group members as a result.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The moving funds timeout must be actually exceeded,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovingFundsTimeout(\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n self.notifyMovingFundsTimeout(walletPubKeyHash, walletMembersIDs);\\n }\\n\\n /// @notice Notifies about a moving funds wallet whose BTC balance is\\n /// below the moving funds dust threshold. Ends the moving funds\\n /// process and begins wallet closing immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known\\n /// on the Ethereum chain.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If the wallet has no main UTXO, this parameter can be empty as it\\n /// is ignored,\\n /// - The wallet BTC balance must be below the moving funds threshold.\\n function notifyMovingFundsBelowDust(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external {\\n self.notifyMovingFundsBelowDust(walletPubKeyHash, mainUtxo);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moved funds sweep\\n /// transaction and to make the necessary state changes. Moved\\n /// funds sweep is only accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the sweep transaction structure by\\n /// checking if it actually spends the moved funds UTXO and the\\n /// sweeping wallet's main UTXO (optionally), and if it locks the\\n /// value on the sweeping wallet's 20-byte public key hash using a\\n /// reasonable transaction fee. If all preconditions are\\n /// met, this function updates the sweeping wallet main UTXO, thus\\n /// their BTC balance.\\n ///\\n /// It is possible to prove the given sweep transaction only\\n /// one time.\\n /// @param sweepTx Bitcoin sweep funds transaction data.\\n /// @param sweepProof Bitcoin sweep funds proof data.\\n /// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with\\n /// the first input pointing to a moved funds sweep request targeted\\n /// to the wallet, and optionally, the second input pointing to the\\n /// wallet's main UTXO, if the sweeping wallet has a main UTXO set.\\n /// There should be only one output locking funds on the sweeping\\n /// wallet 20-byte public key hash,\\n /// - `sweepProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the sweeping wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored,\\n /// - The sweeping wallet must be in the Live or MovingFunds state,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movedFundsSweepTxMaxTotalFee` governable parameter.\\n function submitMovedFundsSweepProof(\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external onlySpvMaintainer {\\n self.submitMovedFundsSweepProof(sweepTx, sweepProof, mainUtxo);\\n }\\n\\n /// @notice Notifies about a timed out moved funds sweep process. If the\\n /// wallet is not terminated yet, that function terminates\\n /// the wallet and slashes signing group members as a result.\\n /// Marks the given sweep request as TimedOut.\\n /// @param movingFundsTxHash 32-byte hash of the moving funds transaction\\n /// that caused the sweep request to be created.\\n /// @param movingFundsTxOutputIndex Index of the moving funds transaction\\n /// output that is subject of the sweep request.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The moved funds sweep request must be in the Pending state,\\n /// - The moved funds sweep timeout must be actually exceeded,\\n /// - The wallet must be either in the Live or MovingFunds or\\n /// Terminated state,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovedFundsSweepTimeout(\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n self.notifyMovedFundsSweepTimeout(\\n movingFundsTxHash,\\n movingFundsTxOutputIndex,\\n walletMembersIDs\\n );\\n }\\n\\n /// @notice Requests creation of a new wallet. This function just\\n /// forms a request and the creation process is performed\\n /// asynchronously. Once a wallet is created, the ECDSA Wallet\\n /// Registry will notify this contract by calling the\\n /// `__ecdsaWalletCreatedCallback` function.\\n /// @param activeWalletMainUtxo Data of the active wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `activeWalletMainUtxo` components must point to the recent main\\n /// UTXO of the given active wallet, as currently known on the\\n /// Ethereum chain. If there is no active wallet at the moment, or\\n /// the active wallet has no main UTXO, this parameter can be\\n /// empty as it is ignored,\\n /// - Wallet creation must not be in progress,\\n /// - If the active wallet is set, one of the following\\n /// conditions must be true:\\n /// - The active wallet BTC balance is above the minimum threshold\\n /// and the active wallet is old enough, i.e. the creation period\\n /// was elapsed since its creation time,\\n /// - The active wallet BTC balance is above the maximum threshold.\\n function requestNewWallet(BitcoinTx.UTXO calldata activeWalletMainUtxo)\\n external\\n {\\n self.requestNewWallet(activeWalletMainUtxo);\\n }\\n\\n /// @notice A callback function that is called by the ECDSA Wallet Registry\\n /// once a new ECDSA wallet is created.\\n /// @param ecdsaWalletID Wallet's unique identifier.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Given wallet data must not belong to an already registered wallet.\\n function __ecdsaWalletCreatedCallback(\\n bytes32 ecdsaWalletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external override {\\n self.registerNewWallet(ecdsaWalletID, publicKeyX, publicKeyY);\\n }\\n\\n /// @notice A callback function that is called by the ECDSA Wallet Registry\\n /// once a wallet heartbeat failure is detected.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Wallet must be in Live state.\\n function __ecdsaWalletHeartbeatFailedCallback(\\n bytes32,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external override {\\n self.notifyWalletHeartbeatFailed(publicKeyX, publicKeyY);\\n }\\n\\n /// @notice Notifies that the wallet is either old enough or has too few\\n /// satoshi left and qualifies to be closed.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMainUtxo Data of the wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - Wallet must not be set as the current active wallet,\\n /// - Wallet must exceed the wallet maximum age OR the wallet BTC\\n /// balance must be lesser than the minimum threshold. If the latter\\n /// case is true, the `walletMainUtxo` components must point to the\\n /// recent main UTXO of the given wallet, as currently known on the\\n /// Ethereum chain. If the wallet has no main UTXO, this parameter\\n /// can be empty as it is ignored since the wallet balance is\\n /// assumed to be zero,\\n /// - Wallet must be in Live state.\\n function notifyWalletCloseable(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) external {\\n self.notifyWalletCloseable(walletPubKeyHash, walletMainUtxo);\\n }\\n\\n /// @notice Notifies about the end of the closing period for the given wallet.\\n /// Closes the wallet ultimately and notifies the ECDSA registry\\n /// about this fact.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the Closing state,\\n /// - The wallet closing period must have elapsed.\\n function notifyWalletClosingPeriodElapsed(bytes20 walletPubKeyHash)\\n external\\n {\\n self.notifyWalletClosingPeriodElapsed(walletPubKeyHash);\\n }\\n\\n /// @notice Submits a fraud challenge indicating that a UTXO being under\\n /// wallet control was unlocked by the wallet but was not used\\n /// according to the protocol rules. That means the wallet signed\\n /// a transaction input pointing to that UTXO and there is a unique\\n /// sighash and signature pair associated with that input. This\\n /// function uses those parameters to create a fraud accusation that\\n /// proves a given transaction input unlocking the given UTXO was\\n /// actually signed by the wallet. This function cannot determine\\n /// whether the transaction was actually broadcast and the input was\\n /// consumed in a fraudulent way so it just opens a challenge period\\n /// during which the wallet can defeat the challenge by submitting\\n /// proof of a transaction that consumes the given input according\\n /// to protocol rules. To prevent spurious allegations, the caller\\n /// must deposit ETH that is returned back upon justified fraud\\n /// challenge or confiscated otherwise.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @param signature Bitcoin signature in the R/S/V format.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPublicKey` must be in Live or MovingFunds\\n /// or Closing state,\\n /// - The challenger must send appropriate amount of ETH used as\\n /// fraud challenge deposit,\\n /// - The signature (represented by r, s and v) must be generated by\\n /// the wallet behind `walletPubKey` during signing of `sighash`\\n /// which was calculated from `preimageSha256`,\\n /// - Wallet can be challenged for the given signature only once.\\n function submitFraudChallenge(\\n bytes calldata walletPublicKey,\\n bytes memory preimageSha256,\\n BitcoinTx.RSVSignature calldata signature\\n ) external payable {\\n self.submitFraudChallenge(walletPublicKey, preimageSha256, signature);\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet if\\n /// the transaction that spends the UTXO follows the protocol rules.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during input signing.\\n /// The fraud challenge defeat attempt will only succeed if the\\n /// inputs in the preimage are considered honestly spent by the\\n /// wallet. Therefore the transaction spending the UTXO must be\\n /// proven in the Bridge before a challenge defeat is called.\\n /// If successfully defeated, the fraud challenge is marked as\\n /// resolved and the amount of ether deposited by the challenger is\\n /// sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference.\\n /// @param witness Flag indicating whether the preimage was produced for a\\n /// witness input. True for witness, false for non-witness input.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as `hash256(preimage)`\\n /// must identify an open fraud challenge,\\n /// - the preimage must be a valid preimage of a transaction generated\\n /// according to the protocol rules and already proved in the Bridge,\\n /// - before a defeat attempt is made the transaction that spends the\\n /// given UTXO must be proven in the Bridge.\\n function defeatFraudChallenge(\\n bytes calldata walletPublicKey,\\n bytes calldata preimage,\\n bool witness\\n ) external {\\n self.defeatFraudChallenge(walletPublicKey, preimage, witness);\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet by\\n /// proving the sighash and signature were produced for an off-chain\\n /// wallet heartbeat message following a strict format.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during heartbeat message\\n /// signing. The fraud challenge defeat attempt will only succeed if\\n /// the signed message follows a strict format required for\\n /// heartbeat messages. If successfully defeated, the fraud\\n /// challenge is marked as resolved and the amount of ether\\n /// deposited by the challenger is sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param heartbeatMessage Off-chain heartbeat message meeting the heartbeat\\n /// message format requirements which produces sighash used to\\n /// generate the ECDSA signature that is the subject of the fraud\\n /// claim.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as\\n /// `hash256(heartbeatMessage)` must identify an open fraud challenge,\\n /// - `heartbeatMessage` must follow a strict format of heartbeat\\n /// messages.\\n function defeatFraudChallengeWithHeartbeat(\\n bytes calldata walletPublicKey,\\n bytes calldata heartbeatMessage\\n ) external {\\n self.defeatFraudChallengeWithHeartbeat(\\n walletPublicKey,\\n heartbeatMessage\\n );\\n }\\n\\n /// @notice Notifies about defeat timeout for the given fraud challenge.\\n /// Can be called only if there was a fraud challenge identified by\\n /// the provided `walletPublicKey` and `sighash` and it was not\\n /// defeated on time. The amount of time that needs to pass after\\n /// a fraud challenge is reported is indicated by the\\n /// `challengeDefeatTimeout`. After a successful fraud challenge\\n /// defeat timeout notification the fraud challenge is marked as\\n /// resolved, the stake of each operator is slashed, the ether\\n /// deposited is returned to the challenger and the challenger is\\n /// rewarded.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Closing or\\n /// Terminated state,\\n /// - The `walletPublicKey` and `sighash` calculated from\\n /// `preimageSha256` must identify an open fraud challenge,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time indicated by `challengeDefeatTimeout` must pass\\n /// after the challenge was reported.\\n function notifyFraudChallengeDefeatTimeout(\\n bytes calldata walletPublicKey,\\n uint32[] calldata walletMembersIDs,\\n bytes memory preimageSha256\\n ) external {\\n self.notifyFraudChallengeDefeatTimeout(\\n walletPublicKey,\\n walletMembersIDs,\\n preimageSha256\\n );\\n }\\n\\n /// @notice Allows the Governance to mark the given vault address as trusted\\n /// or no longer trusted. Vaults are not trusted by default.\\n /// Trusted vault must meet the following criteria:\\n /// - `IVault.receiveBalanceIncrease` must have a known, low gas\\n /// cost,\\n /// - `IVault.receiveBalanceIncrease` must never revert.\\n /// @dev Without restricting reveal only to trusted vaults, malicious\\n /// vaults not meeting the criteria would be able to nuke sweep proof\\n /// transactions executed by ECDSA wallet with deposits routed to\\n /// them.\\n /// @param vault The address of the vault.\\n /// @param isTrusted flag indicating whether the vault is trusted or not.\\n /// @dev Can only be called by the Governance.\\n function setVaultStatus(address vault, bool isTrusted)\\n external\\n onlyGovernance\\n {\\n self.isVaultTrusted[vault] = isTrusted;\\n emit VaultStatusUpdated(vault, isTrusted);\\n }\\n\\n /// @notice Allows the Governance to mark the given address as trusted\\n /// or no longer trusted SPV maintainer. Addresses are not trusted\\n /// as SPV maintainers by default.\\n /// @dev The SPV proof does not check whether the transaction is a part of\\n /// the Bitcoin mainnet, it only checks whether the transaction has been\\n /// mined performing the required amount of work as on Bitcoin mainnet.\\n /// The possibility of submitting SPV proofs is limited to trusted SPV\\n /// maintainers. The system expects transaction confirmations with the\\n /// required work accumulated, so trusted SPV maintainers can not prove\\n /// the transaction without providing the required Bitcoin proof of work.\\n /// Trusted maintainers address the issue of an economic game between\\n /// tBTC and Bitcoin mainnet where large Bitcoin mining pools can decide\\n /// to use their hash power to mine fake Bitcoin blocks to prove them in\\n /// tBTC instead of receiving Bitcoin miner rewards.\\n /// @param spvMaintainer The address of the SPV maintainer.\\n /// @param isTrusted flag indicating whether the address is trusted or not.\\n /// @dev Can only be called by the Governance.\\n function setSpvMaintainerStatus(address spvMaintainer, bool isTrusted)\\n external\\n onlyGovernance\\n {\\n self.isSpvMaintainer[spvMaintainer] = isTrusted;\\n emit SpvMaintainerStatusUpdated(spvMaintainer, isTrusted);\\n }\\n\\n /// @notice Updates parameters of deposits.\\n /// @param depositDustThreshold New value of the deposit dust threshold in\\n /// satoshis. It is the minimal amount that can be requested to\\n //// deposit. Value of this parameter must take into account the value\\n /// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters\\n /// in order to make requests that can incur the treasury and\\n /// transaction fee and still satisfy the depositor.\\n /// @param depositTreasuryFeeDivisor New value of the treasury fee divisor.\\n /// It is the divisor used to compute the treasury fee taken from\\n /// each deposit and transferred to the treasury upon sweep proof\\n /// submission. That fee is computed as follows:\\n /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each deposit,\\n /// the `depositTreasuryFeeDivisor` should be set to `50`\\n /// because `1/50 = 0.02 = 2%`.\\n /// @param depositTxMaxFee New value of the deposit tx max fee in satoshis.\\n /// It is the maximum amount of BTC transaction fee that can\\n /// be incurred by each swept deposit being part of the given sweep\\n /// transaction. If the maximum BTC transaction fee is exceeded,\\n /// such transaction is considered a fraud.\\n /// @param depositRevealAheadPeriod New value of the deposit reveal ahead\\n /// period parameter in seconds. It defines the length of the period\\n /// that must be preserved between the deposit reveal time and the\\n /// deposit refund locktime.\\n /// @dev Requirements:\\n /// - Deposit dust threshold must be greater than zero,\\n /// - Deposit dust threshold must be greater than deposit TX max fee,\\n /// - Deposit transaction max fee must be greater than zero.\\n function updateDepositParameters(\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n ) external onlyGovernance {\\n self.updateDepositParameters(\\n depositDustThreshold,\\n depositTreasuryFeeDivisor,\\n depositTxMaxFee,\\n depositRevealAheadPeriod\\n );\\n }\\n\\n /// @notice Updates parameters of redemptions.\\n /// @param redemptionDustThreshold New value of the redemption dust\\n /// threshold in satoshis. It is the minimal amount that can be\\n /// requested for redemption. Value of this parameter must take into\\n /// account the value of `redemptionTreasuryFeeDivisor` and\\n /// `redemptionTxMaxFee` parameters in order to make requests that\\n /// can incur the treasury and transaction fee and still satisfy the\\n /// redeemer.\\n /// @param redemptionTreasuryFeeDivisor New value of the redemption\\n /// treasury fee divisor. It is the divisor used to compute the\\n /// treasury fee taken from each redemption request and transferred\\n /// to the treasury upon successful request finalization. That fee is\\n /// computed as follows:\\n /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each\\n /// redemption request, the `redemptionTreasuryFeeDivisor` should\\n /// be set to `50` because `1/50 = 0.02 = 2%`.\\n /// @param redemptionTxMaxFee New value of the redemption transaction max\\n /// fee in satoshis. It is the maximum amount of BTC transaction fee\\n /// that can be incurred by each redemption request being part of the\\n /// given redemption transaction. If the maximum BTC transaction fee\\n /// is exceeded, such transaction is considered a fraud.\\n /// This is a per-redemption output max fee for the redemption\\n /// transaction.\\n /// @param redemptionTxMaxTotalFee New value of the redemption transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single redemption\\n /// transaction. This is a _total_ max fee for the entire redemption\\n /// transaction.\\n /// @param redemptionTimeout New value of the redemption timeout in seconds.\\n /// It is the time after which the redemption request can be reported\\n /// as timed out. It is counted from the moment when the redemption\\n /// request was created via `requestRedemption` call. Reported timed\\n /// out requests are cancelled and locked balance is returned to the\\n /// redeemer in full amount.\\n /// @param redemptionTimeoutSlashingAmount New value of the redemption\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for redemption timeout.\\n /// @param redemptionTimeoutNotifierRewardMultiplier New value of the\\n /// redemption timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a redemption timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Redemption dust threshold must be greater than moving funds dust\\n /// threshold,\\n /// - Redemption dust threshold must be greater than the redemption TX\\n /// max fee,\\n /// - Redemption transaction max fee must be greater than zero,\\n /// - Redemption transaction max total fee must be greater than or\\n /// equal to the redemption transaction per-request max fee,\\n /// - Redemption timeout must be greater than zero,\\n /// - Redemption timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateRedemptionParameters(\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n ) external onlyGovernance {\\n self.updateRedemptionParameters(\\n redemptionDustThreshold,\\n redemptionTreasuryFeeDivisor,\\n redemptionTxMaxFee,\\n redemptionTxMaxTotalFee,\\n redemptionTimeout,\\n redemptionTimeoutSlashingAmount,\\n redemptionTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of moving funds.\\n /// @param movingFundsTxMaxTotalFee New value of the moving funds transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single moving funds\\n /// transaction. This is a _total_ max fee for the entire moving\\n /// funds transaction.\\n /// @param movingFundsDustThreshold New value of the moving funds dust\\n /// threshold. It is the minimal satoshi amount that makes sense to\\n /// be transferred during the moving funds process. Moving funds\\n /// wallets having their BTC balance below that value can begin\\n /// closing immediately as transferring such a low value may not be\\n /// possible due to BTC network fees.\\n /// @param movingFundsTimeoutResetDelay New value of the moving funds\\n /// timeout reset delay in seconds. It is the time after which the\\n /// moving funds timeout can be reset in case the target wallet\\n /// commitment cannot be submitted due to a lack of live wallets\\n /// in the system. It is counted from the moment when the wallet\\n /// was requested to move their funds and switched to the MovingFunds\\n /// state or from the moment the timeout was reset the last time.\\n /// @param movingFundsTimeout New value of the moving funds timeout in\\n /// seconds. It is the time after which the moving funds process can\\n /// be reported as timed out. It is counted from the moment when the\\n /// wallet was requested to move their funds and switched to the\\n /// MovingFunds state.\\n /// @param movingFundsTimeoutSlashingAmount New value of the moving funds\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for moving funds timeout.\\n /// @param movingFundsTimeoutNotifierRewardMultiplier New value of the\\n /// moving funds timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a moving funds timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @param movingFundsCommitmentGasOffset New value of the gas offset for\\n /// moving funds target wallet commitment transaction gas costs\\n /// reimbursement.\\n /// @param movedFundsSweepTxMaxTotalFee New value of the moved funds sweep\\n /// transaction max total fee in satoshis. It is the maximum amount\\n /// of the total BTC transaction fee that is acceptable in a single\\n /// moved funds sweep transaction. This is a _total_ max fee for the\\n /// entire moved funds sweep transaction.\\n /// @param movedFundsSweepTimeout New value of the moved funds sweep\\n /// timeout in seconds. It is the time after which the moved funds\\n /// sweep process can be reported as timed out. It is counted from\\n /// the moment when the wallet was requested to sweep the received\\n /// funds.\\n /// @param movedFundsSweepTimeoutSlashingAmount New value of the moved\\n /// funds sweep timeout slashing amount in T, it is the amount\\n /// slashed from each wallet member for moved funds sweep timeout.\\n /// @param movedFundsSweepTimeoutNotifierRewardMultiplier New value of\\n /// the moved funds sweep timeout notifier reward multiplier as\\n /// percentage, it determines the percentage of the notifier reward\\n /// from the staking contact the notifier of a moved funds sweep\\n /// timeout receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Moving funds transaction max total fee must be greater than zero,\\n /// - Moving funds dust threshold must be greater than zero and lower\\n /// than the redemption dust threshold,\\n /// - Moving funds timeout reset delay must be greater than zero,\\n /// - Moving funds timeout must be greater than the moving funds\\n /// timeout reset delay,\\n /// - Moving funds timeout notifier reward multiplier must be in the\\n /// range [0, 100],\\n /// - Moved funds sweep transaction max total fee must be greater than zero,\\n /// - Moved funds sweep timeout must be greater than zero,\\n /// - Moved funds sweep timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateMovingFundsParameters(\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n ) external onlyGovernance {\\n self.updateMovingFundsParameters(\\n movingFundsTxMaxTotalFee,\\n movingFundsDustThreshold,\\n movingFundsTimeoutResetDelay,\\n movingFundsTimeout,\\n movingFundsTimeoutSlashingAmount,\\n movingFundsTimeoutNotifierRewardMultiplier,\\n movingFundsCommitmentGasOffset,\\n movedFundsSweepTxMaxTotalFee,\\n movedFundsSweepTimeout,\\n movedFundsSweepTimeoutSlashingAmount,\\n movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of wallets.\\n /// @param walletCreationPeriod New value of the wallet creation period in\\n /// seconds, determines how frequently a new wallet creation can be\\n /// requested.\\n /// @param walletCreationMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param walletCreationMaxBtcBalance New value of the wallet maximum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param walletClosureMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet closure.\\n /// @param walletMaxAge New value of the wallet maximum age in seconds,\\n /// indicates the maximum age of a wallet in seconds, after which\\n /// the wallet moving funds process can be requested.\\n /// @param walletMaxBtcTransfer New value of the wallet maximum BTC transfer\\n /// in satoshi, determines the maximum amount that can be transferred\\n // to a single target wallet during the moving funds process.\\n /// @param walletClosingPeriod New value of the wallet closing period in\\n /// seconds, determines the length of the wallet closing period,\\n // i.e. the period when the wallet remains in the Closing state\\n // and can be subject of deposit fraud challenges.\\n /// @dev Requirements:\\n /// - Wallet maximum BTC balance must be greater than the wallet\\n /// minimum BTC balance,\\n /// - Wallet maximum BTC transfer must be greater than zero,\\n /// - Wallet closing period must be greater than zero.\\n function updateWalletParameters(\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n ) external onlyGovernance {\\n self.updateWalletParameters(\\n walletCreationPeriod,\\n walletCreationMinBtcBalance,\\n walletCreationMaxBtcBalance,\\n walletClosureMinBtcBalance,\\n walletMaxAge,\\n walletMaxBtcTransfer,\\n walletClosingPeriod\\n );\\n }\\n\\n /// @notice Updates parameters related to frauds.\\n /// @param fraudChallengeDepositAmount New value of the fraud challenge\\n /// deposit amount in wei, it is the amount of ETH the party\\n /// challenging the wallet for fraud needs to deposit.\\n /// @param fraudChallengeDefeatTimeout New value of the challenge defeat\\n /// timeout in seconds, it is the amount of time the wallet has to\\n /// defeat a fraud challenge. The value must be greater than zero.\\n /// @param fraudSlashingAmount New value of the fraud slashing amount in T,\\n /// it is the amount slashed from each wallet member for committing\\n /// a fraud.\\n /// @param fraudNotifierRewardMultiplier New value of the fraud notifier\\n /// reward multiplier as percentage, it determines the percentage of\\n /// the notifier reward from the staking contact the notifier of\\n /// a fraud receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Fraud challenge defeat timeout must be greater than 0,\\n /// - Fraud notifier reward multiplier must be in the range [0, 100].\\n function updateFraudParameters(\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n ) external onlyGovernance {\\n self.updateFraudParameters(\\n fraudChallengeDepositAmount,\\n fraudChallengeDefeatTimeout,\\n fraudSlashingAmount,\\n fraudNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates treasury address. The treasury receives the system fees.\\n /// @param treasury New value of the treasury address.\\n /// @dev The treasury address must not be 0x0.\\n // slither-disable-next-line shadowing-local\\n function updateTreasury(address treasury) external onlyGovernance {\\n self.updateTreasury(treasury);\\n }\\n\\n /// @notice Collection of all revealed deposits indexed by\\n /// keccak256(fundingTxHash | fundingOutputIndex).\\n /// The fundingTxHash is bytes32 (ordered as in Bitcoin internally)\\n /// and fundingOutputIndex an uint32. This mapping may contain valid\\n /// and invalid deposits and the wallet is responsible for\\n /// validating them before attempting to execute a sweep.\\n function deposits(uint256 depositKey)\\n external\\n view\\n returns (Deposit.DepositRequest memory)\\n {\\n return self.deposits[depositKey];\\n }\\n\\n /// @notice Collection of all pending redemption requests indexed by\\n /// redemption key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The walletPubKeyHash is the 20-byte wallet's public key hash\\n /// (computed using Bitcoin HASH160 over the compressed ECDSA\\n /// public key) and `redeemerOutputScript` is a Bitcoin script\\n /// (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC as requested by the redeemer. Requests are added\\n /// to this mapping by the `requestRedemption` method (duplicates\\n /// not allowed) and are removed by one of the following methods:\\n /// - `submitRedemptionProof` in case the request was handled\\n /// successfully,\\n /// - `notifyRedemptionTimeout` in case the request was reported\\n /// to be timed out.\\n function pendingRedemptions(uint256 redemptionKey)\\n external\\n view\\n returns (Redemption.RedemptionRequest memory)\\n {\\n return self.pendingRedemptions[redemptionKey];\\n }\\n\\n /// @notice Collection of all timed out redemptions requests indexed by\\n /// redemption key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The walletPubKeyHash is the 20-byte wallet's public key hash\\n /// (computed using Bitcoin HASH160 over the compressed ECDSA\\n /// public key) and `redeemerOutputScript` is the Bitcoin script\\n /// (P2PKH, P2WPKH, P2SH or P2WSH) that is involved in the timed\\n /// out request.\\n /// Only one method can add to this mapping:\\n /// - `notifyRedemptionTimeout` which puts the redemption key\\n /// to this mapping based on a timed out request stored\\n /// previously in `pendingRedemptions` mapping.\\n /// Only one method can remove entries from this mapping:\\n /// - `submitRedemptionProof` in case the timed out redemption\\n /// request was a part of the proven transaction.\\n function timedOutRedemptions(uint256 redemptionKey)\\n external\\n view\\n returns (Redemption.RedemptionRequest memory)\\n {\\n return self.timedOutRedemptions[redemptionKey];\\n }\\n\\n /// @notice Collection of main UTXOs that are honestly spent indexed by\\n /// keccak256(fundingTxHash | fundingOutputIndex). The fundingTxHash\\n /// is bytes32 (ordered as in Bitcoin internally) and\\n /// fundingOutputIndex an uint32. A main UTXO is considered honestly\\n /// spent if it was used as an input of a transaction that have been\\n /// proven in the Bridge.\\n function spentMainUTXOs(uint256 utxoKey) external view returns (bool) {\\n return self.spentMainUTXOs[utxoKey];\\n }\\n\\n /// @notice Gets details about a registered wallet.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @return Wallet details.\\n function wallets(bytes20 walletPubKeyHash)\\n external\\n view\\n returns (Wallets.Wallet memory)\\n {\\n return self.registeredWallets[walletPubKeyHash];\\n }\\n\\n /// @notice Gets the public key hash of the active wallet.\\n /// @return The 20-byte public key hash (computed using Bitcoin HASH160\\n /// over the compressed ECDSA public key) of the active wallet.\\n /// Returns bytes20(0) if there is no active wallet at the moment.\\n function activeWalletPubKeyHash() external view returns (bytes20) {\\n return self.activeWalletPubKeyHash;\\n }\\n\\n /// @notice Gets the live wallets count.\\n /// @return The current count of wallets being in the Live state.\\n function liveWalletsCount() external view returns (uint32) {\\n return self.liveWalletsCount;\\n }\\n\\n /// @notice Returns the fraud challenge identified by the given key built\\n /// as keccak256(walletPublicKey|sighash).\\n function fraudChallenges(uint256 challengeKey)\\n external\\n view\\n returns (Fraud.FraudChallenge memory)\\n {\\n return self.fraudChallenges[challengeKey];\\n }\\n\\n /// @notice Collection of all moved funds sweep requests indexed by\\n /// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.\\n /// The `movingFundsTxHash` is `bytes32` (ordered as in Bitcoin\\n /// internally) and `movingFundsOutputIndex` an `uint32`. Each entry\\n /// is actually an UTXO representing the moved funds and is supposed\\n /// to be swept with the current main UTXO of the recipient wallet.\\n /// @param requestKey Request key built as\\n /// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.\\n /// @return Details of the moved funds sweep request.\\n function movedFundsSweepRequests(uint256 requestKey)\\n external\\n view\\n returns (MovingFunds.MovedFundsSweepRequest memory)\\n {\\n return self.movedFundsSweepRequests[requestKey];\\n }\\n\\n /// @notice Indicates if the vault with the given address is trusted or not.\\n /// Depositors can route their revealed deposits only to trusted\\n /// vaults and have trusted vaults notified about new deposits as\\n /// soon as these deposits get swept. Vaults not trusted by the\\n /// Bridge can still be used by Bank balance owners on their own\\n /// responsibility - anyone can approve their Bank balance to any\\n /// address.\\n function isVaultTrusted(address vault) external view returns (bool) {\\n return self.isVaultTrusted[vault];\\n }\\n\\n /// @notice Returns the current values of Bridge deposit parameters.\\n /// @return depositDustThreshold The minimal amount that can be requested\\n /// to deposit. Value of this parameter must take into account the\\n /// value of `depositTreasuryFeeDivisor` and `depositTxMaxFee`\\n /// parameters in order to make requests that can incur the\\n /// treasury and transaction fee and still satisfy the depositor.\\n /// @return depositTreasuryFeeDivisor Divisor used to compute the treasury\\n /// fee taken from each deposit and transferred to the treasury upon\\n /// sweep proof submission. That fee is computed as follows:\\n /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each deposit,\\n /// the `depositTreasuryFeeDivisor` should be set to `50`\\n /// because `1/50 = 0.02 = 2%`.\\n /// @return depositTxMaxFee Maximum amount of BTC transaction fee that can\\n /// be incurred by each swept deposit being part of the given sweep\\n /// transaction. If the maximum BTC transaction fee is exceeded,\\n /// such transaction is considered a fraud.\\n /// @return depositRevealAheadPeriod Defines the length of the period that\\n /// must be preserved between the deposit reveal time and the\\n /// deposit refund locktime. For example, if the deposit become\\n /// refundable on August 1st, and the ahead period is 7 days, the\\n /// latest moment for deposit reveal is July 25th. Value in seconds.\\n function depositParameters()\\n external\\n view\\n returns (\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n )\\n {\\n depositDustThreshold = self.depositDustThreshold;\\n depositTreasuryFeeDivisor = self.depositTreasuryFeeDivisor;\\n depositTxMaxFee = self.depositTxMaxFee;\\n depositRevealAheadPeriod = self.depositRevealAheadPeriod;\\n }\\n\\n /// @notice Returns the current values of Bridge redemption parameters.\\n /// @return redemptionDustThreshold The minimal amount that can be requested\\n /// for redemption. Value of this parameter must take into account\\n /// the value of `redemptionTreasuryFeeDivisor` and `redemptionTxMaxFee`\\n /// parameters in order to make requests that can incur the\\n /// treasury and transaction fee and still satisfy the redeemer.\\n /// @return redemptionTreasuryFeeDivisor Divisor used to compute the treasury\\n /// fee taken from each redemption request and transferred to the\\n /// treasury upon successful request finalization. That fee is\\n /// computed as follows:\\n /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each\\n /// redemption request, the `redemptionTreasuryFeeDivisor` should\\n /// be set to `50` because `1/50 = 0.02 = 2%`.\\n /// @return redemptionTxMaxFee Maximum amount of BTC transaction fee that\\n /// can be incurred by each redemption request being part of the\\n /// given redemption transaction. If the maximum BTC transaction\\n /// fee is exceeded, such transaction is considered a fraud.\\n /// This is a per-redemption output max fee for the redemption\\n /// transaction.\\n /// @return redemptionTxMaxTotalFee Maximum amount of the total BTC\\n /// transaction fee that is acceptable in a single redemption\\n /// transaction. This is a _total_ max fee for the entire redemption\\n /// transaction.\\n /// @return redemptionTimeout Time after which the redemption request can be\\n /// reported as timed out. It is counted from the moment when the\\n /// redemption request was created via `requestRedemption` call.\\n /// Reported timed out requests are cancelled and locked balance is\\n /// returned to the redeemer in full amount.\\n /// @return redemptionTimeoutSlashingAmount The amount of stake slashed\\n /// from each member of a wallet for a redemption timeout.\\n /// @return redemptionTimeoutNotifierRewardMultiplier The percentage of the\\n /// notifier reward from the staking contract the notifier of a\\n /// redemption timeout receives. The value is in the range [0, 100].\\n function redemptionParameters()\\n external\\n view\\n returns (\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n )\\n {\\n redemptionDustThreshold = self.redemptionDustThreshold;\\n redemptionTreasuryFeeDivisor = self.redemptionTreasuryFeeDivisor;\\n redemptionTxMaxFee = self.redemptionTxMaxFee;\\n redemptionTxMaxTotalFee = self.redemptionTxMaxTotalFee;\\n redemptionTimeout = self.redemptionTimeout;\\n redemptionTimeoutSlashingAmount = self.redemptionTimeoutSlashingAmount;\\n redemptionTimeoutNotifierRewardMultiplier = self\\n .redemptionTimeoutNotifierRewardMultiplier;\\n }\\n\\n /// @notice Returns the current values of Bridge moving funds between\\n /// wallets parameters.\\n /// @return movingFundsTxMaxTotalFee Maximum amount of the total BTC\\n /// transaction fee that is acceptable in a single moving funds\\n /// transaction. This is a _total_ max fee for the entire moving\\n /// funds transaction.\\n /// @return movingFundsDustThreshold The minimal satoshi amount that makes\\n /// sense to be transferred during the moving funds process. Moving\\n /// funds wallets having their BTC balance below that value can\\n /// begin closing immediately as transferring such a low value may\\n /// not be possible due to BTC network fees.\\n /// @return movingFundsTimeoutResetDelay Time after which the moving funds\\n /// timeout can be reset in case the target wallet commitment\\n /// cannot be submitted due to a lack of live wallets in the system.\\n /// It is counted from the moment when the wallet was requested to\\n /// move their funds and switched to the MovingFunds state or from\\n /// the moment the timeout was reset the last time. Value in seconds\\n /// This value should be lower than the value of the\\n /// `movingFundsTimeout`.\\n /// @return movingFundsTimeout Time after which the moving funds process\\n /// can be reported as timed out. It is counted from the moment\\n /// when the wallet was requested to move their funds and switched\\n /// to the MovingFunds state. Value in seconds.\\n /// @return movingFundsTimeoutSlashingAmount The amount of stake slashed\\n /// from each member of a wallet for a moving funds timeout.\\n /// @return movingFundsTimeoutNotifierRewardMultiplier The percentage of the\\n /// notifier reward from the staking contract the notifier of a\\n /// moving funds timeout receives. The value is in the range [0, 100].\\n /// @return movingFundsCommitmentGasOffset The gas offset used for the\\n /// moving funds target wallet commitment transaction cost\\n /// reimbursement.\\n /// @return movedFundsSweepTxMaxTotalFee Maximum amount of the total BTC\\n /// transaction fee that is acceptable in a single moved funds\\n /// sweep transaction. This is a _total_ max fee for the entire\\n /// moved funds sweep transaction.\\n /// @return movedFundsSweepTimeout Time after which the moved funds sweep\\n /// process can be reported as timed out. It is counted from the\\n /// moment when the wallet was requested to sweep the received funds.\\n /// Value in seconds.\\n /// @return movedFundsSweepTimeoutSlashingAmount The amount of stake slashed\\n /// from each member of a wallet for a moved funds sweep timeout.\\n /// @return movedFundsSweepTimeoutNotifierRewardMultiplier The percentage\\n /// of the notifier reward from the staking contract the notifier\\n /// of a moved funds sweep timeout receives. The value is in the\\n /// range [0, 100].\\n function movingFundsParameters()\\n external\\n view\\n returns (\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n )\\n {\\n movingFundsTxMaxTotalFee = self.movingFundsTxMaxTotalFee;\\n movingFundsDustThreshold = self.movingFundsDustThreshold;\\n movingFundsTimeoutResetDelay = self.movingFundsTimeoutResetDelay;\\n movingFundsTimeout = self.movingFundsTimeout;\\n movingFundsTimeoutSlashingAmount = self\\n .movingFundsTimeoutSlashingAmount;\\n movingFundsTimeoutNotifierRewardMultiplier = self\\n .movingFundsTimeoutNotifierRewardMultiplier;\\n movingFundsCommitmentGasOffset = self.movingFundsCommitmentGasOffset;\\n movedFundsSweepTxMaxTotalFee = self.movedFundsSweepTxMaxTotalFee;\\n movedFundsSweepTimeout = self.movedFundsSweepTimeout;\\n movedFundsSweepTimeoutSlashingAmount = self\\n .movedFundsSweepTimeoutSlashingAmount;\\n movedFundsSweepTimeoutNotifierRewardMultiplier = self\\n .movedFundsSweepTimeoutNotifierRewardMultiplier;\\n }\\n\\n /// @return walletCreationPeriod Determines how frequently a new wallet\\n /// creation can be requested. Value in seconds.\\n /// @return walletCreationMinBtcBalance The minimum BTC threshold in satoshi\\n /// that is used to decide about wallet creation.\\n /// @return walletCreationMaxBtcBalance The maximum BTC threshold in satoshi\\n /// that is used to decide about wallet creation.\\n /// @return walletClosureMinBtcBalance The minimum BTC threshold in satoshi\\n /// that is used to decide about wallet closure.\\n /// @return walletMaxAge The maximum age of a wallet in seconds, after which\\n /// the wallet moving funds process can be requested.\\n /// @return walletMaxBtcTransfer The maximum BTC amount in satoshi than\\n /// can be transferred to a single target wallet during the moving\\n /// funds process.\\n /// @return walletClosingPeriod Determines the length of the wallet closing\\n /// period, i.e. the period when the wallet remains in the Closing\\n /// state and can be subject of deposit fraud challenges. Value\\n /// in seconds.\\n function walletParameters()\\n external\\n view\\n returns (\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n )\\n {\\n walletCreationPeriod = self.walletCreationPeriod;\\n walletCreationMinBtcBalance = self.walletCreationMinBtcBalance;\\n walletCreationMaxBtcBalance = self.walletCreationMaxBtcBalance;\\n walletClosureMinBtcBalance = self.walletClosureMinBtcBalance;\\n walletMaxAge = self.walletMaxAge;\\n walletMaxBtcTransfer = self.walletMaxBtcTransfer;\\n walletClosingPeriod = self.walletClosingPeriod;\\n }\\n\\n /// @notice Returns the current values of Bridge fraud parameters.\\n /// @return fraudChallengeDepositAmount The amount of ETH in wei the party\\n /// challenging the wallet for fraud needs to deposit.\\n /// @return fraudChallengeDefeatTimeout The amount of time the wallet has to\\n /// defeat a fraud challenge.\\n /// @return fraudSlashingAmount The amount slashed from each wallet member\\n /// for committing a fraud.\\n /// @return fraudNotifierRewardMultiplier The percentage of the notifier\\n /// reward from the staking contract the notifier of a fraud\\n /// receives. The value is in the range [0, 100].\\n function fraudParameters()\\n external\\n view\\n returns (\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n )\\n {\\n fraudChallengeDepositAmount = self.fraudChallengeDepositAmount;\\n fraudChallengeDefeatTimeout = self.fraudChallengeDefeatTimeout;\\n fraudSlashingAmount = self.fraudSlashingAmount;\\n fraudNotifierRewardMultiplier = self.fraudNotifierRewardMultiplier;\\n }\\n\\n /// @notice Returns the addresses of contracts Bridge is interacting with.\\n /// @return bank Address of the Bank the Bridge belongs to.\\n /// @return relay Address of the Bitcoin relay providing the current Bitcoin\\n /// network difficulty.\\n /// @return ecdsaWalletRegistry Address of the ECDSA Wallet Registry.\\n /// @return reimbursementPool Address of the Reimbursement Pool.\\n function contractReferences()\\n external\\n view\\n returns (\\n Bank bank,\\n IRelay relay,\\n EcdsaWalletRegistry ecdsaWalletRegistry,\\n ReimbursementPool reimbursementPool\\n )\\n {\\n bank = self.bank;\\n relay = self.relay;\\n ecdsaWalletRegistry = self.ecdsaWalletRegistry;\\n reimbursementPool = self.reimbursementPool;\\n }\\n\\n /// @notice Address where the deposit treasury fees will be sent to.\\n /// Treasury takes part in the operators rewarding process.\\n function treasury() external view returns (address) {\\n return self.treasury;\\n }\\n\\n /// @notice The number of confirmations on the Bitcoin chain required to\\n /// successfully evaluate an SPV proof.\\n function txProofDifficultyFactor() external view returns (uint256) {\\n return self.txProofDifficultyFactor;\\n }\\n}\\n\",\"keccak256\":\"0x0a6e8f890ba55fbd8671f4853c882e5c8c70e476d521013b21a30fa7d0f5bafd\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/BridgeState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {IWalletRegistry as EcdsaWalletRegistry} from \\\"@keep-network/ecdsa/contracts/api/IWalletRegistry.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/ReimbursementPool.sol\\\";\\n\\nimport \\\"./IRelay.sol\\\";\\nimport \\\"./Deposit.sol\\\";\\nimport \\\"./Redemption.sol\\\";\\nimport \\\"./Fraud.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\nimport \\\"./MovingFunds.sol\\\";\\n\\nimport \\\"../bank/Bank.sol\\\";\\n\\nlibrary BridgeState {\\n struct Storage {\\n // Address of the Bank the Bridge belongs to.\\n Bank bank;\\n // Bitcoin relay providing the current Bitcoin network difficulty.\\n IRelay relay;\\n // The number of confirmations on the Bitcoin chain required to\\n // successfully evaluate an SPV proof.\\n uint96 txProofDifficultyFactor;\\n // ECDSA Wallet Registry contract handle.\\n EcdsaWalletRegistry ecdsaWalletRegistry;\\n // Reimbursement Pool contract handle.\\n ReimbursementPool reimbursementPool;\\n // Address where the deposit and redemption treasury fees will be sent\\n // to. Treasury takes part in the operators rewarding process.\\n address treasury;\\n // Move depositDustThreshold to the next storage slot for a more\\n // efficient variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __treasuryAlignmentGap;\\n // The minimal amount that can be requested to deposit.\\n // Value of this parameter must take into account the value of\\n // `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters in order\\n // to make requests that can incur the treasury and transaction fee and\\n // still satisfy the depositor.\\n uint64 depositDustThreshold;\\n // Divisor used to compute the treasury fee taken from each deposit and\\n // transferred to the treasury upon sweep proof submission. That fee is\\n // computed as follows:\\n // `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n // For example, if the treasury fee needs to be 2% of each deposit,\\n // the `depositTreasuryFeeDivisor` should be set to `50` because\\n // `1/50 = 0.02 = 2%`.\\n uint64 depositTreasuryFeeDivisor;\\n // Maximum amount of BTC transaction fee that can be incurred by each\\n // swept deposit being part of the given sweep transaction. If the\\n // maximum BTC transaction fee is exceeded, such transaction is\\n // considered a fraud.\\n //\\n // This is a per-deposit input max fee for the sweep transaction.\\n uint64 depositTxMaxFee;\\n // Defines the length of the period that must be preserved between\\n // the deposit reveal time and the deposit refund locktime. For example,\\n // if the deposit become refundable on August 1st, and the ahead period\\n // is 7 days, the latest moment for deposit reveal is July 25th.\\n // Value in seconds. The value equal to zero disables the validation\\n // of this parameter.\\n uint32 depositRevealAheadPeriod;\\n // Move movingFundsTxMaxTotalFee to the next storage slot for a more\\n // efficient variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __depositAlignmentGap;\\n // Maximum amount of the total BTC transaction fee that is acceptable in\\n // a single moving funds transaction.\\n //\\n // This is a TOTAL max fee for the moving funds transaction. Note\\n // that `depositTxMaxFee` is per single deposit and `redemptionTxMaxFee`\\n // is per single redemption. `movingFundsTxMaxTotalFee` is a total\\n // fee for the entire transaction.\\n uint64 movingFundsTxMaxTotalFee;\\n // The minimal satoshi amount that makes sense to be transferred during\\n // the moving funds process. Moving funds wallets having their BTC\\n // balance below that value can begin closing immediately as\\n // transferring such a low value may not be possible due to\\n // BTC network fees. The value of this parameter must always be lower\\n // than `redemptionDustThreshold` in order to prevent redemption requests\\n // with values lower or equal to `movingFundsDustThreshold`.\\n uint64 movingFundsDustThreshold;\\n // Time after which the moving funds timeout can be reset in case the\\n // target wallet commitment cannot be submitted due to a lack of live\\n // wallets in the system. It is counted from the moment when the wallet\\n // was requested to move their funds and switched to the MovingFunds\\n // state or from the moment the timeout was reset the last time.\\n // Value in seconds. This value should be lower than the value\\n // of the `movingFundsTimeout`.\\n uint32 movingFundsTimeoutResetDelay;\\n // Time after which the moving funds process can be reported as\\n // timed out. It is counted from the moment when the wallet\\n // was requested to move their funds and switched to the MovingFunds\\n // state. Value in seconds.\\n uint32 movingFundsTimeout;\\n // The amount of stake slashed from each member of a wallet for a moving\\n // funds timeout.\\n uint96 movingFundsTimeoutSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a moving funds timeout receives. The value is in the\\n // range [0, 100].\\n uint32 movingFundsTimeoutNotifierRewardMultiplier;\\n // The gas offset used for the target wallet commitment transaction cost\\n // reimbursement.\\n uint16 movingFundsCommitmentGasOffset;\\n // Move movedFundsSweepTxMaxTotalFee to the next storage slot for a more\\n // efficient variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __movingFundsAlignmentGap;\\n // Maximum amount of the total BTC transaction fee that is acceptable in\\n // a single moved funds sweep transaction.\\n //\\n // This is a TOTAL max fee for the moved funds sweep transaction. Note\\n // that `depositTxMaxFee` is per single deposit and `redemptionTxMaxFee`\\n // is per single redemption. `movedFundsSweepTxMaxTotalFee` is a total\\n // fee for the entire transaction.\\n uint64 movedFundsSweepTxMaxTotalFee;\\n // Time after which the moved funds sweep process can be reported as\\n // timed out. It is counted from the moment when the recipient wallet\\n // was requested to sweep the received funds. Value in seconds.\\n uint32 movedFundsSweepTimeout;\\n // The amount of stake slashed from each member of a wallet for a moved\\n // funds sweep timeout.\\n uint96 movedFundsSweepTimeoutSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a moved funds sweep timeout receives. The value is\\n // in the range [0, 100].\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier;\\n // The minimal amount that can be requested for redemption.\\n // Value of this parameter must take into account the value of\\n // `redemptionTreasuryFeeDivisor` and `redemptionTxMaxFee`\\n // parameters in order to make requests that can incur the\\n // treasury and transaction fee and still satisfy the redeemer.\\n // Additionally, the value of this parameter must always be greater\\n // than `movingFundsDustThreshold` in order to prevent redemption\\n // requests with values lower or equal to `movingFundsDustThreshold`.\\n uint64 redemptionDustThreshold;\\n // Divisor used to compute the treasury fee taken from each\\n // redemption request and transferred to the treasury upon\\n // successful request finalization. That fee is computed as follows:\\n // `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n // For example, if the treasury fee needs to be 2% of each\\n // redemption request, the `redemptionTreasuryFeeDivisor` should\\n // be set to `50` because `1/50 = 0.02 = 2%`.\\n uint64 redemptionTreasuryFeeDivisor;\\n // Maximum amount of BTC transaction fee that can be incurred by\\n // each redemption request being part of the given redemption\\n // transaction. If the maximum BTC transaction fee is exceeded, such\\n // transaction is considered a fraud.\\n //\\n // This is a per-redemption output max fee for the redemption\\n // transaction.\\n uint64 redemptionTxMaxFee;\\n // Maximum amount of the total BTC transaction fee that is acceptable in\\n // a single redemption transaction.\\n //\\n // This is a TOTAL max fee for the redemption transaction. Note\\n // that the `redemptionTxMaxFee` is per single redemption.\\n // `redemptionTxMaxTotalFee` is a total fee for the entire transaction.\\n uint64 redemptionTxMaxTotalFee;\\n // Move redemptionTimeout to the next storage slot for a more efficient\\n // variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __redemptionAlignmentGap;\\n // Time after which the redemption request can be reported as\\n // timed out. It is counted from the moment when the redemption\\n // request was created via `requestRedemption` call. Reported\\n // timed out requests are cancelled and locked TBTC is returned\\n // to the redeemer in full amount.\\n uint32 redemptionTimeout;\\n // The amount of stake slashed from each member of a wallet for a\\n // redemption timeout.\\n uint96 redemptionTimeoutSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a redemption timeout receives. The value is in the\\n // range [0, 100].\\n uint32 redemptionTimeoutNotifierRewardMultiplier;\\n // The amount of ETH in wei the party challenging the wallet for fraud\\n // needs to deposit.\\n uint96 fraudChallengeDepositAmount;\\n // The amount of time the wallet has to defeat a fraud challenge.\\n uint32 fraudChallengeDefeatTimeout;\\n // The amount of stake slashed from each member of a wallet for a fraud.\\n uint96 fraudSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a fraud receives. The value is in the range [0, 100].\\n uint32 fraudNotifierRewardMultiplier;\\n // Determines how frequently a new wallet creation can be requested.\\n // Value in seconds.\\n uint32 walletCreationPeriod;\\n // The minimum BTC threshold in satoshi that is used to decide about\\n // wallet creation. Specifically, we allow for the creation of a new\\n // wallet if the active wallet is old enough and their amount of BTC\\n // is greater than or equal this threshold.\\n uint64 walletCreationMinBtcBalance;\\n // The maximum BTC threshold in satoshi that is used to decide about\\n // wallet creation. Specifically, we allow for the creation of a new\\n // wallet if the active wallet's amount of BTC is greater than or equal\\n // this threshold, regardless of the active wallet's age.\\n uint64 walletCreationMaxBtcBalance;\\n // The minimum BTC threshold in satoshi that is used to decide about\\n // wallet closing. Specifically, we allow for the closure of the given\\n // wallet if their amount of BTC is lesser than this threshold,\\n // regardless of the wallet's age.\\n uint64 walletClosureMinBtcBalance;\\n // The maximum age of a wallet in seconds, after which the wallet\\n // moving funds process can be requested.\\n uint32 walletMaxAge;\\n // 20-byte wallet public key hash being reference to the currently\\n // active wallet. Can be unset to the zero value under certain\\n // circumstances.\\n bytes20 activeWalletPubKeyHash;\\n // The current number of wallets in the Live state.\\n uint32 liveWalletsCount;\\n // The maximum BTC amount in satoshi than can be transferred to a single\\n // target wallet during the moving funds process.\\n uint64 walletMaxBtcTransfer;\\n // Determines the length of the wallet closing period, i.e. the period\\n // when the wallet remains in the Closing state and can be subject\\n // of deposit fraud challenges. This value is in seconds and should be\\n // greater than the deposit refund time plus some time margin.\\n uint32 walletClosingPeriod;\\n // Collection of all revealed deposits indexed by\\n // `keccak256(fundingTxHash | fundingOutputIndex)`.\\n // The `fundingTxHash` is `bytes32` (ordered as in Bitcoin internally)\\n // and `fundingOutputIndex` an `uint32`. This mapping may contain valid\\n // and invalid deposits and the wallet is responsible for validating\\n // them before attempting to execute a sweep.\\n mapping(uint256 => Deposit.DepositRequest) deposits;\\n // Indicates if the vault with the given address is trusted.\\n // Depositors can route their revealed deposits only to trusted vaults\\n // and have trusted vaults notified about new deposits as soon as these\\n // deposits get swept. Vaults not trusted by the Bridge can still be\\n // used by Bank balance owners on their own responsibility - anyone can\\n // approve their Bank balance to any address.\\n mapping(address => bool) isVaultTrusted;\\n // Indicates if the address is a trusted SPV maintainer.\\n // The SPV proof does not check whether the transaction is a part of the\\n // Bitcoin mainnet, it only checks whether the transaction has been\\n // mined performing the required amount of work as on Bitcoin mainnet.\\n // The possibility of submitting SPV proofs is limited to trusted SPV\\n // maintainers. The system expects transaction confirmations with the\\n // required work accumulated, so trusted SPV maintainers can not prove\\n // the transaction without providing the required Bitcoin proof of work.\\n // Trusted maintainers address the issue of an economic game between\\n // tBTC and Bitcoin mainnet where large Bitcoin mining pools can decide\\n // to use their hash power to mine fake Bitcoin blocks to prove them in\\n // tBTC instead of receiving Bitcoin miner rewards.\\n mapping(address => bool) isSpvMaintainer;\\n // Collection of all moved funds sweep requests indexed by\\n // `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.\\n // The `movingFundsTxHash` is `bytes32` (ordered as in Bitcoin\\n // internally) and `movingFundsOutputIndex` an `uint32`. Each entry\\n // is actually an UTXO representing the moved funds and is supposed\\n // to be swept with the current main UTXO of the recipient wallet.\\n mapping(uint256 => MovingFunds.MovedFundsSweepRequest) movedFundsSweepRequests;\\n // Collection of all pending redemption requests indexed by\\n // redemption key built as\\n // `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n // The `walletPubKeyHash` is the 20-byte wallet's public key hash\\n // (computed using Bitcoin HASH160 over the compressed ECDSA\\n // public key) and `redeemerOutputScript` is a Bitcoin script\\n // (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n // redeemed BTC as requested by the redeemer. Requests are added\\n // to this mapping by the `requestRedemption` method (duplicates\\n // not allowed) and are removed by one of the following methods:\\n // - `submitRedemptionProof` in case the request was handled\\n // successfully,\\n // - `notifyRedemptionTimeout` in case the request was reported\\n // to be timed out.\\n mapping(uint256 => Redemption.RedemptionRequest) pendingRedemptions;\\n // Collection of all timed out redemptions requests indexed by\\n // redemption key built as\\n // `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n // The `walletPubKeyHash` is the 20-byte wallet's public key hash\\n // (computed using Bitcoin HASH160 over the compressed ECDSA\\n // public key) and `redeemerOutputScript` is the Bitcoin script\\n // (P2PKH, P2WPKH, P2SH or P2WSH) that is involved in the timed\\n // out request.\\n // Only one method can add to this mapping:\\n // - `notifyRedemptionTimeout` which puts the redemption key to this\\n // mapping based on a timed out request stored previously in\\n // `pendingRedemptions` mapping.\\n // Only one method can remove entries from this mapping:\\n // - `submitRedemptionProof` in case the timed out redemption request\\n // was a part of the proven transaction.\\n mapping(uint256 => Redemption.RedemptionRequest) timedOutRedemptions;\\n // Collection of all submitted fraud challenges indexed by challenge\\n // key built as `keccak256(walletPublicKey|sighash)`.\\n mapping(uint256 => Fraud.FraudChallenge) fraudChallenges;\\n // Collection of main UTXOs that are honestly spent indexed by\\n // `keccak256(fundingTxHash | fundingOutputIndex)`. The `fundingTxHash`\\n // is `bytes32` (ordered as in Bitcoin internally) and\\n // `fundingOutputIndex` an `uint32`. A main UTXO is considered honestly\\n // spent if it was used as an input of a transaction that have been\\n // proven in the Bridge.\\n mapping(uint256 => bool) spentMainUTXOs;\\n // Maps the 20-byte wallet public key hash (computed using Bitcoin\\n // HASH160 over the compressed ECDSA public key) to the basic wallet\\n // information like state and pending redemptions value.\\n mapping(bytes20 => Wallets.Wallet) registeredWallets;\\n // Reserved storage space in case we need to add more variables.\\n // The convention from OpenZeppelin suggests the storage space should\\n // add up to 50 slots. Here we want to have more slots as there are\\n // planned upgrades of the Bridge contract. If more entires are added to\\n // the struct in the upcoming versions we need to reduce the array size.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[50] __gap;\\n }\\n\\n event DepositParametersUpdated(\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n\\n event RedemptionParametersUpdated(\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n );\\n\\n event MovingFundsParametersUpdated(\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n\\n event WalletParametersUpdated(\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n );\\n\\n event FraudParametersUpdated(\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n );\\n\\n event TreasuryUpdated(address treasury);\\n\\n /// @notice Updates parameters of deposits.\\n /// @param _depositDustThreshold New value of the deposit dust threshold in\\n /// satoshis. It is the minimal amount that can be requested to\\n //// deposit. Value of this parameter must take into account the value\\n /// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters\\n /// in order to make requests that can incur the treasury and\\n /// transaction fee and still satisfy the depositor.\\n /// @param _depositTreasuryFeeDivisor New value of the treasury fee divisor.\\n /// It is the divisor used to compute the treasury fee taken from\\n /// each deposit and transferred to the treasury upon sweep proof\\n /// submission. That fee is computed as follows:\\n /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each deposit,\\n /// the `depositTreasuryFeeDivisor` should be set to `50`\\n /// because `1/50 = 0.02 = 2%`.\\n /// @param _depositTxMaxFee New value of the deposit tx max fee in satoshis.\\n /// It is the maximum amount of BTC transaction fee that can\\n /// be incurred by each swept deposit being part of the given sweep\\n /// transaction. If the maximum BTC transaction fee is exceeded,\\n /// such transaction is considered a fraud.\\n /// @param _depositRevealAheadPeriod New value of the deposit reveal ahead\\n /// period parameter in seconds. It defines the length of the period\\n /// that must be preserved between the deposit reveal time and the\\n /// deposit refund locktime.\\n /// @dev Requirements:\\n /// - Deposit dust threshold must be greater than zero,\\n /// - Deposit dust threshold must be greater than deposit TX max fee,\\n /// - Deposit transaction max fee must be greater than zero.\\n function updateDepositParameters(\\n Storage storage self,\\n uint64 _depositDustThreshold,\\n uint64 _depositTreasuryFeeDivisor,\\n uint64 _depositTxMaxFee,\\n uint32 _depositRevealAheadPeriod\\n ) internal {\\n require(\\n _depositDustThreshold > 0,\\n \\\"Deposit dust threshold must be greater than zero\\\"\\n );\\n\\n require(\\n _depositDustThreshold > _depositTxMaxFee,\\n \\\"Deposit dust threshold must be greater than deposit TX max fee\\\"\\n );\\n\\n require(\\n _depositTxMaxFee > 0,\\n \\\"Deposit transaction max fee must be greater than zero\\\"\\n );\\n\\n self.depositDustThreshold = _depositDustThreshold;\\n self.depositTreasuryFeeDivisor = _depositTreasuryFeeDivisor;\\n self.depositTxMaxFee = _depositTxMaxFee;\\n self.depositRevealAheadPeriod = _depositRevealAheadPeriod;\\n\\n emit DepositParametersUpdated(\\n _depositDustThreshold,\\n _depositTreasuryFeeDivisor,\\n _depositTxMaxFee,\\n _depositRevealAheadPeriod\\n );\\n }\\n\\n /// @notice Updates parameters of redemptions.\\n /// @param _redemptionDustThreshold New value of the redemption dust\\n /// threshold in satoshis. It is the minimal amount that can be\\n /// requested for redemption. Value of this parameter must take into\\n /// account the value of `redemptionTreasuryFeeDivisor` and\\n /// `redemptionTxMaxFee` parameters in order to make requests that\\n /// can incur the treasury and transaction fee and still satisfy the\\n /// redeemer.\\n /// @param _redemptionTreasuryFeeDivisor New value of the redemption\\n /// treasury fee divisor. It is the divisor used to compute the\\n /// treasury fee taken from each redemption request and transferred\\n /// to the treasury upon successful request finalization. That fee is\\n /// computed as follows:\\n /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each\\n /// redemption request, the `redemptionTreasuryFeeDivisor` should\\n /// be set to `50` because `1/50 = 0.02 = 2%`.\\n /// @param _redemptionTxMaxFee New value of the redemption transaction max\\n /// fee in satoshis. It is the maximum amount of BTC transaction fee\\n /// that can be incurred by each redemption request being part of the\\n /// given redemption transaction. If the maximum BTC transaction fee\\n /// is exceeded, such transaction is considered a fraud.\\n /// This is a per-redemption output max fee for the redemption\\n /// transaction.\\n /// @param _redemptionTxMaxTotalFee New value of the redemption transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single redemption\\n /// transaction. This is a _total_ max fee for the entire redemption\\n /// transaction.\\n /// @param _redemptionTimeout New value of the redemption timeout in seconds.\\n /// It is the time after which the redemption request can be reported\\n /// as timed out. It is counted from the moment when the redemption\\n /// request was created via `requestRedemption` call. Reported timed\\n /// out requests are cancelled and locked TBTC is returned to the\\n /// redeemer in full amount.\\n /// @param _redemptionTimeoutSlashingAmount New value of the redemption\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for redemption timeout.\\n /// @param _redemptionTimeoutNotifierRewardMultiplier New value of the\\n /// redemption timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a redemption timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Redemption dust threshold must be greater than moving funds dust\\n /// threshold,\\n /// - Redemption dust threshold must be greater than the redemption TX\\n /// max fee,\\n /// - Redemption transaction max fee must be greater than zero,\\n /// - Redemption transaction max total fee must be greater than or\\n /// equal to the redemption transaction per-request max fee,\\n /// - Redemption timeout must be greater than zero,\\n /// - Redemption timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateRedemptionParameters(\\n Storage storage self,\\n uint64 _redemptionDustThreshold,\\n uint64 _redemptionTreasuryFeeDivisor,\\n uint64 _redemptionTxMaxFee,\\n uint64 _redemptionTxMaxTotalFee,\\n uint32 _redemptionTimeout,\\n uint96 _redemptionTimeoutSlashingAmount,\\n uint32 _redemptionTimeoutNotifierRewardMultiplier\\n ) internal {\\n require(\\n _redemptionDustThreshold > self.movingFundsDustThreshold,\\n \\\"Redemption dust threshold must be greater than moving funds dust threshold\\\"\\n );\\n\\n require(\\n _redemptionDustThreshold > _redemptionTxMaxFee,\\n \\\"Redemption dust threshold must be greater than redemption TX max fee\\\"\\n );\\n\\n require(\\n _redemptionTxMaxFee > 0,\\n \\\"Redemption transaction max fee must be greater than zero\\\"\\n );\\n\\n require(\\n _redemptionTxMaxTotalFee >= _redemptionTxMaxFee,\\n \\\"Redemption transaction max total fee must be greater than or equal to the redemption transaction per-request max fee\\\"\\n );\\n\\n require(\\n _redemptionTimeout > 0,\\n \\\"Redemption timeout must be greater than zero\\\"\\n );\\n\\n require(\\n _redemptionTimeoutNotifierRewardMultiplier <= 100,\\n \\\"Redemption timeout notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n self.redemptionDustThreshold = _redemptionDustThreshold;\\n self.redemptionTreasuryFeeDivisor = _redemptionTreasuryFeeDivisor;\\n self.redemptionTxMaxFee = _redemptionTxMaxFee;\\n self.redemptionTxMaxTotalFee = _redemptionTxMaxTotalFee;\\n self.redemptionTimeout = _redemptionTimeout;\\n self.redemptionTimeoutSlashingAmount = _redemptionTimeoutSlashingAmount;\\n self\\n .redemptionTimeoutNotifierRewardMultiplier = _redemptionTimeoutNotifierRewardMultiplier;\\n\\n emit RedemptionParametersUpdated(\\n _redemptionDustThreshold,\\n _redemptionTreasuryFeeDivisor,\\n _redemptionTxMaxFee,\\n _redemptionTxMaxTotalFee,\\n _redemptionTimeout,\\n _redemptionTimeoutSlashingAmount,\\n _redemptionTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of moving funds.\\n /// @param _movingFundsTxMaxTotalFee New value of the moving funds transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single moving funds\\n /// transaction. This is a _total_ max fee for the entire moving\\n /// funds transaction.\\n /// @param _movingFundsDustThreshold New value of the moving funds dust\\n /// threshold. It is the minimal satoshi amount that makes sense to\\n /// be transferred during the moving funds process. Moving funds\\n /// wallets having their BTC balance below that value can begin\\n /// closing immediately as transferring such a low value may not be\\n /// possible due to BTC network fees.\\n /// @param _movingFundsTimeoutResetDelay New value of the moving funds\\n /// timeout reset delay in seconds. It is the time after which the\\n /// moving funds timeout can be reset in case the target wallet\\n /// commitment cannot be submitted due to a lack of live wallets\\n /// in the system. It is counted from the moment when the wallet\\n /// was requested to move their funds and switched to the MovingFunds\\n /// state or from the moment the timeout was reset the last time.\\n /// @param _movingFundsTimeout New value of the moving funds timeout in\\n /// seconds. It is the time after which the moving funds process can\\n /// be reported as timed out. It is counted from the moment when the\\n /// wallet was requested to move their funds and switched to the\\n /// MovingFunds state.\\n /// @param _movingFundsTimeoutSlashingAmount New value of the moving funds\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for moving funds timeout.\\n /// @param _movingFundsTimeoutNotifierRewardMultiplier New value of the\\n /// moving funds timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a moving funds timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @param _movingFundsCommitmentGasOffset New value of the gas offset for\\n /// moving funds target wallet commitment transaction gas costs\\n /// reimbursement.\\n /// @param _movedFundsSweepTxMaxTotalFee New value of the moved funds sweep\\n /// transaction max total fee in satoshis. It is the maximum amount\\n /// of the total BTC transaction fee that is acceptable in a single\\n /// moved funds sweep transaction. This is a _total_ max fee for the\\n /// entire moved funds sweep transaction.\\n /// @param _movedFundsSweepTimeout New value of the moved funds sweep\\n /// timeout in seconds. It is the time after which the moved funds\\n /// sweep process can be reported as timed out. It is counted from\\n /// the moment when the wallet was requested to sweep the received\\n /// funds.\\n /// @param _movedFundsSweepTimeoutSlashingAmount New value of the moved\\n /// funds sweep timeout slashing amount in T, it is the amount\\n /// slashed from each wallet member for moved funds sweep timeout.\\n /// @param _movedFundsSweepTimeoutNotifierRewardMultiplier New value of\\n /// the moved funds sweep timeout notifier reward multiplier as\\n /// percentage, it determines the percentage of the notifier reward\\n /// from the staking contact the notifier of a moved funds sweep\\n /// timeout receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Moving funds transaction max total fee must be greater than zero,\\n /// - Moving funds dust threshold must be greater than zero and lower\\n /// than the redemption dust threshold,\\n /// - Moving funds timeout reset delay must be greater than zero,\\n /// - Moving funds timeout must be greater than the moving funds\\n /// timeout reset delay,\\n /// - Moving funds timeout notifier reward multiplier must be in the\\n /// range [0, 100],\\n /// - Moved funds sweep transaction max total fee must be greater than zero,\\n /// - Moved funds sweep timeout must be greater than zero,\\n /// - Moved funds sweep timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateMovingFundsParameters(\\n Storage storage self,\\n uint64 _movingFundsTxMaxTotalFee,\\n uint64 _movingFundsDustThreshold,\\n uint32 _movingFundsTimeoutResetDelay,\\n uint32 _movingFundsTimeout,\\n uint96 _movingFundsTimeoutSlashingAmount,\\n uint32 _movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 _movingFundsCommitmentGasOffset,\\n uint64 _movedFundsSweepTxMaxTotalFee,\\n uint32 _movedFundsSweepTimeout,\\n uint96 _movedFundsSweepTimeoutSlashingAmount,\\n uint32 _movedFundsSweepTimeoutNotifierRewardMultiplier\\n ) internal {\\n require(\\n _movingFundsTxMaxTotalFee > 0,\\n \\\"Moving funds transaction max total fee must be greater than zero\\\"\\n );\\n\\n require(\\n _movingFundsDustThreshold > 0 &&\\n _movingFundsDustThreshold < self.redemptionDustThreshold,\\n \\\"Moving funds dust threshold must be greater than zero and lower than redemption dust threshold\\\"\\n );\\n\\n require(\\n _movingFundsTimeoutResetDelay > 0,\\n \\\"Moving funds timeout reset delay must be greater than zero\\\"\\n );\\n\\n require(\\n _movingFundsTimeout > _movingFundsTimeoutResetDelay,\\n \\\"Moving funds timeout must be greater than its reset delay\\\"\\n );\\n\\n require(\\n _movingFundsTimeoutNotifierRewardMultiplier <= 100,\\n \\\"Moving funds timeout notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n require(\\n _movedFundsSweepTxMaxTotalFee > 0,\\n \\\"Moved funds sweep transaction max total fee must be greater than zero\\\"\\n );\\n\\n require(\\n _movedFundsSweepTimeout > 0,\\n \\\"Moved funds sweep timeout must be greater than zero\\\"\\n );\\n\\n require(\\n _movedFundsSweepTimeoutNotifierRewardMultiplier <= 100,\\n \\\"Moved funds sweep timeout notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n self.movingFundsTxMaxTotalFee = _movingFundsTxMaxTotalFee;\\n self.movingFundsDustThreshold = _movingFundsDustThreshold;\\n self.movingFundsTimeoutResetDelay = _movingFundsTimeoutResetDelay;\\n self.movingFundsTimeout = _movingFundsTimeout;\\n self\\n .movingFundsTimeoutSlashingAmount = _movingFundsTimeoutSlashingAmount;\\n self\\n .movingFundsTimeoutNotifierRewardMultiplier = _movingFundsTimeoutNotifierRewardMultiplier;\\n self.movingFundsCommitmentGasOffset = _movingFundsCommitmentGasOffset;\\n self.movedFundsSweepTxMaxTotalFee = _movedFundsSweepTxMaxTotalFee;\\n self.movedFundsSweepTimeout = _movedFundsSweepTimeout;\\n self\\n .movedFundsSweepTimeoutSlashingAmount = _movedFundsSweepTimeoutSlashingAmount;\\n self\\n .movedFundsSweepTimeoutNotifierRewardMultiplier = _movedFundsSweepTimeoutNotifierRewardMultiplier;\\n\\n emit MovingFundsParametersUpdated(\\n _movingFundsTxMaxTotalFee,\\n _movingFundsDustThreshold,\\n _movingFundsTimeoutResetDelay,\\n _movingFundsTimeout,\\n _movingFundsTimeoutSlashingAmount,\\n _movingFundsTimeoutNotifierRewardMultiplier,\\n _movingFundsCommitmentGasOffset,\\n _movedFundsSweepTxMaxTotalFee,\\n _movedFundsSweepTimeout,\\n _movedFundsSweepTimeoutSlashingAmount,\\n _movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of wallets.\\n /// @param _walletCreationPeriod New value of the wallet creation period in\\n /// seconds, determines how frequently a new wallet creation can be\\n /// requested.\\n /// @param _walletCreationMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param _walletCreationMaxBtcBalance New value of the wallet maximum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param _walletClosureMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet closure.\\n /// @param _walletMaxAge New value of the wallet maximum age in seconds,\\n /// indicates the maximum age of a wallet in seconds, after which\\n /// the wallet moving funds process can be requested.\\n /// @param _walletMaxBtcTransfer New value of the wallet maximum BTC transfer\\n /// in satoshi, determines the maximum amount that can be transferred\\n /// to a single target wallet during the moving funds process.\\n /// @param _walletClosingPeriod New value of the wallet closing period in\\n /// seconds, determines the length of the wallet closing period,\\n // i.e. the period when the wallet remains in the Closing state\\n // and can be subject of deposit fraud challenges.\\n /// @dev Requirements:\\n /// - Wallet maximum BTC balance must be greater than the wallet\\n /// minimum BTC balance,\\n /// - Wallet maximum BTC transfer must be greater than zero,\\n /// - Wallet closing period must be greater than zero.\\n function updateWalletParameters(\\n Storage storage self,\\n uint32 _walletCreationPeriod,\\n uint64 _walletCreationMinBtcBalance,\\n uint64 _walletCreationMaxBtcBalance,\\n uint64 _walletClosureMinBtcBalance,\\n uint32 _walletMaxAge,\\n uint64 _walletMaxBtcTransfer,\\n uint32 _walletClosingPeriod\\n ) internal {\\n require(\\n _walletCreationMaxBtcBalance > _walletCreationMinBtcBalance,\\n \\\"Wallet creation maximum BTC balance must be greater than the creation minimum BTC balance\\\"\\n );\\n require(\\n _walletMaxBtcTransfer > 0,\\n \\\"Wallet maximum BTC transfer must be greater than zero\\\"\\n );\\n require(\\n _walletClosingPeriod > 0,\\n \\\"Wallet closing period must be greater than zero\\\"\\n );\\n\\n self.walletCreationPeriod = _walletCreationPeriod;\\n self.walletCreationMinBtcBalance = _walletCreationMinBtcBalance;\\n self.walletCreationMaxBtcBalance = _walletCreationMaxBtcBalance;\\n self.walletClosureMinBtcBalance = _walletClosureMinBtcBalance;\\n self.walletMaxAge = _walletMaxAge;\\n self.walletMaxBtcTransfer = _walletMaxBtcTransfer;\\n self.walletClosingPeriod = _walletClosingPeriod;\\n\\n emit WalletParametersUpdated(\\n _walletCreationPeriod,\\n _walletCreationMinBtcBalance,\\n _walletCreationMaxBtcBalance,\\n _walletClosureMinBtcBalance,\\n _walletMaxAge,\\n _walletMaxBtcTransfer,\\n _walletClosingPeriod\\n );\\n }\\n\\n /// @notice Updates parameters related to frauds.\\n /// @param _fraudChallengeDepositAmount New value of the fraud challenge\\n /// deposit amount in wei, it is the amount of ETH the party\\n /// challenging the wallet for fraud needs to deposit.\\n /// @param _fraudChallengeDefeatTimeout New value of the challenge defeat\\n /// timeout in seconds, it is the amount of time the wallet has to\\n /// defeat a fraud challenge. The value must be greater than zero.\\n /// @param _fraudSlashingAmount New value of the fraud slashing amount in T,\\n /// it is the amount slashed from each wallet member for committing\\n /// a fraud.\\n /// @param _fraudNotifierRewardMultiplier New value of the fraud notifier\\n /// reward multiplier as percentage, it determines the percentage of\\n /// the notifier reward from the staking contact the notifier of\\n /// a fraud receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Fraud challenge defeat timeout must be greater than 0,\\n /// - Fraud notifier reward multiplier must be in the range [0, 100].\\n function updateFraudParameters(\\n Storage storage self,\\n uint96 _fraudChallengeDepositAmount,\\n uint32 _fraudChallengeDefeatTimeout,\\n uint96 _fraudSlashingAmount,\\n uint32 _fraudNotifierRewardMultiplier\\n ) internal {\\n require(\\n _fraudChallengeDefeatTimeout > 0,\\n \\\"Fraud challenge defeat timeout must be greater than zero\\\"\\n );\\n\\n require(\\n _fraudNotifierRewardMultiplier <= 100,\\n \\\"Fraud notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n self.fraudChallengeDepositAmount = _fraudChallengeDepositAmount;\\n self.fraudChallengeDefeatTimeout = _fraudChallengeDefeatTimeout;\\n self.fraudSlashingAmount = _fraudSlashingAmount;\\n self.fraudNotifierRewardMultiplier = _fraudNotifierRewardMultiplier;\\n\\n emit FraudParametersUpdated(\\n _fraudChallengeDepositAmount,\\n _fraudChallengeDefeatTimeout,\\n _fraudSlashingAmount,\\n _fraudNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates treasury address. The treasury receives the system fees.\\n /// @param _treasury New value of the treasury address.\\n /// @dev The treasury address must not be 0x0.\\n function updateTreasury(Storage storage self, address _treasury) internal {\\n require(_treasury != address(0), \\\"Treasury address must not be 0x0\\\");\\n\\n self.treasury = _treasury;\\n emit TreasuryUpdated(_treasury);\\n }\\n}\\n\",\"keccak256\":\"0x0fe63c47a08ff0e56bd3bf4d2c9db4b09df717ac77ba5b18ab382a1e0bbb11c7\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Deposit.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\n/// @title Bridge deposit\\n/// @notice The library handles the logic for revealing Bitcoin deposits to\\n/// the Bridge.\\n/// @dev The depositor puts together a P2SH or P2WSH address to deposit the\\n/// funds. This script is unique to each depositor and looks like this:\\n///\\n/// ```\\n/// DROP\\n/// DROP\\n/// DUP HASH160 EQUAL\\n/// IF\\n/// CHECKSIG\\n/// ELSE\\n/// DUP HASH160 EQUALVERIFY\\n/// CHECKLOCKTIMEVERIFY DROP\\n/// CHECKSIG\\n/// ENDIF\\n/// ```\\n///\\n/// Since each depositor has their own Ethereum address and their own\\n/// blinding factor, each depositor\\u2019s script is unique, and the hash\\n/// of each depositor\\u2019s script is unique.\\nlibrary Deposit {\\n using BTCUtils for bytes;\\n using BytesLib for bytes;\\n\\n /// @notice Represents data which must be revealed by the depositor during\\n /// deposit reveal.\\n struct DepositRevealInfo {\\n // Index of the funding output belonging to the funding transaction.\\n uint32 fundingOutputIndex;\\n // The blinding factor as 8 bytes. Byte endianness doesn't matter\\n // as this factor is not interpreted as uint. The blinding factor allows\\n // to distinguish deposits from the same depositor.\\n bytes8 blindingFactor;\\n // The compressed Bitcoin public key (33 bytes and 02 or 03 prefix)\\n // of the deposit's wallet hashed in the HASH160 Bitcoin opcode style.\\n bytes20 walletPubKeyHash;\\n // The compressed Bitcoin public key (33 bytes and 02 or 03 prefix)\\n // that can be used to make the deposit refund after the refund\\n // locktime passes. Hashed in the HASH160 Bitcoin opcode style.\\n bytes20 refundPubKeyHash;\\n // The refund locktime (4-byte LE). Interpreted according to locktime\\n // parsing rules described in:\\n // https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number\\n // and used with OP_CHECKLOCKTIMEVERIFY opcode as described in:\\n // https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki\\n bytes4 refundLocktime;\\n // Address of the Bank vault to which the deposit is routed to.\\n // Optional, can be 0x0. The vault must be trusted by the Bridge.\\n address vault;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents tBTC deposit request data.\\n struct DepositRequest {\\n // Ethereum depositor address.\\n address depositor;\\n // Deposit amount in satoshi.\\n uint64 amount;\\n // UNIX timestamp the deposit was revealed at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 revealedAt;\\n // Address of the Bank vault the deposit is routed to.\\n // Optional, can be 0x0.\\n address vault;\\n // Treasury TBTC fee in satoshi at the moment of deposit reveal.\\n uint64 treasuryFee;\\n // UNIX timestamp the deposit was swept at. Note this is not the\\n // time when the deposit was swept on the Bitcoin chain but actually\\n // the time when the sweep proof was delivered to the Ethereum chain.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 sweptAt;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event DepositRevealed(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex,\\n address indexed depositor,\\n uint64 amount,\\n bytes8 blindingFactor,\\n bytes20 indexed walletPubKeyHash,\\n bytes20 refundPubKeyHash,\\n bytes4 refundLocktime,\\n address vault\\n );\\n\\n /// @notice Used by the depositor to reveal information about their P2(W)SH\\n /// Bitcoin deposit to the Bridge on Ethereum chain. The off-chain\\n /// wallet listens for revealed deposit events and may decide to\\n /// include the revealed deposit in the next executed sweep.\\n /// Information about the Bitcoin deposit can be revealed before or\\n /// after the Bitcoin transaction with P2(W)SH deposit is mined on\\n /// the Bitcoin chain. Worth noting, the gas cost of this function\\n /// scales with the number of P2(W)SH transaction inputs and\\n /// outputs. The deposit may be routed to one of the trusted vaults.\\n /// When a deposit is routed to a vault, vault gets notified when\\n /// the deposit gets swept and it may execute the appropriate action.\\n /// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`.\\n /// @param reveal Deposit reveal data, see `RevealInfo struct.\\n /// @dev Requirements:\\n /// - This function must be called by the same Ethereum address as the\\n /// one used in the P2(W)SH BTC deposit transaction as a depositor,\\n /// - `reveal.walletPubKeyHash` must identify a `Live` wallet,\\n /// - `reveal.vault` must be 0x0 or point to a trusted vault,\\n /// - `reveal.fundingOutputIndex` must point to the actual P2(W)SH\\n /// output of the BTC deposit transaction,\\n /// - `reveal.blindingFactor` must be the blinding factor used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - `reveal.walletPubKeyHash` must be the wallet pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundPubKeyHash` must be the refund pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundLocktime` must be the refund locktime used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n ///\\n /// If any of these requirements is not met, the wallet _must_ refuse\\n /// to sweep the deposit and the depositor has to wait until the\\n /// deposit script unlocks to receive their BTC back.\\n function revealDeposit(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata fundingTx,\\n DepositRevealInfo calldata reveal\\n ) external {\\n require(\\n self.registeredWallets[reveal.walletPubKeyHash].state ==\\n Wallets.WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n require(\\n reveal.vault == address(0) || self.isVaultTrusted[reveal.vault],\\n \\\"Vault is not trusted\\\"\\n );\\n\\n if (self.depositRevealAheadPeriod > 0) {\\n validateDepositRefundLocktime(self, reveal.refundLocktime);\\n }\\n\\n bytes memory expectedScript = abi.encodePacked(\\n hex\\\"14\\\", // Byte length of depositor Ethereum address.\\n msg.sender,\\n hex\\\"75\\\", // OP_DROP\\n hex\\\"08\\\", // Byte length of blinding factor value.\\n reveal.blindingFactor,\\n hex\\\"75\\\", // OP_DROP\\n hex\\\"76\\\", // OP_DUP\\n hex\\\"a9\\\", // OP_HASH160\\n hex\\\"14\\\", // Byte length of a compressed Bitcoin public key hash.\\n reveal.walletPubKeyHash,\\n hex\\\"87\\\", // OP_EQUAL\\n hex\\\"63\\\", // OP_IF\\n hex\\\"ac\\\", // OP_CHECKSIG\\n hex\\\"67\\\", // OP_ELSE\\n hex\\\"76\\\", // OP_DUP\\n hex\\\"a9\\\", // OP_HASH160\\n hex\\\"14\\\", // Byte length of a compressed Bitcoin public key hash.\\n reveal.refundPubKeyHash,\\n hex\\\"88\\\", // OP_EQUALVERIFY\\n hex\\\"04\\\", // Byte length of refund locktime value.\\n reveal.refundLocktime,\\n hex\\\"b1\\\", // OP_CHECKLOCKTIMEVERIFY\\n hex\\\"75\\\", // OP_DROP\\n hex\\\"ac\\\", // OP_CHECKSIG\\n hex\\\"68\\\" // OP_ENDIF\\n );\\n\\n bytes memory fundingOutput = fundingTx\\n .outputVector\\n .extractOutputAtIndex(reveal.fundingOutputIndex);\\n bytes memory fundingOutputHash = fundingOutput.extractHash();\\n\\n if (fundingOutputHash.length == 20) {\\n // A 20-byte output hash is used by P2SH. That hash is constructed\\n // by applying OP_HASH160 on the locking script. A 20-byte output\\n // hash is used as well by P2PKH and P2WPKH (OP_HASH160 on the\\n // public key). However, since we compare the actual output hash\\n // with an expected locking script hash, this check will succeed only\\n // for P2SH transaction type with expected script hash value. For\\n // P2PKH and P2WPKH, it will fail on the output hash comparison with\\n // the expected locking script hash.\\n require(\\n fundingOutputHash.slice20(0) == expectedScript.hash160View(),\\n \\\"Wrong 20-byte script hash\\\"\\n );\\n } else if (fundingOutputHash.length == 32) {\\n // A 32-byte output hash is used by P2WSH. That hash is constructed\\n // by applying OP_SHA256 on the locking script.\\n require(\\n fundingOutputHash.toBytes32() == sha256(expectedScript),\\n \\\"Wrong 32-byte script hash\\\"\\n );\\n } else {\\n revert(\\\"Wrong script hash length\\\");\\n }\\n\\n // Resulting TX hash is in native Bitcoin little-endian format.\\n bytes32 fundingTxHash = abi\\n .encodePacked(\\n fundingTx.version,\\n fundingTx.inputVector,\\n fundingTx.outputVector,\\n fundingTx.locktime\\n )\\n .hash256View();\\n\\n DepositRequest storage deposit = self.deposits[\\n uint256(\\n keccak256(\\n abi.encodePacked(fundingTxHash, reveal.fundingOutputIndex)\\n )\\n )\\n ];\\n require(deposit.revealedAt == 0, \\\"Deposit already revealed\\\");\\n\\n uint64 fundingOutputAmount = fundingOutput.extractValue();\\n\\n require(\\n fundingOutputAmount >= self.depositDustThreshold,\\n \\\"Deposit amount too small\\\"\\n );\\n\\n deposit.amount = fundingOutputAmount;\\n deposit.depositor = msg.sender;\\n /* solhint-disable-next-line not-rely-on-time */\\n deposit.revealedAt = uint32(block.timestamp);\\n deposit.vault = reveal.vault;\\n deposit.treasuryFee = self.depositTreasuryFeeDivisor > 0\\n ? fundingOutputAmount / self.depositTreasuryFeeDivisor\\n : 0;\\n // slither-disable-next-line reentrancy-events\\n emit DepositRevealed(\\n fundingTxHash,\\n reveal.fundingOutputIndex,\\n msg.sender,\\n fundingOutputAmount,\\n reveal.blindingFactor,\\n reveal.walletPubKeyHash,\\n reveal.refundPubKeyHash,\\n reveal.refundLocktime,\\n reveal.vault\\n );\\n }\\n\\n /// @notice Validates the deposit refund locktime. The validation passes\\n /// successfully only if the deposit reveal is done respectively\\n /// earlier than the moment when the deposit refund locktime is\\n /// reached, i.e. the deposit become refundable. Reverts otherwise.\\n /// @param refundLocktime The deposit refund locktime as 4-byte LE.\\n /// @dev Requirements:\\n /// - `refundLocktime` as integer must be >= 500M\\n /// - `refundLocktime` must denote a timestamp that is at least\\n /// `depositRevealAheadPeriod` seconds later than the moment\\n /// of `block.timestamp`\\n function validateDepositRefundLocktime(\\n BridgeState.Storage storage self,\\n bytes4 refundLocktime\\n ) internal view {\\n // Convert the refund locktime byte array to a LE integer. This is\\n // the moment in time when the deposit become refundable.\\n uint32 depositRefundableTimestamp = BTCUtils.reverseUint32(\\n uint32(refundLocktime)\\n );\\n // According to https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number\\n // the locktime is parsed as a block number if less than 500M. We always\\n // want to parse the locktime as an Unix timestamp so we allow only for\\n // values bigger than or equal to 500M.\\n require(\\n depositRefundableTimestamp >= 500 * 1e6,\\n \\\"Refund locktime must be a value >= 500M\\\"\\n );\\n // The deposit must be revealed before it becomes refundable.\\n // This is because the sweeping wallet needs to have some time to\\n // sweep the deposit and avoid a potential competition with the\\n // depositor making the deposit refund.\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp + self.depositRevealAheadPeriod <=\\n depositRefundableTimestamp,\\n \\\"Deposit refund locktime is too close\\\"\\n );\\n }\\n}\\n\",\"keccak256\":\"0xc00d41ea9e98a6fa3d8d8701ad8554c459e0268c6bf413f0447bc1c68c6ab7e8\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/DepositSweep.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\nimport \\\"../bank/Bank.sol\\\";\\n\\n/// @title Bridge deposit sweep\\n/// @notice The library handles the logic for sweeping transactions revealed to\\n/// the Bridge\\n/// @dev Bridge active wallet periodically signs a transaction that unlocks all\\n/// of the valid, revealed deposits above the dust threshold, combines them\\n/// into a single UTXO with the existing main wallet UTXO, and relocks\\n/// those transactions without a 30-day refund clause to the same wallet.\\n/// This has two main effects: it consolidates the UTXO set and it disables\\n/// the refund. Balances of depositors in the Bank are increased when the\\n/// SPV sweep proof is submitted to the Bridge.\\nlibrary DepositSweep {\\n using BridgeState for BridgeState.Storage;\\n using BitcoinTx for BridgeState.Storage;\\n\\n using BTCUtils for bytes;\\n\\n /// @notice Represents temporary information needed during the processing\\n /// of the deposit sweep Bitcoin transaction inputs. This structure\\n /// is an internal one and should not be exported outside of the\\n /// deposit sweep transaction processing code.\\n /// @dev Allows to mitigate \\\"stack too deep\\\" errors on EVM.\\n struct DepositSweepTxInputsProcessingInfo {\\n // Input vector of the deposit sweep Bitcoin transaction. It is\\n // assumed the vector's structure is valid so it must be validated\\n // using e.g. `BTCUtils.validateVin` function before being used\\n // during the processing. The validation is usually done as part\\n // of the `BitcoinTx.validateProof` call that checks the SPV proof.\\n bytes sweepTxInputVector;\\n // Data of the wallet's main UTXO. If no main UTXO exists for the given\\n // sweeping wallet, this parameter's fields should be zeroed to bypass\\n // the main UTXO validation\\n BitcoinTx.UTXO mainUtxo;\\n // Address of the vault where all swept deposits should be routed to.\\n // It is used to validate whether all swept deposits have been revealed\\n // with the same `vault` parameter. It is an optional parameter.\\n // Set to zero address if deposits are not routed to a vault.\\n address vault;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n /// @notice Represents an outcome of the sweep Bitcoin transaction\\n /// inputs processing.\\n struct DepositSweepTxInputsInfo {\\n // Sum of all inputs values i.e. all deposits and main UTXO value,\\n // if present.\\n uint256 inputsTotalValue;\\n // Addresses of depositors who performed processed deposits. Ordered in\\n // the same order as deposits inputs in the input vector. Size of this\\n // array is either equal to the number of inputs (main UTXO doesn't\\n // exist) or less by one (main UTXO exists and is pointed by one of\\n // the inputs).\\n address[] depositors;\\n // Amounts of deposits corresponding to processed deposits. Ordered in\\n // the same order as deposits inputs in the input vector. Size of this\\n // array is either equal to the number of inputs (main UTXO doesn't\\n // exist) or less by one (main UTXO exists and is pointed by one of\\n // the inputs).\\n uint256[] depositedAmounts;\\n // Values of the treasury fee corresponding to processed deposits.\\n // Ordered in the same order as deposits inputs in the input vector.\\n // Size of this array is either equal to the number of inputs (main\\n // UTXO doesn't exist) or less by one (main UTXO exists and is pointed\\n // by one of the inputs).\\n uint256[] treasuryFees;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n event DepositsSwept(bytes20 walletPubKeyHash, bytes32 sweepTxHash);\\n\\n /// @notice Used by the wallet to prove the BTC deposit sweep transaction\\n /// and to update Bank balances accordingly. Sweep is only accepted\\n /// if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by first\\n /// computing the Bitcoin fee for the sweep transaction. The fee is\\n /// divided evenly between all swept deposits. Each depositor\\n /// receives a balance in the bank equal to the amount inferred\\n /// during the reveal transaction, minus their fee share.\\n ///\\n /// It is possible to prove the given sweep only one time.\\n /// @param sweepTx Bitcoin sweep transaction data.\\n /// @param sweepProof Bitcoin sweep proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @param vault Optional address of the vault where all swept deposits\\n /// should be routed to. All deposits swept as part of the transaction\\n /// must have their `vault` parameters set to the same address.\\n /// If this parameter is set to an address of a trusted vault, swept\\n /// deposits are routed to that vault.\\n /// If this parameter is set to the zero address or to an address\\n /// of a non-trusted vault, swept deposits are not routed to a\\n /// vault but depositors' balances are increased in the Bank\\n /// individually.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with 1..n\\n /// inputs. If the wallet has no main UTXO, all n inputs should\\n /// correspond to P2(W)SH revealed deposits UTXOs. If the wallet has\\n /// an existing main UTXO, one of the n inputs must point to that\\n /// main UTXO and remaining n-1 inputs should correspond to P2(W)SH\\n /// revealed deposits UTXOs. That transaction must have only\\n /// one P2(W)PKH output locking funds on the 20-byte wallet public\\n /// key hash,\\n /// - All revealed deposits that are swept by `sweepTx` must have\\n /// their `vault` parameters set to the same address as the address\\n /// passed in the `vault` function parameter,\\n /// - `sweepProof` components must match the expected structure. See\\n /// `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored.\\n function submitDepositSweepProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n address vault\\n ) external {\\n // Wallet state validation is performed in the\\n // `resolveDepositSweepingWallet` function.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 sweepTxHash = self.validateProof(sweepTx, sweepProof);\\n\\n // Process sweep transaction output and extract its target wallet\\n // public key hash and value.\\n (\\n bytes20 walletPubKeyHash,\\n uint64 sweepTxOutputValue\\n ) = processDepositSweepTxOutput(self, sweepTx.outputVector);\\n\\n (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n ) = resolveDepositSweepingWallet(self, walletPubKeyHash, mainUtxo);\\n\\n // Process sweep transaction inputs and extract all information needed\\n // to perform deposit bookkeeping.\\n DepositSweepTxInputsInfo\\n memory inputsInfo = processDepositSweepTxInputs(\\n self,\\n DepositSweepTxInputsProcessingInfo(\\n sweepTx.inputVector,\\n resolvedMainUtxo,\\n vault\\n )\\n );\\n\\n // Helper variable that will hold the sum of treasury fees paid by\\n // all deposits.\\n uint256 totalTreasuryFee = 0;\\n\\n // Determine the transaction fee that should be incurred by each deposit\\n // and the indivisible remainder that should be additionally incurred\\n // by the last deposit.\\n (\\n uint256 depositTxFee,\\n uint256 depositTxFeeRemainder\\n ) = depositSweepTxFeeDistribution(\\n inputsInfo.inputsTotalValue,\\n sweepTxOutputValue,\\n inputsInfo.depositedAmounts.length\\n );\\n\\n // Make sure the highest value of the deposit transaction fee does not\\n // exceed the maximum value limited by the governable parameter.\\n require(\\n depositTxFee + depositTxFeeRemainder <= self.depositTxMaxFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n // Reduce each deposit amount by treasury fee and transaction fee.\\n for (uint256 i = 0; i < inputsInfo.depositedAmounts.length; i++) {\\n // The last deposit should incur the deposit transaction fee\\n // remainder.\\n uint256 depositTxFeeIncurred = i ==\\n inputsInfo.depositedAmounts.length - 1\\n ? depositTxFee + depositTxFeeRemainder\\n : depositTxFee;\\n\\n // There is no need to check whether\\n // `inputsInfo.depositedAmounts[i] - inputsInfo.treasuryFees[i] - txFee > 0`\\n // since the `depositDustThreshold` should force that condition\\n // to be always true.\\n inputsInfo.depositedAmounts[i] =\\n inputsInfo.depositedAmounts[i] -\\n inputsInfo.treasuryFees[i] -\\n depositTxFeeIncurred;\\n totalTreasuryFee += inputsInfo.treasuryFees[i];\\n }\\n\\n // Record this sweep data and assign them to the wallet public key hash\\n // as new main UTXO. Transaction output index is always 0 as sweep\\n // transaction always contains only one output.\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(sweepTxHash, uint32(0), sweepTxOutputValue)\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit DepositsSwept(walletPubKeyHash, sweepTxHash);\\n\\n if (vault != address(0) && self.isVaultTrusted[vault]) {\\n // If the `vault` address is not zero and belongs to a trusted\\n // vault, route the deposits to that vault.\\n self.bank.increaseBalanceAndCall(\\n vault,\\n inputsInfo.depositors,\\n inputsInfo.depositedAmounts\\n );\\n } else {\\n // If the `vault` address is zero or belongs to a non-trusted\\n // vault, increase balances in the Bank individually for each\\n // depositor.\\n self.bank.increaseBalances(\\n inputsInfo.depositors,\\n inputsInfo.depositedAmounts\\n );\\n }\\n\\n // Pass the treasury fee to the treasury address.\\n if (totalTreasuryFee > 0) {\\n self.bank.increaseBalance(self.treasury, totalTreasuryFee);\\n }\\n }\\n\\n /// @notice Resolves sweeping wallet based on the provided wallet public key\\n /// hash. Validates the wallet state and current main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletPubKeyHash public key hash of the wallet proving the sweep\\n /// Bitcoin transaction.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @return wallet Data of the sweeping wallet.\\n /// @return resolvedMainUtxo The actual main UTXO of the sweeping wallet\\n /// resolved by cross-checking the `mainUtxo` parameter with\\n /// the chain state. If the validation went well, this is the\\n /// plain-text main UTXO corresponding to the `wallet.mainUtxoHash`.\\n /// @dev Requirements:\\n /// - Sweeping wallet must be either in Live or MovingFunds state,\\n /// - If the main UTXO of the sweeping wallet exists in the storage,\\n /// the passed `mainUTXO` parameter must be equal to the stored one.\\n function resolveDepositSweepingWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n )\\n internal\\n view\\n returns (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n )\\n {\\n wallet = self.registeredWallets[walletPubKeyHash];\\n\\n Wallets.WalletState walletState = wallet.state;\\n require(\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in Live or MovingFunds state\\\"\\n );\\n\\n // Check if the main UTXO for given wallet exists. If so, validate\\n // passed main UTXO data against the stored hash and use them for\\n // further processing. If no main UTXO exists, use empty data.\\n resolvedMainUtxo = BitcoinTx.UTXO(bytes32(0), 0, 0);\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n if (mainUtxoHash != bytes32(0)) {\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n resolvedMainUtxo = mainUtxo;\\n }\\n }\\n\\n /// @notice Processes the Bitcoin sweep transaction output vector by\\n /// extracting the single output and using it to gain additional\\n /// information required for further processing (e.g. value and\\n /// wallet public key hash).\\n /// @param sweepTxOutputVector Bitcoin sweep transaction output vector.\\n /// This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVout` function before\\n /// it is passed here.\\n /// @return walletPubKeyHash 20-byte wallet public key hash.\\n /// @return value 8-byte sweep transaction output value.\\n function processDepositSweepTxOutput(\\n BridgeState.Storage storage self,\\n bytes memory sweepTxOutputVector\\n ) internal view returns (bytes20 walletPubKeyHash, uint64 value) {\\n // To determine the total number of sweep transaction outputs, we need to\\n // parse the compactSize uint (VarInt) the output vector is prepended by.\\n // That compactSize uint encodes the number of vector elements using the\\n // format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVout` validation.\\n // See `BitcoinTx.outputVector` docs for more details.\\n (, uint256 outputsCount) = sweepTxOutputVector.parseVarInt();\\n require(\\n outputsCount == 1,\\n \\\"Sweep transaction must have a single output\\\"\\n );\\n\\n bytes memory output = sweepTxOutputVector.extractOutputAtIndex(0);\\n walletPubKeyHash = self.extractPubKeyHash(output);\\n value = output.extractValue();\\n\\n return (walletPubKeyHash, value);\\n }\\n\\n /// @notice Processes the Bitcoin sweep transaction input vector. It\\n /// extracts each input and tries to obtain associated deposit or\\n /// main UTXO data, depending on the input type. Reverts\\n /// if one of the inputs cannot be recognized as a pointer to a\\n /// revealed deposit or expected main UTXO.\\n /// This function also marks each processed deposit as swept.\\n /// @return resultInfo Outcomes of the processing.\\n function processDepositSweepTxInputs(\\n BridgeState.Storage storage self,\\n DepositSweepTxInputsProcessingInfo memory processInfo\\n ) internal returns (DepositSweepTxInputsInfo memory resultInfo) {\\n // If the passed `mainUtxo` parameter's values are zeroed, the main UTXO\\n // for the given wallet doesn't exist and it is not expected to be\\n // included in the sweep transaction input vector.\\n bool mainUtxoExpected = processInfo.mainUtxo.txHash != bytes32(0);\\n bool mainUtxoFound = false;\\n\\n // Determining the total number of sweep transaction inputs in the same\\n // way as for number of outputs. See `BitcoinTx.inputVector` docs for\\n // more details.\\n (uint256 inputsCompactSizeUintLength, uint256 inputsCount) = processInfo\\n .sweepTxInputVector\\n .parseVarInt();\\n\\n // To determine the first input starting index, we must jump over\\n // the compactSize uint which prepends the input vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 inputStartingIndex = 1 + inputsCompactSizeUintLength;\\n\\n // Determine the swept deposits count. If main UTXO is NOT expected,\\n // all inputs should be deposits. If main UTXO is expected, one input\\n // should point to that main UTXO.\\n resultInfo.depositors = new address[](\\n !mainUtxoExpected ? inputsCount : inputsCount - 1\\n );\\n resultInfo.depositedAmounts = new uint256[](\\n resultInfo.depositors.length\\n );\\n resultInfo.treasuryFees = new uint256[](resultInfo.depositors.length);\\n\\n // Initialize helper variables.\\n uint256 processedDepositsCount = 0;\\n\\n // Inputs processing loop.\\n for (uint256 i = 0; i < inputsCount; i++) {\\n (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex,\\n uint256 inputLength\\n ) = parseDepositSweepTxInputAt(\\n processInfo.sweepTxInputVector,\\n inputStartingIndex\\n );\\n\\n Deposit.DepositRequest storage deposit = self.deposits[\\n uint256(\\n keccak256(abi.encodePacked(outpointTxHash, outpointIndex))\\n )\\n ];\\n\\n if (deposit.revealedAt != 0) {\\n // If we entered here, that means the input was identified as\\n // a revealed deposit.\\n require(deposit.sweptAt == 0, \\\"Deposit already swept\\\");\\n\\n require(\\n deposit.vault == processInfo.vault,\\n \\\"Deposit should be routed to another vault\\\"\\n );\\n\\n if (processedDepositsCount == resultInfo.depositors.length) {\\n // If this condition is true, that means a deposit input\\n // took place of an expected main UTXO input.\\n // In other words, there is no expected main UTXO\\n // input and all inputs come from valid, revealed deposits.\\n revert(\\n \\\"Expected main UTXO not present in sweep transaction inputs\\\"\\n );\\n }\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n deposit.sweptAt = uint32(block.timestamp);\\n\\n resultInfo.depositors[processedDepositsCount] = deposit\\n .depositor;\\n resultInfo.depositedAmounts[processedDepositsCount] = deposit\\n .amount;\\n resultInfo.inputsTotalValue += resultInfo.depositedAmounts[\\n processedDepositsCount\\n ];\\n resultInfo.treasuryFees[processedDepositsCount] = deposit\\n .treasuryFee;\\n\\n processedDepositsCount++;\\n } else if (\\n mainUtxoExpected != mainUtxoFound &&\\n processInfo.mainUtxo.txHash == outpointTxHash &&\\n processInfo.mainUtxo.txOutputIndex == outpointIndex\\n ) {\\n // If we entered here, that means the input was identified as\\n // the expected main UTXO.\\n resultInfo.inputsTotalValue += processInfo\\n .mainUtxo\\n .txOutputValue;\\n mainUtxoFound = true;\\n\\n // Main UTXO used as an input, mark it as spent.\\n self.spentMainUTXOs[\\n uint256(\\n keccak256(\\n abi.encodePacked(outpointTxHash, outpointIndex)\\n )\\n )\\n ] = true;\\n } else {\\n revert(\\\"Unknown input type\\\");\\n }\\n\\n // Make the `inputStartingIndex` pointing to the next input by\\n // increasing it by current input's length.\\n inputStartingIndex += inputLength;\\n }\\n\\n // Construction of the input processing loop guarantees that:\\n // `processedDepositsCount == resultInfo.depositors.length == resultInfo.depositedAmounts.length`\\n // is always true at this point. We just use the first variable\\n // to assert the total count of swept deposit is bigger than zero.\\n require(\\n processedDepositsCount > 0,\\n \\\"Sweep transaction must process at least one deposit\\\"\\n );\\n\\n // Assert the main UTXO was used as one of current sweep's inputs if\\n // it was actually expected.\\n require(\\n mainUtxoExpected == mainUtxoFound,\\n \\\"Expected main UTXO not present in sweep transaction inputs\\\"\\n );\\n\\n return resultInfo;\\n }\\n\\n /// @notice Parses a Bitcoin transaction input starting at the given index.\\n /// @param inputVector Bitcoin transaction input vector.\\n /// @param inputStartingIndex Index the given input starts at.\\n /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is\\n /// pointed in the given input's outpoint.\\n /// @return outpointIndex 4-byte index of the Bitcoin transaction output\\n /// which is pointed in the given input's outpoint.\\n /// @return inputLength Byte length of the given input.\\n /// @dev This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVin` function before it\\n /// is passed here.\\n function parseDepositSweepTxInputAt(\\n bytes memory inputVector,\\n uint256 inputStartingIndex\\n )\\n internal\\n pure\\n returns (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex,\\n uint256 inputLength\\n )\\n {\\n outpointTxHash = inputVector.extractInputTxIdLeAt(inputStartingIndex);\\n\\n outpointIndex = BTCUtils.reverseUint32(\\n uint32(inputVector.extractTxIndexLeAt(inputStartingIndex))\\n );\\n\\n inputLength = inputVector.determineInputLengthAt(inputStartingIndex);\\n\\n return (outpointTxHash, outpointIndex, inputLength);\\n }\\n\\n /// @notice Determines the distribution of the sweep transaction fee\\n /// over swept deposits.\\n /// @param sweepTxInputsTotalValue Total value of all sweep transaction inputs.\\n /// @param sweepTxOutputValue Value of the sweep transaction output.\\n /// @param depositsCount Count of the deposits swept by the sweep transaction.\\n /// @return depositTxFee Transaction fee per deposit determined by evenly\\n /// spreading the divisible part of the sweep transaction fee\\n /// over all deposits.\\n /// @return depositTxFeeRemainder The indivisible part of the sweep\\n /// transaction fee than cannot be distributed over all deposits.\\n /// @dev It is up to the caller to decide how the remainder should be\\n /// counted in. This function only computes its value.\\n function depositSweepTxFeeDistribution(\\n uint256 sweepTxInputsTotalValue,\\n uint256 sweepTxOutputValue,\\n uint256 depositsCount\\n )\\n internal\\n pure\\n returns (uint256 depositTxFee, uint256 depositTxFeeRemainder)\\n {\\n // The sweep transaction fee is just the difference between inputs\\n // amounts sum and the output amount.\\n uint256 sweepTxFee = sweepTxInputsTotalValue - sweepTxOutputValue;\\n // Compute the indivisible remainder that remains after dividing the\\n // sweep transaction fee over all deposits evenly.\\n depositTxFeeRemainder = sweepTxFee % depositsCount;\\n // Compute the transaction fee per deposit by dividing the sweep\\n // transaction fee (reduced by the remainder) by the number of deposits.\\n depositTxFee = (sweepTxFee - depositTxFeeRemainder) / depositsCount;\\n\\n return (depositTxFee, depositTxFeeRemainder);\\n }\\n}\\n\",\"keccak256\":\"0xa5b6319960c51c1c5b1edf0539075b822e70d43035eb5f1d20325d0b57cbd73c\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/EcdsaLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nlibrary EcdsaLib {\\n using BytesLib for bytes;\\n\\n /// @notice Converts public key X and Y coordinates (32-byte each) to a\\n /// compressed public key (33-byte). Compressed public key is X\\n /// coordinate prefixed with `02` or `03` based on the Y coordinate parity.\\n /// It is expected that the uncompressed public key is stripped\\n /// (i.e. it is not prefixed with `04`).\\n /// @param x Wallet's public key's X coordinate.\\n /// @param y Wallet's public key's Y coordinate.\\n /// @return Compressed public key (33-byte), prefixed with `02` or `03`.\\n function compressPublicKey(bytes32 x, bytes32 y)\\n internal\\n pure\\n returns (bytes memory)\\n {\\n bytes1 prefix;\\n if (uint256(y) % 2 == 0) {\\n prefix = hex\\\"02\\\";\\n } else {\\n prefix = hex\\\"03\\\";\\n }\\n\\n return bytes.concat(prefix, x);\\n }\\n}\\n\",\"keccak256\":\"0x670d0fbeb088f78abfe7ae7f844784d774ca515480383378a602af707cace7ff\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Fraud.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {CheckBitcoinSigs} from \\\"@keep-network/bitcoin-spv-sol/contracts/CheckBitcoinSigs.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./EcdsaLib.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Heartbeat.sol\\\";\\nimport \\\"./MovingFunds.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\n/// @title Bridge fraud\\n/// @notice The library handles the logic for challenging Bridge wallets that\\n/// committed fraud.\\n/// @dev Anyone can submit a fraud challenge indicating that a UTXO being under\\n/// the wallet control was unlocked by the wallet but was not used\\n/// according to the protocol rules. That means the wallet signed\\n/// a transaction input pointing to that UTXO and there is a unique\\n/// sighash and signature pair associated with that input.\\n///\\n/// In order to defeat the challenge, the same wallet public key and\\n/// signature must be provided as were used to calculate the sighash during\\n/// the challenge. The wallet provides the preimage which produces sighash\\n/// used to generate the ECDSA signature that is the subject of the fraud\\n/// claim.\\n///\\n/// The fraud challenge defeat attempt will succeed if the inputs in the\\n/// preimage are considered honestly spent by the wallet. Therefore the\\n/// transaction spending the UTXO must be proven in the Bridge before\\n/// a challenge defeat is called.\\n///\\n/// Another option is when a malicious wallet member used a signed heartbeat\\n/// message periodically produced by the wallet off-chain to challenge the\\n/// wallet for a fraud. Anyone from the wallet can defeat the challenge by\\n/// proving the sighash and signature were produced for a heartbeat message\\n/// following a strict format.\\nlibrary Fraud {\\n using Wallets for BridgeState.Storage;\\n\\n using BytesLib for bytes;\\n using BTCUtils for bytes;\\n using BTCUtils for uint32;\\n using EcdsaLib for bytes;\\n\\n struct FraudChallenge {\\n // The address of the party challenging the wallet.\\n address challenger;\\n // The amount of ETH the challenger deposited.\\n uint256 depositAmount;\\n // The timestamp the challenge was submitted at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 reportedAt;\\n // The flag indicating whether the challenge has been resolved.\\n bool resolved;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event FraudChallengeSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n );\\n\\n event FraudChallengeDefeated(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash\\n );\\n\\n event FraudChallengeDefeatTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n // Sighash calculated as a Bitcoin's hash256 (double sha2) of:\\n // - a preimage of a transaction spending UTXO according to the protocol\\n // rules OR\\n // - a valid heartbeat message produced by the wallet off-chain.\\n bytes32 sighash\\n );\\n\\n /// @notice Submits a fraud challenge indicating that a UTXO being under\\n /// wallet control was unlocked by the wallet but was not used\\n /// according to the protocol rules. That means the wallet signed\\n /// a transaction input pointing to that UTXO and there is a unique\\n /// sighash and signature pair associated with that input. This\\n /// function uses those parameters to create a fraud accusation that\\n /// proves a given transaction input unlocking the given UTXO was\\n /// actually signed by the wallet. This function cannot determine\\n /// whether the transaction was actually broadcast and the input was\\n /// consumed in a fraudulent way so it just opens a challenge period\\n /// during which the wallet can defeat the challenge by submitting\\n /// proof of a transaction that consumes the given input according\\n /// to protocol rules. To prevent spurious allegations, the caller\\n /// must deposit ETH that is returned back upon justified fraud\\n /// challenge or confiscated otherwise.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @param signature Bitcoin signature in the R/S/V format\\n /// @dev Requirements:\\n /// - Wallet behind `walletPublicKey` must be in Live or MovingFunds\\n /// or Closing state,\\n /// - The challenger must send appropriate amount of ETH used as\\n /// fraud challenge deposit,\\n /// - The signature (represented by r, s and v) must be generated by\\n /// the wallet behind `walletPubKey` during signing of `sighash`\\n /// which was calculated from `preimageSha256`,\\n /// - Wallet can be challenged for the given signature only once.\\n function submitFraudChallenge(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n bytes memory preimageSha256,\\n BitcoinTx.RSVSignature calldata signature\\n ) external {\\n require(\\n msg.value >= self.fraudChallengeDepositAmount,\\n \\\"The amount of ETH deposited is too low\\\"\\n );\\n\\n // To prevent ECDSA signature forgery `sighash` must be calculated\\n // inside the function and not passed as a function parameter.\\n // Signature forgery could result in a wrongful fraud accusation\\n // against a wallet.\\n bytes32 sighash = sha256(preimageSha256);\\n\\n require(\\n CheckBitcoinSigs.checkSig(\\n walletPublicKey,\\n sighash,\\n signature.v,\\n signature.r,\\n signature.s\\n ),\\n \\\"Signature verification failure\\\"\\n );\\n\\n bytes memory compressedWalletPublicKey = EcdsaLib.compressPublicKey(\\n walletPublicKey.slice32(0),\\n walletPublicKey.slice32(32)\\n );\\n bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();\\n\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.Live ||\\n wallet.state == Wallets.WalletState.MovingFunds ||\\n wallet.state == Wallets.WalletState.Closing,\\n \\\"Wallet must be in Live or MovingFunds or Closing state\\\"\\n );\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n require(challenge.reportedAt == 0, \\\"Fraud challenge already exists\\\");\\n\\n challenge.challenger = msg.sender;\\n challenge.depositAmount = msg.value;\\n /* solhint-disable-next-line not-rely-on-time */\\n challenge.reportedAt = uint32(block.timestamp);\\n challenge.resolved = false;\\n // slither-disable-next-line reentrancy-events\\n emit FraudChallengeSubmitted(\\n walletPubKeyHash,\\n sighash,\\n signature.v,\\n signature.r,\\n signature.s\\n );\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet if\\n /// the transaction that spends the UTXO follows the protocol rules.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during input signing.\\n /// The fraud challenge defeat attempt will only succeed if the\\n /// inputs in the preimage are considered honestly spent by the\\n /// wallet. Therefore the transaction spending the UTXO must be\\n /// proven in the Bridge before a challenge defeat is called.\\n /// If successfully defeated, the fraud challenge is marked as\\n /// resolved and the amount of ether deposited by the challenger is\\n /// sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference.\\n /// @param witness Flag indicating whether the preimage was produced for a\\n /// witness input. True for witness, false for non-witness input.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as `hash256(preimage)`\\n /// must identify an open fraud challenge,\\n /// - the preimage must be a valid preimage of a transaction generated\\n /// according to the protocol rules and already proved in the Bridge,\\n /// - before a defeat attempt is made the transaction that spends the\\n /// given UTXO must be proven in the Bridge.\\n function defeatFraudChallenge(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n bytes calldata preimage,\\n bool witness\\n ) external {\\n bytes32 sighash = preimage.hash256();\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n\\n require(challenge.reportedAt > 0, \\\"Fraud challenge does not exist\\\");\\n require(\\n !challenge.resolved,\\n \\\"Fraud challenge has already been resolved\\\"\\n );\\n\\n // Ensure SIGHASH_ALL type was used during signing, which is represented\\n // by type value `1`.\\n require(extractSighashType(preimage) == 1, \\\"Wrong sighash type\\\");\\n\\n uint256 utxoKey = witness\\n ? extractUtxoKeyFromWitnessPreimage(preimage)\\n : extractUtxoKeyFromNonWitnessPreimage(preimage);\\n\\n // Check that the UTXO key identifies a correctly spent UTXO.\\n require(\\n self.deposits[utxoKey].sweptAt > 0 ||\\n self.spentMainUTXOs[utxoKey] ||\\n self.movedFundsSweepRequests[utxoKey].state ==\\n MovingFunds.MovedFundsSweepRequestState.Processed,\\n \\\"Spent UTXO not found among correctly spent UTXOs\\\"\\n );\\n\\n resolveFraudChallenge(self, walletPublicKey, challenge, sighash);\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet by\\n /// proving the sighash and signature were produced for an off-chain\\n /// wallet heartbeat message following a strict format.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during heartbeat message\\n /// signing. The fraud challenge defeat attempt will only succeed if\\n /// the signed message follows a strict format required for\\n /// heartbeat messages. If successfully defeated, the fraud\\n /// challenge is marked as resolved and the amount of ether\\n /// deposited by the challenger is sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes),\\n /// @param heartbeatMessage Off-chain heartbeat message meeting the heartbeat\\n /// message format requirements which produces sighash used to\\n /// generate the ECDSA signature that is the subject of the fraud\\n /// claim.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as\\n /// `hash256(heartbeatMessage)` must identify an open fraud challenge,\\n /// - `heartbeatMessage` must follow a strict format of heartbeat\\n /// messages.\\n function defeatFraudChallengeWithHeartbeat(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n bytes calldata heartbeatMessage\\n ) external {\\n bytes32 sighash = heartbeatMessage.hash256();\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n\\n require(challenge.reportedAt > 0, \\\"Fraud challenge does not exist\\\");\\n require(\\n !challenge.resolved,\\n \\\"Fraud challenge has already been resolved\\\"\\n );\\n\\n require(\\n Heartbeat.isValidHeartbeatMessage(heartbeatMessage),\\n \\\"Not a valid heartbeat message\\\"\\n );\\n\\n resolveFraudChallenge(self, walletPublicKey, challenge, sighash);\\n }\\n\\n /// @notice Called only for successfully defeated fraud challenges.\\n /// The fraud challenge is marked as resolved and the amount of\\n /// ether deposited by the challenger is sent to the treasury.\\n /// @dev Requirements:\\n /// - Must be called only for successfully defeated fraud challenges.\\n function resolveFraudChallenge(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n FraudChallenge storage challenge,\\n bytes32 sighash\\n ) internal {\\n // Mark the challenge as resolved as it was successfully defeated\\n challenge.resolved = true;\\n\\n // Send the ether deposited by the challenger to the treasury\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,unchecked-lowlevel,arbitrary-send\\n self.treasury.call{gas: 100000, value: challenge.depositAmount}(\\\"\\\");\\n /* solhint-enable avoid-low-level-calls */\\n\\n bytes memory compressedWalletPublicKey = EcdsaLib.compressPublicKey(\\n walletPublicKey.slice32(0),\\n walletPublicKey.slice32(32)\\n );\\n bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();\\n\\n // slither-disable-next-line reentrancy-events\\n emit FraudChallengeDefeated(walletPubKeyHash, sighash);\\n }\\n\\n /// @notice Notifies about defeat timeout for the given fraud challenge.\\n /// Can be called only if there was a fraud challenge identified by\\n /// the provided `walletPublicKey` and `sighash` and it was not\\n /// defeated on time. The amount of time that needs to pass after\\n /// a fraud challenge is reported is indicated by the\\n /// `challengeDefeatTimeout`. After a successful fraud challenge\\n /// defeat timeout notification the fraud challenge is marked as\\n /// resolved, the stake of each operator is slashed, the ether\\n /// deposited is returned to the challenger and the challenger is\\n /// rewarded.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Closing or\\n /// Terminated state,\\n /// - The `walletPublicKey` and `sighash` calculated from\\n /// `preimageSha256` must identify an open fraud challenge,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time indicated by `challengeDefeatTimeout` must pass\\n /// after the challenge was reported.\\n function notifyFraudChallengeDefeatTimeout(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n uint32[] calldata walletMembersIDs,\\n bytes memory preimageSha256\\n ) external {\\n // Wallet state is validated in `notifyWalletFraudChallengeDefeatTimeout`.\\n\\n bytes32 sighash = sha256(preimageSha256);\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n\\n require(challenge.reportedAt > 0, \\\"Fraud challenge does not exist\\\");\\n\\n require(\\n !challenge.resolved,\\n \\\"Fraud challenge has already been resolved\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >=\\n challenge.reportedAt + self.fraudChallengeDefeatTimeout,\\n \\\"Fraud challenge defeat period did not time out yet\\\"\\n );\\n\\n challenge.resolved = true;\\n // Return the ether deposited by the challenger\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,unchecked-lowlevel\\n challenge.challenger.call{gas: 100000, value: challenge.depositAmount}(\\n \\\"\\\"\\n );\\n /* solhint-enable avoid-low-level-calls */\\n\\n bytes memory compressedWalletPublicKey = EcdsaLib.compressPublicKey(\\n walletPublicKey.slice32(0),\\n walletPublicKey.slice32(32)\\n );\\n bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();\\n\\n self.notifyWalletFraudChallengeDefeatTimeout(\\n walletPubKeyHash,\\n walletMembersIDs,\\n challenge.challenger\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit FraudChallengeDefeatTimedOut(walletPubKeyHash, sighash);\\n }\\n\\n /// @notice Extracts the UTXO keys from the given preimage used during\\n /// signing of a witness input.\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference\\n /// @return utxoKey UTXO key that identifies spent input.\\n function extractUtxoKeyFromWitnessPreimage(bytes calldata preimage)\\n internal\\n pure\\n returns (uint256 utxoKey)\\n {\\n // The expected structure of the preimage created during signing of a\\n // witness input:\\n // - transaction version (4 bytes)\\n // - hash of previous outpoints of all inputs (32 bytes)\\n // - hash of sequences of all inputs (32 bytes)\\n // - outpoint (hash + index) of the input being signed (36 bytes)\\n // - the unlocking script of the input (variable length)\\n // - value of the outpoint (8 bytes)\\n // - sequence of the input being signed (4 bytes)\\n // - hash of all outputs (32 bytes)\\n // - transaction locktime (4 bytes)\\n // - sighash type (4 bytes)\\n\\n // See Bitcoin's BIP-143 for reference:\\n // https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki.\\n\\n // The outpoint (hash and index) is located at the constant offset of\\n // 68 (4 + 32 + 32).\\n bytes32 outpointTxHash = preimage.extractInputTxIdLeAt(68);\\n uint32 outpointIndex = BTCUtils.reverseUint32(\\n uint32(preimage.extractTxIndexLeAt(68))\\n );\\n\\n return\\n uint256(keccak256(abi.encodePacked(outpointTxHash, outpointIndex)));\\n }\\n\\n /// @notice Extracts the UTXO key from the given preimage used during\\n /// signing of a non-witness input.\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference.\\n /// @return utxoKey UTXO key that identifies spent input.\\n function extractUtxoKeyFromNonWitnessPreimage(bytes calldata preimage)\\n internal\\n pure\\n returns (uint256 utxoKey)\\n {\\n // The expected structure of the preimage created during signing of a\\n // non-witness input:\\n // - transaction version (4 bytes)\\n // - number of inputs written as compactSize uint (1 byte, 3 bytes,\\n // 5 bytes or 9 bytes)\\n // - for each input\\n // - outpoint (hash and index) (36 bytes)\\n // - unlocking script for the input being signed (variable length)\\n // or `00` for all other inputs (1 byte)\\n // - input sequence (4 bytes)\\n // - number of outputs written as compactSize uint (1 byte, 3 bytes,\\n // 5 bytes or 9 bytes)\\n // - outputs (variable length)\\n // - transaction locktime (4 bytes)\\n // - sighash type (4 bytes)\\n\\n // See example for reference:\\n // https://en.bitcoin.it/wiki/OP_CHECKSIG#Code_samples_and_raw_dumps.\\n\\n // The input data begins at the constant offset of 4 (the first 4 bytes\\n // are for the transaction version).\\n (uint256 inputsCompactSizeUintLength, uint256 inputsCount) = preimage\\n .parseVarIntAt(4);\\n\\n // To determine the first input starting index, we must jump 4 bytes\\n // over the transaction version length and the compactSize uint which\\n // prepends the input vector. One byte must be added because\\n // `BtcUtils.parseVarInt` does not include compactSize uint tag in the\\n // returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 inputStartingIndex = 4 + 1 + inputsCompactSizeUintLength;\\n\\n for (uint256 i = 0; i < inputsCount; i++) {\\n uint256 inputLength = preimage.determineInputLengthAt(\\n inputStartingIndex\\n );\\n\\n (, uint256 scriptSigLength) = preimage.extractScriptSigLenAt(\\n inputStartingIndex\\n );\\n\\n if (scriptSigLength > 0) {\\n // The input this preimage was generated for was found.\\n // All the other inputs in the preimage are marked with a null\\n // scriptSig (\\\"00\\\") which has length of 1.\\n bytes32 outpointTxHash = preimage.extractInputTxIdLeAt(\\n inputStartingIndex\\n );\\n uint32 outpointIndex = BTCUtils.reverseUint32(\\n uint32(preimage.extractTxIndexLeAt(inputStartingIndex))\\n );\\n\\n utxoKey = uint256(\\n keccak256(abi.encodePacked(outpointTxHash, outpointIndex))\\n );\\n\\n break;\\n }\\n\\n inputStartingIndex += inputLength;\\n }\\n\\n return utxoKey;\\n }\\n\\n /// @notice Extracts the sighash type from the given preimage.\\n /// @param preimage Serialized subset of the transaction. See BIP-143 for\\n /// reference.\\n /// @dev Sighash type is stored as the last 4 bytes in the preimage (little\\n /// endian).\\n /// @return sighashType Sighash type as a 32-bit integer.\\n function extractSighashType(bytes calldata preimage)\\n internal\\n pure\\n returns (uint32 sighashType)\\n {\\n bytes4 sighashTypeBytes = preimage.slice4(preimage.length - 4);\\n uint32 sighashTypeLE = uint32(sighashTypeBytes);\\n return sighashTypeLE.reverseUint32();\\n }\\n}\\n\",\"keccak256\":\"0x5b976a45cbee8e5d8e65fc748820e36c692d8fb26a8532319a87e6a614733c58\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Heartbeat.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\n/// @title Bridge wallet heartbeat\\n/// @notice The library establishes expected format for heartbeat messages\\n/// signed by wallet ECDSA signing group. Heartbeat messages are\\n/// constructed in such a way that they can not be used as a Bitcoin\\n/// transaction preimages.\\n/// @dev The smallest Bitcoin non-coinbase transaction is a one spending an\\n/// OP_TRUE anyonecanspend output and creating 1 OP_TRUE anyonecanspend\\n/// output. Such a transaction has 61 bytes (see `BitcoinTx` documentation):\\n/// 4 bytes for version\\n/// 1 byte for tx_in_count\\n/// 36 bytes for tx_in.previous_output\\n/// 1 byte for tx_in.script_bytes (value: 0)\\n/// 0 bytes for tx_in.signature_script\\n/// 4 bytes for tx_in.sequence\\n/// 1 byte for tx_out_count\\n/// 8 bytes for tx_out.value\\n/// 1 byte for tx_out.pk_script_bytes\\n/// 1 byte for tx_out.pk_script\\n/// 4 bytes for lock_time\\n///\\n///\\n/// The smallest Bitcoin coinbase transaction is a one creating\\n/// 1 OP_TRUE anyonecanspend output and having an empty coinbase script.\\n/// Such a transaction has 65 bytes:\\n/// 4 bytes for version\\n/// 1 byte for tx_in_count\\n/// 32 bytes for tx_in.hash (all 0x00)\\n/// 4 bytes for tx_in.index (all 0xff)\\n/// 1 byte for tx_in.script_bytes (value: 0)\\n/// 4 bytes for tx_in.height\\n/// 0 byte for tx_in.coinbase_script\\n/// 4 bytes for tx_in.sequence\\n/// 1 byte for tx_out_count\\n/// 8 bytes for tx_out.value\\n/// 1 byte for tx_out.pk_script_bytes\\n/// 1 byte for tx_out.pk_script\\n/// 4 bytes for lock_time\\n///\\n///\\n/// A SIGHASH flag is used to indicate which part of the transaction is\\n/// signed by the ECDSA signature. There are currently 3 flags:\\n/// SIGHASH_ALL, SIGHASH_NONE, SIGHASH_SINGLE, and different combinations\\n/// of these flags.\\n///\\n/// No matter the SIGHASH flag and no matter the combination, the following\\n/// fields from the transaction are always included in the constructed\\n/// preimage:\\n/// 4 bytes for version\\n/// 36 bytes for tx_in.previous_output (or tx_in.hash + tx_in.index for coinbase)\\n/// 4 bytes for lock_time\\n///\\n/// Additionally, the last 4 bytes of the preimage determines the SIGHASH\\n/// flag.\\n///\\n/// This is enough to say there is no way the preimage could be shorter\\n/// than 4 + 36 + 4 + 4 = 48 bytes.\\n///\\n/// For this reason, we construct the heartbeat message, as a 16-byte\\n/// message. The first 8 bytes are 0xffffffffffffffff. The last 8 bytes\\n/// are for an arbitrary uint64, being a signed heartbeat nonce (for\\n/// example, the last Ethereum block hash).\\n///\\n/// The message being signed by the wallet when executing the heartbeat\\n/// protocol should be Bitcoin's hash256 (double SHA-256) of the heartbeat\\n/// message:\\n/// heartbeat_sighash = hash256(heartbeat_message)\\nlibrary Heartbeat {\\n using BytesLib for bytes;\\n\\n /// @notice Determines if the signed byte array is a valid, non-fraudulent\\n /// heartbeat message.\\n /// @param message Message signed by the wallet. It is a potential heartbeat\\n /// message, Bitcoin transaction preimage, or an arbitrary signed\\n /// bytes.\\n /// @dev Wallet heartbeat message must be exactly 16 bytes long with the first\\n /// 8 bytes set to 0xffffffffffffffff.\\n /// @return True if valid heartbeat message, false otherwise.\\n function isValidHeartbeatMessage(bytes calldata message)\\n internal\\n pure\\n returns (bool)\\n {\\n if (message.length != 16) {\\n return false;\\n }\\n\\n if (message.slice8(0) != 0xffffffffffffffff) {\\n return false;\\n }\\n\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0x2f3ad70beadc4dfb6414064fd7b3621b1edcd2713f186853b4a5fd36fb4502ba\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/IRelay.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\n/// @title Interface for the Bitcoin relay\\n/// @notice Contains only the methods needed by tBTC v2. The Bitcoin relay\\n/// provides the difficulty of the previous and current epoch. One\\n/// difficulty epoch spans 2016 blocks.\\ninterface IRelay {\\n /// @notice Returns the difficulty of the current epoch.\\n function getCurrentEpochDifficulty() external view returns (uint256);\\n\\n /// @notice Returns the difficulty of the previous epoch.\\n function getPrevEpochDifficulty() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xf70c723fc0a1824d92061b5dc76c65c38c22eff6b18ef6a2057f511183ce3c5b\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/MovingFunds.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Redemption.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\n/// @title Moving Bridge wallet funds\\n/// @notice The library handles the logic for moving Bitcoin between Bridge\\n/// wallets.\\n/// @dev A wallet that failed a heartbeat, did not process requested redemption\\n/// on time, or qualifies to be closed, begins the procedure of moving\\n/// funds to other wallets in the Bridge. The wallet needs to commit to\\n/// which other Live wallets it is moving the funds to and then, provide an\\n/// SPV proof of moving funds to the previously committed wallets.\\n/// Once the proof is submitted, all target wallets are supposed to\\n/// sweep the received UTXOs with their own main UTXOs in order to\\n/// update their BTC balances.\\nlibrary MovingFunds {\\n using BridgeState for BridgeState.Storage;\\n using Wallets for BridgeState.Storage;\\n using BitcoinTx for BridgeState.Storage;\\n\\n using BTCUtils for bytes;\\n using BytesLib for bytes;\\n\\n /// @notice Represents temporary information needed during the processing\\n /// of the moving funds Bitcoin transaction outputs. This structure\\n /// is an internal one and should not be exported outside of the\\n /// moving funds transaction processing code.\\n /// @dev Allows to mitigate \\\"stack too deep\\\" errors on EVM.\\n struct MovingFundsTxOutputsProcessingInfo {\\n // 32-byte hash of the moving funds Bitcoin transaction.\\n bytes32 movingFundsTxHash;\\n // Output vector of the moving funds Bitcoin transaction. It is\\n // assumed the vector's structure is valid so it must be validated\\n // using e.g. `BTCUtils.validateVout` function before being used\\n // during the processing. The validation is usually done as part\\n // of the `BitcoinTx.validateProof` call that checks the SPV proof.\\n bytes movingFundsTxOutputVector;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n /// @notice Represents moved funds sweep request state.\\n enum MovedFundsSweepRequestState {\\n /// @dev The request is unknown to the Bridge.\\n Unknown,\\n /// @dev Request is pending and can become either processed or timed out.\\n Pending,\\n /// @dev Request was processed by the target wallet.\\n Processed,\\n /// @dev Request was not processed in the given time window and\\n /// the timeout was reported.\\n TimedOut\\n }\\n\\n /// @notice Represents a moved funds sweep request. The request is\\n /// registered in `submitMovingFundsProof` where we know funds\\n /// have been moved to the target wallet and the only step left is\\n /// to have the target wallet sweep them.\\n struct MovedFundsSweepRequest {\\n // 20-byte public key hash of the wallet supposed to sweep the UTXO\\n // representing the received funds with their own main UTXO\\n bytes20 walletPubKeyHash;\\n // Value of the received funds.\\n uint64 value;\\n // UNIX timestamp the request was created at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 createdAt;\\n // The current state of the request.\\n MovedFundsSweepRequestState state;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event MovingFundsCommitmentSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes20[] targetWallets,\\n address submitter\\n );\\n\\n event MovingFundsTimeoutReset(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash\\n );\\n\\n event MovingFundsTimedOut(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsBelowDustReported(bytes20 indexed walletPubKeyHash);\\n\\n event MovedFundsSwept(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sweepTxHash\\n );\\n\\n event MovedFundsSweepTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex\\n );\\n\\n /// @notice Submits the moving funds target wallets commitment.\\n /// Once all requirements are met, that function registers the\\n /// target wallets commitment and opens the way for moving funds\\n /// proof submission.\\n /// @param walletPubKeyHash 20-byte public key hash of the source wallet.\\n /// @param walletMainUtxo Data of the source wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletMembersIDs Identifiers of the source wallet signing group\\n /// members.\\n /// @param walletMemberIndex Position of the caller in the source wallet\\n /// signing group members list.\\n /// @param targetWallets List of 20-byte public key hashes of the target\\n /// wallets that the source wallet commits to move the funds to.\\n /// @dev Requirements:\\n /// - The source wallet must be in the MovingFunds state,\\n /// - The source wallet must not have pending redemption requests,\\n /// - The source wallet must not have pending moved funds sweep requests,\\n /// - The source wallet must not have submitted its commitment already,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given source wallet in the ECDSA registry. Those IDs are\\n /// not directly stored in the contract for gas efficiency purposes\\n /// but they can be read from appropriate `DkgResultSubmitted`\\n /// and `DkgResultApproved` events,\\n /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],\\n /// - The caller must be the member of the source wallet signing group\\n /// at the position indicated by `walletMemberIndex` parameter,\\n /// - The `walletMainUtxo` components must point to the recent main\\n /// UTXO of the source wallet, as currently known on the Ethereum\\n /// chain,\\n /// - Source wallet BTC balance must be greater than zero,\\n /// - At least one Live wallet must exist in the system,\\n /// - Submitted target wallets count must match the expected count\\n /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`\\n /// where `N > 0`,\\n /// - Each target wallet must be not equal to the source wallet,\\n /// - Each target wallet must follow the expected order i.e. all\\n /// target wallets 20-byte public key hashes represented as numbers\\n /// must form a strictly increasing sequence without duplicates,\\n /// - Each target wallet must be in Live state.\\n function submitMovingFundsCommitment(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo,\\n uint32[] calldata walletMembersIDs,\\n uint256 walletMemberIndex,\\n bytes20[] calldata targetWallets\\n ) external {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.MovingFunds,\\n \\\"Source wallet must be in MovingFunds state\\\"\\n );\\n\\n require(\\n wallet.pendingRedemptionsValue == 0,\\n \\\"Source wallet must handle all pending redemptions first\\\"\\n );\\n\\n require(\\n wallet.pendingMovedFundsSweepRequestsCount == 0,\\n \\\"Source wallet must handle all pending moved funds sweep requests first\\\"\\n );\\n\\n require(\\n wallet.movingFundsTargetWalletsCommitmentHash == bytes32(0),\\n \\\"Target wallets commitment already submitted\\\"\\n );\\n\\n require(\\n self.ecdsaWalletRegistry.isWalletMember(\\n wallet.ecdsaWalletID,\\n walletMembersIDs,\\n msg.sender,\\n walletMemberIndex\\n ),\\n \\\"Caller is not a member of the source wallet\\\"\\n );\\n\\n uint64 walletBtcBalance = self.getWalletBtcBalance(\\n walletPubKeyHash,\\n walletMainUtxo\\n );\\n\\n require(walletBtcBalance > 0, \\\"Wallet BTC balance is zero\\\");\\n\\n uint256 expectedTargetWalletsCount = Math.min(\\n self.liveWalletsCount,\\n Math.ceilDiv(walletBtcBalance, self.walletMaxBtcTransfer)\\n );\\n\\n // This requirement fails only when `liveWalletsCount` is zero. In\\n // that case, the system cannot accept the commitment and must provide\\n // new wallets first. However, the wallet supposed to submit the\\n // commitment can keep resetting the moving funds timeout until then.\\n require(expectedTargetWalletsCount > 0, \\\"No target wallets available\\\");\\n\\n require(\\n targetWallets.length == expectedTargetWalletsCount,\\n \\\"Submitted target wallets count is other than expected\\\"\\n );\\n\\n uint160 lastProcessedTargetWallet = 0;\\n\\n for (uint256 i = 0; i < targetWallets.length; i++) {\\n bytes20 targetWallet = targetWallets[i];\\n\\n require(\\n targetWallet != walletPubKeyHash,\\n \\\"Submitted target wallet cannot be equal to the source wallet\\\"\\n );\\n\\n require(\\n uint160(targetWallet) > lastProcessedTargetWallet,\\n \\\"Submitted target wallet breaks the expected order\\\"\\n );\\n\\n require(\\n self.registeredWallets[targetWallet].state ==\\n Wallets.WalletState.Live,\\n \\\"Submitted target wallet must be in Live state\\\"\\n );\\n\\n lastProcessedTargetWallet = uint160(targetWallet);\\n }\\n\\n wallet.movingFundsTargetWalletsCommitmentHash = keccak256(\\n abi.encodePacked(targetWallets)\\n );\\n\\n emit MovingFundsCommitmentSubmitted(\\n walletPubKeyHash,\\n targetWallets,\\n msg.sender\\n );\\n }\\n\\n /// @notice Resets the moving funds timeout for the given wallet if the\\n /// target wallet commitment cannot be submitted due to a lack\\n /// of live wallets in the system.\\n /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The target wallets commitment must not be already submitted for\\n /// the given moving funds wallet,\\n /// - Live wallets count must be zero,\\n /// - The moving funds timeout reset delay must be elapsed.\\n function resetMovingFundsTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) external {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n // If the moving funds wallet already submitted their target wallets\\n // commitment, there is no point to reset the timeout since the\\n // wallet can make the BTC transaction and submit the proof.\\n require(\\n wallet.movingFundsTargetWalletsCommitmentHash == bytes32(0),\\n \\\"Target wallets commitment already submitted\\\"\\n );\\n\\n require(self.liveWalletsCount == 0, \\\"Live wallets count must be zero\\\");\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >\\n wallet.movingFundsRequestedAt +\\n self.movingFundsTimeoutResetDelay,\\n \\\"Moving funds timeout cannot be reset yet\\\"\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.movingFundsRequestedAt = uint32(block.timestamp);\\n\\n emit MovingFundsTimeoutReset(walletPubKeyHash);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moving funds transaction\\n /// and to make the necessary state changes. Moving funds is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the moving funds transaction structure\\n /// by checking if it actually spends the main UTXO of the declared\\n /// wallet and locks the value on the pre-committed target wallets\\n /// using a reasonable transaction fee. If all preconditions are\\n /// met, this functions closes the source wallet.\\n ///\\n /// It is possible to prove the given moving funds transaction only\\n /// one time.\\n /// @param movingFundsTx Bitcoin moving funds transaction data.\\n /// @param movingFundsProof Bitcoin moving funds proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet\\n /// which performed the moving funds transaction.\\n /// @dev Requirements:\\n /// - `movingFundsTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `movingFundsTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs corresponding to the\\n /// pre-committed target wallets. Outputs must be ordered in the\\n /// same way as their corresponding target wallets are ordered\\n /// within the target wallets commitment,\\n /// - `movingFundsProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input,\\n /// - The wallet that `walletPubKeyHash` points to must be in the\\n /// MovingFunds state,\\n /// - The target wallets commitment must be submitted by the wallet\\n /// that `walletPubKeyHash` points to,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movingFundsTxMaxTotalFee` governable parameter.\\n function submitMovingFundsProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata movingFundsTx,\\n BitcoinTx.Proof calldata movingFundsProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external {\\n // Wallet state is validated in `notifyWalletFundsMoved`.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 movingFundsTxHash = self.validateProof(\\n movingFundsTx,\\n movingFundsProof\\n );\\n\\n // Assert that main UTXO for passed wallet exists in storage.\\n bytes32 mainUtxoHash = self\\n .registeredWallets[walletPubKeyHash]\\n .mainUtxoHash;\\n require(mainUtxoHash != bytes32(0), \\\"No main UTXO for given wallet\\\");\\n\\n // Assert that passed main UTXO parameter is the same as in storage and\\n // can be used for further processing.\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n\\n // Process the moving funds transaction input. Specifically, check if\\n // it refers to the expected wallet's main UTXO.\\n OutboundTx.processWalletOutboundTxInput(\\n self,\\n movingFundsTx.inputVector,\\n mainUtxo\\n );\\n\\n (\\n bytes32 targetWalletsHash,\\n uint256 outputsTotalValue\\n ) = processMovingFundsTxOutputs(\\n self,\\n MovingFundsTxOutputsProcessingInfo(\\n movingFundsTxHash,\\n movingFundsTx.outputVector\\n )\\n );\\n\\n require(\\n mainUtxo.txOutputValue - outputsTotalValue <=\\n self.movingFundsTxMaxTotalFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n self.notifyWalletFundsMoved(walletPubKeyHash, targetWalletsHash);\\n // slither-disable-next-line reentrancy-events\\n emit MovingFundsCompleted(walletPubKeyHash, movingFundsTxHash);\\n }\\n\\n /// @notice Processes the moving funds Bitcoin transaction output vector\\n /// and extracts information required for further processing.\\n /// @param processInfo Processing info containing the moving funds tx\\n /// hash and output vector.\\n /// @return targetWalletsHash keccak256 hash over the list of actual\\n /// target wallets used in the transaction.\\n /// @return outputsTotalValue Sum of all outputs values.\\n /// @dev Requirements:\\n /// - The `movingFundsTxOutputVector` must be parseable, i.e. must\\n /// be validated by the caller as stated in their parameter doc,\\n /// - Each output must refer to a 20-byte public key hash,\\n /// - The total outputs value must be evenly divided over all outputs.\\n function processMovingFundsTxOutputs(\\n BridgeState.Storage storage self,\\n MovingFundsTxOutputsProcessingInfo memory processInfo\\n ) internal returns (bytes32 targetWalletsHash, uint256 outputsTotalValue) {\\n // Determining the total number of Bitcoin transaction outputs in\\n // the same way as for number of inputs. See `BitcoinTx.outputVector`\\n // docs for more details.\\n (\\n uint256 outputsCompactSizeUintLength,\\n uint256 outputsCount\\n ) = processInfo.movingFundsTxOutputVector.parseVarInt();\\n\\n // To determine the first output starting index, we must jump over\\n // the compactSize uint which prepends the output vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 outputStartingIndex = 1 + outputsCompactSizeUintLength;\\n\\n bytes20[] memory targetWallets = new bytes20[](outputsCount);\\n uint64[] memory outputsValues = new uint64[](outputsCount);\\n\\n // Outputs processing loop. Note that the `outputIndex` must be\\n // `uint32` to build proper `movedFundsSweepRequests` keys.\\n for (\\n uint32 outputIndex = 0;\\n outputIndex < outputsCount;\\n outputIndex++\\n ) {\\n uint256 outputLength = processInfo\\n .movingFundsTxOutputVector\\n .determineOutputLengthAt(outputStartingIndex);\\n\\n bytes memory output = processInfo.movingFundsTxOutputVector.slice(\\n outputStartingIndex,\\n outputLength\\n );\\n\\n bytes20 targetWalletPubKeyHash = self.extractPubKeyHash(output);\\n\\n // Add the wallet public key hash to the list that will be used\\n // to build the result list hash. There is no need to check if\\n // given output is a change here because the actual target wallet\\n // list must be exactly the same as the pre-committed target wallet\\n // list which is guaranteed to be valid.\\n targetWallets[outputIndex] = targetWalletPubKeyHash;\\n\\n // Extract the value from given output.\\n outputsValues[outputIndex] = output.extractValue();\\n outputsTotalValue += outputsValues[outputIndex];\\n\\n // Register a moved funds sweep request that must be handled\\n // by the target wallet. The target wallet must sweep the\\n // received funds with their own main UTXO in order to update\\n // their BTC balance. Worth noting there is no need to check\\n // if the sweep request already exists in the system because\\n // the moving funds wallet is moved to the Closing state after\\n // submitting the moving funds proof so there is no possibility\\n // to submit the proof again and register the sweep request twice.\\n self.movedFundsSweepRequests[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n processInfo.movingFundsTxHash,\\n outputIndex\\n )\\n )\\n )\\n ] = MovedFundsSweepRequest(\\n targetWalletPubKeyHash,\\n outputsValues[outputIndex],\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp),\\n MovedFundsSweepRequestState.Pending\\n );\\n // We added a new moved funds sweep request for the target wallet\\n // so we must increment their request counter.\\n self\\n .registeredWallets[targetWalletPubKeyHash]\\n .pendingMovedFundsSweepRequestsCount++;\\n\\n // Make the `outputStartingIndex` pointing to the next output by\\n // increasing it by current output's length.\\n outputStartingIndex += outputLength;\\n }\\n\\n // Compute the indivisible remainder that remains after dividing the\\n // outputs total value over all outputs evenly.\\n uint256 outputsTotalValueRemainder = outputsTotalValue % outputsCount;\\n // Compute the minimum allowed output value by dividing the outputs\\n // total value (reduced by the remainder) by the number of outputs.\\n uint256 minOutputValue = (outputsTotalValue -\\n outputsTotalValueRemainder) / outputsCount;\\n // Maximum possible value is the minimum value with the remainder included.\\n uint256 maxOutputValue = minOutputValue + outputsTotalValueRemainder;\\n\\n for (uint256 i = 0; i < outputsCount; i++) {\\n require(\\n minOutputValue <= outputsValues[i] &&\\n outputsValues[i] <= maxOutputValue,\\n \\\"Transaction amount is not distributed evenly\\\"\\n );\\n }\\n\\n targetWalletsHash = keccak256(abi.encodePacked(targetWallets));\\n\\n return (targetWalletsHash, outputsTotalValue);\\n }\\n\\n /// @notice Notifies about a timed out moving funds process. Terminates\\n /// the wallet and slashes signing group members as a result.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The moving funds timeout must be actually exceeded,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovingFundsTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n // Wallet state is validated in `notifyWalletMovingFundsTimeout`.\\n\\n uint32 movingFundsRequestedAt = self\\n .registeredWallets[walletPubKeyHash]\\n .movingFundsRequestedAt;\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp > movingFundsRequestedAt + self.movingFundsTimeout,\\n \\\"Moving funds has not timed out yet\\\"\\n );\\n\\n self.notifyWalletMovingFundsTimeout(walletPubKeyHash, walletMembersIDs);\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovingFundsTimedOut(walletPubKeyHash);\\n }\\n\\n /// @notice Notifies about a moving funds wallet whose BTC balance is\\n /// below the moving funds dust threshold. Ends the moving funds\\n /// process and begins wallet closing immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known\\n /// on the Ethereum chain.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If the wallet has no main UTXO, this parameter can be empty as it\\n /// is ignored,\\n /// - The wallet BTC balance must be below the moving funds threshold.\\n function notifyMovingFundsBelowDust(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external {\\n // Wallet state is validated in `notifyWalletMovingFundsBelowDust`.\\n\\n uint64 walletBtcBalance = self.getWalletBtcBalance(\\n walletPubKeyHash,\\n mainUtxo\\n );\\n\\n require(\\n walletBtcBalance < self.movingFundsDustThreshold,\\n \\\"Wallet BTC balance must be below the moving funds dust threshold\\\"\\n );\\n\\n self.notifyWalletMovingFundsBelowDust(walletPubKeyHash);\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovingFundsBelowDustReported(walletPubKeyHash);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moved funds sweep\\n /// transaction and to make the necessary state changes. Moved\\n /// funds sweep is only accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the sweep transaction structure by\\n /// checking if it actually spends the moved funds UTXO and the\\n /// sweeping wallet's main UTXO (optionally), and if it locks the\\n /// value on the sweeping wallet's 20-byte public key hash using a\\n /// reasonable transaction fee. If all preconditions are\\n /// met, this function updates the sweeping wallet main UTXO, thus\\n /// their BTC balance.\\n ///\\n /// It is possible to prove the given sweep transaction only\\n /// one time.\\n /// @param sweepTx Bitcoin sweep funds transaction data.\\n /// @param sweepProof Bitcoin sweep funds proof data.\\n /// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with\\n /// the first input pointing to a wallet's sweep Pending request and,\\n /// optionally, the second input pointing to the wallet's main UTXO,\\n /// if the sweeping wallet has a main UTXO set. There should be only\\n /// one output locking funds on the sweeping wallet 20-byte public\\n /// key hash,\\n /// - `sweepProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the sweeping wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored,\\n /// - The sweeping wallet must be in the Live or MovingFunds state,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movedFundsSweepTxMaxTotalFee` governable parameter.\\n function submitMovedFundsSweepProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external {\\n // Wallet state validation is performed in the\\n // `resolveMovedFundsSweepingWallet` function.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 sweepTxHash = self.validateProof(sweepTx, sweepProof);\\n\\n (\\n bytes20 walletPubKeyHash,\\n uint64 sweepTxOutputValue\\n ) = processMovedFundsSweepTxOutput(self, sweepTx.outputVector);\\n\\n (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n ) = resolveMovedFundsSweepingWallet(self, walletPubKeyHash, mainUtxo);\\n\\n uint256 sweepTxInputsTotalValue = processMovedFundsSweepTxInputs(\\n self,\\n sweepTx.inputVector,\\n resolvedMainUtxo,\\n walletPubKeyHash\\n );\\n\\n require(\\n sweepTxInputsTotalValue - sweepTxOutputValue <=\\n self.movedFundsSweepTxMaxTotalFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n // Use the sweep transaction output as the new sweeping wallet's main UTXO.\\n // Transaction output index is always 0 as sweep transaction always\\n // contains only one output.\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(sweepTxHash, uint32(0), sweepTxOutputValue)\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovedFundsSwept(walletPubKeyHash, sweepTxHash);\\n }\\n\\n /// @notice Processes the Bitcoin moved funds sweep transaction output vector\\n /// by extracting the single output and using it to gain additional\\n /// information required for further processing (e.g. value and\\n /// wallet public key hash).\\n /// @param sweepTxOutputVector Bitcoin moved funds sweep transaction output\\n /// vector.\\n /// This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVout` function before\\n /// it is passed here.\\n /// @return walletPubKeyHash 20-byte wallet public key hash.\\n /// @return value 8-byte moved funds sweep transaction output value.\\n /// @dev Requirements:\\n /// - Output vector must contain only one output,\\n /// - The single output must be of P2PKH or P2WPKH type and lock the\\n /// funds on a 20-byte public key hash.\\n function processMovedFundsSweepTxOutput(\\n BridgeState.Storage storage self,\\n bytes memory sweepTxOutputVector\\n ) internal view returns (bytes20 walletPubKeyHash, uint64 value) {\\n // To determine the total number of sweep transaction outputs, we need to\\n // parse the compactSize uint (VarInt) the output vector is prepended by.\\n // That compactSize uint encodes the number of vector elements using the\\n // format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVout` validation performed as\\n // part of the `BitcoinTx.validateProof` call.\\n // See `BitcoinTx.outputVector` docs for more details.\\n (, uint256 outputsCount) = sweepTxOutputVector.parseVarInt();\\n require(\\n outputsCount == 1,\\n \\\"Moved funds sweep transaction must have a single output\\\"\\n );\\n\\n bytes memory output = sweepTxOutputVector.extractOutputAtIndex(0);\\n walletPubKeyHash = self.extractPubKeyHash(output);\\n value = output.extractValue();\\n\\n return (walletPubKeyHash, value);\\n }\\n\\n /// @notice Resolves sweeping wallet based on the provided wallet public key\\n /// hash. Validates the wallet state and current main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletPubKeyHash public key hash of the wallet proving the sweep\\n /// Bitcoin transaction.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @return wallet Data of the sweeping wallet.\\n /// @return resolvedMainUtxo The actual main UTXO of the sweeping wallet\\n /// resolved by cross-checking the `mainUtxo` parameter with\\n /// the chain state. If the validation went well, this is the\\n /// plain-text main UTXO corresponding to the `wallet.mainUtxoHash`.\\n /// @dev Requirements:\\n /// - Sweeping wallet must be either in Live or MovingFunds state,\\n /// - If the main UTXO of the sweeping wallet exists in the storage,\\n /// the passed `mainUTXO` parameter must be equal to the stored one.\\n function resolveMovedFundsSweepingWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n )\\n internal\\n view\\n returns (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n )\\n {\\n wallet = self.registeredWallets[walletPubKeyHash];\\n\\n Wallets.WalletState walletState = wallet.state;\\n require(\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in Live or MovingFunds state\\\"\\n );\\n\\n // Check if the main UTXO for given wallet exists. If so, validate\\n // passed main UTXO data against the stored hash and use them for\\n // further processing. If no main UTXO exists, use empty data.\\n resolvedMainUtxo = BitcoinTx.UTXO(bytes32(0), 0, 0);\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n if (mainUtxoHash != bytes32(0)) {\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n resolvedMainUtxo = mainUtxo;\\n }\\n }\\n\\n /// @notice Processes the Bitcoin moved funds sweep transaction input vector.\\n /// It extracts the first input and tries to match it with one of\\n /// the moved funds sweep requests targeting the sweeping wallet.\\n /// If the sweep request is an existing Pending request, this\\n /// function marks it as Processed. If the sweeping wallet has a\\n /// main UTXO, this function extracts the second input, makes sure\\n /// it refers to the wallet main UTXO, and marks that main UTXO as\\n /// correctly spent.\\n /// @param sweepTxInputVector Bitcoin moved funds sweep transaction input vector.\\n /// This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVin` function before\\n /// it is passed here.\\n /// @param mainUtxo Data of the sweeping wallet's main UTXO. If no main UTXO\\n /// exists for the given the wallet, this parameter's fields should\\n /// be zeroed to bypass the main UTXO validation.\\n /// @param walletPubKeyHash 20-byte public key hash of the sweeping wallet.\\n /// @return inputsTotalValue Total inputs value sum.\\n /// @dev Requirements:\\n /// - The input vector must consist of one mandatory and one optional\\n /// input,\\n /// - The mandatory input must be the first input in the vector,\\n /// - The mandatory input must point to a Pending moved funds sweep\\n /// request that is targeted to the sweeping wallet,\\n /// - The optional output must be the second input in the vector,\\n /// - The optional input is required if the sweeping wallet has a\\n /// main UTXO (i.e. the `mainUtxo` is not zeroed). In that case,\\n /// that input must point the the sweeping wallet main UTXO.\\n function processMovedFundsSweepTxInputs(\\n BridgeState.Storage storage self,\\n bytes memory sweepTxInputVector,\\n BitcoinTx.UTXO memory mainUtxo,\\n bytes20 walletPubKeyHash\\n ) internal returns (uint256 inputsTotalValue) {\\n // To determine the total number of Bitcoin transaction inputs,\\n // we need to parse the compactSize uint (VarInt) the input vector is\\n // prepended by. That compactSize uint encodes the number of vector\\n // elements using the format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVin` validation performed as\\n // part of the `BitcoinTx.validateProof` call.\\n // See `BitcoinTx.inputVector` docs for more details.\\n (\\n uint256 inputsCompactSizeUintLength,\\n uint256 inputsCount\\n ) = sweepTxInputVector.parseVarInt();\\n\\n // To determine the first input starting index, we must jump over\\n // the compactSize uint which prepends the input vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 inputStartingIndex = 1 + inputsCompactSizeUintLength;\\n\\n // We always expect the first input to be the swept UTXO. Additionally,\\n // if the sweeping wallet has a main UTXO, that main UTXO should be\\n // pointed by the second input.\\n require(\\n inputsCount == (mainUtxo.txHash != bytes32(0) ? 2 : 1),\\n \\\"Moved funds sweep transaction must have a proper inputs count\\\"\\n );\\n\\n // Parse the first input and extract its outpoint tx hash and index.\\n (\\n bytes32 firstInputOutpointTxHash,\\n uint32 firstInputOutpointIndex,\\n uint256 firstInputLength\\n ) = parseMovedFundsSweepTxInputAt(\\n sweepTxInputVector,\\n inputStartingIndex\\n );\\n\\n // Build the request key and fetch the corresponding moved funds sweep\\n // request from contract storage.\\n MovedFundsSweepRequest storage sweepRequest = self\\n .movedFundsSweepRequests[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n firstInputOutpointTxHash,\\n firstInputOutpointIndex\\n )\\n )\\n )\\n ];\\n\\n require(\\n sweepRequest.state == MovedFundsSweepRequestState.Pending,\\n \\\"Sweep request must be in Pending state\\\"\\n );\\n // We must check if the wallet extracted from the moved funds sweep\\n // transaction output is truly the owner of the sweep request connected\\n // with the swept UTXO. This is needed to prevent a case when a wallet\\n // handles its own sweep request but locks the funds on another\\n // wallet public key hash.\\n require(\\n sweepRequest.walletPubKeyHash == walletPubKeyHash,\\n \\\"Sweep request belongs to another wallet\\\"\\n );\\n // If the validation passed, the sweep request must be marked as\\n // processed and its value should be counted into the total inputs\\n // value sum.\\n sweepRequest.state = MovedFundsSweepRequestState.Processed;\\n inputsTotalValue += sweepRequest.value;\\n\\n self\\n .registeredWallets[walletPubKeyHash]\\n .pendingMovedFundsSweepRequestsCount--;\\n\\n // If the main UTXO for the sweeping wallet exists, it must be processed.\\n if (mainUtxo.txHash != bytes32(0)) {\\n // The second input is supposed to point to that sweeping wallet\\n // main UTXO. We need to parse that input.\\n (\\n bytes32 secondInputOutpointTxHash,\\n uint32 secondInputOutpointIndex,\\n\\n ) = parseMovedFundsSweepTxInputAt(\\n sweepTxInputVector,\\n inputStartingIndex + firstInputLength\\n );\\n // Make sure the second input refers to the sweeping wallet main UTXO.\\n require(\\n mainUtxo.txHash == secondInputOutpointTxHash &&\\n mainUtxo.txOutputIndex == secondInputOutpointIndex,\\n \\\"Second input must point to the wallet's main UTXO\\\"\\n );\\n\\n // If the validation passed, count the main UTXO value into the\\n // total inputs value sum.\\n inputsTotalValue += mainUtxo.txOutputValue;\\n\\n // Main UTXO used as an input, mark it as spent. This is needed\\n // to defend against fraud challenges referring to this main UTXO.\\n self.spentMainUTXOs[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n secondInputOutpointTxHash,\\n secondInputOutpointIndex\\n )\\n )\\n )\\n ] = true;\\n }\\n\\n return inputsTotalValue;\\n }\\n\\n /// @notice Parses a Bitcoin transaction input starting at the given index.\\n /// @param inputVector Bitcoin transaction input vector.\\n /// @param inputStartingIndex Index the given input starts at.\\n /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is\\n /// pointed in the given input's outpoint.\\n /// @return outpointIndex 4-byte index of the Bitcoin transaction output\\n /// which is pointed in the given input's outpoint.\\n /// @return inputLength Byte length of the given input.\\n /// @dev This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVin` function before it\\n /// is passed here.\\n function parseMovedFundsSweepTxInputAt(\\n bytes memory inputVector,\\n uint256 inputStartingIndex\\n )\\n internal\\n pure\\n returns (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex,\\n uint256 inputLength\\n )\\n {\\n outpointTxHash = inputVector.extractInputTxIdLeAt(inputStartingIndex);\\n\\n outpointIndex = BTCUtils.reverseUint32(\\n uint32(inputVector.extractTxIndexLeAt(inputStartingIndex))\\n );\\n\\n inputLength = inputVector.determineInputLengthAt(inputStartingIndex);\\n\\n return (outpointTxHash, outpointIndex, inputLength);\\n }\\n\\n /// @notice Notifies about a timed out moved funds sweep process. If the\\n /// wallet is not terminated yet, that function terminates\\n /// the wallet and slashes signing group members as a result.\\n /// Marks the given sweep request as TimedOut.\\n /// @param movingFundsTxHash 32-byte hash of the moving funds transaction\\n /// that caused the sweep request to be created.\\n /// @param movingFundsTxOutputIndex Index of the moving funds transaction\\n /// output that is subject of the sweep request.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The moved funds sweep request must be in the Pending state,\\n /// - The moved funds sweep timeout must be actually exceeded,\\n /// - The wallet must be either in the Live or MovingFunds or\\n /// Terminated state,,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovedFundsSweepTimeout(\\n BridgeState.Storage storage self,\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n // Wallet state is validated in `notifyWalletMovedFundsSweepTimeout`.\\n\\n MovedFundsSweepRequest storage sweepRequest = self\\n .movedFundsSweepRequests[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n movingFundsTxHash,\\n movingFundsTxOutputIndex\\n )\\n )\\n )\\n ];\\n\\n require(\\n sweepRequest.state == MovedFundsSweepRequestState.Pending,\\n \\\"Sweep request must be in Pending state\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >\\n sweepRequest.createdAt + self.movedFundsSweepTimeout,\\n \\\"Sweep request has not timed out yet\\\"\\n );\\n\\n bytes20 walletPubKeyHash = sweepRequest.walletPubKeyHash;\\n\\n self.notifyWalletMovedFundsSweepTimeout(\\n walletPubKeyHash,\\n walletMembersIDs\\n );\\n\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n sweepRequest.state = MovedFundsSweepRequestState.TimedOut;\\n wallet.pendingMovedFundsSweepRequestsCount--;\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovedFundsSweepTimedOut(\\n walletPubKeyHash,\\n movingFundsTxHash,\\n movingFundsTxOutputIndex\\n );\\n }\\n}\\n\",\"keccak256\":\"0xce1afc1875d364e64cfa088558ee166a441e55ef6727f38002934654ac14b25d\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Redemption.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\nimport \\\"../bank/Bank.sol\\\";\\n\\n/// @notice Aggregates functions common to the redemption transaction proof\\n/// validation and to the moving funds transaction proof validation.\\nlibrary OutboundTx {\\n using BTCUtils for bytes;\\n\\n /// @notice Checks whether an outbound Bitcoin transaction performed from\\n /// the given wallet has an input vector that contains a single\\n /// input referring to the wallet's main UTXO. Marks that main UTXO\\n /// as correctly spent if the validation succeeds. Reverts otherwise.\\n /// There are two outbound transactions from a wallet possible: a\\n /// redemption transaction or a moving funds to another wallet\\n /// transaction.\\n /// @param walletOutboundTxInputVector Bitcoin outbound transaction's input\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVin` function\\n /// before it is passed here.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n function processWalletOutboundTxInput(\\n BridgeState.Storage storage self,\\n bytes memory walletOutboundTxInputVector,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) internal {\\n // Assert that the single outbound transaction input actually\\n // refers to the wallet's main UTXO.\\n (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex\\n ) = parseWalletOutboundTxInput(walletOutboundTxInputVector);\\n require(\\n mainUtxo.txHash == outpointTxHash &&\\n mainUtxo.txOutputIndex == outpointIndex,\\n \\\"Outbound transaction input must point to the wallet's main UTXO\\\"\\n );\\n\\n // Main UTXO used as an input, mark it as spent.\\n self.spentMainUTXOs[\\n uint256(\\n keccak256(\\n abi.encodePacked(mainUtxo.txHash, mainUtxo.txOutputIndex)\\n )\\n )\\n ] = true;\\n }\\n\\n /// @notice Parses the input vector of an outbound Bitcoin transaction\\n /// performed from the given wallet. It extracts the single input\\n /// then the transaction hash and output index from its outpoint.\\n /// There are two outbound transactions from a wallet possible: a\\n /// redemption transaction or a moving funds to another wallet\\n /// transaction.\\n /// @param walletOutboundTxInputVector Bitcoin outbound transaction input\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVin` function\\n /// before it is passed here.\\n /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is\\n /// pointed in the input's outpoint.\\n /// @return outpointIndex 4-byte index of the Bitcoin transaction output\\n /// which is pointed in the input's outpoint.\\n function parseWalletOutboundTxInput(\\n bytes memory walletOutboundTxInputVector\\n ) internal pure returns (bytes32 outpointTxHash, uint32 outpointIndex) {\\n // To determine the total number of Bitcoin transaction inputs,\\n // we need to parse the compactSize uint (VarInt) the input vector is\\n // prepended by. That compactSize uint encodes the number of vector\\n // elements using the format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVin` validation.\\n // See `BitcoinTx.inputVector` docs for more details.\\n (, uint256 inputsCount) = walletOutboundTxInputVector.parseVarInt();\\n require(\\n inputsCount == 1,\\n \\\"Outbound transaction must have a single input\\\"\\n );\\n\\n bytes memory input = walletOutboundTxInputVector.extractInputAtIndex(0);\\n\\n outpointTxHash = input.extractInputTxIdLE();\\n\\n outpointIndex = BTCUtils.reverseUint32(\\n uint32(input.extractTxIndexLE())\\n );\\n\\n // There is only one input in the transaction. Input has an outpoint\\n // field that is a reference to the transaction being spent (see\\n // `BitcoinTx` docs). The outpoint contains the hash of the transaction\\n // to spend (`outpointTxHash`) and the index of the specific output\\n // from that transaction (`outpointIndex`).\\n return (outpointTxHash, outpointIndex);\\n }\\n}\\n\\n/// @title Bridge redemption\\n/// @notice The library handles the logic for redeeming Bitcoin balances from\\n/// the Bridge.\\n/// @dev To initiate a redemption, a user with a Bank balance supplies\\n/// a Bitcoin address. Then, the system calculates the redemption fee, and\\n/// releases balance to the provided Bitcoin address. Just like in case of\\n/// sweeps of revealed deposits, redemption requests are processed in\\n/// batches and require SPV proof to be submitted to the Bridge.\\nlibrary Redemption {\\n using BridgeState for BridgeState.Storage;\\n using Wallets for BridgeState.Storage;\\n using BitcoinTx for BridgeState.Storage;\\n\\n using BTCUtils for bytes;\\n using BytesLib for bytes;\\n\\n /// @notice Represents a redemption request.\\n struct RedemptionRequest {\\n // ETH address of the redeemer who created the request.\\n address redeemer;\\n // Requested TBTC amount in satoshi.\\n uint64 requestedAmount;\\n // Treasury TBTC fee in satoshi at the moment of request creation.\\n uint64 treasuryFee;\\n // Transaction maximum BTC fee in satoshi at the moment of request\\n // creation.\\n uint64 txMaxFee;\\n // UNIX timestamp the request was created at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 requestedAt;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n /// @notice Represents an outcome of the redemption Bitcoin transaction\\n /// outputs processing.\\n struct RedemptionTxOutputsInfo {\\n // Sum of all outputs values i.e. all redemptions and change value,\\n // if present.\\n uint256 outputsTotalValue;\\n // Total TBTC value in satoshi that should be burned by the Bridge.\\n // It includes the total amount of all BTC redeemed in the transaction\\n // and the fee paid to BTC miners for the redemption transaction.\\n uint64 totalBurnableValue;\\n // Total TBTC value in satoshi that should be transferred to\\n // the treasury. It is a sum of all treasury fees paid by all\\n // redeemers included in the redemption transaction.\\n uint64 totalTreasuryFee;\\n // Index of the change output. The change output becomes\\n // the new main wallet's UTXO.\\n uint32 changeIndex;\\n // Value in satoshi of the change output.\\n uint64 changeValue;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n /// @notice Represents temporary information needed during the processing of\\n /// the redemption Bitcoin transaction outputs. This structure is an\\n /// internal one and should not be exported outside of the redemption\\n /// transaction processing code.\\n /// @dev Allows to mitigate \\\"stack too deep\\\" errors on EVM.\\n struct RedemptionTxOutputsProcessingInfo {\\n // The first output starting index in the transaction.\\n uint256 outputStartingIndex;\\n // The number of outputs in the transaction.\\n uint256 outputsCount;\\n // P2PKH script for the wallet. Needed to determine the change output.\\n bytes32 walletP2PKHScriptKeccak;\\n // P2WPKH script for the wallet. Needed to determine the change output.\\n bytes32 walletP2WPKHScriptKeccak;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n event RedemptionRequested(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript,\\n address indexed redeemer,\\n uint64 requestedAmount,\\n uint64 treasuryFee,\\n uint64 txMaxFee\\n );\\n\\n event RedemptionsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 redemptionTxHash\\n );\\n\\n event RedemptionTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript\\n );\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script.\\n /// This function handles the simplest case, where balance owner is\\n /// the redeemer.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed. Balance owner address is stored as\\n /// a redeemer address who will be able co claim back the Bank\\n /// balance if anything goes wrong during the redemption.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to proceed the request,\\n /// - Balance owner must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo,\\n address balanceOwner,\\n bytes calldata redeemerOutputScript,\\n uint64 amount\\n ) external {\\n requestRedemption(\\n self,\\n walletPubKeyHash,\\n mainUtxo,\\n balanceOwner,\\n balanceOwner,\\n redeemerOutputScript,\\n amount\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script. Used by\\n /// `Bridge.receiveBalanceApproval`. Can handle more complex cases\\n /// where balance owner may be someone else than the redeemer.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @param redemptionData ABI-encoded redemption data:\\n /// [\\n /// address redeemer,\\n /// bytes20 walletPubKeyHash,\\n /// bytes32 mainUtxoTxHash,\\n /// uint32 mainUtxoTxOutputIndex,\\n /// uint64 mainUtxoTxOutputValue,\\n /// bytes redeemerOutputScript\\n /// ]\\n ///\\n /// - redeemer: The Ethereum address of the redeemer who will be able\\n /// to claim Bank balance if anything goes wrong during the redemption.\\n /// In the most basic case, when someone redeems their Bitcoin\\n /// balance from the Bank, `balanceOwner` is the same as `redeemer`.\\n /// However, when a Vault is redeeming part of its balance for some\\n /// redeemer address (for example, someone who has earlier deposited\\n /// into that Vault), `balanceOwner` is the Vault, and `redeemer` is\\n /// the address for which the vault is redeeming its balance to,\\n /// - walletPubKeyHash: The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key),\\n /// - mainUtxoTxHash: Data of the wallet's main UTXO TX hash, as\\n /// currently known on the Ethereum chain,\\n /// - mainUtxoTxOutputIndex: Data of the wallet's main UTXO output\\n /// index, as currently known on Ethereum chain,\\n /// - mainUtxoTxOutputValue: Data of the wallet's main UTXO output\\n /// value, as currently known on Ethereum chain,\\n /// - redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo*` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to proceed the request,\\n /// - Balance owner must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n BridgeState.Storage storage self,\\n address balanceOwner,\\n uint64 amount,\\n bytes calldata redemptionData\\n ) external {\\n (\\n address redeemer,\\n bytes20 walletPubKeyHash,\\n bytes32 mainUtxoTxHash,\\n uint32 mainUtxoTxOutputIndex,\\n uint64 mainUtxoTxOutputValue,\\n bytes memory redeemerOutputScript\\n ) = abi.decode(\\n redemptionData,\\n (address, bytes20, bytes32, uint32, uint64, bytes)\\n );\\n\\n requestRedemption(\\n self,\\n walletPubKeyHash,\\n BitcoinTx.UTXO(\\n mainUtxoTxHash,\\n mainUtxoTxOutputIndex,\\n mainUtxoTxOutputValue\\n ),\\n balanceOwner,\\n redeemer,\\n redeemerOutputScript,\\n amount\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed.\\n /// @param redeemer The Ethereum address of the redeemer who will be able to\\n /// claim Bank balance if anything goes wrong during the redemption.\\n /// In the most basic case, when someone redeems their Bitcoin\\n /// balance from the Bank, `balanceOwner` is the same as `redeemer`.\\n /// However, when a Vault is redeeming part of its balance for some\\n /// redeemer address (for example, someone who has earlier deposited\\n /// into that Vault), `balanceOwner` is the Vault, and `redeemer` is\\n /// the address for which the vault is redeeming its balance to.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to proceed the request,\\n /// - Balance owner must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO memory mainUtxo,\\n address balanceOwner,\\n address redeemer,\\n bytes memory redeemerOutputScript,\\n uint64 amount\\n ) internal {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n require(\\n mainUtxoHash != bytes32(0),\\n \\\"No main UTXO for the given wallet\\\"\\n );\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n\\n // Validate if redeemer output script is a correct standard type\\n // (P2PKH, P2WPKH, P2SH or P2WSH). This is done by using\\n // `BTCUtils.extractHashAt` on it. Such a function extracts the payload\\n // properly only from standard outputs so if it succeeds, we have a\\n // guarantee the redeemer output script is proper. The underlying way\\n // of validation is the same as in tBTC v1.\\n bytes memory redeemerOutputScriptPayload = redeemerOutputScript\\n .extractHashAt(0, redeemerOutputScript.length);\\n\\n require(\\n redeemerOutputScriptPayload.length > 0,\\n \\\"Redeemer output script must be a standard type\\\"\\n );\\n // Check if the redeemer output script payload does not point to the\\n // wallet public key hash.\\n require(\\n redeemerOutputScriptPayload.length != 20 ||\\n walletPubKeyHash != redeemerOutputScriptPayload.slice20(0),\\n \\\"Redeemer output script must not point to the wallet PKH\\\"\\n );\\n\\n require(\\n amount >= self.redemptionDustThreshold,\\n \\\"Redemption amount too small\\\"\\n );\\n\\n // The redemption key is built on top of the wallet public key hash\\n // and redeemer output script pair. That means there can be only one\\n // request asking for redemption from the given wallet to the given\\n // BTC script at the same time.\\n uint256 redemptionKey = getRedemptionKey(\\n walletPubKeyHash,\\n redeemerOutputScript\\n );\\n\\n // Check if given redemption key is not used by a pending redemption.\\n // There is no need to check for existence in `timedOutRedemptions`\\n // since the wallet's state is changed to other than Live after\\n // first time out is reported so making new requests is not possible.\\n // slither-disable-next-line incorrect-equality\\n require(\\n self.pendingRedemptions[redemptionKey].requestedAt == 0,\\n \\\"There is a pending redemption request from this wallet to the same address\\\"\\n );\\n\\n // No need to check whether `amount - treasuryFee - txMaxFee > 0`\\n // since the `redemptionDustThreshold` should force that condition\\n // to be always true.\\n uint64 treasuryFee = self.redemptionTreasuryFeeDivisor > 0\\n ? amount / self.redemptionTreasuryFeeDivisor\\n : 0;\\n uint64 txMaxFee = self.redemptionTxMaxFee;\\n\\n // The main wallet UTXO's value doesn't include all pending redemptions.\\n // To determine if the requested redemption can be performed by the\\n // wallet we need to subtract the total value of all pending redemptions\\n // from that wallet's main UTXO value. Given that the treasury fee is\\n // not redeemed from the wallet, we are subtracting it.\\n wallet.pendingRedemptionsValue += amount - treasuryFee;\\n require(\\n mainUtxo.txOutputValue >= wallet.pendingRedemptionsValue,\\n \\\"Insufficient wallet funds\\\"\\n );\\n\\n self.pendingRedemptions[redemptionKey] = RedemptionRequest(\\n redeemer,\\n amount,\\n treasuryFee,\\n txMaxFee,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit RedemptionRequested(\\n walletPubKeyHash,\\n redeemerOutputScript,\\n redeemer,\\n amount,\\n treasuryFee,\\n txMaxFee\\n );\\n\\n self.bank.transferBalanceFrom(balanceOwner, address(this), amount);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC redemption transaction\\n /// and to make the necessary bookkeeping. Redemption is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by burning\\n /// the total redeemed Bitcoin amount from Bridge balance and\\n /// transferring the treasury fee sum to the treasury address.\\n ///\\n /// It is possible to prove the given redemption only one time.\\n /// @param redemptionTx Bitcoin redemption transaction data.\\n /// @param redemptionProof Bitcoin redemption proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @dev Requirements:\\n /// - `redemptionTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `redemptionTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs handling existing pending\\n /// redemption requests or pointing to reported timed out requests.\\n /// There can be also 1 optional output representing the\\n /// change and pointing back to the 20-byte wallet public key hash.\\n /// The change should be always present if the redeemed value sum\\n /// is lower than the total wallet's BTC balance,\\n /// - `redemptionProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input.\\n /// Other remarks:\\n /// - Putting the change output as the first transaction output can\\n /// save some gas because the output processing loop begins each\\n /// iteration by checking whether the given output is the change\\n /// thus uses some gas for making the comparison. Once the change\\n /// is identified, that check is omitted in further iterations.\\n function submitRedemptionProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata redemptionTx,\\n BitcoinTx.Proof calldata redemptionProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external {\\n // Wallet state validation is performed in the `resolveRedeemingWallet`\\n // function.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 redemptionTxHash = self.validateProof(\\n redemptionTx,\\n redemptionProof\\n );\\n\\n Wallets.Wallet storage wallet = resolveRedeemingWallet(\\n self,\\n walletPubKeyHash,\\n mainUtxo\\n );\\n\\n // Process the redemption transaction input. Specifically, check if it\\n // refers to the expected wallet's main UTXO.\\n OutboundTx.processWalletOutboundTxInput(\\n self,\\n redemptionTx.inputVector,\\n mainUtxo\\n );\\n\\n // Process redemption transaction outputs to extract some info required\\n // for further processing.\\n RedemptionTxOutputsInfo memory outputsInfo = processRedemptionTxOutputs(\\n self,\\n redemptionTx.outputVector,\\n walletPubKeyHash\\n );\\n\\n require(\\n mainUtxo.txOutputValue - outputsInfo.outputsTotalValue <=\\n self.redemptionTxMaxTotalFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n if (outputsInfo.changeValue > 0) {\\n // If the change value is grater than zero, it means the change\\n // output exists and can be used as new wallet's main UTXO.\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(\\n redemptionTxHash,\\n outputsInfo.changeIndex,\\n outputsInfo.changeValue\\n )\\n );\\n } else {\\n // If the change value is zero, it means the change output doesn't\\n // exists and no funds left on the wallet. Delete the main UTXO\\n // for that wallet to represent that state in a proper way.\\n delete wallet.mainUtxoHash;\\n }\\n\\n wallet.pendingRedemptionsValue -= outputsInfo.totalBurnableValue;\\n\\n emit RedemptionsCompleted(walletPubKeyHash, redemptionTxHash);\\n\\n self.bank.decreaseBalance(outputsInfo.totalBurnableValue);\\n\\n if (outputsInfo.totalTreasuryFee > 0) {\\n self.bank.transferBalance(\\n self.treasury,\\n outputsInfo.totalTreasuryFee\\n );\\n }\\n }\\n\\n /// @notice Resolves redeeming wallet based on the provided wallet public\\n /// key hash. Validates the wallet state and current main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletPubKeyHash public key hash of the wallet proving the sweep\\n /// Bitcoin transaction.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @return wallet Data of the sweeping wallet.\\n /// @dev Requirements:\\n /// - Sweeping wallet must be either in Live or MovingFunds state,\\n /// - Main UTXO of the redeeming wallet must exists in the storage,\\n /// - The passed `mainUTXO` parameter must be equal to the stored one.\\n function resolveRedeemingWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) internal view returns (Wallets.Wallet storage wallet) {\\n wallet = self.registeredWallets[walletPubKeyHash];\\n\\n // Assert that main UTXO for passed wallet exists in storage.\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n require(mainUtxoHash != bytes32(0), \\\"No main UTXO for given wallet\\\");\\n\\n // Assert that passed main UTXO parameter is the same as in storage and\\n // can be used for further processing.\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n\\n Wallets.WalletState walletState = wallet.state;\\n require(\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in Live or MovingFunds state\\\"\\n );\\n }\\n\\n /// @notice Processes the Bitcoin redemption transaction output vector.\\n /// It extracts each output and tries to identify it as a pending\\n /// redemption request, reported timed out request, or change.\\n /// Reverts if one of the outputs cannot be recognized properly.\\n /// This function also marks each request as processed by removing\\n /// them from `pendingRedemptions` mapping.\\n /// @param redemptionTxOutputVector Bitcoin redemption transaction output\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVout` function\\n /// before it is passed here.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @return info Outcomes of the processing.\\n function processRedemptionTxOutputs(\\n BridgeState.Storage storage self,\\n bytes memory redemptionTxOutputVector,\\n bytes20 walletPubKeyHash\\n ) internal returns (RedemptionTxOutputsInfo memory info) {\\n // Determining the total number of redemption transaction outputs in\\n // the same way as for number of inputs. See `BitcoinTx.outputVector`\\n // docs for more details.\\n (\\n uint256 outputsCompactSizeUintLength,\\n uint256 outputsCount\\n ) = redemptionTxOutputVector.parseVarInt();\\n\\n // To determine the first output starting index, we must jump over\\n // the compactSize uint which prepends the output vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 outputStartingIndex = 1 + outputsCompactSizeUintLength;\\n\\n // Calculate the keccak256 for two possible wallet's P2PKH or P2WPKH\\n // scripts that can be used to lock the change. This is done upfront to\\n // save on gas. Both scripts have a strict format defined by Bitcoin.\\n //\\n // The P2PKH script has the byte format: <0x1976a914> <20-byte PKH> <0x88ac>.\\n // According to https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n // - 0x19: Byte length of the entire script\\n // - 0x76: OP_DUP\\n // - 0xa9: OP_HASH160\\n // - 0x14: Byte length of the public key hash\\n // - 0x88: OP_EQUALVERIFY\\n // - 0xac: OP_CHECKSIG\\n // which matches the P2PKH structure as per:\\n // https://en.bitcoin.it/wiki/Transaction#Pay-to-PubkeyHash\\n bytes32 walletP2PKHScriptKeccak = keccak256(\\n abi.encodePacked(BitcoinTx.makeP2PKHScript(walletPubKeyHash))\\n );\\n // The P2WPKH script has the byte format: <0x160014> <20-byte PKH>.\\n // According to https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n // - 0x16: Byte length of the entire script\\n // - 0x00: OP_0\\n // - 0x14: Byte length of the public key hash\\n // which matches the P2WPKH structure as per:\\n // https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH\\n bytes32 walletP2WPKHScriptKeccak = keccak256(\\n abi.encodePacked(BitcoinTx.makeP2WPKHScript(walletPubKeyHash))\\n );\\n\\n return\\n processRedemptionTxOutputs(\\n self,\\n redemptionTxOutputVector,\\n walletPubKeyHash,\\n RedemptionTxOutputsProcessingInfo(\\n outputStartingIndex,\\n outputsCount,\\n walletP2PKHScriptKeccak,\\n walletP2WPKHScriptKeccak\\n )\\n );\\n }\\n\\n /// @notice Processes all outputs from the redemption transaction. Tries to\\n /// identify output as a change output, pending redemption request\\n /// or reported redemption. Reverts if one of the outputs cannot be\\n /// recognized properly. Marks each request as processed by removing\\n /// them from `pendingRedemptions` mapping.\\n /// @param redemptionTxOutputVector Bitcoin redemption transaction output\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVout` function\\n /// before it is passed here.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @param processInfo RedemptionTxOutputsProcessingInfo identifying output\\n /// starting index, the number of outputs and possible wallet change\\n /// P2PKH and P2WPKH scripts.\\n function processRedemptionTxOutputs(\\n BridgeState.Storage storage self,\\n bytes memory redemptionTxOutputVector,\\n bytes20 walletPubKeyHash,\\n RedemptionTxOutputsProcessingInfo memory processInfo\\n ) internal returns (RedemptionTxOutputsInfo memory resultInfo) {\\n // Helper flag indicating whether there was at least one redemption\\n // output present (redemption must be either pending or reported as\\n // timed out).\\n bool redemptionPresent = false;\\n\\n // Outputs processing loop.\\n for (uint256 i = 0; i < processInfo.outputsCount; i++) {\\n uint256 outputLength = redemptionTxOutputVector\\n .determineOutputLengthAt(processInfo.outputStartingIndex);\\n\\n // Extract the value from given output.\\n uint64 outputValue = redemptionTxOutputVector.extractValueAt(\\n processInfo.outputStartingIndex\\n );\\n\\n // The output consists of an 8-byte value and a variable length\\n // script. To hash that script we slice the output starting from\\n // 9th byte until the end.\\n uint256 scriptLength = outputLength - 8;\\n uint256 outputScriptStart = processInfo.outputStartingIndex + 8;\\n\\n bytes32 outputScriptHash;\\n /* solhint-disable-next-line no-inline-assembly */\\n assembly {\\n // The first argument to assembly keccak256 is the pointer.\\n // We point to `redemptionTxOutputVector` but at the position\\n // indicated by `outputScriptStart`. To load that position, we\\n // need to call `add(outputScriptStart, 32)` because\\n // `outputScriptStart` has 32 bytes.\\n outputScriptHash := keccak256(\\n add(redemptionTxOutputVector, add(outputScriptStart, 32)),\\n scriptLength\\n )\\n }\\n\\n if (\\n resultInfo.changeValue == 0 &&\\n (outputScriptHash == processInfo.walletP2PKHScriptKeccak ||\\n outputScriptHash == processInfo.walletP2WPKHScriptKeccak) &&\\n outputValue > 0\\n ) {\\n // If we entered here, that means the change output with a\\n // proper non-zero value was found.\\n resultInfo.changeIndex = uint32(i);\\n resultInfo.changeValue = outputValue;\\n } else {\\n // If we entered here, that the means the given output is\\n // supposed to represent a redemption.\\n (\\n uint64 burnableValue,\\n uint64 treasuryFee\\n ) = processNonChangeRedemptionTxOutput(\\n self,\\n _getRedemptionKey(walletPubKeyHash, outputScriptHash),\\n outputValue\\n );\\n resultInfo.totalBurnableValue += burnableValue;\\n resultInfo.totalTreasuryFee += treasuryFee;\\n redemptionPresent = true;\\n }\\n\\n resultInfo.outputsTotalValue += outputValue;\\n\\n // Make the `outputStartingIndex` pointing to the next output by\\n // increasing it by current output's length.\\n processInfo.outputStartingIndex += outputLength;\\n }\\n\\n // Protect against the cases when there is only a single change output\\n // referring back to the wallet PKH and just burning main UTXO value\\n // for transaction fees.\\n require(\\n redemptionPresent,\\n \\\"Redemption transaction must process at least one redemption\\\"\\n );\\n }\\n\\n /// @notice Processes a single redemption transaction output. Tries to\\n /// identify output as a pending redemption request or reported\\n /// redemption timeout. Output script passed to this function must\\n /// not be the change output. Such output needs to be identified\\n /// separately before calling this function.\\n /// Reverts if output is neither requested pending redemption nor\\n /// requested and reported timed-out redemption.\\n /// This function also marks each pending request as processed by\\n /// removing them from `pendingRedemptions` mapping.\\n /// @param redemptionKey Redemption key of the output being processed.\\n /// @param outputValue Value of the output being processed.\\n /// @return burnableValue The value burnable as a result of processing this\\n /// single redemption output. This value needs to be summed up with\\n /// burnable values of all other outputs to evaluate total burnable\\n /// value for the entire redemption transaction. This value is 0\\n /// for a timed-out redemption request.\\n /// @return treasuryFee The treasury fee from this single redemption output.\\n /// This value needs to be summed up with treasury fees of all other\\n /// outputs to evaluate the total treasury fee for the entire\\n /// redemption transaction. This value is 0 for a timed-out\\n /// redemption request.\\n /// @dev Requirements:\\n /// - This function should be called only if the given output\\n /// represents redemption. It must not be the change output.\\n function processNonChangeRedemptionTxOutput(\\n BridgeState.Storage storage self,\\n uint256 redemptionKey,\\n uint64 outputValue\\n ) internal returns (uint64 burnableValue, uint64 treasuryFee) {\\n if (self.pendingRedemptions[redemptionKey].requestedAt != 0) {\\n // If we entered here, that means the output was identified\\n // as a pending redemption request.\\n RedemptionRequest storage request = self.pendingRedemptions[\\n redemptionKey\\n ];\\n // Compute the request's redeemable amount as the requested\\n // amount reduced by the treasury fee. The request's\\n // minimal amount is then the redeemable amount reduced by\\n // the maximum transaction fee.\\n uint64 redeemableAmount = request.requestedAmount -\\n request.treasuryFee;\\n // Output value must fit between the request's redeemable\\n // and minimal amounts to be deemed valid.\\n require(\\n redeemableAmount - request.txMaxFee <= outputValue &&\\n outputValue <= redeemableAmount,\\n \\\"Output value is not within the acceptable range of the pending request\\\"\\n );\\n // Add the redeemable amount to the total burnable value\\n // the Bridge will use to decrease its balance in the Bank.\\n burnableValue = redeemableAmount;\\n // Add the request's treasury fee to the total treasury fee\\n // value the Bridge will transfer to the treasury.\\n treasuryFee = request.treasuryFee;\\n // Request was properly handled so remove its redemption\\n // key from the mapping to make it reusable for further\\n // requests.\\n delete self.pendingRedemptions[redemptionKey];\\n } else {\\n // If we entered here, the output is not a redemption\\n // request but there is still a chance the given output is\\n // related to a reported timed out redemption request.\\n // If so, check if the output value matches the request\\n // amount to confirm this is an overdue request fulfillment\\n // then bypass this output and process the subsequent\\n // ones. That also means the wallet was already punished\\n // for the inactivity. Otherwise, just revert.\\n RedemptionRequest storage request = self.timedOutRedemptions[\\n redemptionKey\\n ];\\n\\n require(\\n request.requestedAt != 0,\\n \\\"Output is a non-requested redemption\\\"\\n );\\n\\n uint64 redeemableAmount = request.requestedAmount -\\n request.treasuryFee;\\n\\n require(\\n redeemableAmount - request.txMaxFee <= outputValue &&\\n outputValue <= redeemableAmount,\\n \\\"Output value is not within the acceptable range of the timed out request\\\"\\n );\\n\\n delete self.timedOutRedemptions[redemptionKey];\\n }\\n }\\n\\n /// @notice Notifies that there is a pending redemption request associated\\n /// with the given wallet, that has timed out. The redemption\\n /// request is identified by the key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The results of calling this function:\\n /// - the pending redemptions value for the wallet will be decreased\\n /// by the requested amount (minus treasury fee),\\n /// - the tokens taken from the redeemer on redemption request will\\n /// be returned to the redeemer,\\n /// - the request will be moved from pending redemptions to\\n /// timed-out redemptions,\\n /// - if the state of the wallet is `Live` or `MovingFunds`, the\\n /// wallet operators will be slashed and the notifier will be\\n /// rewarded,\\n /// - if the state of wallet is `Live`, the wallet will be closed or\\n /// marked as `MovingFunds` (depending on the presence or absence\\n /// of the wallet's main UTXO) and the wallet will no longer be\\n /// marked as the active wallet (if it was marked as such).\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH).\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Terminated state,\\n /// - The redemption request identified by `walletPubKeyHash` and\\n /// `redeemerOutputScript` must exist,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time defined by `redemptionTimeout` must have\\n /// passed since the redemption was requested (the request must be\\n /// timed-out).\\n function notifyRedemptionTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs,\\n bytes calldata redeemerOutputScript\\n ) external {\\n // Wallet state is validated in `notifyWalletRedemptionTimeout`.\\n uint256 redemptionKey = getRedemptionKey(\\n walletPubKeyHash,\\n redeemerOutputScript\\n );\\n Redemption.RedemptionRequest memory request = self.pendingRedemptions[\\n redemptionKey\\n ];\\n\\n require(request.requestedAt > 0, \\\"Redemption request does not exist\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n request.requestedAt + self.redemptionTimeout < block.timestamp,\\n \\\"Redemption request has not timed out\\\"\\n );\\n\\n // Update the wallet's pending redemptions value\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n wallet.pendingRedemptionsValue -=\\n request.requestedAmount -\\n request.treasuryFee;\\n\\n // It is worth noting that there is no need to check if\\n // `timedOutRedemption` mapping already contains the given redemption\\n // key. There is no possibility to re-use a key of a reported timed-out\\n // redemption because the wallet responsible for causing the timeout is\\n // moved to a state that prevents it to receive new redemption requests.\\n\\n // Propagate timeout consequences to the wallet\\n self.notifyWalletRedemptionTimeout(walletPubKeyHash, walletMembersIDs);\\n\\n // Move the redemption from pending redemptions to timed-out redemptions\\n self.timedOutRedemptions[redemptionKey] = request;\\n delete self.pendingRedemptions[redemptionKey];\\n\\n // slither-disable-next-line reentrancy-events\\n emit RedemptionTimedOut(walletPubKeyHash, redeemerOutputScript);\\n\\n // Return the requested amount of tokens to the redeemer\\n self.bank.transferBalance(request.redeemer, request.requestedAmount);\\n }\\n\\n /// @notice Calculate redemption key without allocations.\\n /// @param walletPubKeyHash the pubkey hash of the wallet.\\n /// @param script the output script of the redemption.\\n /// @return The key = keccak256(keccak256(script) | walletPubKeyHash).\\n function getRedemptionKey(bytes20 walletPubKeyHash, bytes memory script)\\n internal\\n pure\\n returns (uint256)\\n {\\n bytes32 scriptHash = keccak256(script);\\n uint256 key;\\n /* solhint-disable-next-line no-inline-assembly */\\n assembly {\\n mstore(0, scriptHash)\\n mstore(32, walletPubKeyHash)\\n key := keccak256(0, 52)\\n }\\n return key;\\n }\\n\\n /// @notice Finish calculating redemption key without allocations.\\n /// @param walletPubKeyHash the pubkey hash of the wallet.\\n /// @param scriptHash the output script hash of the redemption.\\n /// @return The key = keccak256(scriptHash | walletPubKeyHash).\\n function _getRedemptionKey(bytes20 walletPubKeyHash, bytes32 scriptHash)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 key;\\n /* solhint-disable-next-line no-inline-assembly */\\n assembly {\\n mstore(0, scriptHash)\\n mstore(32, walletPubKeyHash)\\n key := keccak256(0, 52)\\n }\\n return key;\\n }\\n}\\n\",\"keccak256\":\"0x341e2636230764f1bcc75948adedd4c8b38e34a87bb9094b251f9b0870922e93\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Wallets.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {EcdsaDkg} from \\\"@keep-network/ecdsa/contracts/libraries/EcdsaDkg.sol\\\";\\nimport {Math} from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./EcdsaLib.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\n\\n/// @title Wallet library\\n/// @notice Library responsible for handling integration between Bridge\\n/// contract and ECDSA wallets.\\nlibrary Wallets {\\n using BTCUtils for bytes;\\n\\n /// @notice Represents wallet state:\\n enum WalletState {\\n /// @dev The wallet is unknown to the Bridge.\\n Unknown,\\n /// @dev The wallet can sweep deposits and accept redemption requests.\\n Live,\\n /// @dev The wallet was deemed unhealthy and is expected to move their\\n /// outstanding funds to another wallet. The wallet can still\\n /// fulfill their pending redemption requests although new\\n /// redemption requests and new deposit reveals are not accepted.\\n MovingFunds,\\n /// @dev The wallet moved or redeemed all their funds and is in the\\n /// closing period where it is still a subject of fraud challenges\\n /// and must defend against them. This state is needed to protect\\n /// against deposit frauds on deposits revealed but not swept.\\n /// The closing period must be greater that the deposit refund\\n /// time plus some time margin.\\n Closing,\\n /// @dev The wallet finalized the closing period successfully and\\n /// can no longer perform any action in the Bridge.\\n Closed,\\n /// @dev The wallet committed a fraud that was reported, did not move\\n /// funds to another wallet before a timeout, or did not sweep\\n /// funds moved to if from another wallet before a timeout. The\\n /// wallet is blocked and can not perform any actions in the Bridge.\\n /// Off-chain coordination with the wallet operators is needed to\\n /// recover funds.\\n Terminated\\n }\\n\\n /// @notice Holds information about a wallet.\\n struct Wallet {\\n // Identifier of a ECDSA Wallet registered in the ECDSA Wallet Registry.\\n bytes32 ecdsaWalletID;\\n // Latest wallet's main UTXO hash computed as\\n // keccak256(txHash | txOutputIndex | txOutputValue). The `tx` prefix\\n // refers to the transaction which created that main UTXO. The `txHash`\\n // is `bytes32` (ordered as in Bitcoin internally), `txOutputIndex`\\n // an `uint32`, and `txOutputValue` an `uint64` value.\\n bytes32 mainUtxoHash;\\n // The total redeemable value of pending redemption requests targeting\\n // that wallet.\\n uint64 pendingRedemptionsValue;\\n // UNIX timestamp the wallet was created at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 createdAt;\\n // UNIX timestamp indicating the moment the wallet was requested to\\n // move their funds.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 movingFundsRequestedAt;\\n // UNIX timestamp indicating the moment the wallet's closing period\\n // started.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 closingStartedAt;\\n // Total count of pending moved funds sweep requests targeting this wallet.\\n uint32 pendingMovedFundsSweepRequestsCount;\\n // Current state of the wallet.\\n WalletState state;\\n // Moving funds target wallet commitment submitted by the wallet. It\\n // is built by applying the keccak256 hash over the list of 20-byte\\n // public key hashes of the target wallets.\\n bytes32 movingFundsTargetWalletsCommitmentHash;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event NewWalletRequested();\\n\\n event NewWalletRegistered(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletMovingFunds(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosing(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosed(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletTerminated(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n /// @notice Requests creation of a new wallet. This function just\\n /// forms a request and the creation process is performed\\n /// asynchronously. Outcome of that process should be delivered\\n /// using `registerNewWallet` function.\\n /// @param activeWalletMainUtxo Data of the active wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `activeWalletMainUtxo` components must point to the recent main\\n /// UTXO of the given active wallet, as currently known on the\\n /// Ethereum chain. If there is no active wallet at the moment, or\\n /// the active wallet has no main UTXO, this parameter can be\\n /// empty as it is ignored,\\n /// - Wallet creation must not be in progress,\\n /// - If the active wallet is set, one of the following\\n /// conditions must be true:\\n /// - The active wallet BTC balance is above the minimum threshold\\n /// and the active wallet is old enough, i.e. the creation period\\n /// was elapsed since its creation time,\\n /// - The active wallet BTC balance is above the maximum threshold.\\n function requestNewWallet(\\n BridgeState.Storage storage self,\\n BitcoinTx.UTXO calldata activeWalletMainUtxo\\n ) external {\\n require(\\n self.ecdsaWalletRegistry.getWalletCreationState() ==\\n EcdsaDkg.State.IDLE,\\n \\\"Wallet creation already in progress\\\"\\n );\\n\\n bytes20 activeWalletPubKeyHash = self.activeWalletPubKeyHash;\\n\\n // If the active wallet is set, fetch this wallet's details from\\n // storage to perform conditions check. The `registerNewWallet`\\n // function guarantees an active wallet is always one of the\\n // registered ones.\\n if (activeWalletPubKeyHash != bytes20(0)) {\\n uint64 activeWalletBtcBalance = getWalletBtcBalance(\\n self,\\n activeWalletPubKeyHash,\\n activeWalletMainUtxo\\n );\\n uint32 activeWalletCreatedAt = self\\n .registeredWallets[activeWalletPubKeyHash]\\n .createdAt;\\n /* solhint-disable-next-line not-rely-on-time */\\n bool activeWalletOldEnough = block.timestamp >=\\n activeWalletCreatedAt + self.walletCreationPeriod;\\n\\n require(\\n (activeWalletOldEnough &&\\n activeWalletBtcBalance >=\\n self.walletCreationMinBtcBalance) ||\\n activeWalletBtcBalance >= self.walletCreationMaxBtcBalance,\\n \\\"Wallet creation conditions are not met\\\"\\n );\\n }\\n\\n emit NewWalletRequested();\\n\\n self.ecdsaWalletRegistry.requestNewWallet();\\n }\\n\\n /// @notice Registers a new wallet. This function should be called\\n /// after the wallet creation process initiated using\\n /// `requestNewWallet` completes and brings the outcomes.\\n /// @param ecdsaWalletID Wallet's unique identifier.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Given wallet data must not belong to an already registered wallet.\\n function registerNewWallet(\\n BridgeState.Storage storage self,\\n bytes32 ecdsaWalletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external {\\n require(\\n msg.sender == address(self.ecdsaWalletRegistry),\\n \\\"Caller is not the ECDSA Wallet Registry\\\"\\n );\\n\\n // Compress wallet's public key and calculate Bitcoin's hash160 of it.\\n bytes20 walletPubKeyHash = bytes20(\\n EcdsaLib.compressPublicKey(publicKeyX, publicKeyY).hash160View()\\n );\\n\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n require(\\n wallet.state == WalletState.Unknown,\\n \\\"ECDSA wallet has been already registered\\\"\\n );\\n wallet.ecdsaWalletID = ecdsaWalletID;\\n wallet.state = WalletState.Live;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.createdAt = uint32(block.timestamp);\\n\\n // Set the freshly created wallet as the new active wallet.\\n self.activeWalletPubKeyHash = walletPubKeyHash;\\n\\n self.liveWalletsCount++;\\n\\n emit NewWalletRegistered(ecdsaWalletID, walletPubKeyHash);\\n }\\n\\n /// @notice Handles a notification about a wallet redemption timeout.\\n /// Triggers the wallet moving funds process only if the wallet is\\n /// still in the Live state. That means multiple action timeouts can\\n /// be reported for the same wallet but only the first report\\n /// requests the wallet to move their funds. Executes slashing if\\n /// the wallet is in Live or MovingFunds state. Allows to notify\\n /// redemption timeout also for a Terminated wallet in case the\\n /// redemption was requested before the wallet got terminated.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the `Live`, `MovingFunds`,\\n /// or `Terminated` state.\\n function notifyWalletRedemptionTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n WalletState walletState = wallet.state;\\n\\n require(\\n walletState == WalletState.Live ||\\n walletState == WalletState.MovingFunds ||\\n walletState == WalletState.Terminated,\\n \\\"Wallet must be in Live or MovingFunds or Terminated state\\\"\\n );\\n\\n if (\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds\\n ) {\\n // Slash the wallet operators and reward the notifier\\n self.ecdsaWalletRegistry.seize(\\n self.redemptionTimeoutSlashingAmount,\\n self.redemptionTimeoutNotifierRewardMultiplier,\\n msg.sender,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n }\\n\\n if (walletState == WalletState.Live) {\\n moveFunds(self, walletPubKeyHash);\\n }\\n }\\n\\n /// @notice Handles a notification about a wallet heartbeat failure and\\n /// triggers the wallet moving funds process.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Wallet must be in Live state.\\n function notifyWalletHeartbeatFailed(\\n BridgeState.Storage storage self,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external {\\n require(\\n msg.sender == address(self.ecdsaWalletRegistry),\\n \\\"Caller is not the ECDSA Wallet Registry\\\"\\n );\\n\\n // Compress wallet's public key and calculate Bitcoin's hash160 of it.\\n bytes20 walletPubKeyHash = bytes20(\\n EcdsaLib.compressPublicKey(publicKeyX, publicKeyY).hash160View()\\n );\\n\\n require(\\n self.registeredWallets[walletPubKeyHash].state == WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n moveFunds(self, walletPubKeyHash);\\n }\\n\\n /// @notice Notifies that the wallet is either old enough or has too few\\n /// satoshis left and qualifies to be closed.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMainUtxo Data of the wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - Wallet must not be set as the current active wallet,\\n /// - Wallet must exceed the wallet maximum age OR the wallet BTC\\n /// balance must be lesser than the minimum threshold. If the latter\\n /// case is true, the `walletMainUtxo` components must point to the\\n /// recent main UTXO of the given wallet, as currently known on the\\n /// Ethereum chain. If the wallet has no main UTXO, this parameter\\n /// can be empty as it is ignored since the wallet balance is\\n /// assumed to be zero,\\n /// - Wallet must be in Live state.\\n function notifyWalletCloseable(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) external {\\n require(\\n self.activeWalletPubKeyHash != walletPubKeyHash,\\n \\\"Active wallet cannot be considered closeable\\\"\\n );\\n\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n require(\\n wallet.state == WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n bool walletOldEnough = block.timestamp >=\\n wallet.createdAt + self.walletMaxAge;\\n\\n require(\\n walletOldEnough ||\\n getWalletBtcBalance(self, walletPubKeyHash, walletMainUtxo) <\\n self.walletClosureMinBtcBalance,\\n \\\"Wallet needs to be old enough or have too few satoshis\\\"\\n );\\n\\n moveFunds(self, walletPubKeyHash);\\n }\\n\\n /// @notice Notifies about the end of the closing period for the given wallet.\\n /// Closes the wallet ultimately and notifies the ECDSA registry\\n /// about this fact.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the Closing state,\\n /// - The wallet closing period must have elapsed.\\n function notifyWalletClosingPeriodElapsed(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n require(\\n wallet.state == WalletState.Closing,\\n \\\"Wallet must be in Closing state\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >\\n wallet.closingStartedAt + self.walletClosingPeriod,\\n \\\"Closing period has not elapsed yet\\\"\\n );\\n\\n finalizeWalletClosing(self, walletPubKeyHash);\\n }\\n\\n /// @notice Notifies that the wallet completed the moving funds process\\n /// successfully. Checks if the funds were moved to the expected\\n /// target wallets. Closes the source wallet if everything went\\n /// good and reverts otherwise.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param targetWalletsHash 32-byte keccak256 hash over the list of\\n /// 20-byte public key hashes of the target wallets actually used\\n /// within the moving funds transactions.\\n /// @dev Requirements:\\n /// - The caller must make sure the moving funds transaction actually\\n /// happened on Bitcoin chain and fits the protocol requirements,\\n /// - The source wallet must be in the MovingFunds state,\\n /// - The target wallets commitment must be submitted by the source\\n /// wallet,\\n /// - The actual target wallets used in the moving funds transaction\\n /// must be exactly the same as the target wallets commitment.\\n function notifyWalletFundsMoved(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n bytes32 targetWalletsHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n // Check that the wallet is in the MovingFunds state but don't check\\n // if the moving funds timeout is exceeded. That should give a\\n // possibility to move funds in case when timeout was hit but was\\n // not reported yet.\\n require(\\n wallet.state == WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n bytes32 targetWalletsCommitmentHash = wallet\\n .movingFundsTargetWalletsCommitmentHash;\\n\\n require(\\n targetWalletsCommitmentHash != bytes32(0),\\n \\\"Target wallets commitment not submitted yet\\\"\\n );\\n\\n // Make sure that the target wallets where funds were moved to are\\n // exactly the same as the ones the source wallet committed to.\\n require(\\n targetWalletsCommitmentHash == targetWalletsHash,\\n \\\"Target wallets don't correspond to the commitment\\\"\\n );\\n\\n // If funds were moved, the wallet has no longer a main UTXO.\\n delete wallet.mainUtxoHash;\\n\\n beginWalletClosing(self, walletPubKeyHash);\\n }\\n\\n /// @notice Called when a MovingFunds wallet has a balance below the dust\\n /// threshold. Begins the wallet closing.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state.\\n function notifyWalletMovingFundsBelowDust(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n WalletState walletState = self\\n .registeredWallets[walletPubKeyHash]\\n .state;\\n\\n require(\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n beginWalletClosing(self, walletPubKeyHash);\\n }\\n\\n /// @notice Called when the timeout for MovingFunds for the wallet elapsed.\\n /// Slashes wallet members and terminates the wallet.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state.\\n function notifyWalletMovingFundsTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) internal {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n self.ecdsaWalletRegistry.seize(\\n self.movingFundsTimeoutSlashingAmount,\\n self.movingFundsTimeoutNotifierRewardMultiplier,\\n msg.sender,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n\\n terminateWallet(self, walletPubKeyHash);\\n }\\n\\n /// @notice Called when a wallet which was asked to sweep funds moved from\\n /// another wallet did not provide a sweeping proof before a timeout.\\n /// Slashes and terminates the wallet who failed to provide a proof.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet which was\\n /// supposed to sweep funds.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the `Live`, `MovingFunds`,\\n /// or `Terminated` state.\\n function notifyWalletMovedFundsSweepTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n WalletState walletState = wallet.state;\\n\\n require(\\n walletState == WalletState.Live ||\\n walletState == WalletState.MovingFunds ||\\n walletState == WalletState.Terminated,\\n \\\"Wallet must be in Live or MovingFunds or Terminated state\\\"\\n );\\n\\n if (\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds\\n ) {\\n self.ecdsaWalletRegistry.seize(\\n self.movedFundsSweepTimeoutSlashingAmount,\\n self.movedFundsSweepTimeoutNotifierRewardMultiplier,\\n msg.sender,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n\\n terminateWallet(self, walletPubKeyHash);\\n }\\n }\\n\\n /// @notice Called when a wallet which was challenged for a fraud did not\\n /// defeat the challenge before the timeout. Slashes and terminates\\n /// the wallet who failed to defeat the challenge. If the wallet is\\n /// already terminated, it does nothing.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet which was\\n /// supposed to sweep funds.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param challenger Address of the party which submitted the fraud\\n /// challenge.\\n /// @dev Requirements:\\n /// - The wallet must be in the `Live`, `MovingFunds`, `Closing`\\n /// or `Terminated` state.\\n function notifyWalletFraudChallengeDefeatTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs,\\n address challenger\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n WalletState walletState = wallet.state;\\n\\n if (\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds ||\\n walletState == Wallets.WalletState.Closing\\n ) {\\n self.ecdsaWalletRegistry.seize(\\n self.fraudSlashingAmount,\\n self.fraudNotifierRewardMultiplier,\\n challenger,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n\\n terminateWallet(self, walletPubKeyHash);\\n } else if (walletState == Wallets.WalletState.Terminated) {\\n // This is a special case when the wallet was already terminated\\n // due to a previous deliberate protocol violation. In that\\n // case, this function should be still callable for other fraud\\n // challenges timeouts in order to let the challenger unlock its\\n // ETH deposit back. However, the wallet termination logic is\\n // not called and the challenger is not rewarded.\\n } else {\\n revert(\\n \\\"Wallet must be in Live or MovingFunds or Closing or Terminated state\\\"\\n );\\n }\\n }\\n\\n /// @notice Requests a wallet to move their funds. If the wallet balance\\n /// is zero, the wallet closing begins immediately. If the move\\n /// funds request refers to the current active wallet, such a wallet\\n /// is no longer considered active and the active wallet slot\\n /// is unset allowing to trigger a new wallet creation immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the Live state.\\n function moveFunds(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n if (wallet.mainUtxoHash == bytes32(0)) {\\n // If the wallet has no main UTXO, that means its BTC balance\\n // is zero and the wallet closing should begin immediately.\\n beginWalletClosing(self, walletPubKeyHash);\\n } else {\\n // Otherwise, initialize the moving funds process.\\n wallet.state = WalletState.MovingFunds;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.movingFundsRequestedAt = uint32(block.timestamp);\\n\\n // slither-disable-next-line reentrancy-events\\n emit WalletMovingFunds(wallet.ecdsaWalletID, walletPubKeyHash);\\n }\\n\\n if (self.activeWalletPubKeyHash == walletPubKeyHash) {\\n // If the move funds request refers to the current active wallet,\\n // unset the active wallet and make the wallet creation process\\n // possible in order to get a new healthy active wallet.\\n delete self.activeWalletPubKeyHash;\\n }\\n\\n self.liveWalletsCount--;\\n }\\n\\n /// @notice Begins the closing period of the given wallet.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the\\n /// MovingFunds state.\\n function beginWalletClosing(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n // Initialize the closing period.\\n wallet.state = WalletState.Closing;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.closingStartedAt = uint32(block.timestamp);\\n\\n // slither-disable-next-line reentrancy-events\\n emit WalletClosing(wallet.ecdsaWalletID, walletPubKeyHash);\\n }\\n\\n /// @notice Finalizes the closing period of the given wallet and notifies\\n /// the ECDSA registry about this fact.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the Closing state.\\n function finalizeWalletClosing(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n wallet.state = WalletState.Closed;\\n\\n emit WalletClosed(wallet.ecdsaWalletID, walletPubKeyHash);\\n\\n self.ecdsaWalletRegistry.closeWallet(wallet.ecdsaWalletID);\\n }\\n\\n /// @notice Terminates the given wallet and notifies the ECDSA registry\\n /// about this fact. If the wallet termination refers to the current\\n /// active wallet, such a wallet is no longer considered active and\\n /// the active wallet slot is unset allowing to trigger a new wallet\\n /// creation immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the\\n /// Live or MovingFunds or Closing state.\\n function terminateWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n if (wallet.state == WalletState.Live) {\\n self.liveWalletsCount--;\\n }\\n\\n wallet.state = WalletState.Terminated;\\n\\n // slither-disable-next-line reentrancy-events\\n emit WalletTerminated(wallet.ecdsaWalletID, walletPubKeyHash);\\n\\n if (self.activeWalletPubKeyHash == walletPubKeyHash) {\\n // If termination refers to the current active wallet,\\n // unset the active wallet and make the wallet creation process\\n // possible in order to get a new healthy active wallet.\\n delete self.activeWalletPubKeyHash;\\n }\\n\\n self.ecdsaWalletRegistry.closeWallet(wallet.ecdsaWalletID);\\n }\\n\\n /// @notice Gets BTC balance for given the wallet.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMainUtxo Data of the wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @return walletBtcBalance Current BTC balance for the given wallet.\\n /// @dev Requirements:\\n /// - `walletMainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If the wallet has no main UTXO, this parameter can be empty as it\\n /// is ignored.\\n function getWalletBtcBalance(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) internal view returns (uint64 walletBtcBalance) {\\n bytes32 walletMainUtxoHash = self\\n .registeredWallets[walletPubKeyHash]\\n .mainUtxoHash;\\n\\n // If the wallet has a main UTXO hash set, cross-check it with the\\n // provided plain-text parameter and get the transaction output value\\n // as BTC balance. Otherwise, the BTC balance is just zero.\\n if (walletMainUtxoHash != bytes32(0)) {\\n require(\\n keccak256(\\n abi.encodePacked(\\n walletMainUtxo.txHash,\\n walletMainUtxo.txOutputIndex,\\n walletMainUtxo.txOutputValue\\n )\\n ) == walletMainUtxoHash,\\n \\\"Invalid wallet main UTXO data\\\"\\n );\\n\\n walletBtcBalance = walletMainUtxo.txOutputValue;\\n }\\n\\n return walletBtcBalance;\\n }\\n}\\n\",\"keccak256\":\"0x7d0ddff8dc20c10b1e62c8dba304c928c8d8de1c8b6c4d3a1c557dae99743435\",\"license\":\"GPL-3.0-only\"},\"contracts/token/TBTC.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\\\";\\n\\ncontract TBTC is ERC20WithPermit, MisfundRecovery {\\n constructor() ERC20WithPermit(\\\"tBTC v2\\\", \\\"tBTC\\\") {}\\n}\\n\",\"keccak256\":\"0x4542aaa48f7682005b815253768b6433c811daff5d2727db256d5f1879f5ccbf\",\"license\":\"GPL-3.0-only\"},\"contracts/vault/IVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"../bank/IReceiveBalanceApproval.sol\\\";\\n\\n/// @title Bank Vault interface\\n/// @notice `IVault` is an interface for a smart contract consuming Bank\\n/// balances of other contracts or externally owned accounts (EOA).\\ninterface IVault is IReceiveBalanceApproval {\\n /// @notice Called by the Bank in `increaseBalanceAndCall` function after\\n /// increasing the balance in the Bank for the vault. It happens in\\n /// the same transaction in which deposits were swept by the Bridge.\\n /// This allows the depositor to route their deposit revealed to the\\n /// Bridge to the particular smart contract (vault) in the same\\n /// transaction in which the deposit is revealed. This way, the\\n /// depositor does not have to execute additional transaction after\\n /// the deposit gets swept by the Bridge to approve and transfer\\n /// their balance to the vault.\\n /// @param depositors Addresses of depositors whose deposits have been swept.\\n /// @param depositedAmounts Amounts deposited by individual depositors and\\n /// swept.\\n /// @dev The implementation must ensure this function can only be called\\n /// by the Bank. The Bank guarantees that the vault's balance was\\n /// increased by the sum of all deposited amounts before this function\\n /// is called, in the same transaction.\\n function receiveBalanceIncrease(\\n address[] calldata depositors,\\n uint256[] calldata depositedAmounts\\n ) external;\\n}\\n\",\"keccak256\":\"0x12866d625abab349324ee28c6f6ec0114eaa7069ea0c5f7c7b23f6a0f833ae60\",\"license\":\"GPL-3.0-only\"},\"contracts/vault/TBTCOptimisticMinting.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"../bridge/Bridge.sol\\\";\\nimport \\\"../bridge/Deposit.sol\\\";\\nimport \\\"../GovernanceUtils.sol\\\";\\n\\n/// @title TBTC Optimistic Minting\\n/// @notice The Optimistic Minting mechanism allows to mint TBTC before\\n/// `TBTCVault` receives the Bank balance. There are two permissioned\\n/// sets in the system: Minters and Guardians, both set up in 1-of-n\\n/// mode. Minters observe the revealed deposits and request minting TBTC.\\n/// Any single Minter can perform this action. There is an\\n/// `optimisticMintingDelay` between the time of the request from\\n/// a Minter to the time TBTC is minted. During the time of the delay,\\n/// any Guardian can cancel the minting.\\n/// @dev This functionality is a part of `TBTCVault`. It is implemented in\\n/// a separate abstract contract to achieve better separation of concerns\\n/// and easier-to-follow code.\\nabstract contract TBTCOptimisticMinting is Ownable {\\n // Represents optimistic minting request for the given deposit revealed\\n // to the Bridge.\\n struct OptimisticMintingRequest {\\n // UNIX timestamp at which the optimistic minting was requested.\\n uint64 requestedAt;\\n // UNIX timestamp at which the optimistic minting was finalized.\\n // 0 if not yet finalized.\\n uint64 finalizedAt;\\n }\\n\\n /// @notice The time delay that needs to pass between initializing and\\n /// finalizing the upgrade of governable parameters.\\n uint256 public constant GOVERNANCE_DELAY = 24 hours;\\n\\n /// @notice Multiplier to convert satoshi to TBTC token units.\\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\\n\\n Bridge public immutable bridge;\\n\\n /// @notice Indicates if the optimistic minting has been paused. Only the\\n /// Governance can pause optimistic minting. Note that the pause of\\n /// the optimistic minting does not stop the standard minting flow\\n /// where wallets sweep deposits.\\n bool public isOptimisticMintingPaused;\\n\\n /// @notice Divisor used to compute the treasury fee taken from each\\n /// optimistically minted deposit and transferred to the treasury\\n /// upon finalization of the optimistic mint. This fee is computed\\n /// as follows: `fee = amount / optimisticMintingFeeDivisor`.\\n /// For example, if the fee needs to be 2%, the\\n /// `optimisticMintingFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n /// The optimistic minting fee does not replace the deposit treasury\\n /// fee cut by the Bridge. The optimistic fee is a percentage AFTER\\n /// the treasury fee is cut:\\n /// `optimisticMintingFee = (depositAmount - treasuryFee) / optimisticMintingFeeDivisor`\\n uint32 public optimisticMintingFeeDivisor = 500; // 1/500 = 0.002 = 0.2%\\n\\n /// @notice The time that needs to pass between the moment the optimistic\\n /// minting is requested and the moment optimistic minting is\\n /// finalized with minting TBTC.\\n uint32 public optimisticMintingDelay = 3 hours;\\n\\n /// @notice Indicates if the given address is a Minter. Only Minters can\\n /// request optimistic minting.\\n mapping(address => bool) public isMinter;\\n\\n /// @notice List of all Minters.\\n /// @dev May be used to establish an order in which the Minters should\\n /// request for an optimistic minting.\\n address[] public minters;\\n\\n /// @notice Indicates if the given address is a Guardian. Only Guardians can\\n /// cancel requested optimistic minting.\\n mapping(address => bool) public isGuardian;\\n\\n /// @notice Collection of all revealed deposits for which the optimistic\\n /// minting was requested. Indexed by a deposit key computed as\\n /// `keccak256(fundingTxHash | fundingOutputIndex)`.\\n mapping(uint256 => OptimisticMintingRequest)\\n public optimisticMintingRequests;\\n\\n /// @notice Optimistic minting debt value per depositor's address. The debt\\n /// represents the total value of all depositor's deposits revealed\\n /// to the Bridge that has not been yet swept and led to the\\n /// optimistic minting of TBTC. When `TBTCVault` sweeps a deposit,\\n /// the debt is fully or partially paid off, no matter if that\\n /// particular swept deposit was used for the optimistic minting or\\n /// not. The values are in 1e18 Ethereum precision.\\n mapping(address => uint256) public optimisticMintingDebt;\\n\\n /// @notice New optimistic minting fee divisor value. Set only when the\\n /// parameter update process is pending. Once the update gets\\n // finalized, this will be the value of the divisor.\\n uint32 public newOptimisticMintingFeeDivisor;\\n /// @notice The timestamp at which the update of the optimistic minting fee\\n /// divisor started. Zero if update is not in progress.\\n uint256 public optimisticMintingFeeUpdateInitiatedTimestamp;\\n\\n /// @notice New optimistic minting delay value. Set only when the parameter\\n /// update process is pending. Once the update gets finalized, this\\n // will be the value of the delay.\\n uint32 public newOptimisticMintingDelay;\\n /// @notice The timestamp at which the update of the optimistic minting\\n /// delay started. Zero if update is not in progress.\\n uint256 public optimisticMintingDelayUpdateInitiatedTimestamp;\\n\\n event OptimisticMintingRequested(\\n address indexed minter,\\n uint256 indexed depositKey,\\n address indexed depositor,\\n uint256 amount, // amount in 1e18 Ethereum precision\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n );\\n event OptimisticMintingFinalized(\\n address indexed minter,\\n uint256 indexed depositKey,\\n address indexed depositor,\\n uint256 optimisticMintingDebt\\n );\\n event OptimisticMintingCancelled(\\n address indexed guardian,\\n uint256 indexed depositKey\\n );\\n event OptimisticMintingDebtRepaid(\\n address indexed depositor,\\n uint256 optimisticMintingDebt\\n );\\n event MinterAdded(address indexed minter);\\n event MinterRemoved(address indexed minter);\\n event GuardianAdded(address indexed guardian);\\n event GuardianRemoved(address indexed guardian);\\n event OptimisticMintingPaused();\\n event OptimisticMintingUnpaused();\\n\\n event OptimisticMintingFeeUpdateStarted(\\n uint32 newOptimisticMintingFeeDivisor\\n );\\n event OptimisticMintingFeeUpdated(uint32 newOptimisticMintingFeeDivisor);\\n\\n event OptimisticMintingDelayUpdateStarted(uint32 newOptimisticMintingDelay);\\n event OptimisticMintingDelayUpdated(uint32 newOptimisticMintingDelay);\\n\\n modifier onlyMinter() {\\n require(isMinter[msg.sender], \\\"Caller is not a minter\\\");\\n _;\\n }\\n\\n modifier onlyGuardian() {\\n require(isGuardian[msg.sender], \\\"Caller is not a guardian\\\");\\n _;\\n }\\n\\n modifier onlyOwnerOrGuardian() {\\n require(\\n owner() == msg.sender || isGuardian[msg.sender],\\n \\\"Caller is not the owner or guardian\\\"\\n );\\n _;\\n }\\n\\n modifier whenOptimisticMintingNotPaused() {\\n require(!isOptimisticMintingPaused, \\\"Optimistic minting paused\\\");\\n _;\\n }\\n\\n modifier onlyAfterGovernanceDelay(uint256 updateInitiatedTimestamp) {\\n GovernanceUtils.onlyAfterGovernanceDelay(\\n updateInitiatedTimestamp,\\n GOVERNANCE_DELAY\\n );\\n _;\\n }\\n\\n constructor(Bridge _bridge) {\\n require(\\n address(_bridge) != address(0),\\n \\\"Bridge can not be the zero address\\\"\\n );\\n\\n bridge = _bridge;\\n }\\n\\n /// @dev Mints the given amount of TBTC to the given depositor's address.\\n /// Implemented by TBTCVault.\\n function _mint(address minter, uint256 amount) internal virtual;\\n\\n /// @notice Allows to fetch a list of all Minters.\\n function getMinters() external view returns (address[] memory) {\\n return minters;\\n }\\n\\n /// @notice Allows a Minter to request for an optimistic minting of TBTC.\\n /// The following conditions must be met:\\n /// - There is no optimistic minting request for the deposit,\\n /// finalized or not.\\n /// - The deposit with the given Bitcoin funding transaction hash\\n /// and output index has been revealed to the Bridge.\\n /// - The deposit has not been swept yet.\\n /// - The deposit is targeted into the TBTCVault.\\n /// - The optimistic minting is not paused.\\n /// After calling this function, the Minter has to wait for\\n /// `optimisticMintingDelay` before finalizing the mint with a call\\n /// to finalizeOptimisticMint.\\n /// @dev The deposit done on the Bitcoin side must be revealed early enough\\n /// to the Bridge on Ethereum to pass the Bridge's validation. The\\n /// validation passes successfully only if the deposit reveal is done\\n /// respectively earlier than the moment when the deposit refund\\n /// locktime is reached, i.e. the deposit becomes refundable. It may\\n /// happen that the wallet does not sweep a revealed deposit and one of\\n /// the Minters requests an optimistic mint for that deposit just\\n /// before the locktime is reached. Guardians must cancel optimistic\\n /// minting for this deposit because the wallet will not be able to\\n /// sweep it. The on-chain optimistic minting code does not perform any\\n /// validation for gas efficiency: it would have to perform the same\\n /// validation as `validateDepositRefundLocktime` and expect the entire\\n /// `DepositRevealInfo` to be passed to assemble the expected script\\n /// hash on-chain. Guardians must validate if the deposit happened on\\n /// Bitcoin, that the script hash has the expected format, and that the\\n /// wallet is an active one so they can also validate the time left for\\n /// the refund.\\n function requestOptimisticMint(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external onlyMinter whenOptimisticMintingNotPaused {\\n uint256 depositKey = calculateDepositKey(\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n\\n OptimisticMintingRequest storage request = optimisticMintingRequests[\\n depositKey\\n ];\\n require(\\n request.requestedAt == 0,\\n \\\"Optimistic minting already requested for the deposit\\\"\\n );\\n\\n Deposit.DepositRequest memory deposit = bridge.deposits(depositKey);\\n\\n require(deposit.revealedAt != 0, \\\"The deposit has not been revealed\\\");\\n require(deposit.sweptAt == 0, \\\"The deposit is already swept\\\");\\n require(deposit.vault == address(this), \\\"Unexpected vault address\\\");\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n request.requestedAt = uint64(block.timestamp);\\n\\n emit OptimisticMintingRequested(\\n msg.sender,\\n depositKey,\\n deposit.depositor,\\n deposit.amount * SATOSHI_MULTIPLIER,\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n }\\n\\n /// @notice Allows a Minter to finalize previously requested optimistic\\n /// minting. The following conditions must be met:\\n /// - The optimistic minting has been requested for the given\\n /// deposit.\\n /// - The deposit has not been swept yet.\\n /// - At least `optimisticMintingDelay` passed since the optimistic\\n /// minting was requested for the given deposit.\\n /// - The optimistic minting has not been finalized earlier for the\\n /// given deposit.\\n /// - The optimistic minting request for the given deposit has not\\n /// been canceled by a Guardian.\\n /// - The optimistic minting is not paused.\\n /// This function mints TBTC and increases `optimisticMintingDebt`\\n /// for the given depositor. The optimistic minting request is\\n /// marked as finalized.\\n function finalizeOptimisticMint(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external onlyMinter whenOptimisticMintingNotPaused {\\n uint256 depositKey = calculateDepositKey(\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n\\n OptimisticMintingRequest storage request = optimisticMintingRequests[\\n depositKey\\n ];\\n require(\\n request.requestedAt != 0,\\n \\\"Optimistic minting not requested for the deposit\\\"\\n );\\n require(\\n request.finalizedAt == 0,\\n \\\"Optimistic minting already finalized for the deposit\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp > request.requestedAt + optimisticMintingDelay,\\n \\\"Optimistic minting delay has not passed yet\\\"\\n );\\n\\n Deposit.DepositRequest memory deposit = bridge.deposits(depositKey);\\n require(deposit.sweptAt == 0, \\\"The deposit is already swept\\\");\\n\\n // Bridge, when sweeping, cuts a deposit treasury fee and splits\\n // Bitcoin miner fee for the sweep transaction evenly between the\\n // depositors in the sweep.\\n //\\n // When tokens are optimistically minted, we do not know what the\\n // Bitcoin miner fee for the sweep transaction will look like.\\n // The Bitcoin miner fee is ignored. When sweeping, the miner fee is\\n // subtracted so the optimisticMintingDebt may stay non-zero after the\\n // deposit is swept.\\n //\\n // This imbalance is supposed to be solved by a donation to the Bridge.\\n uint256 amountToMint = (deposit.amount - deposit.treasuryFee) *\\n SATOSHI_MULTIPLIER;\\n\\n // The Optimistic Minting mechanism may additionally cut a fee from the\\n // amount that is left after deducting the Bridge deposit treasury fee.\\n // Think of this fee as an extra payment for faster processing of\\n // deposits. One does not need to use the Optimistic Minting mechanism\\n // and they may wait for the Bridge to sweep their deposit if they do\\n // not want to pay the Optimistic Minting fee.\\n uint256 optimisticMintFee = optimisticMintingFeeDivisor > 0\\n ? (amountToMint / optimisticMintingFeeDivisor)\\n : 0;\\n\\n // Both the optimistic minting fee and the share that goes to the\\n // depositor are optimistically minted. All TBTC that is optimistically\\n // minted should be added to the optimistic minting debt. When the\\n // deposit is swept, it is paying off both the depositor's share and the\\n // treasury's share (optimistic minting fee).\\n uint256 newDebt = optimisticMintingDebt[deposit.depositor] +\\n amountToMint;\\n optimisticMintingDebt[deposit.depositor] = newDebt;\\n\\n _mint(deposit.depositor, amountToMint - optimisticMintFee);\\n if (optimisticMintFee > 0) {\\n _mint(bridge.treasury(), optimisticMintFee);\\n }\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n request.finalizedAt = uint64(block.timestamp);\\n\\n emit OptimisticMintingFinalized(\\n msg.sender,\\n depositKey,\\n deposit.depositor,\\n newDebt\\n );\\n }\\n\\n /// @notice Allows a Guardian to cancel optimistic minting request. The\\n /// following conditions must be met:\\n /// - The optimistic minting request for the given deposit exists.\\n /// - The optimistic minting request for the given deposit has not\\n /// been finalized yet.\\n /// Optimistic minting request is removed. It is possible to request\\n /// optimistic minting again for the same deposit later.\\n /// @dev Guardians must validate the following conditions for every deposit\\n /// for which the optimistic minting was requested:\\n /// - The deposit happened on Bitcoin side and it has enough\\n /// confirmations.\\n /// - The optimistic minting has been requested early enough so that\\n /// the wallet has enough time to sweep the deposit.\\n /// - The wallet is an active one and it does perform sweeps or it will\\n /// perform sweeps once the sweeps are activated.\\n function cancelOptimisticMint(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external onlyGuardian {\\n uint256 depositKey = calculateDepositKey(\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n\\n OptimisticMintingRequest storage request = optimisticMintingRequests[\\n depositKey\\n ];\\n require(\\n request.requestedAt != 0,\\n \\\"Optimistic minting not requested for the deposit\\\"\\n );\\n require(\\n request.finalizedAt == 0,\\n \\\"Optimistic minting already finalized for the deposit\\\"\\n );\\n\\n // Delete it. It allows to request optimistic minting for the given\\n // deposit again. Useful in case of an errant Guardian.\\n delete optimisticMintingRequests[depositKey];\\n\\n emit OptimisticMintingCancelled(msg.sender, depositKey);\\n }\\n\\n /// @notice Adds the address to the Minter list.\\n function addMinter(address minter) external onlyOwner {\\n require(!isMinter[minter], \\\"This address is already a minter\\\");\\n isMinter[minter] = true;\\n minters.push(minter);\\n emit MinterAdded(minter);\\n }\\n\\n /// @notice Removes the address from the Minter list.\\n function removeMinter(address minter) external onlyOwnerOrGuardian {\\n require(isMinter[minter], \\\"This address is not a minter\\\");\\n delete isMinter[minter];\\n\\n // We do not expect too many Minters so a simple loop is safe.\\n for (uint256 i = 0; i < minters.length; i++) {\\n if (minters[i] == minter) {\\n minters[i] = minters[minters.length - 1];\\n // slither-disable-next-line costly-loop\\n minters.pop();\\n break;\\n }\\n }\\n\\n emit MinterRemoved(minter);\\n }\\n\\n /// @notice Adds the address to the Guardian set.\\n function addGuardian(address guardian) external onlyOwner {\\n require(!isGuardian[guardian], \\\"This address is already a guardian\\\");\\n isGuardian[guardian] = true;\\n emit GuardianAdded(guardian);\\n }\\n\\n /// @notice Removes the address from the Guardian set.\\n function removeGuardian(address guardian) external onlyOwner {\\n require(isGuardian[guardian], \\\"This address is not a guardian\\\");\\n delete isGuardian[guardian];\\n emit GuardianRemoved(guardian);\\n }\\n\\n /// @notice Pauses the optimistic minting. Note that the pause of the\\n /// optimistic minting does not stop the standard minting flow\\n /// where wallets sweep deposits.\\n function pauseOptimisticMinting() external onlyOwner {\\n require(\\n !isOptimisticMintingPaused,\\n \\\"Optimistic minting already paused\\\"\\n );\\n isOptimisticMintingPaused = true;\\n emit OptimisticMintingPaused();\\n }\\n\\n /// @notice Unpauses the optimistic minting.\\n function unpauseOptimisticMinting() external onlyOwner {\\n require(isOptimisticMintingPaused, \\\"Optimistic minting is not paused\\\");\\n isOptimisticMintingPaused = false;\\n emit OptimisticMintingUnpaused();\\n }\\n\\n /// @notice Begins the process of updating optimistic minting fee.\\n /// The fee is computed as follows:\\n /// `fee = amount / optimisticMintingFeeDivisor`.\\n /// For example, if the fee needs to be 2% of each deposit,\\n /// the `optimisticMintingFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n /// @dev See the documentation for optimisticMintingFeeDivisor.\\n function beginOptimisticMintingFeeUpdate(\\n uint32 _newOptimisticMintingFeeDivisor\\n ) external onlyOwner {\\n /* solhint-disable-next-line not-rely-on-time */\\n optimisticMintingFeeUpdateInitiatedTimestamp = block.timestamp;\\n newOptimisticMintingFeeDivisor = _newOptimisticMintingFeeDivisor;\\n emit OptimisticMintingFeeUpdateStarted(_newOptimisticMintingFeeDivisor);\\n }\\n\\n /// @notice Finalizes the update process of the optimistic minting fee.\\n function finalizeOptimisticMintingFeeUpdate()\\n external\\n onlyOwner\\n onlyAfterGovernanceDelay(optimisticMintingFeeUpdateInitiatedTimestamp)\\n {\\n optimisticMintingFeeDivisor = newOptimisticMintingFeeDivisor;\\n emit OptimisticMintingFeeUpdated(newOptimisticMintingFeeDivisor);\\n\\n newOptimisticMintingFeeDivisor = 0;\\n optimisticMintingFeeUpdateInitiatedTimestamp = 0;\\n }\\n\\n /// @notice Begins the process of updating optimistic minting delay.\\n function beginOptimisticMintingDelayUpdate(\\n uint32 _newOptimisticMintingDelay\\n ) external onlyOwner {\\n /* solhint-disable-next-line not-rely-on-time */\\n optimisticMintingDelayUpdateInitiatedTimestamp = block.timestamp;\\n newOptimisticMintingDelay = _newOptimisticMintingDelay;\\n emit OptimisticMintingDelayUpdateStarted(_newOptimisticMintingDelay);\\n }\\n\\n /// @notice Finalizes the update process of the optimistic minting delay.\\n function finalizeOptimisticMintingDelayUpdate()\\n external\\n onlyOwner\\n onlyAfterGovernanceDelay(optimisticMintingDelayUpdateInitiatedTimestamp)\\n {\\n optimisticMintingDelay = newOptimisticMintingDelay;\\n emit OptimisticMintingDelayUpdated(newOptimisticMintingDelay);\\n\\n newOptimisticMintingDelay = 0;\\n optimisticMintingDelayUpdateInitiatedTimestamp = 0;\\n }\\n\\n /// @notice Calculates deposit key the same way as the Bridge contract.\\n /// The deposit key is computed as\\n /// `keccak256(fundingTxHash | fundingOutputIndex)`.\\n function calculateDepositKey(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) public pure returns (uint256) {\\n return\\n uint256(\\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\\n );\\n }\\n\\n /// @notice Used by `TBTCVault.receiveBalanceIncrease` to repay the optimistic\\n /// minting debt before TBTC is minted. When optimistic minting is\\n /// finalized, debt equal to the value of the deposit being\\n /// a subject of the optimistic minting is incurred. When `TBTCVault`\\n /// sweeps a deposit, the debt is fully or partially paid off, no\\n /// matter if that particular deposit was used for the optimistic\\n /// minting or not.\\n /// @dev See `TBTCVault.receiveBalanceIncrease`\\n /// @param depositor The depositor whose balance increase is received.\\n /// @param amount The balance increase amount for the depositor received.\\n /// @return The TBTC amount that should be minted after paying off the\\n /// optimistic minting debt.\\n function repayOptimisticMintingDebt(address depositor, uint256 amount)\\n internal\\n returns (uint256)\\n {\\n uint256 debt = optimisticMintingDebt[depositor];\\n if (debt == 0) {\\n return amount;\\n }\\n\\n if (amount > debt) {\\n optimisticMintingDebt[depositor] = 0;\\n emit OptimisticMintingDebtRepaid(depositor, 0);\\n return amount - debt;\\n } else {\\n optimisticMintingDebt[depositor] = debt - amount;\\n emit OptimisticMintingDebtRepaid(depositor, debt - amount);\\n return 0;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa4bfc703dafeca2acb0e3c5c96d7f052692147b3812496f426f43e25ef4ba123\",\"license\":\"GPL-3.0-only\"},\"contracts/vault/TBTCVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IVault.sol\\\";\\nimport \\\"./TBTCOptimisticMinting.sol\\\";\\nimport \\\"../bank/Bank.sol\\\";\\nimport \\\"../token/TBTC.sol\\\";\\n\\n/// @title TBTC application vault\\n/// @notice TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of\\n/// Bitcoin. It facilitates Bitcoin holders to act on the Ethereum\\n/// blockchain and access the decentralized finance (DeFi) ecosystem.\\n/// TBTC Vault mints and unmints TBTC based on Bitcoin balances in the\\n/// Bank.\\n/// @dev TBTC Vault is the owner of TBTC token contract and is the only contract\\n/// minting the token.\\ncontract TBTCVault is IVault, Ownable, TBTCOptimisticMinting {\\n using SafeERC20 for IERC20;\\n\\n Bank public immutable bank;\\n TBTC public immutable tbtcToken;\\n\\n /// @notice The address of a new TBTC vault. Set only when the upgrade\\n /// process is pending. Once the upgrade gets finalized, the new\\n /// TBTC vault will become an owner of TBTC token.\\n address public newVault;\\n /// @notice The timestamp at which an upgrade to a new TBTC vault was\\n /// initiated. Set only when the upgrade process is pending.\\n uint256 public upgradeInitiatedTimestamp;\\n\\n event Minted(address indexed to, uint256 amount);\\n event Unminted(address indexed from, uint256 amount);\\n\\n event UpgradeInitiated(address newVault, uint256 timestamp);\\n event UpgradeFinalized(address newVault);\\n\\n modifier onlyBank() {\\n require(msg.sender == address(bank), \\\"Caller is not the Bank\\\");\\n _;\\n }\\n\\n constructor(\\n Bank _bank,\\n TBTC _tbtcToken,\\n Bridge _bridge\\n ) TBTCOptimisticMinting(_bridge) {\\n require(\\n address(_bank) != address(0),\\n \\\"Bank can not be the zero address\\\"\\n );\\n\\n require(\\n address(_tbtcToken) != address(0),\\n \\\"TBTC token can not be the zero address\\\"\\n );\\n\\n bank = _bank;\\n tbtcToken = _tbtcToken;\\n }\\n\\n /// @notice Mints the given `amount` of TBTC to the caller previously\\n /// transferring `amount / SATOSHI_MULTIPLIER` of the Bank balance\\n /// from caller to TBTC Vault. If `amount` is not divisible by\\n /// SATOSHI_MULTIPLIER, the remainder is left on the caller's\\n /// Bank balance.\\n /// @dev TBTC Vault must have an allowance for caller's balance in the\\n /// Bank for at least `amount / SATOSHI_MULTIPLIER`.\\n /// @param amount Amount of TBTC to mint.\\n function mint(uint256 amount) external {\\n (uint256 convertibleAmount, , uint256 satoshis) = amountToSatoshis(\\n amount\\n );\\n\\n require(\\n bank.balanceOf(msg.sender) >= satoshis,\\n \\\"Amount exceeds balance in the bank\\\"\\n );\\n _mint(msg.sender, convertibleAmount);\\n bank.transferBalanceFrom(msg.sender, address(this), satoshis);\\n }\\n\\n /// @notice Transfers `satoshis` of the Bank balance from the caller\\n /// to TBTC Vault and mints `satoshis * SATOSHI_MULTIPLIER` of TBTC\\n /// to the caller.\\n /// @dev Can only be called by the Bank via `approveBalanceAndCall`.\\n /// @param owner The owner who approved their Bank balance.\\n /// @param satoshis Amount of satoshis used to mint TBTC.\\n function receiveBalanceApproval(\\n address owner,\\n uint256 satoshis,\\n bytes calldata\\n ) external override onlyBank {\\n require(\\n bank.balanceOf(owner) >= satoshis,\\n \\\"Amount exceeds balance in the bank\\\"\\n );\\n _mint(owner, satoshis * SATOSHI_MULTIPLIER);\\n bank.transferBalanceFrom(owner, address(this), satoshis);\\n }\\n\\n /// @notice Mints the same amount of TBTC as the deposited satoshis amount\\n /// multiplied by SATOSHI_MULTIPLIER for each depositor in the array.\\n /// Can only be called by the Bank after the Bridge swept deposits\\n /// and Bank increased balance for the vault.\\n /// @dev Fails if `depositors` array is empty. Expects the length of\\n /// `depositors` and `depositedSatoshiAmounts` is the same.\\n function receiveBalanceIncrease(\\n address[] calldata depositors,\\n uint256[] calldata depositedSatoshiAmounts\\n ) external override onlyBank {\\n require(depositors.length != 0, \\\"No depositors specified\\\");\\n for (uint256 i = 0; i < depositors.length; i++) {\\n address depositor = depositors[i];\\n uint256 satoshis = depositedSatoshiAmounts[i];\\n _mint(\\n depositor,\\n repayOptimisticMintingDebt(\\n depositor,\\n satoshis * SATOSHI_MULTIPLIER\\n )\\n );\\n }\\n }\\n\\n /// @notice Burns `amount` of TBTC from the caller's balance and transfers\\n /// `amount / SATOSHI_MULTIPLIER` back to the caller's balance in\\n /// the Bank. If `amount` is not divisible by SATOSHI_MULTIPLIER,\\n /// the remainder is left on the caller's account.\\n /// @dev Caller must have at least `amount` of TBTC approved to\\n /// TBTC Vault.\\n /// @param amount Amount of TBTC to unmint.\\n function unmint(uint256 amount) external {\\n (uint256 convertibleAmount, , ) = amountToSatoshis(amount);\\n\\n _unmint(msg.sender, convertibleAmount);\\n }\\n\\n /// @notice Burns `amount` of TBTC from the caller's balance and transfers\\n /// `amount / SATOSHI_MULTIPLIER` of Bank balance to the Bridge\\n /// requesting redemption based on the provided `redemptionData`.\\n /// If `amount` is not divisible by SATOSHI_MULTIPLIER, the\\n /// remainder is left on the caller's account.\\n /// @dev Caller must have at least `amount` of TBTC approved to\\n /// TBTC Vault.\\n /// @param amount Amount of TBTC to unmint and request to redeem in Bridge.\\n /// @param redemptionData Redemption data in a format expected from\\n /// `redemptionData` parameter of Bridge's `receiveBalanceApproval`\\n /// function.\\n function unmintAndRedeem(uint256 amount, bytes calldata redemptionData)\\n external\\n {\\n (uint256 convertibleAmount, , ) = amountToSatoshis(amount);\\n\\n _unmintAndRedeem(msg.sender, convertibleAmount, redemptionData);\\n }\\n\\n /// @notice Burns `amount` of TBTC from the caller's balance. If `extraData`\\n /// is empty, transfers `amount` back to the caller's balance in the\\n /// Bank. If `extraData` is not empty, requests redemption in the\\n /// Bridge using the `extraData` as a `redemptionData` parameter to\\n /// Bridge's `receiveBalanceApproval` function.\\n /// If `amount` is not divisible by SATOSHI_MULTIPLIER, the\\n /// remainder is left on the caller's account. Note that it may\\n /// left a token approval equal to the remainder.\\n /// @dev This function is doing the same as `unmint` or `unmintAndRedeem`\\n /// (depending on `extraData` parameter) but it allows to execute\\n /// unminting without a separate approval transaction. The function can\\n /// be called only via `approveAndCall` of TBTC token.\\n /// @param from TBTC token holder executing unminting.\\n /// @param amount Amount of TBTC to unmint.\\n /// @param token TBTC token address.\\n /// @param extraData Redemption data in a format expected from\\n /// `redemptionData` parameter of Bridge's `receiveBalanceApproval`\\n /// function. If empty, `receiveApproval` is not requesting a\\n /// redemption of Bank balance but is instead performing just TBTC\\n /// unminting to a Bank balance.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external {\\n require(token == address(tbtcToken), \\\"Token is not TBTC\\\");\\n require(msg.sender == token, \\\"Only TBTC caller allowed\\\");\\n (uint256 convertibleAmount, , ) = amountToSatoshis(amount);\\n if (extraData.length == 0) {\\n _unmint(from, convertibleAmount);\\n } else {\\n _unmintAndRedeem(from, convertibleAmount, extraData);\\n }\\n }\\n\\n /// @notice Initiates vault upgrade process. The upgrade process needs to be\\n /// finalized with a call to `finalizeUpgrade` function after the\\n /// `UPGRADE_GOVERNANCE_DELAY` passes. Only the governance can\\n /// initiate the upgrade.\\n /// @param _newVault The new vault address.\\n function initiateUpgrade(address _newVault) external onlyOwner {\\n require(_newVault != address(0), \\\"New vault address cannot be zero\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n emit UpgradeInitiated(_newVault, block.timestamp);\\n /* solhint-disable-next-line not-rely-on-time */\\n upgradeInitiatedTimestamp = block.timestamp;\\n newVault = _newVault;\\n }\\n\\n /// @notice Allows the governance to finalize vault upgrade process. The\\n /// upgrade process needs to be first initiated with a call to\\n /// `initiateUpgrade` and the `GOVERNANCE_DELAY` needs to pass.\\n /// Once the upgrade is finalized, the new vault becomes the owner\\n /// of the TBTC token and receives the whole Bank balance of this\\n /// vault.\\n function finalizeUpgrade()\\n external\\n onlyOwner\\n onlyAfterGovernanceDelay(upgradeInitiatedTimestamp)\\n {\\n emit UpgradeFinalized(newVault);\\n // slither-disable-next-line reentrancy-no-eth\\n tbtcToken.transferOwnership(newVault);\\n bank.transferBalance(newVault, bank.balanceOf(address(this)));\\n newVault = address(0);\\n upgradeInitiatedTimestamp = 0;\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC20\\n /// token sent mistakenly to the TBTC token contract address.\\n /// @param token Address of the recovered ERC20 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param amount Recovered amount.\\n function recoverERC20FromToken(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n tbtcToken.recoverERC20(token, recipient, amount);\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC721\\n /// token sent mistakenly to the TBTC token contract address.\\n /// @param token Address of the recovered ERC721 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param tokenId Identifier of the recovered token.\\n /// @param data Additional data.\\n function recoverERC721FromToken(\\n IERC721 token,\\n address recipient,\\n uint256 tokenId,\\n bytes calldata data\\n ) external onlyOwner {\\n tbtcToken.recoverERC721(token, recipient, tokenId, data);\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC20\\n /// token sent - mistakenly or not - to the vault address. This\\n /// function should be used to withdraw TBTC v1 tokens transferred\\n /// to TBTCVault as a result of VendingMachine > TBTCVault upgrade.\\n /// @param token Address of the recovered ERC20 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param amount Recovered amount.\\n function recoverERC20(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n token.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC721\\n /// token sent mistakenly to the vault address.\\n /// @param token Address of the recovered ERC721 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param tokenId Identifier of the recovered token.\\n /// @param data Additional data.\\n function recoverERC721(\\n IERC721 token,\\n address recipient,\\n uint256 tokenId,\\n bytes calldata data\\n ) external onlyOwner {\\n token.safeTransferFrom(address(this), recipient, tokenId, data);\\n }\\n\\n /// @notice Returns the amount of TBTC to be minted/unminted, the remainder,\\n /// and the Bank balance to be transferred for the given mint/unmint.\\n /// Note that if the `amount` is not divisible by SATOSHI_MULTIPLIER,\\n /// the remainder is left on the caller's account when minting or\\n /// unminting.\\n /// @return convertibleAmount Amount of TBTC to be minted/unminted.\\n /// @return remainder Not convertible remainder if amount is not divisible\\n /// by SATOSHI_MULTIPLIER.\\n /// @return satoshis Amount in satoshis - the Bank balance to be transferred\\n /// for the given mint/unmint\\n function amountToSatoshis(uint256 amount)\\n public\\n view\\n returns (\\n uint256 convertibleAmount,\\n uint256 remainder,\\n uint256 satoshis\\n )\\n {\\n remainder = amount % SATOSHI_MULTIPLIER;\\n convertibleAmount = amount - remainder;\\n satoshis = convertibleAmount / SATOSHI_MULTIPLIER;\\n }\\n\\n // slither-disable-next-line calls-loop\\n function _mint(address minter, uint256 amount) internal override {\\n emit Minted(minter, amount);\\n tbtcToken.mint(minter, amount);\\n }\\n\\n /// @dev `amount` MUST be divisible by SATOSHI_MULTIPLIER with no change.\\n function _unmint(address unminter, uint256 amount) internal {\\n emit Unminted(unminter, amount);\\n tbtcToken.burnFrom(unminter, amount);\\n bank.transferBalance(unminter, amount / SATOSHI_MULTIPLIER);\\n }\\n\\n /// @dev `amount` MUST be divisible by SATOSHI_MULTIPLIER with no change.\\n function _unmintAndRedeem(\\n address redeemer,\\n uint256 amount,\\n bytes calldata redemptionData\\n ) internal {\\n emit Unminted(redeemer, amount);\\n tbtcToken.burnFrom(redeemer, amount);\\n bank.approveBalanceAndCall(\\n address(bridge),\\n amount / SATOSHI_MULTIPLIER,\\n redemptionData\\n );\\n }\\n}\\n\",\"keccak256\":\"0x98f5c27ce01926f53eb30daa11bd9b2b0cf24274d81a99a04a74ed220f0a69cb\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60e060405260008054600160a81b600160e81b031916650a8c0000007d60aa1b1790553480156200002f57600080fd5b5060405162003e2f38038062003e2f83398101604081905262000052916200020c565b806200005e33620001a3565b6001600160a01b038116620000c55760405162461bcd60e51b815260206004820152602260248201527f4272696467652063616e206e6f7420626520746865207a65726f206164647265604482015261737360f01b60648201526084015b60405180910390fd5b6001600160a01b039081166080528316620001235760405162461bcd60e51b815260206004820181905260248201527f42616e6b2063616e206e6f7420626520746865207a65726f20616464726573736044820152606401620000bc565b6001600160a01b0382166200018a5760405162461bcd60e51b815260206004820152602660248201527f5442544320746f6b656e2063616e206e6f7420626520746865207a65726f206160448201526564647265737360d01b6064820152608401620000bc565b506001600160a01b0391821660a0521660c05262000260565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200020957600080fd5b50565b6000806000606084860312156200022257600080fd5b83516200022f81620001f3565b60208501519093506200024281620001f3565b60408501519092506200025581620001f3565b809150509250925092565b60805160a05160c051613b136200031c600039600081816107330152818161098001528181610cf401528181611fb0015281816123b101528181612d6d01528181612ed8015261301f01526000818161057901528181610d6101528181610ebc01528181610f4a0152818161104f0152818161242d015281816125650152818161265601528181612f36015261307d01526000818161075a015281816115720152818161170e01528181611d620152612f650152613b136000f3fe608060405234801561001057600080fd5b50600436106103365760003560e01c80638532c511116101b2578063a410d29b116100f9578063c36b32b7116100a2578063e5d3d7141161007c578063e5d3d7141461072e578063e78cea9214610755578063f2fde38b1461077c578063fc4e51f61461078f57600080fd5b8063c36b32b7146106ff578063c7ba034714610712578063d0ff65b51461071e57600080fd5b8063b0b54895116100d3578063b0b54895146106cd578063b9f78798146106d7578063bc7b6b99146106f757600080fd5b8063a410d29b1461068f578063a526d83b14610697578063aa271e1a146106aa57600080fd5b8063951315261161015b5780639a508c8e116101355780639a508c8e1461066b578063a0712d6814610673578063a0cceb951461068657600080fd5b80639513152614610647578063983b2d56146106505780639a4e36d51461066357600080fd5b8063897f712c1161018c578063897f712c1461060f5780638da5cb5b146106235780638f4ffcb11461063457600080fd5b80638532c511146105d95780638623ec7b146105e957806388aaf0c8146105fc57600080fd5b806347c1ffdb116102815780636c626aa41161022a5780637445a5a0116102045780637445a5a01461054657806376cdb03b1461057457806380df5ed2146105b3578063820b5513146105c657600080fd5b80636c626aa4146104d0578063714041561461052b578063715018a61461053e57600080fd5b806364e779b11161025b57806364e779b1146104955780636abe3a6c146104a85780636b32810b146104bb57600080fd5b806347c1ffdb1461046357806353dce4df1461046b5780635ae2da461461047e57600080fd5b80633092afd5116102e3578063461c6373116102bd578063461c63731461042a578063475d05701461043d578063479aa9271461045057600080fd5b80633092afd5146103fb578063317dfa761461040e57806341906ab71461042157600080fd5b80631171bda9116103145780631171bda9146103b4578063124f65bd146103c75780632e73e398146103e857600080fd5b806309b53f511461033b5780630c68ba211461036c5780630f3425731461039f575b600080fd5b60005461035290600160a81b900463ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b61038f61037a3660046133e9565b60036020526000908152604090205460ff1681565b6040519015158152602001610363565b6103b26103ad366004613418565b6107a2565b005b6103b26103c2366004613435565b610842565b6103da6103d5366004613476565b6108a3565b604051908152602001610363565b6103b26103f63660046134ef565b610908565b6103b26104093660046133e9565b6109f6565b6103b261041c366004613435565b610c65565b6103da60095481565b6103b26104383660046135a7565b610d56565b6103b261044b366004613613565b610eb1565b6103b261045e3660046133e9565b6110b2565b6103b26111b7565b6103b2610479366004613663565b611295565b60005461035290600160c81b900463ffffffff1681565b6103b26104a33660046136af565b6112b6565b6103b26104b6366004613476565b6112d3565b6104c3611820565b60405161036391906136c8565b61050a6104de3660046136af565b60046020526000908152604090205467ffffffffffffffff808216916801000000000000000090041682565b6040805167ffffffffffffffff938416815292909116602083015201610363565b6103b26105393660046133e9565b611882565b6103b261197b565b6105596105543660046136af565b6119cf565b60408051938452602084019290925290820152606001610363565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610363565b6103b26105c1366004613476565b611a07565b6103b26105d4366004613476565b611bf3565b6006546103529063ffffffff1681565b61059b6105f73660046136af565b611f84565b600a5461059b906001600160a01b031681565b60005461038f90600160a01b900460ff1681565b6000546001600160a01b031661059b565b6103b2610642366004613715565b611fae565b6103da600b5481565b6103b261065e3660046133e9565b6120c3565b6103b2612200565b6103b26122de565b6103b26106813660046136af565b612535565b6103da60075481565b6103b261268d565b6103b26106a53660046133e9565b612775565b61038f6106b83660046133e9565b60016020526000908152604090205460ff1681565b6103da6201518081565b6103da6106e53660046133e9565b60056020526000908152604090205481565b6103b2612898565b6103b261070d366004613418565b61296f565b6103da6402540be40081565b6008546103529063ffffffff1681565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6103b261078a3660046133e9565b612a03565b6103b261079d3660046134ef565b612ad3565b6000546001600160a01b031633146107ef5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064015b60405180910390fd5b426009556008805463ffffffff191663ffffffff83169081179091556040519081527f682bc0fb7e0d6bcb974cf556b95f68533cafc411d83d9f33ac192ccf45dda605906020015b60405180910390a150565b6000546001600160a01b0316331461088a5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b61089e6001600160a01b0384168383612b68565b505050565b600082826040516020016108e692919091825260e01b7fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6040516020818303038152906040528051906020012060001c90505b92915050565b6000546001600160a01b031633146109505760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fc4e51f6906109bd9088908890889088908890600401613794565b600060405180830381600087803b1580156109d757600080fd5b505af11580156109eb573d6000803e3d6000fd5b505050505050505050565b33610a096000546001600160a01b031690565b6001600160a01b03161480610a2d57503360009081526003602052604090205460ff165b610a9f5760405162461bcd60e51b815260206004820152602360248201527f43616c6c6572206973206e6f7420746865206f776e6572206f7220677561726460448201527f69616e000000000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b03811660009081526001602052604090205460ff16610b075760405162461bcd60e51b815260206004820152601c60248201527f546869732061646472657373206973206e6f742061206d696e7465720000000060448201526064016107e6565b6001600160a01b0381166000908152600160205260408120805460ff191690555b600254811015610c2d57816001600160a01b031660028281548110610b4f57610b4f6137c7565b6000918252602090912001546001600160a01b031603610c1b5760028054610b79906001906137f3565b81548110610b8957610b896137c7565b600091825260209091200154600280546001600160a01b039092169183908110610bb557610bb56137c7565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506002805480610bf457610bf4613806565b600082815260209020810160001990810180546001600160a01b0319169055019055610c2d565b80610c258161381c565b915050610b28565b506040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b6000546001600160a01b03163314610cad5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301528381166024830152604482018390527f00000000000000000000000000000000000000000000000000000000000000001690631171bda9906064015b600060405180830381600087803b158015610d3957600080fd5b505af1158015610d4d573d6000803e3d6000fd5b50505050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610dce5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016107e6565b6000839003610e1f5760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f72732073706563696669656400000000000000000060448201526064016107e6565b60005b83811015610eaa576000858583818110610e3e57610e3e6137c7565b9050602002016020810190610e5391906133e9565b90506000848484818110610e6957610e696137c7565b905060200201359050610e9582610e90846402540be40085610e8b9190613835565b612be8565b612ceb565b50508080610ea29061381c565b915050610e22565b5050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610f295760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016107e6565b6040516370a0823160e01b81526001600160a01b03858116600483015284917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa158015610f93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb7919061384c565b10156110105760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016107e6565b61102384610e906402540be40086613835565b604051631f1b6d2760e21b81526001600160a01b038581166004830152306024830152604482018590527f00000000000000000000000000000000000000000000000000000000000000001690637c6db49c906064015b600060405180830381600087803b15801561109457600080fd5b505af11580156110a8573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146110fa5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b0381166111505760405162461bcd60e51b815260206004820181905260248201527f4e6577207661756c7420616464726573732063616e6e6f74206265207a65726f60448201526064016107e6565b604080516001600160a01b03831681524260208201527f5cc842cab066489e13292128663547c68705dbf476f0131e0107f155719c6124910160405180910390a142600b55600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146111ff5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b60075461120f8162015180612dc6565b600654600080547fffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160a81b81029290921790556040519081527fa7f4ce7c3586e2000cdec6b25c5e7d0b20f9b4f435aa22d9c1feb32dbb506f779060200160405180910390a1506006805463ffffffff191690556000600755565b60006112a0846119cf565b505090506112b033828585612e6f565b50505050565b60006112c1826119cf565b505090506112cf3382612fb6565b5050565b3360009081526001602052604090205460ff166113325760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016107e6565b600054600160a01b900460ff161561138c5760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016107e6565b600061139883836108a3565b600081815260046020526040812080549293509167ffffffffffffffff16900361142a5760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016107e6565b805468010000000000000000900467ffffffffffffffff16156114b55760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b60005481546114db91600160c81b900463ffffffff169067ffffffffffffffff16613865565b67ffffffffffffffff1642116115595760405162461bcd60e51b815260206004820152602b60248201527f4f7074696d6973746963206d696e74696e672064656c617920686173206e6f7460448201527f207061737365642079657400000000000000000000000000000000000000000060648201526084016107e6565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa1580156115c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e591906138b9565b90508060a0015163ffffffff166000146116415760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016107e6565b60006402540be4008260800151836020015161165d9190613966565b67ffffffffffffffff166116719190613835565b6000805491925090600160a81b900463ffffffff166116915760006116ab565b6000546116ab90600160a81b900463ffffffff168361399d565b83516001600160a01b0316600090815260056020526040812054919250906116d49084906139b1565b84516001600160a01b03166000908152600560205260409020819055845190915061170390610e9084866137f3565b8115611794576117947f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561176a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178e91906139c4565b83612ceb565b84547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff16680100000000000000004267ffffffffffffffff160217855583516040518281526001600160a01b0390911690879033907f2cffebf26d639426e79514d100febae8b2c63e700e5dc0fa6c88a129633506369060200160405180910390a45050505050505050565b6060600280548060200260200160405190810160405280929190818152602001828054801561187857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161185a575b5050505050905090565b6000546001600160a01b031633146118ca5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526003602052604090205460ff166119325760405162461bcd60e51b815260206004820152601e60248201527f546869732061646472657373206973206e6f74206120677561726469616e000060448201526064016107e6565b6001600160a01b038116600081815260036020526040808220805460ff19169055517fb8107d0c6b40be480ce3172ee66ba6d64b71f6b1685a851340036e6e2e3e3c529190a250565b6000546001600160a01b031633146119c35760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6119cd6000613105565b565b600080806119e26402540be400856139e1565b91506119ee82856137f3565b92506119ff6402540be4008461399d565b929491935050565b3360009081526003602052604090205460ff16611a665760405162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f74206120677561726469616e000000000000000060448201526064016107e6565b6000611a7283836108a3565b600081815260046020526040812080549293509167ffffffffffffffff169003611b045760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016107e6565b805468010000000000000000900467ffffffffffffffff1615611b8f5760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b60008281526004602052604080822080547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016905551839133917f1256b41d4b18d922811c358ab80cb0375aae28f45373de35cfda580662193fcd9190a350505050565b3360009081526001602052604090205460ff16611c525760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016107e6565b600054600160a01b900460ff1615611cac5760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016107e6565b6000611cb883836108a3565b600081815260046020526040902080549192509067ffffffffffffffff1615611d495760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c726561647920726571756560448201527f7374656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa158015611db1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd591906138b9565b9050806040015163ffffffff16600003611e3b5760405162461bcd60e51b815260206004820152602160248201527f546865206465706f73697420686173206e6f74206265656e2072657665616c656044820152601960fa1b60648201526084016107e6565b60a081015163ffffffff1615611e935760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016107e6565b60608101516001600160a01b03163014611eef5760405162461bcd60e51b815260206004820152601860248201527f556e6578706563746564207661756c742061646472657373000000000000000060448201526064016107e6565b815467ffffffffffffffff19164267ffffffffffffffff908116919091178355815160208301516001600160a01b0390911691859133917f36f39c606d55d7dd2a05b8c4e41e9a6ca8c501cea10009c1762f6826a146e05591611f59916402540be4009116613835565b60408051918252602082018b905263ffffffff8a169082015260600160405180910390a45050505050565b60028181548110611f9457600080fd5b6000918252602090912001546001600160a01b0316905081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461202f5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f74205442544300000000000000000000000000000060448201526064016107e6565b336001600160a01b038416146120875760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f776564000000000000000060448201526064016107e6565b6000612092856119cf565b509091505060008290036120af576120aa8682612fb6565b6120bb565b6120bb86828585612e6f565b505050505050565b6000546001600160a01b0316331461210b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526001602052604090205460ff16156121745760405162461bcd60e51b815260206004820181905260248201527f54686973206164647265737320697320616c72656164792061206d696e74657260448201526064016107e6565b6001600160a01b0381166000818152600160208190526040808320805460ff19168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180546001600160a01b03191684179055517f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f69190a250565b6000546001600160a01b031633146122485760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6009546122588162015180612dc6565b600854600080547fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160c81b81029290921790556040519081527ff52de3377e3ae270d1e38f99b9b8d587814643811516ea55ba4d597f9950d4ec9060200160405180910390a1506008805463ffffffff191690556000600955565b6000546001600160a01b031633146123265760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600b546123368162015180612dc6565b600a546040516001600160a01b0390911681527f81a9bb8030ed4116b405800280e065110a37afb57b69948e714c97fab23475ec9060200160405180910390a1600a546040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063f2fde38b90602401600060405180830381600087803b1580156123f757600080fd5b505af115801561240b573d6000803e3d6000fd5b5050600a546040516370a0823160e01b81523060048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811694506356a6d9ef93509091169083906370a0823190602401602060405180830381865afa158015612483573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a7919061384c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561250557600080fd5b505af1158015612519573d6000803e3d6000fd5b5050600a80546001600160a01b031916905550506000600b5550565b600080612541836119cf565b6040516370a0823160e01b8152336004820152929450925082916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691506370a0823190602401602060405180830381865afa1580156125ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125d1919061384c565b101561262a5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016107e6565b6126343383612ceb565b604051631f1b6d2760e21b8152336004820152306024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637c6db49c90606401610d1f565b6000546001600160a01b031633146126d55760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600054600160a01b900460ff16156127395760405162461bcd60e51b815260206004820152602160248201527f4f7074696d6973746963206d696e74696e6720616c72656164792070617573656044820152601960fa1b60648201526084016107e6565b6000805460ff60a01b1916600160a01b1781556040517f23a83c8aeda8c831401c17b5bfb8b2ead79fcfe9c027fe34a4f8576e2c7c74cc9190a1565b6000546001600160a01b031633146127bd5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526003602052604090205460ff161561284c5760405162461bcd60e51b815260206004820152602260248201527f54686973206164647265737320697320616c726561647920612067756172646960448201527f616e00000000000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b038116600081815260036020526040808220805460ff19166001179055517f038596bb31e2e7d3d9f184d4c98b310103f6d7f5830e5eec32bffe6f1728f9699190a250565b6000546001600160a01b031633146128e05760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600054600160a01b900460ff166129395760405162461bcd60e51b815260206004820181905260248201527f4f7074696d6973746963206d696e74696e67206973206e6f742070617573656460448201526064016107e6565b6000805460ff60a01b191681556040517fcb27470ed9568d9eeb8939707bafc19404d908a26ce5f468a6aa781024fd6a839190a1565b6000546001600160a01b031633146129b75760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b426007556006805463ffffffff191663ffffffff83169081179091556040519081527f0dbfec7f12acffbb5cec595ac4370907eaf84caa7025dd71f4021433be79eba990602001610837565b6000546001600160a01b03163314612a4b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b038116612ac75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107e6565b612ad081613105565b50565b6000546001600160a01b03163314612b1b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde906109bd9030908890889088908890600401613794565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261089e908490613155565b6001600160a01b038216600090815260056020526040812054808203612c115782915050610902565b80831115612c78576001600160a01b0384166000818152600560209081526040808320839055519182527fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8910160405180910390a2612c7081846137f3565b915050610902565b612c8283826137f3565b6001600160a01b0385166000818152600560205260409020919091557fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8612cc985846137f3565b60405190815260200160405180910390a26000915050610902565b5092915050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe82604051612d2691815260200190565b60405180910390a26040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906340c10f19906044015b600060405180830381600087803b158015612db257600080fd5b505af11580156120bb573d6000803e3d6000fd5b60008211612e165760405162461bcd60e51b815260206004820152601460248201527f4368616e6765206e6f7420696e6974696174656400000000000000000000000060448201526064016107e6565b80612e2183426137f3565b10156112cf5760405162461bcd60e51b815260206004820181905260248201527f476f7665726e616e63652064656c617920686173206e6f7420656c617073656460448201526064016107e6565b836001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b884604051612eaa91815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038581166004830152602482018590527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b158015612f1c57600080fd5b505af1158015612f30573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a38757e7f00000000000000000000000000000000000000000000000000000000000000006402540be40086612f95919061399d565b85856040518563ffffffff1660e01b815260040161107a94939291906139f5565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b882604051612ff191815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b15801561306357600080fd5b505af1158015613077573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166356a6d9ef836402540be400846130bc919061399d565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401612d98565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006131aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661323a9092919063ffffffff16565b80519091501561089e57808060200190518101906131c89190613a28565b61089e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107e6565b60606132498484600085613253565b90505b9392505050565b6060824710156132cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b0385163b6133225760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107e6565b600080866001600160a01b0316858760405161333e9190613a6e565b60006040518083038185875af1925050503d806000811461337b576040519150601f19603f3d011682016040523d82523d6000602084013e613380565b606091505b509150915061339082828661339b565b979650505050505050565b606083156133aa57508161324c565b8251156133ba5782518084602001fd5b8160405162461bcd60e51b81526004016107e69190613a8a565b6001600160a01b0381168114612ad057600080fd5b6000602082840312156133fb57600080fd5b813561324c816133d4565b63ffffffff81168114612ad057600080fd5b60006020828403121561342a57600080fd5b813561324c81613406565b60008060006060848603121561344a57600080fd5b8335613455816133d4565b92506020840135613465816133d4565b929592945050506040919091013590565b6000806040838503121561348957600080fd5b82359150602083013561349b81613406565b809150509250929050565b60008083601f8401126134b857600080fd5b50813567ffffffffffffffff8111156134d057600080fd5b6020830191508360208285010111156134e857600080fd5b9250929050565b60008060008060006080868803121561350757600080fd5b8535613512816133d4565b94506020860135613522816133d4565b935060408601359250606086013567ffffffffffffffff81111561354557600080fd5b613551888289016134a6565b969995985093965092949392505050565b60008083601f84011261357457600080fd5b50813567ffffffffffffffff81111561358c57600080fd5b6020830191508360208260051b85010111156134e857600080fd5b600080600080604085870312156135bd57600080fd5b843567ffffffffffffffff808211156135d557600080fd5b6135e188838901613562565b909650945060208701359150808211156135fa57600080fd5b5061360787828801613562565b95989497509550505050565b6000806000806060858703121561362957600080fd5b8435613634816133d4565b935060208501359250604085013567ffffffffffffffff81111561365757600080fd5b613607878288016134a6565b60008060006040848603121561367857600080fd5b83359250602084013567ffffffffffffffff81111561369657600080fd5b6136a2868287016134a6565b9497909650939450505050565b6000602082840312156136c157600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156137095783516001600160a01b0316835292840192918401916001016136e4565b50909695505050505050565b60008060008060006080868803121561372d57600080fd5b8535613738816133d4565b945060208601359350604086013561374f816133d4565b9250606086013567ffffffffffffffff81111561354557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b0380881683528087166020840152508460408301526080606083015261339060808301848661376b565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610902576109026137dd565b634e487b7160e01b600052603160045260246000fd5b60006001820161382e5761382e6137dd565b5060010190565b8082028115828204841417610902576109026137dd565b60006020828403121561385e57600080fd5b5051919050565b67ffffffffffffffff818116838216019080821115612ce457612ce46137dd565b8051613891816133d4565b919050565b805167ffffffffffffffff8116811461389157600080fd5b805161389181613406565b600060c082840312156138cb57600080fd5b60405160c0810181811067ffffffffffffffff821117156138fc57634e487b7160e01b600052604160045260246000fd5b60405261390883613886565b815261391660208401613896565b6020820152613927604084016138ae565b604082015261393860608401613886565b606082015261394960808401613896565b608082015261395a60a084016138ae565b60a08201529392505050565b67ffffffffffffffff828116828216039080821115612ce457612ce46137dd565b634e487b7160e01b600052601260045260246000fd5b6000826139ac576139ac613987565b500490565b80820180821115610902576109026137dd565b6000602082840312156139d657600080fd5b815161324c816133d4565b6000826139f0576139f0613987565b500690565b6001600160a01b0385168152836020820152606060408201526000613a1e60608301848661376b565b9695505050505050565b600060208284031215613a3a57600080fd5b8151801515811461324c57600080fd5b60005b83811015613a65578181015183820152602001613a4d565b50506000910152565b60008251613a80818460208701613a4a565b9190910192915050565b6020815260008251806020840152613aa9816040850160208701613a4a565b601f01601f1916919091016040019291505056fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220aabd28c13405d8cf2c5332bb69dcd504bd839194f1d43914aef46237f5af30d464736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103365760003560e01c80638532c511116101b2578063a410d29b116100f9578063c36b32b7116100a2578063e5d3d7141161007c578063e5d3d7141461072e578063e78cea9214610755578063f2fde38b1461077c578063fc4e51f61461078f57600080fd5b8063c36b32b7146106ff578063c7ba034714610712578063d0ff65b51461071e57600080fd5b8063b0b54895116100d3578063b0b54895146106cd578063b9f78798146106d7578063bc7b6b99146106f757600080fd5b8063a410d29b1461068f578063a526d83b14610697578063aa271e1a146106aa57600080fd5b8063951315261161015b5780639a508c8e116101355780639a508c8e1461066b578063a0712d6814610673578063a0cceb951461068657600080fd5b80639513152614610647578063983b2d56146106505780639a4e36d51461066357600080fd5b8063897f712c1161018c578063897f712c1461060f5780638da5cb5b146106235780638f4ffcb11461063457600080fd5b80638532c511146105d95780638623ec7b146105e957806388aaf0c8146105fc57600080fd5b806347c1ffdb116102815780636c626aa41161022a5780637445a5a0116102045780637445a5a01461054657806376cdb03b1461057457806380df5ed2146105b3578063820b5513146105c657600080fd5b80636c626aa4146104d0578063714041561461052b578063715018a61461053e57600080fd5b806364e779b11161025b57806364e779b1146104955780636abe3a6c146104a85780636b32810b146104bb57600080fd5b806347c1ffdb1461046357806353dce4df1461046b5780635ae2da461461047e57600080fd5b80633092afd5116102e3578063461c6373116102bd578063461c63731461042a578063475d05701461043d578063479aa9271461045057600080fd5b80633092afd5146103fb578063317dfa761461040e57806341906ab71461042157600080fd5b80631171bda9116103145780631171bda9146103b4578063124f65bd146103c75780632e73e398146103e857600080fd5b806309b53f511461033b5780630c68ba211461036c5780630f3425731461039f575b600080fd5b60005461035290600160a81b900463ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b61038f61037a3660046133e9565b60036020526000908152604090205460ff1681565b6040519015158152602001610363565b6103b26103ad366004613418565b6107a2565b005b6103b26103c2366004613435565b610842565b6103da6103d5366004613476565b6108a3565b604051908152602001610363565b6103b26103f63660046134ef565b610908565b6103b26104093660046133e9565b6109f6565b6103b261041c366004613435565b610c65565b6103da60095481565b6103b26104383660046135a7565b610d56565b6103b261044b366004613613565b610eb1565b6103b261045e3660046133e9565b6110b2565b6103b26111b7565b6103b2610479366004613663565b611295565b60005461035290600160c81b900463ffffffff1681565b6103b26104a33660046136af565b6112b6565b6103b26104b6366004613476565b6112d3565b6104c3611820565b60405161036391906136c8565b61050a6104de3660046136af565b60046020526000908152604090205467ffffffffffffffff808216916801000000000000000090041682565b6040805167ffffffffffffffff938416815292909116602083015201610363565b6103b26105393660046133e9565b611882565b6103b261197b565b6105596105543660046136af565b6119cf565b60408051938452602084019290925290820152606001610363565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610363565b6103b26105c1366004613476565b611a07565b6103b26105d4366004613476565b611bf3565b6006546103529063ffffffff1681565b61059b6105f73660046136af565b611f84565b600a5461059b906001600160a01b031681565b60005461038f90600160a01b900460ff1681565b6000546001600160a01b031661059b565b6103b2610642366004613715565b611fae565b6103da600b5481565b6103b261065e3660046133e9565b6120c3565b6103b2612200565b6103b26122de565b6103b26106813660046136af565b612535565b6103da60075481565b6103b261268d565b6103b26106a53660046133e9565b612775565b61038f6106b83660046133e9565b60016020526000908152604090205460ff1681565b6103da6201518081565b6103da6106e53660046133e9565b60056020526000908152604090205481565b6103b2612898565b6103b261070d366004613418565b61296f565b6103da6402540be40081565b6008546103529063ffffffff1681565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6103b261078a3660046133e9565b612a03565b6103b261079d3660046134ef565b612ad3565b6000546001600160a01b031633146107ef5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064015b60405180910390fd5b426009556008805463ffffffff191663ffffffff83169081179091556040519081527f682bc0fb7e0d6bcb974cf556b95f68533cafc411d83d9f33ac192ccf45dda605906020015b60405180910390a150565b6000546001600160a01b0316331461088a5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b61089e6001600160a01b0384168383612b68565b505050565b600082826040516020016108e692919091825260e01b7fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6040516020818303038152906040528051906020012060001c90505b92915050565b6000546001600160a01b031633146109505760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fc4e51f6906109bd9088908890889088908890600401613794565b600060405180830381600087803b1580156109d757600080fd5b505af11580156109eb573d6000803e3d6000fd5b505050505050505050565b33610a096000546001600160a01b031690565b6001600160a01b03161480610a2d57503360009081526003602052604090205460ff165b610a9f5760405162461bcd60e51b815260206004820152602360248201527f43616c6c6572206973206e6f7420746865206f776e6572206f7220677561726460448201527f69616e000000000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b03811660009081526001602052604090205460ff16610b075760405162461bcd60e51b815260206004820152601c60248201527f546869732061646472657373206973206e6f742061206d696e7465720000000060448201526064016107e6565b6001600160a01b0381166000908152600160205260408120805460ff191690555b600254811015610c2d57816001600160a01b031660028281548110610b4f57610b4f6137c7565b6000918252602090912001546001600160a01b031603610c1b5760028054610b79906001906137f3565b81548110610b8957610b896137c7565b600091825260209091200154600280546001600160a01b039092169183908110610bb557610bb56137c7565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506002805480610bf457610bf4613806565b600082815260209020810160001990810180546001600160a01b0319169055019055610c2d565b80610c258161381c565b915050610b28565b506040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b6000546001600160a01b03163314610cad5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301528381166024830152604482018390527f00000000000000000000000000000000000000000000000000000000000000001690631171bda9906064015b600060405180830381600087803b158015610d3957600080fd5b505af1158015610d4d573d6000803e3d6000fd5b50505050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610dce5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016107e6565b6000839003610e1f5760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f72732073706563696669656400000000000000000060448201526064016107e6565b60005b83811015610eaa576000858583818110610e3e57610e3e6137c7565b9050602002016020810190610e5391906133e9565b90506000848484818110610e6957610e696137c7565b905060200201359050610e9582610e90846402540be40085610e8b9190613835565b612be8565b612ceb565b50508080610ea29061381c565b915050610e22565b5050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610f295760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016107e6565b6040516370a0823160e01b81526001600160a01b03858116600483015284917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa158015610f93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb7919061384c565b10156110105760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016107e6565b61102384610e906402540be40086613835565b604051631f1b6d2760e21b81526001600160a01b038581166004830152306024830152604482018590527f00000000000000000000000000000000000000000000000000000000000000001690637c6db49c906064015b600060405180830381600087803b15801561109457600080fd5b505af11580156110a8573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146110fa5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b0381166111505760405162461bcd60e51b815260206004820181905260248201527f4e6577207661756c7420616464726573732063616e6e6f74206265207a65726f60448201526064016107e6565b604080516001600160a01b03831681524260208201527f5cc842cab066489e13292128663547c68705dbf476f0131e0107f155719c6124910160405180910390a142600b55600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146111ff5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b60075461120f8162015180612dc6565b600654600080547fffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160a81b81029290921790556040519081527fa7f4ce7c3586e2000cdec6b25c5e7d0b20f9b4f435aa22d9c1feb32dbb506f779060200160405180910390a1506006805463ffffffff191690556000600755565b60006112a0846119cf565b505090506112b033828585612e6f565b50505050565b60006112c1826119cf565b505090506112cf3382612fb6565b5050565b3360009081526001602052604090205460ff166113325760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016107e6565b600054600160a01b900460ff161561138c5760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016107e6565b600061139883836108a3565b600081815260046020526040812080549293509167ffffffffffffffff16900361142a5760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016107e6565b805468010000000000000000900467ffffffffffffffff16156114b55760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b60005481546114db91600160c81b900463ffffffff169067ffffffffffffffff16613865565b67ffffffffffffffff1642116115595760405162461bcd60e51b815260206004820152602b60248201527f4f7074696d6973746963206d696e74696e672064656c617920686173206e6f7460448201527f207061737365642079657400000000000000000000000000000000000000000060648201526084016107e6565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa1580156115c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e591906138b9565b90508060a0015163ffffffff166000146116415760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016107e6565b60006402540be4008260800151836020015161165d9190613966565b67ffffffffffffffff166116719190613835565b6000805491925090600160a81b900463ffffffff166116915760006116ab565b6000546116ab90600160a81b900463ffffffff168361399d565b83516001600160a01b0316600090815260056020526040812054919250906116d49084906139b1565b84516001600160a01b03166000908152600560205260409020819055845190915061170390610e9084866137f3565b8115611794576117947f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561176a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178e91906139c4565b83612ceb565b84547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff16680100000000000000004267ffffffffffffffff160217855583516040518281526001600160a01b0390911690879033907f2cffebf26d639426e79514d100febae8b2c63e700e5dc0fa6c88a129633506369060200160405180910390a45050505050505050565b6060600280548060200260200160405190810160405280929190818152602001828054801561187857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161185a575b5050505050905090565b6000546001600160a01b031633146118ca5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526003602052604090205460ff166119325760405162461bcd60e51b815260206004820152601e60248201527f546869732061646472657373206973206e6f74206120677561726469616e000060448201526064016107e6565b6001600160a01b038116600081815260036020526040808220805460ff19169055517fb8107d0c6b40be480ce3172ee66ba6d64b71f6b1685a851340036e6e2e3e3c529190a250565b6000546001600160a01b031633146119c35760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6119cd6000613105565b565b600080806119e26402540be400856139e1565b91506119ee82856137f3565b92506119ff6402540be4008461399d565b929491935050565b3360009081526003602052604090205460ff16611a665760405162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f74206120677561726469616e000000000000000060448201526064016107e6565b6000611a7283836108a3565b600081815260046020526040812080549293509167ffffffffffffffff169003611b045760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016107e6565b805468010000000000000000900467ffffffffffffffff1615611b8f5760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b60008281526004602052604080822080547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016905551839133917f1256b41d4b18d922811c358ab80cb0375aae28f45373de35cfda580662193fcd9190a350505050565b3360009081526001602052604090205460ff16611c525760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016107e6565b600054600160a01b900460ff1615611cac5760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016107e6565b6000611cb883836108a3565b600081815260046020526040902080549192509067ffffffffffffffff1615611d495760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c726561647920726571756560448201527f7374656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa158015611db1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd591906138b9565b9050806040015163ffffffff16600003611e3b5760405162461bcd60e51b815260206004820152602160248201527f546865206465706f73697420686173206e6f74206265656e2072657665616c656044820152601960fa1b60648201526084016107e6565b60a081015163ffffffff1615611e935760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016107e6565b60608101516001600160a01b03163014611eef5760405162461bcd60e51b815260206004820152601860248201527f556e6578706563746564207661756c742061646472657373000000000000000060448201526064016107e6565b815467ffffffffffffffff19164267ffffffffffffffff908116919091178355815160208301516001600160a01b0390911691859133917f36f39c606d55d7dd2a05b8c4e41e9a6ca8c501cea10009c1762f6826a146e05591611f59916402540be4009116613835565b60408051918252602082018b905263ffffffff8a169082015260600160405180910390a45050505050565b60028181548110611f9457600080fd5b6000918252602090912001546001600160a01b0316905081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461202f5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f74205442544300000000000000000000000000000060448201526064016107e6565b336001600160a01b038416146120875760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f776564000000000000000060448201526064016107e6565b6000612092856119cf565b509091505060008290036120af576120aa8682612fb6565b6120bb565b6120bb86828585612e6f565b505050505050565b6000546001600160a01b0316331461210b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526001602052604090205460ff16156121745760405162461bcd60e51b815260206004820181905260248201527f54686973206164647265737320697320616c72656164792061206d696e74657260448201526064016107e6565b6001600160a01b0381166000818152600160208190526040808320805460ff19168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180546001600160a01b03191684179055517f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f69190a250565b6000546001600160a01b031633146122485760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6009546122588162015180612dc6565b600854600080547fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160c81b81029290921790556040519081527ff52de3377e3ae270d1e38f99b9b8d587814643811516ea55ba4d597f9950d4ec9060200160405180910390a1506008805463ffffffff191690556000600955565b6000546001600160a01b031633146123265760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600b546123368162015180612dc6565b600a546040516001600160a01b0390911681527f81a9bb8030ed4116b405800280e065110a37afb57b69948e714c97fab23475ec9060200160405180910390a1600a546040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063f2fde38b90602401600060405180830381600087803b1580156123f757600080fd5b505af115801561240b573d6000803e3d6000fd5b5050600a546040516370a0823160e01b81523060048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811694506356a6d9ef93509091169083906370a0823190602401602060405180830381865afa158015612483573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a7919061384c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561250557600080fd5b505af1158015612519573d6000803e3d6000fd5b5050600a80546001600160a01b031916905550506000600b5550565b600080612541836119cf565b6040516370a0823160e01b8152336004820152929450925082916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691506370a0823190602401602060405180830381865afa1580156125ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125d1919061384c565b101561262a5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016107e6565b6126343383612ceb565b604051631f1b6d2760e21b8152336004820152306024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637c6db49c90606401610d1f565b6000546001600160a01b031633146126d55760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600054600160a01b900460ff16156127395760405162461bcd60e51b815260206004820152602160248201527f4f7074696d6973746963206d696e74696e6720616c72656164792070617573656044820152601960fa1b60648201526084016107e6565b6000805460ff60a01b1916600160a01b1781556040517f23a83c8aeda8c831401c17b5bfb8b2ead79fcfe9c027fe34a4f8576e2c7c74cc9190a1565b6000546001600160a01b031633146127bd5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526003602052604090205460ff161561284c5760405162461bcd60e51b815260206004820152602260248201527f54686973206164647265737320697320616c726561647920612067756172646960448201527f616e00000000000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b038116600081815260036020526040808220805460ff19166001179055517f038596bb31e2e7d3d9f184d4c98b310103f6d7f5830e5eec32bffe6f1728f9699190a250565b6000546001600160a01b031633146128e05760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600054600160a01b900460ff166129395760405162461bcd60e51b815260206004820181905260248201527f4f7074696d6973746963206d696e74696e67206973206e6f742070617573656460448201526064016107e6565b6000805460ff60a01b191681556040517fcb27470ed9568d9eeb8939707bafc19404d908a26ce5f468a6aa781024fd6a839190a1565b6000546001600160a01b031633146129b75760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b426007556006805463ffffffff191663ffffffff83169081179091556040519081527f0dbfec7f12acffbb5cec595ac4370907eaf84caa7025dd71f4021433be79eba990602001610837565b6000546001600160a01b03163314612a4b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b038116612ac75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107e6565b612ad081613105565b50565b6000546001600160a01b03163314612b1b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde906109bd9030908890889088908890600401613794565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261089e908490613155565b6001600160a01b038216600090815260056020526040812054808203612c115782915050610902565b80831115612c78576001600160a01b0384166000818152600560209081526040808320839055519182527fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8910160405180910390a2612c7081846137f3565b915050610902565b612c8283826137f3565b6001600160a01b0385166000818152600560205260409020919091557fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8612cc985846137f3565b60405190815260200160405180910390a26000915050610902565b5092915050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe82604051612d2691815260200190565b60405180910390a26040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906340c10f19906044015b600060405180830381600087803b158015612db257600080fd5b505af11580156120bb573d6000803e3d6000fd5b60008211612e165760405162461bcd60e51b815260206004820152601460248201527f4368616e6765206e6f7420696e6974696174656400000000000000000000000060448201526064016107e6565b80612e2183426137f3565b10156112cf5760405162461bcd60e51b815260206004820181905260248201527f476f7665726e616e63652064656c617920686173206e6f7420656c617073656460448201526064016107e6565b836001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b884604051612eaa91815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038581166004830152602482018590527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b158015612f1c57600080fd5b505af1158015612f30573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a38757e7f00000000000000000000000000000000000000000000000000000000000000006402540be40086612f95919061399d565b85856040518563ffffffff1660e01b815260040161107a94939291906139f5565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b882604051612ff191815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b15801561306357600080fd5b505af1158015613077573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166356a6d9ef836402540be400846130bc919061399d565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401612d98565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006131aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661323a9092919063ffffffff16565b80519091501561089e57808060200190518101906131c89190613a28565b61089e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107e6565b60606132498484600085613253565b90505b9392505050565b6060824710156132cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b0385163b6133225760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107e6565b600080866001600160a01b0316858760405161333e9190613a6e565b60006040518083038185875af1925050503d806000811461337b576040519150601f19603f3d011682016040523d82523d6000602084013e613380565b606091505b509150915061339082828661339b565b979650505050505050565b606083156133aa57508161324c565b8251156133ba5782518084602001fd5b8160405162461bcd60e51b81526004016107e69190613a8a565b6001600160a01b0381168114612ad057600080fd5b6000602082840312156133fb57600080fd5b813561324c816133d4565b63ffffffff81168114612ad057600080fd5b60006020828403121561342a57600080fd5b813561324c81613406565b60008060006060848603121561344a57600080fd5b8335613455816133d4565b92506020840135613465816133d4565b929592945050506040919091013590565b6000806040838503121561348957600080fd5b82359150602083013561349b81613406565b809150509250929050565b60008083601f8401126134b857600080fd5b50813567ffffffffffffffff8111156134d057600080fd5b6020830191508360208285010111156134e857600080fd5b9250929050565b60008060008060006080868803121561350757600080fd5b8535613512816133d4565b94506020860135613522816133d4565b935060408601359250606086013567ffffffffffffffff81111561354557600080fd5b613551888289016134a6565b969995985093965092949392505050565b60008083601f84011261357457600080fd5b50813567ffffffffffffffff81111561358c57600080fd5b6020830191508360208260051b85010111156134e857600080fd5b600080600080604085870312156135bd57600080fd5b843567ffffffffffffffff808211156135d557600080fd5b6135e188838901613562565b909650945060208701359150808211156135fa57600080fd5b5061360787828801613562565b95989497509550505050565b6000806000806060858703121561362957600080fd5b8435613634816133d4565b935060208501359250604085013567ffffffffffffffff81111561365757600080fd5b613607878288016134a6565b60008060006040848603121561367857600080fd5b83359250602084013567ffffffffffffffff81111561369657600080fd5b6136a2868287016134a6565b9497909650939450505050565b6000602082840312156136c157600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156137095783516001600160a01b0316835292840192918401916001016136e4565b50909695505050505050565b60008060008060006080868803121561372d57600080fd5b8535613738816133d4565b945060208601359350604086013561374f816133d4565b9250606086013567ffffffffffffffff81111561354557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b0380881683528087166020840152508460408301526080606083015261339060808301848661376b565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610902576109026137dd565b634e487b7160e01b600052603160045260246000fd5b60006001820161382e5761382e6137dd565b5060010190565b8082028115828204841417610902576109026137dd565b60006020828403121561385e57600080fd5b5051919050565b67ffffffffffffffff818116838216019080821115612ce457612ce46137dd565b8051613891816133d4565b919050565b805167ffffffffffffffff8116811461389157600080fd5b805161389181613406565b600060c082840312156138cb57600080fd5b60405160c0810181811067ffffffffffffffff821117156138fc57634e487b7160e01b600052604160045260246000fd5b60405261390883613886565b815261391660208401613896565b6020820152613927604084016138ae565b604082015261393860608401613886565b606082015261394960808401613896565b608082015261395a60a084016138ae565b60a08201529392505050565b67ffffffffffffffff828116828216039080821115612ce457612ce46137dd565b634e487b7160e01b600052601260045260246000fd5b6000826139ac576139ac613987565b500490565b80820180821115610902576109026137dd565b6000602082840312156139d657600080fd5b815161324c816133d4565b6000826139f0576139f0613987565b500690565b6001600160a01b0385168152836020820152606060408201526000613a1e60608301848661376b565b9695505050505050565b600060208284031215613a3a57600080fd5b8151801515811461324c57600080fd5b60005b83811015613a65578181015183820152602001613a4d565b50506000910152565b60008251613a80818460208701613a4a565b9190910192915050565b6020815260008251806020840152613aa9816040850160208701613a4a565b601f01601f1916919091016040019291505056fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a2646970667358221220aabd28c13405d8cf2c5332bb69dcd504bd839194f1d43914aef46237f5af30d464736f6c63430008110033", + "devdoc": { + "details": "TBTC Vault is the owner of TBTC token contract and is the only contract minting the token.", + "kind": "dev", + "methods": { + "amountToSatoshis(uint256)": { + "returns": { + "convertibleAmount": "Amount of TBTC to be minted/unminted.", + "remainder": "Not convertible remainder if amount is not divisible by SATOSHI_MULTIPLIER.", + "satoshis": "Amount in satoshis - the Bank balance to be transferred for the given mint/unmint" + } + }, + "beginOptimisticMintingFeeUpdate(uint32)": { + "details": "See the documentation for optimisticMintingFeeDivisor." + }, + "cancelOptimisticMint(bytes32,uint32)": { + "details": "Guardians must validate the following conditions for every deposit for which the optimistic minting was requested: - The deposit happened on Bitcoin side and it has enough confirmations. - The optimistic minting has been requested early enough so that the wallet has enough time to sweep the deposit. - The wallet is an active one and it does perform sweeps or it will perform sweeps once the sweeps are activated." + }, + "initiateUpgrade(address)": { + "params": { + "_newVault": "The new vault address." + } + }, + "mint(uint256)": { + "details": "TBTC Vault must have an allowance for caller's balance in the Bank for at least `amount / SATOSHI_MULTIPLIER`.", + "params": { + "amount": "Amount of TBTC to mint." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "receiveApproval(address,uint256,address,bytes)": { + "details": "This function is doing the same as `unmint` or `unmintAndRedeem` (depending on `extraData` parameter) but it allows to execute unminting without a separate approval transaction. The function can be called only via `approveAndCall` of TBTC token.", + "params": { + "amount": "Amount of TBTC to unmint.", + "extraData": "Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function. If empty, `receiveApproval` is not requesting a redemption of Bank balance but is instead performing just TBTC unminting to a Bank balance.", + "from": "TBTC token holder executing unminting.", + "token": "TBTC token address." + } + }, + "receiveBalanceApproval(address,uint256,bytes)": { + "details": "Can only be called by the Bank via `approveBalanceAndCall`.", + "params": { + "owner": "The owner who approved their Bank balance.", + "satoshis": "Amount of satoshis used to mint TBTC." + } + }, + "receiveBalanceIncrease(address[],uint256[])": { + "details": "Fails if `depositors` array is empty. Expects the length of `depositors` and `depositedSatoshiAmounts` is the same." + }, + "recoverERC20(address,address,uint256)": { + "params": { + "amount": "Recovered amount.", + "recipient": "Address the recovered token should be sent to.", + "token": "Address of the recovered ERC20 token contract." + } + }, + "recoverERC20FromToken(address,address,uint256)": { + "params": { + "amount": "Recovered amount.", + "recipient": "Address the recovered token should be sent to.", + "token": "Address of the recovered ERC20 token contract." + } + }, + "recoverERC721(address,address,uint256,bytes)": { + "params": { + "data": "Additional data.", + "recipient": "Address the recovered token should be sent to.", + "token": "Address of the recovered ERC721 token contract.", + "tokenId": "Identifier of the recovered token." + } + }, + "recoverERC721FromToken(address,address,uint256,bytes)": { + "params": { + "data": "Additional data.", + "recipient": "Address the recovered token should be sent to.", + "token": "Address of the recovered ERC721 token contract.", + "tokenId": "Identifier of the recovered token." + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "requestOptimisticMint(bytes32,uint32)": { + "details": "The deposit done on the Bitcoin side must be revealed early enough to the Bridge on Ethereum to pass the Bridge's validation. The validation passes successfully only if the deposit reveal is done respectively earlier than the moment when the deposit refund locktime is reached, i.e. the deposit becomes refundable. It may happen that the wallet does not sweep a revealed deposit and one of the Minters requests an optimistic mint for that deposit just before the locktime is reached. Guardians must cancel optimistic minting for this deposit because the wallet will not be able to sweep it. The on-chain optimistic minting code does not perform any validation for gas efficiency: it would have to perform the same validation as `validateDepositRefundLocktime` and expect the entire `DepositRevealInfo` to be passed to assemble the expected script hash on-chain. Guardians must validate if the deposit happened on Bitcoin, that the script hash has the expected format, and that the wallet is an active one so they can also validate the time left for the refund." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "unmint(uint256)": { + "details": "Caller must have at least `amount` of TBTC approved to TBTC Vault.", + "params": { + "amount": "Amount of TBTC to unmint." + } + }, + "unmintAndRedeem(uint256,bytes)": { + "details": "Caller must have at least `amount` of TBTC approved to TBTC Vault.", + "params": { + "amount": "Amount of TBTC to unmint and request to redeem in Bridge.", + "redemptionData": "Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function." + } + } + }, + "title": "TBTC application vault", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "GOVERNANCE_DELAY()": { + "notice": "The time delay that needs to pass between initializing and finalizing the upgrade of governable parameters." + }, + "SATOSHI_MULTIPLIER()": { + "notice": "Multiplier to convert satoshi to TBTC token units." + }, + "addGuardian(address)": { + "notice": "Adds the address to the Guardian set." + }, + "addMinter(address)": { + "notice": "Adds the address to the Minter list." + }, + "amountToSatoshis(uint256)": { + "notice": "Returns the amount of TBTC to be minted/unminted, the remainder, and the Bank balance to be transferred for the given mint/unmint. Note that if the `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account when minting or unminting." + }, + "beginOptimisticMintingDelayUpdate(uint32)": { + "notice": "Begins the process of updating optimistic minting delay." + }, + "beginOptimisticMintingFeeUpdate(uint32)": { + "notice": "Begins the process of updating optimistic minting fee. The fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2% of each deposit, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`." + }, + "calculateDepositKey(bytes32,uint32)": { + "notice": "Calculates deposit key the same way as the Bridge contract. The deposit key is computed as `keccak256(fundingTxHash | fundingOutputIndex)`." + }, + "cancelOptimisticMint(bytes32,uint32)": { + "notice": "Allows a Guardian to cancel optimistic minting request. The following conditions must be met: - The optimistic minting request for the given deposit exists. - The optimistic minting request for the given deposit has not been finalized yet. Optimistic minting request is removed. It is possible to request optimistic minting again for the same deposit later." + }, + "finalizeOptimisticMint(bytes32,uint32)": { + "notice": "Allows a Minter to finalize previously requested optimistic minting. The following conditions must be met: - The optimistic minting has been requested for the given deposit. - The deposit has not been swept yet. - At least `optimisticMintingDelay` passed since the optimistic minting was requested for the given deposit. - The optimistic minting has not been finalized earlier for the given deposit. - The optimistic minting request for the given deposit has not been canceled by a Guardian. - The optimistic minting is not paused. This function mints TBTC and increases `optimisticMintingDebt` for the given depositor. The optimistic minting request is marked as finalized." + }, + "finalizeOptimisticMintingDelayUpdate()": { + "notice": "Finalizes the update process of the optimistic minting delay." + }, + "finalizeOptimisticMintingFeeUpdate()": { + "notice": "Finalizes the update process of the optimistic minting fee." + }, + "finalizeUpgrade()": { + "notice": "Allows the governance to finalize vault upgrade process. The upgrade process needs to be first initiated with a call to `initiateUpgrade` and the `GOVERNANCE_DELAY` needs to pass. Once the upgrade is finalized, the new vault becomes the owner of the TBTC token and receives the whole Bank balance of this vault." + }, + "getMinters()": { + "notice": "Allows to fetch a list of all Minters." + }, + "initiateUpgrade(address)": { + "notice": "Initiates vault upgrade process. The upgrade process needs to be finalized with a call to `finalizeUpgrade` function after the `UPGRADE_GOVERNANCE_DELAY` passes. Only the governance can initiate the upgrade." + }, + "isGuardian(address)": { + "notice": "Indicates if the given address is a Guardian. Only Guardians can cancel requested optimistic minting." + }, + "isMinter(address)": { + "notice": "Indicates if the given address is a Minter. Only Minters can request optimistic minting." + }, + "isOptimisticMintingPaused()": { + "notice": "Indicates if the optimistic minting has been paused. Only the Governance can pause optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits." + }, + "mint(uint256)": { + "notice": "Mints the given `amount` of TBTC to the caller previously transferring `amount / SATOSHI_MULTIPLIER` of the Bank balance from caller to TBTC Vault. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's Bank balance." + }, + "minters(uint256)": { + "notice": "List of all Minters." + }, + "newOptimisticMintingDelay()": { + "notice": "New optimistic minting delay value. Set only when the parameter update process is pending. Once the update gets finalized, this" + }, + "newOptimisticMintingFeeDivisor()": { + "notice": "New optimistic minting fee divisor value. Set only when the parameter update process is pending. Once the update gets" + }, + "newVault()": { + "notice": "The address of a new TBTC vault. Set only when the upgrade process is pending. Once the upgrade gets finalized, the new TBTC vault will become an owner of TBTC token." + }, + "optimisticMintingDebt(address)": { + "notice": "Optimistic minting debt value per depositor's address. The debt represents the total value of all depositor's deposits revealed to the Bridge that has not been yet swept and led to the optimistic minting of TBTC. When `TBTCVault` sweeps a deposit, the debt is fully or partially paid off, no matter if that particular swept deposit was used for the optimistic minting or not. The values are in 1e18 Ethereum precision." + }, + "optimisticMintingDelay()": { + "notice": "The time that needs to pass between the moment the optimistic minting is requested and the moment optimistic minting is finalized with minting TBTC." + }, + "optimisticMintingDelayUpdateInitiatedTimestamp()": { + "notice": "The timestamp at which the update of the optimistic minting delay started. Zero if update is not in progress." + }, + "optimisticMintingFeeDivisor()": { + "notice": "Divisor used to compute the treasury fee taken from each optimistically minted deposit and transferred to the treasury upon finalization of the optimistic mint. This fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2%, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`. The optimistic minting fee does not replace the deposit treasury fee cut by the Bridge. The optimistic fee is a percentage AFTER the treasury fee is cut: `optimisticMintingFee = (depositAmount - treasuryFee) / optimisticMintingFeeDivisor`" + }, + "optimisticMintingFeeUpdateInitiatedTimestamp()": { + "notice": "The timestamp at which the update of the optimistic minting fee divisor started. Zero if update is not in progress." + }, + "optimisticMintingRequests(uint256)": { + "notice": "Collection of all revealed deposits for which the optimistic minting was requested. Indexed by a deposit key computed as `keccak256(fundingTxHash | fundingOutputIndex)`." + }, + "pauseOptimisticMinting()": { + "notice": "Pauses the optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits." + }, + "receiveApproval(address,uint256,address,bytes)": { + "notice": "Burns `amount` of TBTC from the caller's balance. If `extraData` is empty, transfers `amount` back to the caller's balance in the Bank. If `extraData` is not empty, requests redemption in the Bridge using the `extraData` as a `redemptionData` parameter to Bridge's `receiveBalanceApproval` function. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account. Note that it may left a token approval equal to the remainder." + }, + "receiveBalanceApproval(address,uint256,bytes)": { + "notice": "Transfers `satoshis` of the Bank balance from the caller to TBTC Vault and mints `satoshis * SATOSHI_MULTIPLIER` of TBTC to the caller." + }, + "receiveBalanceIncrease(address[],uint256[])": { + "notice": "Mints the same amount of TBTC as the deposited satoshis amount multiplied by SATOSHI_MULTIPLIER for each depositor in the array. Can only be called by the Bank after the Bridge swept deposits and Bank increased balance for the vault." + }, + "recoverERC20(address,address,uint256)": { + "notice": "Allows the governance of the TBTCVault to recover any ERC20 token sent - mistakenly or not - to the vault address. This function should be used to withdraw TBTC v1 tokens transferred to TBTCVault as a result of VendingMachine > TBTCVault upgrade." + }, + "recoverERC20FromToken(address,address,uint256)": { + "notice": "Allows the governance of the TBTCVault to recover any ERC20 token sent mistakenly to the TBTC token contract address." + }, + "recoverERC721(address,address,uint256,bytes)": { + "notice": "Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the vault address." + }, + "recoverERC721FromToken(address,address,uint256,bytes)": { + "notice": "Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the TBTC token contract address." + }, + "removeGuardian(address)": { + "notice": "Removes the address from the Guardian set." + }, + "removeMinter(address)": { + "notice": "Removes the address from the Minter list." + }, + "requestOptimisticMint(bytes32,uint32)": { + "notice": "Allows a Minter to request for an optimistic minting of TBTC. The following conditions must be met: - There is no optimistic minting request for the deposit, finalized or not. - The deposit with the given Bitcoin funding transaction hash and output index has been revealed to the Bridge. - The deposit has not been swept yet. - The deposit is targeted into the TBTCVault. - The optimistic minting is not paused. After calling this function, the Minter has to wait for `optimisticMintingDelay` before finalizing the mint with a call to finalizeOptimisticMint." + }, + "unmint(uint256)": { + "notice": "Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` back to the caller's balance in the Bank. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account." + }, + "unmintAndRedeem(uint256,bytes)": { + "notice": "Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` of Bank balance to the Bridge requesting redemption based on the provided `redemptionData`. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account." + }, + "unpauseOptimisticMinting()": { + "notice": "Unpauses the optimistic minting." + }, + "upgradeInitiatedTimestamp()": { + "notice": "The timestamp at which an upgrade to a new TBTC vault was initiated. Set only when the upgrade process is pending." + } + }, + "notice": "TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of Bitcoin. It facilitates Bitcoin holders to act on the Ethereum blockchain and access the decentralized finance (DeFi) ecosystem. TBTC Vault mints and unmints TBTC based on Bitcoin balances in the Bank.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 13249, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 33289, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "isOptimisticMintingPaused", + "offset": 20, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 33293, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingFeeDivisor", + "offset": 21, + "slot": "0", + "type": "t_uint32" + }, + { + "astId": 33297, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingDelay", + "offset": 25, + "slot": "0", + "type": "t_uint32" + }, + { + "astId": 33302, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "isMinter", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 33306, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "minters", + "offset": 0, + "slot": "2", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 33311, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "isGuardian", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 33317, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingRequests", + "offset": 0, + "slot": "4", + "type": "t_mapping(t_uint256,t_struct(OptimisticMintingRequest)33273_storage)" + }, + { + "astId": 33322, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingDebt", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 33325, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "newOptimisticMintingFeeDivisor", + "offset": 0, + "slot": "6", + "type": "t_uint32" + }, + { + "astId": 33328, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingFeeUpdateInitiatedTimestamp", + "offset": 0, + "slot": "7", + "type": "t_uint256" + }, + { + "astId": 33331, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "newOptimisticMintingDelay", + "offset": 0, + "slot": "8", + "type": "t_uint32" + }, + { + "astId": 33334, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingDelayUpdateInitiatedTimestamp", + "offset": 0, + "slot": "9", + "type": "t_uint256" + }, + { + "astId": 34205, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "newVault", + "offset": 0, + "slot": "10", + "type": "t_address" + }, + { + "astId": 34208, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "upgradeInitiatedTimestamp", + "offset": 0, + "slot": "11", + "type": "t_uint256" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_uint256,t_struct(OptimisticMintingRequest)33273_storage)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => struct TBTCOptimisticMinting.OptimisticMintingRequest)", + "numberOfBytes": "32", + "value": "t_struct(OptimisticMintingRequest)33273_storage" + }, + "t_struct(OptimisticMintingRequest)33273_storage": { + "encoding": "inplace", + "label": "struct TBTCOptimisticMinting.OptimisticMintingRequest", + "members": [ + { + "astId": 33270, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "requestedAt", + "offset": 0, + "slot": "0", + "type": "t_uint64" + }, + { + "astId": 33272, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "finalizedAt", + "offset": 8, + "slot": "0", + "type": "t_uint64" + } + ], + "numberOfBytes": "32" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint32": { + "encoding": "inplace", + "label": "uint32", + "numberOfBytes": "4" + }, + "t_uint64": { + "encoding": "inplace", + "label": "uint64", + "numberOfBytes": "8" + } + } + } +} diff --git a/typescript/src/lib/ethereum/artifacts/goerli/WalletRegistry.json b/typescript/src/lib/ethereum/artifacts/goerli/WalletRegistry.json new file mode 100644 index 000000000..aa493fad5 --- /dev/null +++ b/typescript/src/lib/ethereum/artifacts/goerli/WalletRegistry.json @@ -0,0 +1,1962 @@ +{ + "address": "0x0f0E2afF99A55B11026Fb270A05f04d37724dE86", + "abi": [ + { + "inputs": [ + { + "internalType": "contract SortitionPool", + "name": "_sortitionPool", + "type": "address" + }, + { + "internalType": "contract IStaking", + "name": "_staking", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "AuthorizationDecreaseApproved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "decreasingAt", + "type": "uint64" + } + ], + "name": "AuthorizationDecreaseRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "AuthorizationIncreased", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint96", + "name": "minimumAuthorization", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "authorizationDecreaseDelay", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "authorizationDecreaseChangePeriod", + "type": "uint64" + } + ], + "name": "AuthorizationParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "slashingAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "maliciousSubmitter", + "type": "address" + } + ], + "name": "DkgMaliciousResultSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "slashingAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "maliciousSubmitter", + "type": "address" + } + ], + "name": "DkgMaliciousResultSlashingFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "seedTimeout", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "resultChallengePeriodLength", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "resultChallengeExtraGas", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "resultSubmissionTimeout", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "resultSubmitterPrecedencePeriodLength", + "type": "uint256" + } + ], + "name": "DkgParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "DkgResultApproved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "challenger", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "reason", + "type": "string" + } + ], + "name": "DkgResultChallenged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "seed", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "indexed": false, + "internalType": "struct EcdsaDkg.Result", + "name": "result", + "type": "tuple" + } + ], + "name": "DkgResultSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "DkgSeedTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "seed", + "type": "uint256" + } + ], + "name": "DkgStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "DkgStateLocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "DkgTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "dkgResultSubmissionGas", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "dkgResultApprovalGasOffset", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "notifyOperatorInactivityGasOffset", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "notifySeedTimeoutGasOffset", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "notifyDkgTimeoutNegativeGasOffset", + "type": "uint256" + } + ], + "name": "GasParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldGovernance", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "GovernanceTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "notifier", + "type": "address" + } + ], + "name": "InactivityClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "InvoluntaryAuthorizationDecreaseFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "OperatorJoinedSortitionPool", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "OperatorRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "OperatorStatusUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "randomBeacon", + "type": "address" + } + ], + "name": "RandomBeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newReimbursementPool", + "type": "address" + } + ], + "name": "ReimbursementPoolUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "maliciousDkgResultNotificationRewardMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sortitionPoolRewardsBanDuration", + "type": "uint256" + } + ], + "name": "RewardParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "amount", + "type": "uint96" + } + ], + "name": "RewardsWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "maliciousDkgResultSlashingAmount", + "type": "uint256" + } + ], + "name": "SlashingParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "WalletClosed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "dkgResultHash", + "type": "bytes32" + } + ], + "name": "WalletCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "walletOwner", + "type": "address" + } + ], + "name": "WalletOwnerUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "relayEntry", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "__beaconCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "approveAuthorizationDecrease", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "internalType": "struct EcdsaDkg.Result", + "name": "dkgResult", + "type": "tuple" + } + ], + "name": "approveDkgResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "authorizationDecreaseRequested", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "authorizationIncreased", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "authorizationParameters", + "outputs": [ + { + "internalType": "uint96", + "name": "minimumAuthorization", + "type": "uint96" + }, + { + "internalType": "uint64", + "name": "authorizationDecreaseDelay", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "authorizationDecreaseChangePeriod", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "availableRewards", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "internalType": "struct EcdsaDkg.Result", + "name": "dkgResult", + "type": "tuple" + } + ], + "name": "challengeDkgResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "closeWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "dkgParameters", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "seedTimeout", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resultChallengePeriodLength", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resultChallengeExtraGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resultSubmissionTimeout", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "submitterPrecedencePeriodLength", + "type": "uint256" + } + ], + "internalType": "struct EcdsaDkg.Parameters", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "eligibleStake", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gasParameters", + "outputs": [ + { + "internalType": "uint256", + "name": "dkgResultSubmissionGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dkgResultApprovalGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifyOperatorInactivityGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifySeedTimeoutGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifyDkgTimeoutNegativeGasOffset", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "getWallet", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "membersIdsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyX", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyY", + "type": "bytes32" + } + ], + "internalType": "struct Wallets.Wallet", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWalletCreationState", + "outputs": [ + { + "internalType": "enum EcdsaDkg.State", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "getWalletPublicKey", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governance", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hasDkgTimedOut", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hasSeedTimedOut", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "inactivityClaimNonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract EcdsaDkgValidator", + "name": "_ecdsaDkgValidator", + "type": "address" + }, + { + "internalType": "contract IRandomBeacon", + "name": "_randomBeacon", + "type": "address" + }, + { + "internalType": "contract ReimbursementPool", + "name": "_reimbursementPool", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "involuntaryAuthorizationDecrease", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "internalType": "struct EcdsaDkg.Result", + "name": "result", + "type": "tuple" + } + ], + "name": "isDkgResultValid", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isOperatorInPool", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isOperatorUpToDate", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "uint256", + "name": "walletMemberIndex", + "type": "uint256" + } + ], + "name": "isWalletMember", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "isWalletRegistered", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "joinSortitionPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "minimumAuthorization", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "notifyDkgTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "inactiveMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "bool", + "name": "heartbeatFailed", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + } + ], + "internalType": "struct EcdsaInactivity.Claim", + "name": "claim", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint32[]", + "name": "groupMembers", + "type": "uint32[]" + } + ], + "name": "notifyOperatorInactivity", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "notifySeedTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "operatorToStakingProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "pendingAuthorizationDecrease", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "randomBeacon", + "outputs": [ + { + "internalType": "contract IRandomBeacon", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "registerOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "reimbursementPool", + "outputs": [ + { + "internalType": "contract ReimbursementPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "remainingAuthorizationDecreaseDelay", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "requestNewWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardParameters", + "outputs": [ + { + "internalType": "uint256", + "name": "maliciousDkgResultNotificationRewardMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sortitionPoolRewardsBanDuration", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint96", + "name": "amount", + "type": "uint96" + }, + { + "internalType": "uint256", + "name": "rewardMultiplier", + "type": "uint256" + }, + { + "internalType": "address", + "name": "notifier", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + } + ], + "name": "seize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "selectGroup", + "outputs": [ + { + "internalType": "uint32[]", + "name": "", + "type": "uint32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "slashingParameters", + "outputs": [ + { + "internalType": "uint96", + "name": "maliciousDkgResultSlashingAmount", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "sortitionPool", + "outputs": [ + { + "internalType": "contract SortitionPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "staking", + "outputs": [ + { + "internalType": "contract IStaking", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "stakingProviderToOperator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "internalType": "struct EcdsaDkg.Result", + "name": "dkgResult", + "type": "tuple" + } + ], + "name": "submitDkgResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint96", + "name": "_minimumAuthorization", + "type": "uint96" + }, + { + "internalType": "uint64", + "name": "_authorizationDecreaseDelay", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "_authorizationDecreaseChangePeriod", + "type": "uint64" + } + ], + "name": "updateAuthorizationParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_seedTimeout", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_resultChallengePeriodLength", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_resultChallengeExtraGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_resultSubmissionTimeout", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_submitterPrecedencePeriodLength", + "type": "uint256" + } + ], + "name": "updateDkgParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "dkgResultSubmissionGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dkgResultApprovalGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifyOperatorInactivityGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifySeedTimeoutGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifyDkgTimeoutNegativeGasOffset", + "type": "uint256" + } + ], + "name": "updateGasParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "updateOperatorStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ReimbursementPool", + "name": "_reimbursementPool", + "type": "address" + } + ], + "name": "updateReimbursementPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "maliciousDkgResultNotificationRewardMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sortitionPoolRewardsBanDuration", + "type": "uint256" + } + ], + "name": "updateRewardParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint96", + "name": "maliciousDkgResultSlashingAmount", + "type": "uint96" + } + ], + "name": "updateSlashingParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IWalletOwner", + "name": "_walletOwner", + "type": "address" + } + ], + "name": "updateWalletOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRandomBeacon", + "name": "_randomBeacon", + "type": "address" + } + ], + "name": "upgradeRandomBeacon", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "walletOwner", + "outputs": [ + { + "internalType": "contract IWalletOwner", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "withdrawIneligibleRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "withdrawRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xf40a2de63c196595c23cb8c78a0dd237ea6b3ed21803518b543245cda65cd1a8", + "receipt": { + "to": null, + "from": "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + "contractAddress": "0x0f0E2afF99A55B11026Fb270A05f04d37724dE86", + "transactionIndex": 10, + "gasUsed": "1053777", + "logsBloom": "0x00000000000000000000000000400000400000004000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000800000000800000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000040000000000000000000000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000000000040000002000000400000000000000000800000000000000000000000800000000000000000000000000000000000000000000", + "blockHash": "0x848e125a89628cf2e92b414febe60f4fa0d32b38d20696dc6c7c864cae1e9a80", + "transactionHash": "0xf40a2de63c196595c23cb8c78a0dd237ea6b3ed21803518b543245cda65cd1a8", + "logs": [ + { + "transactionIndex": 10, + "blockNumber": 8364851, + "transactionHash": "0xf40a2de63c196595c23cb8c78a0dd237ea6b3ed21803518b543245cda65cd1a8", + "address": "0x0f0E2afF99A55B11026Fb270A05f04d37724dE86", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000005b1ebf8008097ac3ef6785220bfb9eca2b1a73dd" + ], + "data": "0x", + "logIndex": 13, + "blockHash": "0x848e125a89628cf2e92b414febe60f4fa0d32b38d20696dc6c7c864cae1e9a80" + }, + { + "transactionIndex": 10, + "blockNumber": 8364851, + "transactionHash": "0xf40a2de63c196595c23cb8c78a0dd237ea6b3ed21803518b543245cda65cd1a8", + "address": "0x0f0E2afF99A55B11026Fb270A05f04d37724dE86", + "topics": [ + "0x5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80" + ], + "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000068ad60cc5e8f3b7cc53beab321cf0e6036962dbc", + "logIndex": 14, + "blockHash": "0x848e125a89628cf2e92b414febe60f4fa0d32b38d20696dc6c7c864cae1e9a80" + }, + { + "transactionIndex": 10, + "blockNumber": 8364851, + "transactionHash": "0xf40a2de63c196595c23cb8c78a0dd237ea6b3ed21803518b543245cda65cd1a8", + "address": "0x0f0E2afF99A55B11026Fb270A05f04d37724dE86", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 15, + "blockHash": "0x848e125a89628cf2e92b414febe60f4fa0d32b38d20696dc6c7c864cae1e9a80" + }, + { + "transactionIndex": 10, + "blockNumber": 8364851, + "transactionHash": "0xf40a2de63c196595c23cb8c78a0dd237ea6b3ed21803518b543245cda65cd1a8", + "address": "0x0f0E2afF99A55B11026Fb270A05f04d37724dE86", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cbcf87d133123f7b48e4343fa1861d4c0d6eef24", + "logIndex": 16, + "blockHash": "0x848e125a89628cf2e92b414febe60f4fa0d32b38d20696dc6c7c864cae1e9a80" + } + ], + "blockNumber": 8364851, + "cumulativeGasUsed": "3144686", + "status": 1, + "byzantium": true + }, + "args": [ + "0x3985b5320148D04fe0D1eE9D6380caD49baF2CD4", + "0x1da5d88C26EA4f87b5e09C3452eE2384Ee20DC75" + ], + "numDeployments": 1, + "libraries": { + "EcdsaInactivity": "0x7102345e1Eb62aE60044f0c4B8Ad97984D27fcf6" + }, + "implementation": "0x5b1ebF8008097Ac3EF6785220bFb9ecA2B1a73Dd", + "devdoc": "Contract deployed as upgradable proxy" +} diff --git a/typescript/src/lib/ethereum/artifacts/mainnet/Bridge.json b/typescript/src/lib/ethereum/artifacts/mainnet/Bridge.json new file mode 100644 index 000000000..5ca597163 --- /dev/null +++ b/typescript/src/lib/ethereum/artifacts/mainnet/Bridge.json @@ -0,0 +1,2624 @@ +{ + "address": "0x5e4861a80B55f035D899f66772117F00FA0E8e7B", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "depositDustThreshold", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "depositTreasuryFeeDivisor", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "depositTxMaxFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "depositRevealAheadPeriod", + "type": "uint32" + } + ], + "name": "DepositParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "amount", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "bytes8", + "name": "blindingFactor", + "type": "bytes8" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes20", + "name": "refundPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes4", + "name": "refundLocktime", + "type": "bytes4" + }, + { + "indexed": false, + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "name": "DepositRevealed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sweepTxHash", + "type": "bytes32" + } + ], + "name": "DepositsSwept", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sighash", + "type": "bytes32" + } + ], + "name": "FraudChallengeDefeatTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sighash", + "type": "bytes32" + } + ], + "name": "FraudChallengeDefeated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sighash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "FraudChallengeSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint96", + "name": "fraudChallengeDepositAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "fraudChallengeDefeatTimeout", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "fraudSlashingAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "fraudNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "FraudParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldGovernance", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "GovernanceTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "movingFundsTxHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movingFundsTxOutputIndex", + "type": "uint32" + } + ], + "name": "MovedFundsSweepTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "sweepTxHash", + "type": "bytes32" + } + ], + "name": "MovedFundsSwept", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "MovingFundsBelowDustReported", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes20[]", + "name": "targetWallets", + "type": "bytes20[]" + }, + { + "indexed": false, + "internalType": "address", + "name": "submitter", + "type": "address" + } + ], + "name": "MovingFundsCommitmentSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "movingFundsTxHash", + "type": "bytes32" + } + ], + "name": "MovingFundsCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "movingFundsTxMaxTotalFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "movingFundsDustThreshold", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movingFundsTimeoutResetDelay", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movingFundsTimeout", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "movingFundsTimeoutSlashingAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movingFundsTimeoutNotifierRewardMultiplier", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "movingFundsCommitmentGasOffset", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "movedFundsSweepTxMaxTotalFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movedFundsSweepTimeout", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "movedFundsSweepTimeoutSlashingAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "movedFundsSweepTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "MovingFundsParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "MovingFundsTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "MovingFundsTimeoutReset", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "NewWalletRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "NewWalletRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "redemptionDustThreshold", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "redemptionTreasuryFeeDivisor", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "redemptionTxMaxFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "redemptionTxMaxTotalFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "redemptionTimeout", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "redemptionTimeoutSlashingAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "redemptionTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "RedemptionParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "redeemerOutputScript", + "type": "bytes" + }, + { + "indexed": true, + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "requestedAmount", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "treasuryFee", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "txMaxFee", + "type": "uint64" + } + ], + "name": "RedemptionRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "redeemerOutputScript", + "type": "bytes" + } + ], + "name": "RedemptionTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "redemptionTxHash", + "type": "bytes32" + } + ], + "name": "RedemptionsCompleted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "spvMaintainer", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isTrusted", + "type": "bool" + } + ], + "name": "SpvMaintainerStatusUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "treasury", + "type": "address" + } + ], + "name": "TreasuryUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "vault", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "isTrusted", + "type": "bool" + } + ], + "name": "VaultStatusUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "WalletClosed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "WalletClosing", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "WalletMovingFunds", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "walletCreationPeriod", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "walletCreationMinBtcBalance", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "walletCreationMaxBtcBalance", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "walletClosureMinBtcBalance", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "walletMaxAge", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "walletMaxBtcTransfer", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "walletClosingPeriod", + "type": "uint32" + } + ], + "name": "WalletParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "WalletTerminated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyX", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyY", + "type": "bytes32" + } + ], + "name": "__ecdsaWalletCreatedCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyX", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyY", + "type": "bytes32" + } + ], + "name": "__ecdsaWalletHeartbeatFailedCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "activeWalletPubKeyHash", + "outputs": [ + { + "internalType": "bytes20", + "name": "", + "type": "bytes20" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "contractReferences", + "outputs": [ + { + "internalType": "contract Bank", + "name": "bank", + "type": "address" + }, + { + "internalType": "contract IRelay", + "name": "relay", + "type": "address" + }, + { + "internalType": "contract IWalletRegistry", + "name": "ecdsaWalletRegistry", + "type": "address" + }, + { + "internalType": "contract ReimbursementPool", + "name": "reimbursementPool", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "walletPublicKey", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "preimage", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "witness", + "type": "bool" + } + ], + "name": "defeatFraudChallenge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "walletPublicKey", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "heartbeatMessage", + "type": "bytes" + } + ], + "name": "defeatFraudChallengeWithHeartbeat", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "depositParameters", + "outputs": [ + { + "internalType": "uint64", + "name": "depositDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "depositTreasuryFeeDivisor", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "depositTxMaxFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "depositRevealAheadPeriod", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "deposits", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "internalType": "uint64", + "name": "amount", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "revealedAt", + "type": "uint32" + }, + { + "internalType": "address", + "name": "vault", + "type": "address" + }, + { + "internalType": "uint64", + "name": "treasuryFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "sweptAt", + "type": "uint32" + } + ], + "internalType": "struct Deposit.DepositRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "challengeKey", + "type": "uint256" + } + ], + "name": "fraudChallenges", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "challenger", + "type": "address" + }, + { + "internalType": "uint256", + "name": "depositAmount", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "reportedAt", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "resolved", + "type": "bool" + } + ], + "internalType": "struct Fraud.FraudChallenge", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "fraudParameters", + "outputs": [ + { + "internalType": "uint96", + "name": "fraudChallengeDepositAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "fraudChallengeDefeatTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "fraudSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "fraudNotifierRewardMultiplier", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governance", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_bank", + "type": "address" + }, + { + "internalType": "address", + "name": "_relay", + "type": "address" + }, + { + "internalType": "address", + "name": "_treasury", + "type": "address" + }, + { + "internalType": "address", + "name": "_ecdsaWalletRegistry", + "type": "address" + }, + { + "internalType": "address payable", + "name": "_reimbursementPool", + "type": "address" + }, + { + "internalType": "uint96", + "name": "_txProofDifficultyFactor", + "type": "uint96" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "name": "isVaultTrusted", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "liveWalletsCount", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "requestKey", + "type": "uint256" + } + ], + "name": "movedFundsSweepRequests", + "outputs": [ + { + "components": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "uint64", + "name": "value", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "createdAt", + "type": "uint32" + }, + { + "internalType": "enum MovingFunds.MovedFundsSweepRequestState", + "name": "state", + "type": "uint8" + } + ], + "internalType": "struct MovingFunds.MovedFundsSweepRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "movingFundsParameters", + "outputs": [ + { + "internalType": "uint64", + "name": "movingFundsTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "movingFundsDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeoutResetDelay", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "movingFundsTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeoutNotifierRewardMultiplier", + "type": "uint32" + }, + { + "internalType": "uint16", + "name": "movingFundsCommitmentGasOffset", + "type": "uint16" + }, + { + "internalType": "uint64", + "name": "movedFundsSweepTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "movedFundsSweepTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "movedFundsSweepTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "movedFundsSweepTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "walletPublicKey", + "type": "bytes" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + }, + { + "internalType": "bytes", + "name": "preimageSha256", + "type": "bytes" + } + ], + "name": "notifyFraudChallengeDefeatTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "movingFundsTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "movingFundsTxOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + } + ], + "name": "notifyMovedFundsSweepTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + } + ], + "name": "notifyMovingFundsBelowDust", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + } + ], + "name": "notifyMovingFundsTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + }, + { + "internalType": "bytes", + "name": "redeemerOutputScript", + "type": "bytes" + } + ], + "name": "notifyRedemptionTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "walletMainUtxo", + "type": "tuple" + } + ], + "name": "notifyWalletCloseable", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "notifyWalletClosingPeriodElapsed", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redemptionKey", + "type": "uint256" + } + ], + "name": "pendingRedemptions", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint64", + "name": "requestedAmount", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "treasuryFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "txMaxFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "requestedAt", + "type": "uint32" + } + ], + "internalType": "struct Redemption.RedemptionRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "balanceOwner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "redemptionData", + "type": "bytes" + } + ], + "name": "receiveBalanceApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "redemptionParameters", + "outputs": [ + { + "internalType": "uint64", + "name": "redemptionDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTreasuryFeeDivisor", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTxMaxFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "redemptionTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "redemptionTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "redemptionTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "activeWalletMainUtxo", + "type": "tuple" + } + ], + "name": "requestNewWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "redeemerOutputScript", + "type": "bytes" + }, + { + "internalType": "uint64", + "name": "amount", + "type": "uint64" + } + ], + "name": "requestRedemption", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "resetMovingFundsTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "fundingTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + }, + { + "internalType": "bytes8", + "name": "blindingFactor", + "type": "bytes8" + }, + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "bytes20", + "name": "refundPubKeyHash", + "type": "bytes20" + }, + { + "internalType": "bytes4", + "name": "refundLocktime", + "type": "bytes4" + }, + { + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "internalType": "struct Deposit.DepositRevealInfo", + "name": "reveal", + "type": "tuple" + } + ], + "name": "revealDeposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spvMaintainer", + "type": "address" + }, + { + "internalType": "bool", + "name": "isTrusted", + "type": "bool" + } + ], + "name": "setSpvMaintainerStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "vault", + "type": "address" + }, + { + "internalType": "bool", + "name": "isTrusted", + "type": "bool" + } + ], + "name": "setVaultStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "utxoKey", + "type": "uint256" + } + ], + "name": "spentMainUTXOs", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "sweepTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "merkleProof", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "txIndexInBlock", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "bitcoinHeaders", + "type": "bytes" + } + ], + "internalType": "struct BitcoinTx.Proof", + "name": "sweepProof", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + }, + { + "internalType": "address", + "name": "vault", + "type": "address" + } + ], + "name": "submitDepositSweepProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "walletPublicKey", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "preimageSha256", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + } + ], + "internalType": "struct BitcoinTx.RSVSignature", + "name": "signature", + "type": "tuple" + } + ], + "name": "submitFraudChallenge", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "sweepTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "merkleProof", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "txIndexInBlock", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "bitcoinHeaders", + "type": "bytes" + } + ], + "internalType": "struct BitcoinTx.Proof", + "name": "sweepProof", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + } + ], + "name": "submitMovedFundsSweepProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "walletMainUtxo", + "type": "tuple" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + }, + { + "internalType": "uint256", + "name": "walletMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes20[]", + "name": "targetWallets", + "type": "bytes20[]" + } + ], + "name": "submitMovingFundsCommitment", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "movingFundsTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "merkleProof", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "txIndexInBlock", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "bitcoinHeaders", + "type": "bytes" + } + ], + "internalType": "struct BitcoinTx.Proof", + "name": "movingFundsProof", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + }, + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "submitMovingFundsProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes4", + "name": "version", + "type": "bytes4" + }, + { + "internalType": "bytes", + "name": "inputVector", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "outputVector", + "type": "bytes" + }, + { + "internalType": "bytes4", + "name": "locktime", + "type": "bytes4" + } + ], + "internalType": "struct BitcoinTx.Info", + "name": "redemptionTx", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes", + "name": "merkleProof", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "txIndexInBlock", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "bitcoinHeaders", + "type": "bytes" + } + ], + "internalType": "struct BitcoinTx.Proof", + "name": "redemptionProof", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "bytes32", + "name": "txHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "txOutputIndex", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "txOutputValue", + "type": "uint64" + } + ], + "internalType": "struct BitcoinTx.UTXO", + "name": "mainUtxo", + "type": "tuple" + }, + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "submitRedemptionProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "redemptionKey", + "type": "uint256" + } + ], + "name": "timedOutRedemptions", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "redeemer", + "type": "address" + }, + { + "internalType": "uint64", + "name": "requestedAmount", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "treasuryFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "txMaxFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "requestedAt", + "type": "uint32" + } + ], + "internalType": "struct Redemption.RedemptionRequest", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "treasury", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "txProofDifficultyFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "depositDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "depositTreasuryFeeDivisor", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "depositTxMaxFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "depositRevealAheadPeriod", + "type": "uint32" + } + ], + "name": "updateDepositParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint96", + "name": "fraudChallengeDepositAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "fraudChallengeDefeatTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "fraudSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "fraudNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "updateFraudParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "movingFundsTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "movingFundsDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeoutResetDelay", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "movingFundsTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "movingFundsTimeoutNotifierRewardMultiplier", + "type": "uint32" + }, + { + "internalType": "uint16", + "name": "movingFundsCommitmentGasOffset", + "type": "uint16" + }, + { + "internalType": "uint64", + "name": "movedFundsSweepTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "movedFundsSweepTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "movedFundsSweepTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "movedFundsSweepTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "updateMovingFundsParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "redemptionDustThreshold", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTreasuryFeeDivisor", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTxMaxFee", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "redemptionTxMaxTotalFee", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "redemptionTimeout", + "type": "uint32" + }, + { + "internalType": "uint96", + "name": "redemptionTimeoutSlashingAmount", + "type": "uint96" + }, + { + "internalType": "uint32", + "name": "redemptionTimeoutNotifierRewardMultiplier", + "type": "uint32" + } + ], + "name": "updateRedemptionParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "treasury", + "type": "address" + } + ], + "name": "updateTreasury", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "walletCreationPeriod", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "walletCreationMinBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "walletCreationMaxBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "walletClosureMinBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "walletMaxAge", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "walletMaxBtcTransfer", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "walletClosingPeriod", + "type": "uint32" + } + ], + "name": "updateWalletParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "walletParameters", + "outputs": [ + { + "internalType": "uint32", + "name": "walletCreationPeriod", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "walletCreationMinBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "walletCreationMaxBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "walletClosureMinBtcBalance", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "walletMaxAge", + "type": "uint32" + }, + { + "internalType": "uint64", + "name": "walletMaxBtcTransfer", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "walletClosingPeriod", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes20", + "name": "walletPubKeyHash", + "type": "bytes20" + } + ], + "name": "wallets", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "ecdsaWalletID", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "mainUtxoHash", + "type": "bytes32" + }, + { + "internalType": "uint64", + "name": "pendingRedemptionsValue", + "type": "uint64" + }, + { + "internalType": "uint32", + "name": "createdAt", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "movingFundsRequestedAt", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "closingStartedAt", + "type": "uint32" + }, + { + "internalType": "uint32", + "name": "pendingMovedFundsSweepRequestsCount", + "type": "uint32" + }, + { + "internalType": "enum Wallets.WalletState", + "name": "state", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "movingFundsTargetWalletsCommitmentHash", + "type": "bytes32" + } + ], + "internalType": "struct Wallets.Wallet", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0xa2980d644ed3713ca5ebd545dbd4daee76745ebaff4aca2e4222b859a8400ced", + "receipt": { + "to": "0x16A76d3cd3C1e3CE843C6680d6B37E9116b5C706", + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": null, + "transactionIndex": 144, + "gasUsed": "38748", + "logsBloom": "0x00000000000000000000000000000000400000000000000000000000000000000000000000000000000000000200000000000000000000020000000000000000100000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000001000000000020000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x3042ecc12f13d8a45f547456da41ee726fc960ab5e430bfe1184823d94439094", + "transactionHash": "0xa2980d644ed3713ca5ebd545dbd4daee76745ebaff4aca2e4222b859a8400ced", + "logs": [ + { + "transactionIndex": 144, + "blockNumber": 16399102, + "transactionHash": "0xa2980d644ed3713ca5ebd545dbd4daee76745ebaff4aca2e4222b859a8400ced", + "address": "0x5e4861a80B55f035D899f66772117F00FA0E8e7B", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x0000000000000000000000008d014903bf7867260584d714e11809fea5293234" + ], + "data": "0x", + "logIndex": 167, + "blockHash": "0x3042ecc12f13d8a45f547456da41ee726fc960ab5e430bfe1184823d94439094" + } + ], + "blockNumber": 16399102, + "cumulativeGasUsed": "8682572", + "status": 1, + "byzantium": true + }, + "numDeployments": 2, + "libraries": { + "Deposit": "0x1Ac1841a47054E070236F1664991e52c30C04dC5", + "DepositSweep": "0xE6F919e62c370Ef04EDF4cA5E2a901Ea1aa87085", + "Redemption": "0xfa4FC53BEB5B7721d173342FfC24058e9D47a1Ff", + "Wallets": "0xC67913137429985416DbCe28D9fa9ec960BA47BF", + "Fraud": "0xd040Def4bC6372Cd27b433288008aDCe7c9de71C", + "MovingFunds": "0xB857117ae7639255d7305DdbC7346b4a644CA432" + }, + "implementation": "0x8D014903BF7867260584d714e11809fea5293234", + "devdoc": "Contract deployed as upgradable proxy" +} diff --git a/typescript/src/lib/ethereum/artifacts/mainnet/TBTCToken.json b/typescript/src/lib/ethereum/artifacts/mainnet/TBTCToken.json new file mode 100644 index 000000000..dbb8de123 --- /dev/null +++ b/typescript/src/lib/ethereum/artifacts/mainnet/TBTCToken.json @@ -0,0 +1,762 @@ +{ + "address": "0x18084fbA666a33d37592fA2633fD49a74DD93a88", + "abi": [ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "approveAndCall", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "cachedChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "cachedDomainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "recoverERC721", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0x52538ac60ce0a5672aa77991e9f030ca6eed76db0bf027821ed5170b29971ba2", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x18084fbA666a33d37592fA2633fD49a74DD93a88", + "transactionIndex": 44, + "gasUsed": "2909503", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000040000001000000000000000000020000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x3586b492c74f630a840cbf65b80646da78860364cbdc7976521aee86449a6759", + "transactionHash": "0x52538ac60ce0a5672aa77991e9f030ca6eed76db0bf027821ed5170b29971ba2", + "logs": [ + { + "transactionIndex": 44, + "blockNumber": 13042356, + "transactionHash": "0x52538ac60ce0a5672aa77991e9f030ca6eed76db0bf027821ed5170b29971ba2", + "address": "0x18084fbA666a33d37592fA2633fD49a74DD93a88", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 54, + "blockHash": "0x3586b492c74f630a840cbf65b80646da78860364cbdc7976521aee86449a6759" + } + ], + "blockNumber": 13042356, + "cumulativeGasUsed": "5443048", + "status": 1, + "byzantium": true + }, + "args": [], + "solcInputHash": "7cc3eda3cb3ff2522d18b5e7b31ea228", + "metadata": "{\"compiler\":{\"version\":\"0.8.4+commit.c7e474f2\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"extraData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burnFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cachedChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"cachedDomainSeparator\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC721\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recoverERC721\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"approve(address,uint256)\":{\"details\":\"If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\",\"returns\":{\"_0\":\"True if the operation succeeded.\"}},\"approveAndCall(address,uint256,bytes)\":{\"details\":\"If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.\",\"returns\":{\"_0\":\"True if both approval and `receiveApproval` calls succeeded.\"}},\"burn(uint256)\":{\"details\":\"Requirements: - the caller must have a balance of at least `amount`.\"},\"burnFrom(address,uint256)\":{\"details\":\"Requirements: - `account` must have a balance of at least `amount`, - the caller must have allowance for `account`'s tokens of at least `amount`.\"},\"mint(address,uint256)\":{\"details\":\"Requirements: - `recipient` cannot be the zero address.\"},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"details\":\"The deadline argument can be set to `type(uint256).max to create permits that effectively never expire. If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"transfer(address,uint256)\":{\"details\":\"Requirements: - `recipient` cannot be the zero address, - the caller must have a balance of at least `amount`.\",\"returns\":{\"_0\":\"True if the operation succeeded, reverts otherwise.\"}},\"transferFrom(address,address,uint256)\":{\"details\":\"Requirements: - `sender` and `recipient` cannot be the zero address, - `sender` must have a balance of at least `amount`, - the caller must have allowance for `sender`'s tokens of at least `amount`.\",\"returns\":{\"_0\":\"True if the operation succeeded, reverts otherwise.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"DOMAIN_SEPARATOR()\":{\"notice\":\"Returns hash of EIP712 Domain struct with the token name as a signing domain and token contract as a verifying contract. Used to construct EIP2612 signature provided to `permit` function.\"},\"PERMIT_TYPEHASH()\":{\"notice\":\"Returns EIP2612 Permit message hash. Used to construct EIP2612 signature provided to `permit` function.\"},\"allowance(address,address)\":{\"notice\":\"The remaining number of tokens that spender will be allowed to spend on behalf of owner through `transferFrom` and `burnFrom`. This is zero by default.\"},\"approve(address,uint256)\":{\"notice\":\"Sets `amount` as the allowance of `spender` over the caller's tokens.\"},\"approveAndCall(address,uint256,bytes)\":{\"notice\":\"Calls `receiveApproval` function on spender previously approving the spender to withdraw from the caller multiple times, up to the `amount` amount. If this function is called again, it overwrites the current allowance with `amount`. Reverts if the approval reverted or if `receiveApproval` call on the spender reverted.\"},\"balanceOf(address)\":{\"notice\":\"The amount of tokens owned by the given account.\"},\"burn(uint256)\":{\"notice\":\"Destroys `amount` tokens from the caller.\"},\"burnFrom(address,uint256)\":{\"notice\":\"Destroys `amount` of tokens from `account` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`.\"},\"decimals()\":{\"notice\":\"The decimals places of the token.\"},\"mint(address,uint256)\":{\"notice\":\"Creates `amount` tokens and assigns them to `account`, increasing the total supply.\"},\"name()\":{\"notice\":\"The name of the token.\"},\"nonces(address)\":{\"notice\":\"Returns the current nonce for EIP2612 permission for the provided token owner for a replay protection. Used to construct EIP2612 signature provided to `permit` function.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"notice\":\"EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their tokens with a signature conforming EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, paying gas fees, and possibly performing other actions in the same transaction.\"},\"symbol()\":{\"notice\":\"The symbol of the token.\"},\"totalSupply()\":{\"notice\":\"The amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"notice\":\"Moves `amount` tokens from the caller's account to `recipient`.\"},\"transferFrom(address,address,uint256)\":{\"notice\":\"Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/token/TBTC.sol\":\"TBTC\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _setOwner(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _setOwner(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _setOwner(newOwner);\\n }\\n\\n function _setOwner(address newOwner) private {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x6bb804a310218875e89d12c053e94a13a4607cdf7cc2052f3e52bd32a0dc50a1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address recipient, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address sender,\\n address recipient,\\n uint256 amount\\n ) external returns (bool);\\n\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n}\\n\",\"keccak256\":\"0x027b891937d20ccf213fdb9c31531574256de774bda99d3a70ecef6e1913ed2a\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x83fe24f5c04a56091e50f4a345ff504c8bff658a76d4c43b16878c8f940c53b2\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0x02348b2e4b9f3200c7e3907c5c2661643a6d8520e9f79939fbb9b4005a54894d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n}\\n\",\"keccak256\":\"0xf101e8720213560fab41104d53b3cc7ba0456ef3a98455aa7f022391783144a0\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize, which returns 0 for contracts in\\n // construction, since the code is only stored at the end of the\\n // constructor execution.\\n\\n uint256 size;\\n assembly {\\n size := extcodesize(account)\\n }\\n return size > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return _verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n function _verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) private pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3b4820cac4f127869f6eb496c1d74fa6ac86ed24071e0f94742e6aef20e7252c\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/*\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x95098bd1d9c8dec4d80d3dedb88a0d949fa0d740ee99f2aa466bc308216ca6d5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xa28007762d9da9db878dd421960c8cb9a10471f47ab5c1b3309bfe48e9e79ff4\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonces;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `sender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `sender` and `recipient` cannot be the zero address,\\n /// - `sender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `sender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address sender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[sender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(sender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address sender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(sender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(sender, recipient, amount);\\n\\n uint256 senderBalance = balanceOf[sender];\\n require(senderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[sender] = senderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(sender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x03d73b1cb4915aee716e6245c0bb79335bbe0510cf16a08b2228151eb35d3183\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonces(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xe6ecbd8d29688969b11bedb4ce1d076be09a69c97d31ae89c913734ece5d61fc\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\n/// @title MisfundRecovery\\n/// @notice Allows the owner of the token contract extending MisfundRecovery\\n/// to recover any ERC20 and ERC721 sent mistakenly to the token\\n/// contract address.\\ncontract MisfundRecovery is Ownable {\\n using SafeERC20 for IERC20;\\n\\n function recoverERC20(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n token.safeTransfer(recipient, amount);\\n }\\n\\n function recoverERC721(\\n IERC721 token,\\n address recipient,\\n uint256 tokenId,\\n bytes calldata data\\n ) external onlyOwner {\\n token.safeTransferFrom(address(this), recipient, tokenId, data);\\n }\\n}\\n\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"contracts/token/TBTC.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity 0.8.4;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\\\";\\n\\ncontract TBTC is ERC20WithPermit, MisfundRecovery {\\n constructor() ERC20WithPermit(\\\"tBTC v2\\\", \\\"tBTC\\\") {}\\n}\\n\",\"keccak256\":\"0xc139767d54b9d525f99cee906d2f6ee5b0c049fa97606e39ed88ccc4858c1ad3\",\"license\":\"MIT\"}},\"version\":1}", + "bytecode": "0x60c06040523480156200001157600080fd5b506040518060400160405280600781526020017f74425443207632000000000000000000000000000000000000000000000000008152506040518060400160405280600481526020017f74425443000000000000000000000000000000000000000000000000000000008152506200009e62000092620000f760201b60201c565b620000ff60201b60201c565b8160059080519060200190620000b69291906200026f565b508060069080519060200190620000cf9291906200026f565b504660808181525050620000e8620001c360201b60201c565b60a08181525050505062000520565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6005604051620001f79190620003dd565b60405180910390206040518060400160405280600181526020017f310000000000000000000000000000000000000000000000000000000000000081525080519060200120463060405160200162000254959493929190620003f6565b60405160208183030381529060405280519060200120905090565b8280546200027d90620004bb565b90600052602060002090601f016020900481019282620002a15760008555620002ed565b82601f10620002bc57805160ff1916838001178555620002ed565b82800160010185558215620002ed579182015b82811115620002ec578251825591602001919060010190620002cf565b5b509050620002fc919062000300565b5090565b5b808211156200031b57600081600090555060010162000301565b5090565b6200032a8162000473565b82525050565b6200033b8162000487565b82525050565b600081546200035081620004bb565b6200035c818662000468565b945060018216600081146200037a57600181146200038c57620003c3565b60ff19831686528186019350620003c3565b620003978562000453565b60005b83811015620003bb578154818901526001820191506020810190506200039a565b838801955050505b50505092915050565b620003d781620004b1565b82525050565b6000620003eb828462000341565b915081905092915050565b600060a0820190506200040d600083018862000330565b6200041c602083018762000330565b6200042b604083018662000330565b6200043a6060830185620003cc565b6200044960808301846200031f565b9695505050505050565b60008190508160005260206000209050919050565b600081905092915050565b6000620004808262000491565b9050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60006002820490506001821680620004d457607f821691505b60208210811415620004eb57620004ea620004f1565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60805160a05161324d620005546000396000818161074f0152610c1e0152600081816107270152610a03015261324d6000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c8063771da5c5116100c3578063b4f94b2e1161007c578063b4f94b2e146103b7578063cae9ca51146103d5578063d505accf14610405578063dd62ed3e14610421578063f2fde38b14610451578063fc4e51f61461046d57610158565b8063771da5c5146102e157806379cc6790146102ff5780637ecebe001461031b5780638da5cb5b1461034b57806395d89b4114610369578063a9059cbb1461038757610158565b8063313ce56711610115578063313ce567146102335780633644e5151461025157806340c10f191461026f57806342966c681461028b57806370a08231146102a7578063715018a6146102d757610158565b806306fdde031461015d578063095ea7b31461017b5780631171bda9146101ab57806318160ddd146101c757806323b872dd146101e557806330adf81f14610215575b600080fd5b610165610489565b6040516101729190612796565b60405180910390f35b61019560048036038101906101909190611ef3565b610517565b6040516101a29190612667565b60405180910390f35b6101c560048036038101906101c09190611fbf565b61052e565b005b6101cf6105da565b6040516101dc9190612a18565b60405180910390f35b6101ff60048036038101906101fa9190611e06565b6105e0565b60405161020c9190612667565b60405180910390f35b61021d6106fa565b60405161022a9190612682565b60405180910390f35b61023b61071e565b6040516102489190612a33565b60405180910390f35b610259610723565b6040516102669190612682565b60405180910390f35b61028960048036038101906102849190611ef3565b610783565b005b6102a560048036038101906102a0919061208e565b610954565b005b6102c160048036038101906102bc9190611da1565b610961565b6040516102ce9190612a18565b60405180910390f35b6102df610979565b005b6102e9610a01565b6040516102f69190612a18565b60405180910390f35b61031960048036038101906103149190611ef3565b610a25565b005b61033560048036038101906103309190611da1565b610b36565b6040516103429190612a18565b60405180910390f35b610353610b4e565b6040516103609190612589565b60405180910390f35b610371610b77565b60405161037e9190612796565b60405180910390f35b6103a1600480360381019061039c9190611ef3565b610c05565b6040516103ae9190612667565b60405180910390f35b6103bf610c1c565b6040516103cc9190612682565b60405180910390f35b6103ef60048036038101906103ea9190611f2f565b610c40565b6040516103fc9190612667565b60405180910390f35b61041f600480360381019061041a9190611e55565b610cd7565b005b61043b60048036038101906104369190611dca565b610fbb565b6040516104489190612a18565b60405180910390f35b61046b60048036038101906104669190611da1565b610fe0565b005b6104876004803603810190610482919061200e565b6110d8565b005b6005805461049690612c56565b80601f01602080910402602001604051908101604052809291908181526020018280546104c290612c56565b801561050f5780601f106104e45761010080835404028352916020019161050f565b820191906000526020600020905b8154815290600101906020018083116104f257829003601f168201915b505050505081565b60006105243384846111ce565b6001905092915050565b610536611399565b73ffffffffffffffffffffffffffffffffffffffff16610554610b4e565b73ffffffffffffffffffffffffffffffffffffffff16146105aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105a190612918565b60405180910390fd5b6105d582828573ffffffffffffffffffffffffffffffffffffffff166113a19092919063ffffffff16565b505050565b60045481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146106e357828110156106cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106c3906127f8565b60405180910390fd5b6106e2853385846106dd9190612b5d565b6111ce565b5b6106ee858585611427565b60019150509392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60007f0000000000000000000000000000000000000000000000000000000000000000461415610775577f00000000000000000000000000000000000000000000000000000000000000009050610780565b61077d611718565b90505b90565b61078b611399565b73ffffffffffffffffffffffffffffffffffffffff166107a9610b4e565b73ffffffffffffffffffffffffffffffffffffffff16146107ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107f690612918565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561086f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086690612998565b60405180910390fd5b61087b600083836117c0565b806004600082825461088d9190612b07565b9250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546108e39190612b07565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516109489190612a18565b60405180910390a35050565b61095e33826117c5565b50565b60016020528060005260406000206000915090505481565b610981611399565b73ffffffffffffffffffffffffffffffffffffffff1661099f610b4e565b73ffffffffffffffffffffffffffffffffffffffff16146109f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ec90612918565b60405180910390fd5b6109ff600061192b565b565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610b275781811015610b10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b07906128b8565b60405180910390fd5b610b2683338484610b219190612b5d565b6111ce565b5b610b3183836117c5565b505050565b60036020528060005260406000206000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60068054610b8490612c56565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb090612c56565b8015610bfd5780601f10610bd257610100808354040283529160200191610bfd565b820191906000526020600020905b815481529060010190602001808311610be057829003601f168201915b505050505081565b6000610c12338484611427565b6001905092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000610c4c8484610517565b15610ccb578373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b8152600401610c90949392919061261b565b600060405180830381600087803b158015610caa57600080fd5b505af1158015610cbe573d6000803e3d6000fd5b5050505060019050610cd0565b600090505b9392505050565b42841015610d1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1190612938565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c1115610d80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7790612978565b60405180910390fd5b601b8360ff161480610d955750601c8360ff16145b610dd4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dcb90612818565b60405180910390fd5b6000610dde610723565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9898989600360008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610e5290612cb9565b919050558a604051602001610e6c9695949392919061269d565b60405160208183030381529060405280519060200120604051602001610e93929190612552565b604051602081830303815290604052805190602001209050600060018286868660405160008152602001604052604051610ed09493929190612751565b6020604051602081039080840390855afa158015610ef2573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015610f6657508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610fa5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9c90612858565b60405180910390fd5b610fb08989896111ce565b505050505050505050565b6002602052816000526040600020602052806000526040600020600091509150505481565b610fe8611399565b73ffffffffffffffffffffffffffffffffffffffff16611006610b4e565b73ffffffffffffffffffffffffffffffffffffffff161461105c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105390612918565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110c3906127d8565b60405180910390fd5b6110d58161192b565b50565b6110e0611399565b73ffffffffffffffffffffffffffffffffffffffff166110fe610b4e565b73ffffffffffffffffffffffffffffffffffffffff1614611154576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114b90612918565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff1663b88d4fde30868686866040518663ffffffff1660e01b81526004016111959594939291906125a4565b600060405180830381600087803b1580156111af57600080fd5b505af11580156111c3573d6000803e3d6000fd5b505050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561123e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123590612898565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a5906127b8565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161138c9190612a18565b60405180910390a3505050565b600033905090565b6114228363a9059cbb60e01b84846040516024016113c09291906125f2565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506119ef565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611497576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161148e906129f8565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611507576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114fe906129d8565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611576576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161156d90612838565b60405180910390fd5b6115818383836117c0565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611608576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ff906128d8565b60405180910390fd5b81816116149190612b5d565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546116a69190612b07565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161170a9190612a18565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600560405161174a919061253b565b60405180910390206040518060400160405280600181526020017f31000000000000000000000000000000000000000000000000000000000000008152508051906020012046306040516020016117a59594939291906126fe565b60405160208183030381529060405280519060200120905090565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561184c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611843906128f8565b60405180910390fd5b611858836000846117c0565b81816118649190612b5d565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600460008282546118b99190612b5d565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161191e9190612a18565b60405180910390a3505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000611a51826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611ab69092919063ffffffff16565b9050600081511115611ab15780806020019051810190611a719190611f96565b611ab0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aa7906129b8565b60405180910390fd5b5b505050565b6060611ac58484600085611ace565b90509392505050565b606082471015611b13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b0a90612878565b60405180910390fd5b611b1c85611be2565b611b5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b5290612958565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611b849190612524565b60006040518083038185875af1925050503d8060008114611bc1576040519150601f19603f3d011682016040523d82523d6000602084013e611bc6565b606091505b5091509150611bd6828286611bf5565b92505050949350505050565b600080823b905060008111915050919050565b60608315611c0557829050611c55565b600083511115611c185782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c4c9190612796565b60405180910390fd5b9392505050565b6000611c6f611c6a84612a73565b612a4e565b905082815260208101848484011115611c8757600080fd5b611c92848285612c14565b509392505050565b600081359050611ca981613176565b92915050565b600081519050611cbe8161318d565b92915050565b600081359050611cd3816131a4565b92915050565b60008083601f840112611ceb57600080fd5b8235905067ffffffffffffffff811115611d0457600080fd5b602083019150836001820283011115611d1c57600080fd5b9250929050565b600082601f830112611d3457600080fd5b8135611d44848260208601611c5c565b91505092915050565b600081359050611d5c816131bb565b92915050565b600081359050611d71816131d2565b92915050565b600081359050611d86816131e9565b92915050565b600081359050611d9b81613200565b92915050565b600060208284031215611db357600080fd5b6000611dc184828501611c9a565b91505092915050565b60008060408385031215611ddd57600080fd5b6000611deb85828601611c9a565b9250506020611dfc85828601611c9a565b9150509250929050565b600080600060608486031215611e1b57600080fd5b6000611e2986828701611c9a565b9350506020611e3a86828701611c9a565b9250506040611e4b86828701611d77565b9150509250925092565b600080600080600080600060e0888a031215611e7057600080fd5b6000611e7e8a828b01611c9a565b9750506020611e8f8a828b01611c9a565b9650506040611ea08a828b01611d77565b9550506060611eb18a828b01611d77565b9450506080611ec28a828b01611d8c565b93505060a0611ed38a828b01611cc4565b92505060c0611ee48a828b01611cc4565b91505092959891949750929550565b60008060408385031215611f0657600080fd5b6000611f1485828601611c9a565b9250506020611f2585828601611d77565b9150509250929050565b600080600060608486031215611f4457600080fd5b6000611f5286828701611c9a565b9350506020611f6386828701611d77565b925050604084013567ffffffffffffffff811115611f8057600080fd5b611f8c86828701611d23565b9150509250925092565b600060208284031215611fa857600080fd5b6000611fb684828501611caf565b91505092915050565b600080600060608486031215611fd457600080fd5b6000611fe286828701611d4d565b9350506020611ff386828701611c9a565b925050604061200486828701611d77565b9150509250925092565b60008060008060006080868803121561202657600080fd5b600061203488828901611d62565b955050602061204588828901611c9a565b945050604061205688828901611d77565b935050606086013567ffffffffffffffff81111561207357600080fd5b61207f88828901611cd9565b92509250509295509295909350565b6000602082840312156120a057600080fd5b60006120ae84828501611d77565b91505092915050565b6120c081612b91565b82525050565b6120cf81612ba3565b82525050565b6120de81612baf565b82525050565b6120f56120f082612baf565b612d02565b82525050565b60006121078385612acf565b9350612114838584612c14565b61211d83612d99565b840190509392505050565b600061213382612ab9565b61213d8185612acf565b935061214d818560208601612c23565b61215681612d99565b840191505092915050565b600061216c82612ab9565b6121768185612ae0565b9350612186818560208601612c23565b80840191505092915050565b6000815461219f81612c56565b6121a98186612ae0565b945060018216600081146121c457600181146121d557612208565b60ff19831686528186019350612208565b6121de85612aa4565b60005b83811015612200578154818901526001820191506020810190506121e1565b838801955050505b50505092915050565b600061221c82612ac4565b6122268185612aeb565b9350612236818560208601612c23565b61223f81612d99565b840191505092915050565b6000612257601b83612aeb565b915061226282612daa565b602082019050919050565b600061227a602683612aeb565b915061228582612dd3565b604082019050919050565b600061229d602183612aeb565b91506122a882612e22565b604082019050919050565b60006122c0600283612afc565b91506122cb82612e71565b600282019050919050565b60006122e3601b83612aeb565b91506122ee82612e9a565b602082019050919050565b6000612306601d83612aeb565b915061231182612ec3565b602082019050919050565b6000612329601183612aeb565b915061233482612eec565b602082019050919050565b600061234c602683612aeb565b915061235782612f15565b604082019050919050565b600061236f601d83612aeb565b915061237a82612f64565b602082019050919050565b6000612392601d83612aeb565b915061239d82612f8d565b602082019050919050565b60006123b5601f83612aeb565b91506123c082612fb6565b602082019050919050565b60006123d8601b83612aeb565b91506123e382612fdf565b602082019050919050565b60006123fb602083612aeb565b915061240682613008565b602082019050919050565b600061241e601283612aeb565b915061242982613031565b602082019050919050565b6000612441601d83612aeb565b915061244c8261305a565b602082019050919050565b6000612464601b83612aeb565b915061246f82613083565b602082019050919050565b6000612487601883612aeb565b9150612492826130ac565b602082019050919050565b60006124aa602a83612aeb565b91506124b5826130d5565b604082019050919050565b60006124cd601c83612aeb565b91506124d882613124565b602082019050919050565b60006124f0601e83612aeb565b91506124fb8261314d565b602082019050919050565b61250f81612bfd565b82525050565b61251e81612c07565b82525050565b60006125308284612161565b915081905092915050565b60006125478284612192565b915081905092915050565b600061255d826122b3565b915061256982856120e4565b60208201915061257982846120e4565b6020820191508190509392505050565b600060208201905061259e60008301846120b7565b92915050565b60006080820190506125b960008301886120b7565b6125c660208301876120b7565b6125d36040830186612506565b81810360608301526125e68184866120fb565b90509695505050505050565b600060408201905061260760008301856120b7565b6126146020830184612506565b9392505050565b600060808201905061263060008301876120b7565b61263d6020830186612506565b61264a60408301856120b7565b818103606083015261265c8184612128565b905095945050505050565b600060208201905061267c60008301846120c6565b92915050565b600060208201905061269760008301846120d5565b92915050565b600060c0820190506126b260008301896120d5565b6126bf60208301886120b7565b6126cc60408301876120b7565b6126d96060830186612506565b6126e66080830185612506565b6126f360a0830184612506565b979650505050505050565b600060a08201905061271360008301886120d5565b61272060208301876120d5565b61272d60408301866120d5565b61273a6060830185612506565b61274760808301846120b7565b9695505050505050565b600060808201905061276660008301876120d5565b6127736020830186612515565b61278060408301856120d5565b61278d60608301846120d5565b95945050505050565b600060208201905081810360008301526127b08184612211565b905092915050565b600060208201905081810360008301526127d18161224a565b9050919050565b600060208201905081810360008301526127f18161226d565b9050919050565b6000602082019050818103600083015261281181612290565b9050919050565b60006020820190508181036000830152612831816122d6565b9050919050565b60006020820190508181036000830152612851816122f9565b9050919050565b600060208201905081810360008301526128718161231c565b9050919050565b600060208201905081810360008301526128918161233f565b9050919050565b600060208201905081810360008301526128b181612362565b9050919050565b600060208201905081810360008301526128d181612385565b9050919050565b600060208201905081810360008301526128f1816123a8565b9050919050565b60006020820190508181036000830152612911816123cb565b9050919050565b60006020820190508181036000830152612931816123ee565b9050919050565b6000602082019050818103600083015261295181612411565b9050919050565b6000602082019050818103600083015261297181612434565b9050919050565b6000602082019050818103600083015261299181612457565b9050919050565b600060208201905081810360008301526129b18161247a565b9050919050565b600060208201905081810360008301526129d18161249d565b9050919050565b600060208201905081810360008301526129f1816124c0565b9050919050565b60006020820190508181036000830152612a11816124e3565b9050919050565b6000602082019050612a2d6000830184612506565b92915050565b6000602082019050612a486000830184612515565b92915050565b6000612a58612a69565b9050612a648282612c88565b919050565b6000604051905090565b600067ffffffffffffffff821115612a8e57612a8d612d6a565b5b612a9782612d99565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000612b1282612bfd565b9150612b1d83612bfd565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612b5257612b51612d0c565b5b828201905092915050565b6000612b6882612bfd565b9150612b7383612bfd565b925082821015612b8657612b85612d0c565b5b828203905092915050565b6000612b9c82612bdd565b9050919050565b60008115159050919050565b6000819050919050565b6000612bc482612b91565b9050919050565b6000612bd682612b91565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015612c41578082015181840152602081019050612c26565b83811115612c50576000848401525b50505050565b60006002820490506001821680612c6e57607f821691505b60208210811415612c8257612c81612d3b565b5b50919050565b612c9182612d99565b810181811067ffffffffffffffff82111715612cb057612caf612d6a565b5b80604052505050565b6000612cc482612bfd565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612cf757612cf6612d0c565b5b600182019050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f417070726f766520746f20746865207a65726f20616464726573730000000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360008201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b7f496e76616c6964207369676e6174757265202776272076616c75650000000000600082015250565b7f5472616e7366657220746f2074686520746f6b656e2061646472657373000000600082015250565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f417070726f76652066726f6d20746865207a65726f2061646472657373000000600082015250565b7f4275726e20616d6f756e74206578636565647320616c6c6f77616e6365000000600082015250565b7f5472616e7366657220616d6f756e7420657863656564732062616c616e636500600082015250565b7f4275726e20616d6f756e7420657863656564732062616c616e63650000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5065726d697373696f6e20657870697265640000000000000000000000000000600082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f496e76616c6964207369676e6174757265202773272076616c75650000000000600082015250565b7f4d696e7420746f20746865207a65726f20616464726573730000000000000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f5472616e7366657220746f20746865207a65726f206164647265737300000000600082015250565b7f5472616e736665722066726f6d20746865207a65726f20616464726573730000600082015250565b61317f81612b91565b811461318a57600080fd5b50565b61319681612ba3565b81146131a157600080fd5b50565b6131ad81612baf565b81146131b857600080fd5b50565b6131c481612bb9565b81146131cf57600080fd5b50565b6131db81612bcb565b81146131e657600080fd5b50565b6131f281612bfd565b81146131fd57600080fd5b50565b61320981612c07565b811461321457600080fd5b5056fea2646970667358221220b66e3ef21ffde9263f6eb3247e39c2adf91afb2daa59dd552c43bf8eace893db64736f6c63430008040033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101585760003560e01c8063771da5c5116100c3578063b4f94b2e1161007c578063b4f94b2e146103b7578063cae9ca51146103d5578063d505accf14610405578063dd62ed3e14610421578063f2fde38b14610451578063fc4e51f61461046d57610158565b8063771da5c5146102e157806379cc6790146102ff5780637ecebe001461031b5780638da5cb5b1461034b57806395d89b4114610369578063a9059cbb1461038757610158565b8063313ce56711610115578063313ce567146102335780633644e5151461025157806340c10f191461026f57806342966c681461028b57806370a08231146102a7578063715018a6146102d757610158565b806306fdde031461015d578063095ea7b31461017b5780631171bda9146101ab57806318160ddd146101c757806323b872dd146101e557806330adf81f14610215575b600080fd5b610165610489565b6040516101729190612796565b60405180910390f35b61019560048036038101906101909190611ef3565b610517565b6040516101a29190612667565b60405180910390f35b6101c560048036038101906101c09190611fbf565b61052e565b005b6101cf6105da565b6040516101dc9190612a18565b60405180910390f35b6101ff60048036038101906101fa9190611e06565b6105e0565b60405161020c9190612667565b60405180910390f35b61021d6106fa565b60405161022a9190612682565b60405180910390f35b61023b61071e565b6040516102489190612a33565b60405180910390f35b610259610723565b6040516102669190612682565b60405180910390f35b61028960048036038101906102849190611ef3565b610783565b005b6102a560048036038101906102a0919061208e565b610954565b005b6102c160048036038101906102bc9190611da1565b610961565b6040516102ce9190612a18565b60405180910390f35b6102df610979565b005b6102e9610a01565b6040516102f69190612a18565b60405180910390f35b61031960048036038101906103149190611ef3565b610a25565b005b61033560048036038101906103309190611da1565b610b36565b6040516103429190612a18565b60405180910390f35b610353610b4e565b6040516103609190612589565b60405180910390f35b610371610b77565b60405161037e9190612796565b60405180910390f35b6103a1600480360381019061039c9190611ef3565b610c05565b6040516103ae9190612667565b60405180910390f35b6103bf610c1c565b6040516103cc9190612682565b60405180910390f35b6103ef60048036038101906103ea9190611f2f565b610c40565b6040516103fc9190612667565b60405180910390f35b61041f600480360381019061041a9190611e55565b610cd7565b005b61043b60048036038101906104369190611dca565b610fbb565b6040516104489190612a18565b60405180910390f35b61046b60048036038101906104669190611da1565b610fe0565b005b6104876004803603810190610482919061200e565b6110d8565b005b6005805461049690612c56565b80601f01602080910402602001604051908101604052809291908181526020018280546104c290612c56565b801561050f5780601f106104e45761010080835404028352916020019161050f565b820191906000526020600020905b8154815290600101906020018083116104f257829003601f168201915b505050505081565b60006105243384846111ce565b6001905092915050565b610536611399565b73ffffffffffffffffffffffffffffffffffffffff16610554610b4e565b73ffffffffffffffffffffffffffffffffffffffff16146105aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105a190612918565b60405180910390fd5b6105d582828573ffffffffffffffffffffffffffffffffffffffff166113a19092919063ffffffff16565b505050565b60045481565b600080600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146106e357828110156106cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106c3906127f8565b60405180910390fd5b6106e2853385846106dd9190612b5d565b6111ce565b5b6106ee858585611427565b60019150509392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60007f0000000000000000000000000000000000000000000000000000000000000000461415610775577f00000000000000000000000000000000000000000000000000000000000000009050610780565b61077d611718565b90505b90565b61078b611399565b73ffffffffffffffffffffffffffffffffffffffff166107a9610b4e565b73ffffffffffffffffffffffffffffffffffffffff16146107ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107f690612918565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561086f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086690612998565b60405180910390fd5b61087b600083836117c0565b806004600082825461088d9190612b07565b9250508190555080600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546108e39190612b07565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516109489190612a18565b60405180910390a35050565b61095e33826117c5565b50565b60016020528060005260406000206000915090505481565b610981611399565b73ffffffffffffffffffffffffffffffffffffffff1661099f610b4e565b73ffffffffffffffffffffffffffffffffffffffff16146109f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ec90612918565b60405180910390fd5b6109ff600061192b565b565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610b275781811015610b10576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b07906128b8565b60405180910390fd5b610b2683338484610b219190612b5d565b6111ce565b5b610b3183836117c5565b505050565b60036020528060005260406000206000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60068054610b8490612c56565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb090612c56565b8015610bfd5780601f10610bd257610100808354040283529160200191610bfd565b820191906000526020600020905b815481529060010190602001808311610be057829003601f168201915b505050505081565b6000610c12338484611427565b6001905092915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000610c4c8484610517565b15610ccb578373ffffffffffffffffffffffffffffffffffffffff16638f4ffcb1338530866040518563ffffffff1660e01b8152600401610c90949392919061261b565b600060405180830381600087803b158015610caa57600080fd5b505af1158015610cbe573d6000803e3d6000fd5b5050505060019050610cd0565b600090505b9392505050565b42841015610d1a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d1190612938565b60405180910390fd5b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08160001c1115610d80576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7790612978565b60405180910390fd5b601b8360ff161480610d955750601c8360ff16145b610dd4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dcb90612818565b60405180910390fd5b6000610dde610723565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9898989600360008e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610e5290612cb9565b919050558a604051602001610e6c9695949392919061269d565b60405160208183030381529060405280519060200120604051602001610e93929190612552565b604051602081830303815290604052805190602001209050600060018286868660405160008152602001604052604051610ed09493929190612751565b6020604051602081039080840390855afa158015610ef2573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015610f6657508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610fa5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9c90612858565b60405180910390fd5b610fb08989896111ce565b505050505050505050565b6002602052816000526040600020602052806000526040600020600091509150505481565b610fe8611399565b73ffffffffffffffffffffffffffffffffffffffff16611006610b4e565b73ffffffffffffffffffffffffffffffffffffffff161461105c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161105390612918565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156110cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110c3906127d8565b60405180910390fd5b6110d58161192b565b50565b6110e0611399565b73ffffffffffffffffffffffffffffffffffffffff166110fe610b4e565b73ffffffffffffffffffffffffffffffffffffffff1614611154576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161114b90612918565b60405180910390fd5b8473ffffffffffffffffffffffffffffffffffffffff1663b88d4fde30868686866040518663ffffffff1660e01b81526004016111959594939291906125a4565b600060405180830381600087803b1580156111af57600080fd5b505af11580156111c3573d6000803e3d6000fd5b505050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141561123e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161123590612898565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156112ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112a5906127b8565b60405180910390fd5b80600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161138c9190612a18565b60405180910390a3505050565b600033905090565b6114228363a9059cbb60e01b84846040516024016113c09291906125f2565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506119ef565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611497576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161148e906129f8565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611507576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114fe906129d8565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611576576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161156d90612838565b60405180910390fd5b6115818383836117c0565b6000600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611608576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115ff906128d8565b60405180910390fd5b81816116149190612b5d565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546116a69190612b07565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161170a9190612a18565b60405180910390a350505050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f600560405161174a919061253b565b60405180910390206040518060400160405280600181526020017f31000000000000000000000000000000000000000000000000000000000000008152508051906020012046306040516020016117a59594939291906126fe565b60405160208183030381529060405280519060200120905090565b505050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205490508181101561184c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611843906128f8565b60405180910390fd5b611858836000846117c0565b81816118649190612b5d565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600460008282546118b99190612b5d565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8460405161191e9190612a18565b60405180910390a3505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000611a51826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611ab69092919063ffffffff16565b9050600081511115611ab15780806020019051810190611a719190611f96565b611ab0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aa7906129b8565b60405180910390fd5b5b505050565b6060611ac58484600085611ace565b90509392505050565b606082471015611b13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b0a90612878565b60405180910390fd5b611b1c85611be2565b611b5b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b5290612958565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611b849190612524565b60006040518083038185875af1925050503d8060008114611bc1576040519150601f19603f3d011682016040523d82523d6000602084013e611bc6565b606091505b5091509150611bd6828286611bf5565b92505050949350505050565b600080823b905060008111915050919050565b60608315611c0557829050611c55565b600083511115611c185782518084602001fd5b816040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c4c9190612796565b60405180910390fd5b9392505050565b6000611c6f611c6a84612a73565b612a4e565b905082815260208101848484011115611c8757600080fd5b611c92848285612c14565b509392505050565b600081359050611ca981613176565b92915050565b600081519050611cbe8161318d565b92915050565b600081359050611cd3816131a4565b92915050565b60008083601f840112611ceb57600080fd5b8235905067ffffffffffffffff811115611d0457600080fd5b602083019150836001820283011115611d1c57600080fd5b9250929050565b600082601f830112611d3457600080fd5b8135611d44848260208601611c5c565b91505092915050565b600081359050611d5c816131bb565b92915050565b600081359050611d71816131d2565b92915050565b600081359050611d86816131e9565b92915050565b600081359050611d9b81613200565b92915050565b600060208284031215611db357600080fd5b6000611dc184828501611c9a565b91505092915050565b60008060408385031215611ddd57600080fd5b6000611deb85828601611c9a565b9250506020611dfc85828601611c9a565b9150509250929050565b600080600060608486031215611e1b57600080fd5b6000611e2986828701611c9a565b9350506020611e3a86828701611c9a565b9250506040611e4b86828701611d77565b9150509250925092565b600080600080600080600060e0888a031215611e7057600080fd5b6000611e7e8a828b01611c9a565b9750506020611e8f8a828b01611c9a565b9650506040611ea08a828b01611d77565b9550506060611eb18a828b01611d77565b9450506080611ec28a828b01611d8c565b93505060a0611ed38a828b01611cc4565b92505060c0611ee48a828b01611cc4565b91505092959891949750929550565b60008060408385031215611f0657600080fd5b6000611f1485828601611c9a565b9250506020611f2585828601611d77565b9150509250929050565b600080600060608486031215611f4457600080fd5b6000611f5286828701611c9a565b9350506020611f6386828701611d77565b925050604084013567ffffffffffffffff811115611f8057600080fd5b611f8c86828701611d23565b9150509250925092565b600060208284031215611fa857600080fd5b6000611fb684828501611caf565b91505092915050565b600080600060608486031215611fd457600080fd5b6000611fe286828701611d4d565b9350506020611ff386828701611c9a565b925050604061200486828701611d77565b9150509250925092565b60008060008060006080868803121561202657600080fd5b600061203488828901611d62565b955050602061204588828901611c9a565b945050604061205688828901611d77565b935050606086013567ffffffffffffffff81111561207357600080fd5b61207f88828901611cd9565b92509250509295509295909350565b6000602082840312156120a057600080fd5b60006120ae84828501611d77565b91505092915050565b6120c081612b91565b82525050565b6120cf81612ba3565b82525050565b6120de81612baf565b82525050565b6120f56120f082612baf565b612d02565b82525050565b60006121078385612acf565b9350612114838584612c14565b61211d83612d99565b840190509392505050565b600061213382612ab9565b61213d8185612acf565b935061214d818560208601612c23565b61215681612d99565b840191505092915050565b600061216c82612ab9565b6121768185612ae0565b9350612186818560208601612c23565b80840191505092915050565b6000815461219f81612c56565b6121a98186612ae0565b945060018216600081146121c457600181146121d557612208565b60ff19831686528186019350612208565b6121de85612aa4565b60005b83811015612200578154818901526001820191506020810190506121e1565b838801955050505b50505092915050565b600061221c82612ac4565b6122268185612aeb565b9350612236818560208601612c23565b61223f81612d99565b840191505092915050565b6000612257601b83612aeb565b915061226282612daa565b602082019050919050565b600061227a602683612aeb565b915061228582612dd3565b604082019050919050565b600061229d602183612aeb565b91506122a882612e22565b604082019050919050565b60006122c0600283612afc565b91506122cb82612e71565b600282019050919050565b60006122e3601b83612aeb565b91506122ee82612e9a565b602082019050919050565b6000612306601d83612aeb565b915061231182612ec3565b602082019050919050565b6000612329601183612aeb565b915061233482612eec565b602082019050919050565b600061234c602683612aeb565b915061235782612f15565b604082019050919050565b600061236f601d83612aeb565b915061237a82612f64565b602082019050919050565b6000612392601d83612aeb565b915061239d82612f8d565b602082019050919050565b60006123b5601f83612aeb565b91506123c082612fb6565b602082019050919050565b60006123d8601b83612aeb565b91506123e382612fdf565b602082019050919050565b60006123fb602083612aeb565b915061240682613008565b602082019050919050565b600061241e601283612aeb565b915061242982613031565b602082019050919050565b6000612441601d83612aeb565b915061244c8261305a565b602082019050919050565b6000612464601b83612aeb565b915061246f82613083565b602082019050919050565b6000612487601883612aeb565b9150612492826130ac565b602082019050919050565b60006124aa602a83612aeb565b91506124b5826130d5565b604082019050919050565b60006124cd601c83612aeb565b91506124d882613124565b602082019050919050565b60006124f0601e83612aeb565b91506124fb8261314d565b602082019050919050565b61250f81612bfd565b82525050565b61251e81612c07565b82525050565b60006125308284612161565b915081905092915050565b60006125478284612192565b915081905092915050565b600061255d826122b3565b915061256982856120e4565b60208201915061257982846120e4565b6020820191508190509392505050565b600060208201905061259e60008301846120b7565b92915050565b60006080820190506125b960008301886120b7565b6125c660208301876120b7565b6125d36040830186612506565b81810360608301526125e68184866120fb565b90509695505050505050565b600060408201905061260760008301856120b7565b6126146020830184612506565b9392505050565b600060808201905061263060008301876120b7565b61263d6020830186612506565b61264a60408301856120b7565b818103606083015261265c8184612128565b905095945050505050565b600060208201905061267c60008301846120c6565b92915050565b600060208201905061269760008301846120d5565b92915050565b600060c0820190506126b260008301896120d5565b6126bf60208301886120b7565b6126cc60408301876120b7565b6126d96060830186612506565b6126e66080830185612506565b6126f360a0830184612506565b979650505050505050565b600060a08201905061271360008301886120d5565b61272060208301876120d5565b61272d60408301866120d5565b61273a6060830185612506565b61274760808301846120b7565b9695505050505050565b600060808201905061276660008301876120d5565b6127736020830186612515565b61278060408301856120d5565b61278d60608301846120d5565b95945050505050565b600060208201905081810360008301526127b08184612211565b905092915050565b600060208201905081810360008301526127d18161224a565b9050919050565b600060208201905081810360008301526127f18161226d565b9050919050565b6000602082019050818103600083015261281181612290565b9050919050565b60006020820190508181036000830152612831816122d6565b9050919050565b60006020820190508181036000830152612851816122f9565b9050919050565b600060208201905081810360008301526128718161231c565b9050919050565b600060208201905081810360008301526128918161233f565b9050919050565b600060208201905081810360008301526128b181612362565b9050919050565b600060208201905081810360008301526128d181612385565b9050919050565b600060208201905081810360008301526128f1816123a8565b9050919050565b60006020820190508181036000830152612911816123cb565b9050919050565b60006020820190508181036000830152612931816123ee565b9050919050565b6000602082019050818103600083015261295181612411565b9050919050565b6000602082019050818103600083015261297181612434565b9050919050565b6000602082019050818103600083015261299181612457565b9050919050565b600060208201905081810360008301526129b18161247a565b9050919050565b600060208201905081810360008301526129d18161249d565b9050919050565b600060208201905081810360008301526129f1816124c0565b9050919050565b60006020820190508181036000830152612a11816124e3565b9050919050565b6000602082019050612a2d6000830184612506565b92915050565b6000602082019050612a486000830184612515565b92915050565b6000612a58612a69565b9050612a648282612c88565b919050565b6000604051905090565b600067ffffffffffffffff821115612a8e57612a8d612d6a565b5b612a9782612d99565b9050602081019050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000612b1282612bfd565b9150612b1d83612bfd565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115612b5257612b51612d0c565b5b828201905092915050565b6000612b6882612bfd565b9150612b7383612bfd565b925082821015612b8657612b85612d0c565b5b828203905092915050565b6000612b9c82612bdd565b9050919050565b60008115159050919050565b6000819050919050565b6000612bc482612b91565b9050919050565b6000612bd682612b91565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b82818337600083830152505050565b60005b83811015612c41578082015181840152602081019050612c26565b83811115612c50576000848401525b50505050565b60006002820490506001821680612c6e57607f821691505b60208210811415612c8257612c81612d3b565b5b50919050565b612c9182612d99565b810181811067ffffffffffffffff82111715612cb057612caf612d6a565b5b80604052505050565b6000612cc482612bfd565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612cf757612cf6612d0c565b5b600182019050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f417070726f766520746f20746865207a65726f20616464726573730000000000600082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f5472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6360008201527f6500000000000000000000000000000000000000000000000000000000000000602082015250565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b7f496e76616c6964207369676e6174757265202776272076616c75650000000000600082015250565b7f5472616e7366657220746f2074686520746f6b656e2061646472657373000000600082015250565b7f496e76616c6964207369676e6174757265000000000000000000000000000000600082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f417070726f76652066726f6d20746865207a65726f2061646472657373000000600082015250565b7f4275726e20616d6f756e74206578636565647320616c6c6f77616e6365000000600082015250565b7f5472616e7366657220616d6f756e7420657863656564732062616c616e636500600082015250565b7f4275726e20616d6f756e7420657863656564732062616c616e63650000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f5065726d697373696f6e20657870697265640000000000000000000000000000600082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f496e76616c6964207369676e6174757265202773272076616c75650000000000600082015250565b7f4d696e7420746f20746865207a65726f20616464726573730000000000000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f5472616e7366657220746f20746865207a65726f206164647265737300000000600082015250565b7f5472616e736665722066726f6d20746865207a65726f20616464726573730000600082015250565b61317f81612b91565b811461318a57600080fd5b50565b61319681612ba3565b81146131a157600080fd5b50565b6131ad81612baf565b81146131b857600080fd5b50565b6131c481612bb9565b81146131cf57600080fd5b50565b6131db81612bcb565b81146131e657600080fd5b50565b6131f281612bfd565b81146131fd57600080fd5b50565b61320981612c07565b811461321457600080fd5b5056fea2646970667358221220b66e3ef21ffde9263f6eb3247e39c2adf91afb2daa59dd552c43bf8eace893db64736f6c63430008040033", + "devdoc": { + "kind": "dev", + "methods": { + "approve(address,uint256)": { + "details": "If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729", + "returns": { + "_0": "True if the operation succeeded." + } + }, + "approveAndCall(address,uint256,bytes)": { + "details": "If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance.", + "returns": { + "_0": "True if both approval and `receiveApproval` calls succeeded." + } + }, + "burn(uint256)": { + "details": "Requirements: - the caller must have a balance of at least `amount`." + }, + "burnFrom(address,uint256)": { + "details": "Requirements: - `account` must have a balance of at least `amount`, - the caller must have allowance for `account`'s tokens of at least `amount`." + }, + "mint(address,uint256)": { + "details": "Requirements: - `recipient` cannot be the zero address." + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": { + "details": "The deadline argument can be set to `type(uint256).max to create permits that effectively never expire. If the `amount` is set to `type(uint256).max` then `transferFrom` and `burnFrom` will not reduce an allowance." + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "transfer(address,uint256)": { + "details": "Requirements: - `recipient` cannot be the zero address, - the caller must have a balance of at least `amount`.", + "returns": { + "_0": "True if the operation succeeded, reverts otherwise." + } + }, + "transferFrom(address,address,uint256)": { + "details": "Requirements: - `sender` and `recipient` cannot be the zero address, - `sender` must have a balance of at least `amount`, - the caller must have allowance for `sender`'s tokens of at least `amount`.", + "returns": { + "_0": "True if the operation succeeded, reverts otherwise." + } + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "DOMAIN_SEPARATOR()": { + "notice": "Returns hash of EIP712 Domain struct with the token name as a signing domain and token contract as a verifying contract. Used to construct EIP2612 signature provided to `permit` function." + }, + "PERMIT_TYPEHASH()": { + "notice": "Returns EIP2612 Permit message hash. Used to construct EIP2612 signature provided to `permit` function." + }, + "allowance(address,address)": { + "notice": "The remaining number of tokens that spender will be allowed to spend on behalf of owner through `transferFrom` and `burnFrom`. This is zero by default." + }, + "approve(address,uint256)": { + "notice": "Sets `amount` as the allowance of `spender` over the caller's tokens." + }, + "approveAndCall(address,uint256,bytes)": { + "notice": "Calls `receiveApproval` function on spender previously approving the spender to withdraw from the caller multiple times, up to the `amount` amount. If this function is called again, it overwrites the current allowance with `amount`. Reverts if the approval reverted or if `receiveApproval` call on the spender reverted." + }, + "balanceOf(address)": { + "notice": "The amount of tokens owned by the given account." + }, + "burn(uint256)": { + "notice": "Destroys `amount` tokens from the caller." + }, + "burnFrom(address,uint256)": { + "notice": "Destroys `amount` of tokens from `account` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`." + }, + "decimals()": { + "notice": "The decimals places of the token." + }, + "mint(address,uint256)": { + "notice": "Creates `amount` tokens and assigns them to `account`, increasing the total supply." + }, + "name()": { + "notice": "The name of the token." + }, + "nonces(address)": { + "notice": "Returns the current nonce for EIP2612 permission for the provided token owner for a replay protection. Used to construct EIP2612 signature provided to `permit` function." + }, + "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)": { + "notice": "EIP2612 approval made with secp256k1 signature. Users can authorize a transfer of their tokens with a signature conforming EIP712 standard, rather than an on-chain transaction from their address. Anyone can submit this signature on the user's behalf by calling the permit function, paying gas fees, and possibly performing other actions in the same transaction." + }, + "symbol()": { + "notice": "The symbol of the token." + }, + "totalSupply()": { + "notice": "The amount of tokens in existence." + }, + "transfer(address,uint256)": { + "notice": "Moves `amount` tokens from the caller's account to `recipient`." + }, + "transferFrom(address,address,uint256)": { + "notice": "Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance unless the allowance was made for `type(uint256).max`." + } + }, + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 7, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 1981, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "balanceOf", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 1989, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "allowance", + "offset": 0, + "slot": "2", + "type": "t_mapping(t_address,t_mapping(t_address,t_uint256))" + }, + { + "astId": 1995, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "nonces", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 2010, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "totalSupply", + "offset": 0, + "slot": "4", + "type": "t_uint256" + }, + { + "astId": 2014, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "name", + "offset": 0, + "slot": "5", + "type": "t_string_storage" + }, + { + "astId": 2018, + "contract": "contracts/token/TBTC.sol:TBTC", + "label": "symbol", + "offset": 0, + "slot": "6", + "type": "t_string_storage" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_mapping(t_address,t_mapping(t_address,t_uint256))": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => mapping(address => uint256))", + "numberOfBytes": "32", + "value": "t_mapping(t_address,t_uint256)" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_string_storage": { + "encoding": "bytes", + "label": "string", + "numberOfBytes": "32" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + } + } + } +} diff --git a/typescript/src/lib/ethereum/artifacts/mainnet/TBTCVault.json b/typescript/src/lib/ethereum/artifacts/mainnet/TBTCVault.json new file mode 100644 index 000000000..2bb682a67 --- /dev/null +++ b/typescript/src/lib/ethereum/artifacts/mainnet/TBTCVault.json @@ -0,0 +1,1606 @@ +{ + "address": "0x9C070027cdC9dc8F82416B2e5314E11DFb4FE3CD", + "abi": [ + { + "inputs": [ + { + "internalType": "contract Bank", + "name": "_bank", + "type": "address" + }, + { + "internalType": "contract TBTC", + "name": "_tbtcToken", + "type": "address" + }, + { + "internalType": "contract Bridge", + "name": "_bridge", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "GuardianAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "GuardianRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Minted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "MinterAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "MinterRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "guardian", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + } + ], + "name": "OptimisticMintingCancelled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "optimisticMintingDebt", + "type": "uint256" + } + ], + "name": "OptimisticMintingDebtRepaid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "newOptimisticMintingDelay", + "type": "uint32" + } + ], + "name": "OptimisticMintingDelayUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "newOptimisticMintingDelay", + "type": "uint32" + } + ], + "name": "OptimisticMintingDelayUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "newOptimisticMintingFeeDivisor", + "type": "uint32" + } + ], + "name": "OptimisticMintingFeeUpdateStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint32", + "name": "newOptimisticMintingFeeDivisor", + "type": "uint32" + } + ], + "name": "OptimisticMintingFeeUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "optimisticMintingDebt", + "type": "uint256" + } + ], + "name": "OptimisticMintingFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "OptimisticMintingPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "minter", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "depositKey", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "depositor", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "OptimisticMintingRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "OptimisticMintingUnpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Unminted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newVault", + "type": "address" + } + ], + "name": "UpgradeFinalized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newVault", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "name": "UpgradeInitiated", + "type": "event" + }, + { + "inputs": [], + "name": "GOVERNANCE_DELAY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "SATOSHI_MULTIPLIER", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "addGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "addMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "amountToSatoshis", + "outputs": [ + { + "internalType": "uint256", + "name": "convertibleAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "remainder", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "satoshis", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bank", + "outputs": [ + { + "internalType": "contract Bank", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_newOptimisticMintingDelay", + "type": "uint32" + } + ], + "name": "beginOptimisticMintingDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "_newOptimisticMintingFeeDivisor", + "type": "uint32" + } + ], + "name": "beginOptimisticMintingFeeUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "bridge", + "outputs": [ + { + "internalType": "contract Bridge", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "calculateDepositKey", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "cancelOptimisticMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "finalizeOptimisticMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeOptimisticMintingDelayUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeOptimisticMintingFeeUpdate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "finalizeUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getMinters", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newVault", + "type": "address" + } + ], + "name": "initiateUpgrade", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isGuardian", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "isMinter", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isOptimisticMintingPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "minters", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newOptimisticMintingDelay", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newOptimisticMintingFeeDivisor", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "newVault", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "optimisticMintingDebt", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "optimisticMintingDelay", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "optimisticMintingDelayUpdateInitiatedTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "optimisticMintingFeeDivisor", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "optimisticMintingFeeUpdateInitiatedTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "optimisticMintingRequests", + "outputs": [ + { + "internalType": "uint64", + "name": "requestedAt", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "finalizedAt", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pauseOptimisticMinting", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "bytes", + "name": "extraData", + "type": "bytes" + } + ], + "name": "receiveApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "uint256", + "name": "satoshis", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "receiveBalanceApproval", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "depositors", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "depositedSatoshiAmounts", + "type": "uint256[]" + } + ], + "name": "receiveBalanceIncrease", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20FromToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "recoverERC721", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC721", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "recoverERC721FromToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "guardian", + "type": "address" + } + ], + "name": "removeGuardian", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "minter", + "type": "address" + } + ], + "name": "removeMinter", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "fundingTxHash", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "fundingOutputIndex", + "type": "uint32" + } + ], + "name": "requestOptimisticMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "tbtcToken", + "outputs": [ + { + "internalType": "contract TBTC", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "unmint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "redemptionData", + "type": "bytes" + } + ], + "name": "unmintAndRedeem", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpauseOptimisticMinting", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "upgradeInitiatedTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "transactionHash": "0x328b5ea0d524480a7d27a2b1c04906927341b9b28134919001c6ed53b6c00083", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x9C070027cdC9dc8F82416B2e5314E11DFb4FE3CD", + "transactionIndex": 115, + "gasUsed": "3340772", + "logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000000000000000000000000080000000000000000000000000000000000400200000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000020000000000000000000000000000000000000400000000000000000000000000000", + "blockHash": "0xdf461e4baea5c76afa03ae1d580c98c2494ff97204c3e5f1ce324ead8ce02fc4", + "transactionHash": "0x328b5ea0d524480a7d27a2b1c04906927341b9b28134919001c6ed53b6c00083", + "logs": [ + { + "transactionIndex": 115, + "blockNumber": 16472741, + "transactionHash": "0x328b5ea0d524480a7d27a2b1c04906927341b9b28134919001c6ed53b6c00083", + "address": "0x9C070027cdC9dc8F82416B2e5314E11DFb4FE3CD", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x000000000000000000000000123694886dbf5ac94dda07135349534536d14caf" + ], + "data": "0x", + "logIndex": 233, + "blockHash": "0xdf461e4baea5c76afa03ae1d580c98c2494ff97204c3e5f1ce324ead8ce02fc4" + } + ], + "blockNumber": 16472741, + "cumulativeGasUsed": "14998097", + "status": 1, + "byzantium": true + }, + "args": [ + "0x65Fbae61ad2C8836fFbFB502A0dA41b0789D9Fc6", + "0x18084fbA666a33d37592fA2633fD49a74DD93a88", + "0x5e4861a80B55f035D899f66772117F00FA0E8e7B" + ], + "numDeployments": 2, + "solcInputHash": "802132f7da69a8a4226cb9424480847b", + "metadata": "{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract Bank\",\"name\":\"_bank\",\"type\":\"address\"},{\"internalType\":\"contract TBTC\",\"name\":\"_tbtcToken\",\"type\":\"address\"},{\"internalType\":\"contract Bridge\",\"name\":\"_bridge\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"GuardianAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"GuardianRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Minted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"MinterAdded\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"MinterRemoved\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"OptimisticMintingCancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticMintingDebt\",\"type\":\"uint256\"}],\"name\":\"OptimisticMintingDebtRepaid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingDelay\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingDelayUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingDelay\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingDelayUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingFeeDivisor\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingFeeUpdateStarted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"newOptimisticMintingFeeDivisor\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingFeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"optimisticMintingDebt\",\"type\":\"uint256\"}],\"name\":\"OptimisticMintingFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"OptimisticMintingPaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"OptimisticMintingRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"OptimisticMintingUnpaused\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Unminted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newVault\",\"type\":\"address\"}],\"name\":\"UpgradeFinalized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newVault\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"UpgradeInitiated\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"GOVERNANCE_DELAY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"SATOSHI_MULTIPLIER\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"addGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"addMinter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"amountToSatoshis\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"convertibleAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"remainder\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"satoshis\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bank\",\"outputs\":[{\"internalType\":\"contract Bank\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_newOptimisticMintingDelay\",\"type\":\"uint32\"}],\"name\":\"beginOptimisticMintingDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"_newOptimisticMintingFeeDivisor\",\"type\":\"uint32\"}],\"name\":\"beginOptimisticMintingFeeUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contract Bridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"calculateDepositKey\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"cancelOptimisticMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"finalizeOptimisticMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeOptimisticMintingDelayUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeOptimisticMintingFeeUpdate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"finalizeUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getMinters\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newVault\",\"type\":\"address\"}],\"name\":\"initiateUpgrade\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isGuardian\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"isMinter\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isOptimisticMintingPaused\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"minters\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newOptimisticMintingDelay\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newOptimisticMintingFeeDivisor\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"newVault\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"optimisticMintingDebt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingDelay\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingDelayUpdateInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingFeeDivisor\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"optimisticMintingFeeUpdateInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"optimisticMintingRequests\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"requestedAt\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"finalizedAt\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pauseOptimisticMinting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"extraData\",\"type\":\"bytes\"}],\"name\":\"receiveApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"satoshis\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"receiveBalanceApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"depositors\",\"type\":\"address[]\"},{\"internalType\":\"uint256[]\",\"name\":\"depositedSatoshiAmounts\",\"type\":\"uint256[]\"}],\"name\":\"receiveBalanceIncrease\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverERC20\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC20\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"recoverERC20FromToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC721\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recoverERC721\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"contract IERC721\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"recoverERC721FromToken\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"guardian\",\"type\":\"address\"}],\"name\":\"removeGuardian\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"minter\",\"type\":\"address\"}],\"name\":\"removeMinter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"name\":\"requestOptimisticMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tbtcToken\",\"outputs\":[{\"internalType\":\"contract TBTC\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"unmint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"redemptionData\",\"type\":\"bytes\"}],\"name\":\"unmintAndRedeem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unpauseOptimisticMinting\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"upgradeInitiatedTimestamp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"TBTC Vault is the owner of TBTC token contract and is the only contract minting the token.\",\"kind\":\"dev\",\"methods\":{\"amountToSatoshis(uint256)\":{\"returns\":{\"convertibleAmount\":\"Amount of TBTC to be minted/unminted.\",\"remainder\":\"Not convertible remainder if amount is not divisible by SATOSHI_MULTIPLIER.\",\"satoshis\":\"Amount in satoshis - the Bank balance to be transferred for the given mint/unmint\"}},\"beginOptimisticMintingFeeUpdate(uint32)\":{\"details\":\"See the documentation for optimisticMintingFeeDivisor.\"},\"cancelOptimisticMint(bytes32,uint32)\":{\"details\":\"Guardians must validate the following conditions for every deposit for which the optimistic minting was requested: - The deposit happened on Bitcoin side and it has enough confirmations. - The optimistic minting has been requested early enough so that the wallet has enough time to sweep the deposit. - The wallet is an active one and it does perform sweeps or it will perform sweeps once the sweeps are activated.\"},\"initiateUpgrade(address)\":{\"params\":{\"_newVault\":\"The new vault address.\"}},\"mint(uint256)\":{\"details\":\"TBTC Vault must have an allowance for caller's balance in the Bank for at least `amount / SATOSHI_MULTIPLIER`.\",\"params\":{\"amount\":\"Amount of TBTC to mint.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"details\":\"This function is doing the same as `unmint` or `unmintAndRedeem` (depending on `extraData` parameter) but it allows to execute unminting without a separate approval transaction. The function can be called only via `approveAndCall` of TBTC token.\",\"params\":{\"amount\":\"Amount of TBTC to unmint.\",\"extraData\":\"Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function. If empty, `receiveApproval` is not requesting a redemption of Bank balance but is instead performing just TBTC unminting to a Bank balance.\",\"from\":\"TBTC token holder executing unminting.\",\"token\":\"TBTC token address.\"}},\"receiveBalanceApproval(address,uint256,bytes)\":{\"details\":\"Can only be called by the Bank via `approveBalanceAndCall`.\",\"params\":{\"owner\":\"The owner who approved their Bank balance.\",\"satoshis\":\"Amount of satoshis used to mint TBTC.\"}},\"receiveBalanceIncrease(address[],uint256[])\":{\"details\":\"Fails if `depositors` array is empty. Expects the length of `depositors` and `depositedSatoshiAmounts` is the same.\"},\"recoverERC20(address,address,uint256)\":{\"params\":{\"amount\":\"Recovered amount.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC20 token contract.\"}},\"recoverERC20FromToken(address,address,uint256)\":{\"params\":{\"amount\":\"Recovered amount.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC20 token contract.\"}},\"recoverERC721(address,address,uint256,bytes)\":{\"params\":{\"data\":\"Additional data.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC721 token contract.\",\"tokenId\":\"Identifier of the recovered token.\"}},\"recoverERC721FromToken(address,address,uint256,bytes)\":{\"params\":{\"data\":\"Additional data.\",\"recipient\":\"Address the recovered token should be sent to.\",\"token\":\"Address of the recovered ERC721 token contract.\",\"tokenId\":\"Identifier of the recovered token.\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.\"},\"requestOptimisticMint(bytes32,uint32)\":{\"details\":\"The deposit done on the Bitcoin side must be revealed early enough to the Bridge on Ethereum to pass the Bridge's validation. The validation passes successfully only if the deposit reveal is done respectively earlier than the moment when the deposit refund locktime is reached, i.e. the deposit becomes refundable. It may happen that the wallet does not sweep a revealed deposit and one of the Minters requests an optimistic mint for that deposit just before the locktime is reached. Guardians must cancel optimistic minting for this deposit because the wallet will not be able to sweep it. The on-chain optimistic minting code does not perform any validation for gas efficiency: it would have to perform the same validation as `validateDepositRefundLocktime` and expect the entire `DepositRevealInfo` to be passed to assemble the expected script hash on-chain. Guardians must validate if the deposit happened on Bitcoin, that the script hash has the expected format, and that the wallet is an active one so they can also validate the time left for the refund.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"unmint(uint256)\":{\"details\":\"Caller must have at least `amount` of TBTC approved to TBTC Vault.\",\"params\":{\"amount\":\"Amount of TBTC to unmint.\"}},\"unmintAndRedeem(uint256,bytes)\":{\"details\":\"Caller must have at least `amount` of TBTC approved to TBTC Vault.\",\"params\":{\"amount\":\"Amount of TBTC to unmint and request to redeem in Bridge.\",\"redemptionData\":\"Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function.\"}}},\"title\":\"TBTC application vault\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"GOVERNANCE_DELAY()\":{\"notice\":\"The time delay that needs to pass between initializing and finalizing the upgrade of governable parameters.\"},\"SATOSHI_MULTIPLIER()\":{\"notice\":\"Multiplier to convert satoshi to TBTC token units.\"},\"addGuardian(address)\":{\"notice\":\"Adds the address to the Guardian set.\"},\"addMinter(address)\":{\"notice\":\"Adds the address to the Minter list.\"},\"amountToSatoshis(uint256)\":{\"notice\":\"Returns the amount of TBTC to be minted/unminted, the remainder, and the Bank balance to be transferred for the given mint/unmint. Note that if the `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account when minting or unminting.\"},\"beginOptimisticMintingDelayUpdate(uint32)\":{\"notice\":\"Begins the process of updating optimistic minting delay.\"},\"beginOptimisticMintingFeeUpdate(uint32)\":{\"notice\":\"Begins the process of updating optimistic minting fee. The fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2% of each deposit, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`.\"},\"calculateDepositKey(bytes32,uint32)\":{\"notice\":\"Calculates deposit key the same way as the Bridge contract. The deposit key is computed as `keccak256(fundingTxHash | fundingOutputIndex)`.\"},\"cancelOptimisticMint(bytes32,uint32)\":{\"notice\":\"Allows a Guardian to cancel optimistic minting request. The following conditions must be met: - The optimistic minting request for the given deposit exists. - The optimistic minting request for the given deposit has not been finalized yet. Optimistic minting request is removed. It is possible to request optimistic minting again for the same deposit later.\"},\"finalizeOptimisticMint(bytes32,uint32)\":{\"notice\":\"Allows a Minter to finalize previously requested optimistic minting. The following conditions must be met: - The optimistic minting has been requested for the given deposit. - The deposit has not been swept yet. - At least `optimisticMintingDelay` passed since the optimistic minting was requested for the given deposit. - The optimistic minting has not been finalized earlier for the given deposit. - The optimistic minting request for the given deposit has not been canceled by a Guardian. - The optimistic minting is not paused. This function mints TBTC and increases `optimisticMintingDebt` for the given depositor. The optimistic minting request is marked as finalized.\"},\"finalizeOptimisticMintingDelayUpdate()\":{\"notice\":\"Finalizes the update process of the optimistic minting delay.\"},\"finalizeOptimisticMintingFeeUpdate()\":{\"notice\":\"Finalizes the update process of the optimistic minting fee.\"},\"finalizeUpgrade()\":{\"notice\":\"Allows the governance to finalize vault upgrade process. The upgrade process needs to be first initiated with a call to `initiateUpgrade` and the `GOVERNANCE_DELAY` needs to pass. Once the upgrade is finalized, the new vault becomes the owner of the TBTC token and receives the whole Bank balance of this vault.\"},\"getMinters()\":{\"notice\":\"Allows to fetch a list of all Minters.\"},\"initiateUpgrade(address)\":{\"notice\":\"Initiates vault upgrade process. The upgrade process needs to be finalized with a call to `finalizeUpgrade` function after the `UPGRADE_GOVERNANCE_DELAY` passes. Only the governance can initiate the upgrade.\"},\"isGuardian(address)\":{\"notice\":\"Indicates if the given address is a Guardian. Only Guardians can cancel requested optimistic minting.\"},\"isMinter(address)\":{\"notice\":\"Indicates if the given address is a Minter. Only Minters can request optimistic minting.\"},\"isOptimisticMintingPaused()\":{\"notice\":\"Indicates if the optimistic minting has been paused. Only the Governance can pause optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits.\"},\"mint(uint256)\":{\"notice\":\"Mints the given `amount` of TBTC to the caller previously transferring `amount / SATOSHI_MULTIPLIER` of the Bank balance from caller to TBTC Vault. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's Bank balance.\"},\"minters(uint256)\":{\"notice\":\"List of all Minters.\"},\"newOptimisticMintingDelay()\":{\"notice\":\"New optimistic minting delay value. Set only when the parameter update process is pending. Once the update gets finalized, this\"},\"newOptimisticMintingFeeDivisor()\":{\"notice\":\"New optimistic minting fee divisor value. Set only when the parameter update process is pending. Once the update gets\"},\"newVault()\":{\"notice\":\"The address of a new TBTC vault. Set only when the upgrade process is pending. Once the upgrade gets finalized, the new TBTC vault will become an owner of TBTC token.\"},\"optimisticMintingDebt(address)\":{\"notice\":\"Optimistic minting debt value per depositor's address. The debt represents the total value of all depositor's deposits revealed to the Bridge that has not been yet swept and led to the optimistic minting of TBTC. When `TBTCVault` sweeps a deposit, the debt is fully or partially paid off, no matter if that particular swept deposit was used for the optimistic minting or not. The values are in 1e18 Ethereum precision.\"},\"optimisticMintingDelay()\":{\"notice\":\"The time that needs to pass between the moment the optimistic minting is requested and the moment optimistic minting is finalized with minting TBTC.\"},\"optimisticMintingDelayUpdateInitiatedTimestamp()\":{\"notice\":\"The timestamp at which the update of the optimistic minting delay started. Zero if update is not in progress.\"},\"optimisticMintingFeeDivisor()\":{\"notice\":\"Divisor used to compute the treasury fee taken from each optimistically minted deposit and transferred to the treasury upon finalization of the optimistic mint. This fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2%, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`. The optimistic minting fee does not replace the deposit treasury fee cut by the Bridge. The optimistic fee is a percentage AFTER the treasury fee is cut: `optimisticMintingFee = (depositAmount - treasuryFee) / optimisticMintingFeeDivisor`\"},\"optimisticMintingFeeUpdateInitiatedTimestamp()\":{\"notice\":\"The timestamp at which the update of the optimistic minting fee divisor started. Zero if update is not in progress.\"},\"optimisticMintingRequests(uint256)\":{\"notice\":\"Collection of all revealed deposits for which the optimistic minting was requested. Indexed by a deposit key computed as `keccak256(fundingTxHash | fundingOutputIndex)`.\"},\"pauseOptimisticMinting()\":{\"notice\":\"Pauses the optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits.\"},\"receiveApproval(address,uint256,address,bytes)\":{\"notice\":\"Burns `amount` of TBTC from the caller's balance. If `extraData` is empty, transfers `amount` back to the caller's balance in the Bank. If `extraData` is not empty, requests redemption in the Bridge using the `extraData` as a `redemptionData` parameter to Bridge's `receiveBalanceApproval` function. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account. Note that it may left a token approval equal to the remainder.\"},\"receiveBalanceApproval(address,uint256,bytes)\":{\"notice\":\"Transfers `satoshis` of the Bank balance from the caller to TBTC Vault and mints `satoshis * SATOSHI_MULTIPLIER` of TBTC to the caller.\"},\"receiveBalanceIncrease(address[],uint256[])\":{\"notice\":\"Mints the same amount of TBTC as the deposited satoshis amount multiplied by SATOSHI_MULTIPLIER for each depositor in the array. Can only be called by the Bank after the Bridge swept deposits and Bank increased balance for the vault.\"},\"recoverERC20(address,address,uint256)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC20 token sent - mistakenly or not - to the vault address. This function should be used to withdraw TBTC v1 tokens transferred to TBTCVault as a result of VendingMachine > TBTCVault upgrade.\"},\"recoverERC20FromToken(address,address,uint256)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC20 token sent mistakenly to the TBTC token contract address.\"},\"recoverERC721(address,address,uint256,bytes)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the vault address.\"},\"recoverERC721FromToken(address,address,uint256,bytes)\":{\"notice\":\"Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the TBTC token contract address.\"},\"removeGuardian(address)\":{\"notice\":\"Removes the address from the Guardian set.\"},\"removeMinter(address)\":{\"notice\":\"Removes the address from the Minter list.\"},\"requestOptimisticMint(bytes32,uint32)\":{\"notice\":\"Allows a Minter to request for an optimistic minting of TBTC. The following conditions must be met: - There is no optimistic minting request for the deposit, finalized or not. - The deposit with the given Bitcoin funding transaction hash and output index has been revealed to the Bridge. - The deposit has not been swept yet. - The deposit is targeted into the TBTCVault. - The optimistic minting is not paused. After calling this function, the Minter has to wait for `optimisticMintingDelay` before finalizing the mint with a call to finalizeOptimisticMint.\"},\"unmint(uint256)\":{\"notice\":\"Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` back to the caller's balance in the Bank. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account.\"},\"unmintAndRedeem(uint256,bytes)\":{\"notice\":\"Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` of Bank balance to the Bridge requesting redemption based on the provided `redemptionData`. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account.\"},\"unpauseOptimisticMinting()\":{\"notice\":\"Unpauses the optimistic minting.\"},\"upgradeInitiatedTimestamp()\":{\"notice\":\"The timestamp at which an upgrade to a new TBTC vault was initiated. Set only when the upgrade process is pending.\"}},\"notice\":\"TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of Bitcoin. It facilitates Bitcoin holders to act on the Ethereum blockchain and access the decentralized finance (DeFi) ecosystem. TBTC Vault mints and unmints TBTC based on Bitcoin balances in the Bank.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"contracts/vault/TBTCVault.sol\":\"TBTCVault\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":1000},\"remappings\":[]},\"sources\":{\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title BitcoinSPV */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\n\\nlibrary BTCUtils {\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n // The target at minimum Difficulty. Also the target of the genesis block\\n uint256 public constant DIFF1_TARGET = 0xffff0000000000000000000000000000000000000000000000000000;\\n\\n uint256 public constant RETARGET_PERIOD = 2 * 7 * 24 * 60 * 60; // 2 weeks in seconds\\n uint256 public constant RETARGET_PERIOD_BLOCKS = 2016; // 2 weeks in blocks\\n\\n uint256 public constant ERR_BAD_ARG = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n\\n /* ***** */\\n /* UTILS */\\n /* ***** */\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _flag The first byte of a VarInt\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLength(bytes memory _flag) internal pure returns (uint8) {\\n return determineVarIntDataLengthAt(_flag, 0);\\n }\\n\\n /// @notice Determines the length of a VarInt in bytes\\n /// @dev A VarInt of >1 byte is prefixed with a flag indicating its length\\n /// @param _b The byte array containing a VarInt\\n /// @param _at The position of the VarInt in the array\\n /// @return The number of non-flag bytes in the VarInt\\n function determineVarIntDataLengthAt(bytes memory _b, uint256 _at) internal pure returns (uint8) {\\n if (uint8(_b[_at]) == 0xff) {\\n return 8; // one-byte flag, 8 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfe) {\\n return 4; // one-byte flag, 4 bytes data\\n }\\n if (uint8(_b[_at]) == 0xfd) {\\n return 2; // one-byte flag, 2 bytes data\\n }\\n\\n return 0; // flag is data\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string starting with a VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarInt(bytes memory _b) internal pure returns (uint256, uint256) {\\n return parseVarIntAt(_b, 0);\\n }\\n\\n /// @notice Parse a VarInt into its data length and the number it represents\\n /// @dev Useful for Parsing Vins and Vouts. Returns ERR_BAD_ARG if insufficient bytes.\\n /// Caller SHOULD explicitly handle this case (or bubble it up)\\n /// @param _b A byte-string containing a VarInt\\n /// @param _at The position of the VarInt\\n /// @return number of bytes in the encoding (not counting the tag), the encoded int\\n function parseVarIntAt(bytes memory _b, uint256 _at) internal pure returns (uint256, uint256) {\\n uint8 _dataLen = determineVarIntDataLengthAt(_b, _at);\\n\\n if (_dataLen == 0) {\\n return (0, uint8(_b[_at]));\\n }\\n if (_b.length < 1 + _dataLen + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n uint256 _number;\\n if (_dataLen == 2) {\\n _number = reverseUint16(uint16(_b.slice2(1 + _at)));\\n } else if (_dataLen == 4) {\\n _number = reverseUint32(uint32(_b.slice4(1 + _at)));\\n } else if (_dataLen == 8) {\\n _number = reverseUint64(uint64(_b.slice8(1 + _at)));\\n }\\n return (_dataLen, _number);\\n }\\n\\n /// @notice Changes the endianness of a byte array\\n /// @dev Returns a new, backwards, bytes\\n /// @param _b The bytes to reverse\\n /// @return The reversed bytes\\n function reverseEndianness(bytes memory _b) internal pure returns (bytes memory) {\\n bytes memory _newValue = new bytes(_b.length);\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _newValue[_b.length - i - 1] = _b[i];\\n }\\n\\n return _newValue;\\n }\\n\\n /// @notice Changes the endianness of a uint256\\n /// @dev https://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint256(uint256 _b) internal pure returns (uint256 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = ((v >> 32) & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) |\\n ((v & 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF) << 32);\\n // swap 8-byte long pairs\\n v = ((v >> 64) & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) |\\n ((v & 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF) << 64);\\n // swap 16-byte long pairs\\n v = (v >> 128) | (v << 128);\\n }\\n\\n /// @notice Changes the endianness of a uint64\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint64(uint64 _b) internal pure returns (uint64 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF00FF00FF) |\\n ((v & 0x00FF00FF00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = ((v >> 16) & 0x0000FFFF0000FFFF) |\\n ((v & 0x0000FFFF0000FFFF) << 16);\\n // swap 4-byte long pairs\\n v = (v >> 32) | (v << 32);\\n }\\n\\n /// @notice Changes the endianness of a uint32\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint32(uint32 _b) internal pure returns (uint32 v) {\\n v = _b;\\n\\n // swap bytes\\n v = ((v >> 8) & 0x00FF00FF) |\\n ((v & 0x00FF00FF) << 8);\\n // swap 2-byte long pairs\\n v = (v >> 16) | (v << 16);\\n }\\n\\n /// @notice Changes the endianness of a uint24\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint24(uint24 _b) internal pure returns (uint24 v) {\\n v = (_b << 16) | (_b & 0x00FF00) | (_b >> 16);\\n }\\n\\n /// @notice Changes the endianness of a uint16\\n /// @param _b The unsigned integer to reverse\\n /// @return v The reversed value\\n function reverseUint16(uint16 _b) internal pure returns (uint16 v) {\\n v = (_b << 8) | (_b >> 8);\\n }\\n\\n\\n /// @notice Converts big-endian bytes to a uint\\n /// @dev Traverses the byte array and sums the bytes\\n /// @param _b The big-endian bytes-encoded integer\\n /// @return The integer representation\\n function bytesToUint(bytes memory _b) internal pure returns (uint256) {\\n uint256 _number;\\n\\n for (uint i = 0; i < _b.length; i++) {\\n _number = _number + uint8(_b[i]) * (2 ** (8 * (_b.length - (i + 1))));\\n }\\n\\n return _number;\\n }\\n\\n /// @notice Get the last _num bytes from a byte array\\n /// @param _b The byte array to slice\\n /// @param _num The number of bytes to extract from the end\\n /// @return The last _num bytes of _b\\n function lastBytes(bytes memory _b, uint256 _num) internal pure returns (bytes memory) {\\n uint256 _start = _b.length.sub(_num);\\n\\n return _b.slice(_start, _num);\\n }\\n\\n /// @notice Implements bitcoin's hash160 (rmd160(sha2()))\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash160(bytes memory _b) internal pure returns (bytes memory) {\\n return abi.encodePacked(ripemd160(abi.encodePacked(sha256(_b))));\\n }\\n\\n /// @notice Implements bitcoin's hash160 (sha2 + ripemd160)\\n /// @dev sha2 precompile at address(2), ripemd160 at address(3)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash160View(bytes memory _b) internal view returns (bytes20 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 3, 0x00, 32, 0x00, 32))\\n // read from position 12 = 0c\\n res := mload(0x0c)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev abi.encodePacked changes the return to bytes instead of bytes32\\n /// @param _b The pre-image\\n /// @return The digest\\n function hash256(bytes memory _b) internal pure returns (bytes32) {\\n return sha256(abi.encodePacked(sha256(_b)));\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The pre-image\\n /// @return res The digest\\n function hash256View(bytes memory _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, 32), mload(_b), 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 on a pair of bytes32\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _a The first bytes32 of the pre-image\\n /// @param _b The second bytes32 of the pre-image\\n /// @return res The digest\\n function hash256Pair(bytes32 _a, bytes32 _b) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n mstore(0x00, _a)\\n mstore(0x20, _b)\\n pop(staticcall(gas(), 2, 0x00, 64, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /// @notice Implements bitcoin's hash256 (double sha2)\\n /// @dev sha2 is precompiled smart contract located at address(2)\\n /// @param _b The array containing the pre-image\\n /// @param at The start of the pre-image\\n /// @param len The length of the pre-image\\n /// @return res The digest\\n function hash256Slice(\\n bytes memory _b,\\n uint256 at,\\n uint256 len\\n ) internal view returns (bytes32 res) {\\n // solium-disable-next-line security/no-inline-assembly\\n assembly {\\n pop(staticcall(gas(), 2, add(_b, add(32, at)), len, 0x00, 32))\\n pop(staticcall(gas(), 2, 0x00, 32, 0x00, 32))\\n res := mload(0x00)\\n }\\n }\\n\\n /* ************ */\\n /* Legacy Input */\\n /* ************ */\\n\\n /// @notice Extracts the nth input from the vin (0-indexed)\\n /// @dev Iterates over the vin. If you need to extract several, write a custom function\\n /// @param _vin The vin as a tightly-packed byte array\\n /// @param _index The 0-indexed location of the input to extract\\n /// @return The input as a byte array\\n function extractInputAtIndex(bytes memory _vin, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nIns, \\\"Vin read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n _offset = _offset + _len;\\n }\\n\\n _len = determineInputLengthAt(_vin, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _vin.slice(_offset, _len);\\n }\\n\\n /// @notice Determines whether an input is legacy\\n /// @dev False if no scriptSig, otherwise True\\n /// @param _input The input\\n /// @return True for legacy, False for witness\\n function isLegacyInput(bytes memory _input) internal pure returns (bool) {\\n return _input[36] != hex\\\"00\\\";\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The LEGACY input\\n /// @return The length of the script sig\\n function extractScriptSigLen(bytes memory _input) internal pure returns (uint256, uint256) {\\n return extractScriptSigLenAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of a scriptSig in an input\\n /// starting at the specified position\\n /// @dev Will return 0 if passed a witness input.\\n /// @param _input The byte array containing the LEGACY input\\n /// @param _at The position of the input in the array\\n /// @return The length of the script sig\\n function extractScriptSigLenAt(bytes memory _input, uint256 _at) internal pure returns (uint256, uint256) {\\n if (_input.length < 37 + _at) {\\n return (ERR_BAD_ARG, 0);\\n }\\n\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = parseVarIntAt(_input, _at + 36);\\n\\n return (_varIntDataLen, _scriptSigLen);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The input\\n /// @return The length of the input in bytes\\n function determineInputLength(bytes memory _input) internal pure returns (uint256) {\\n return determineInputLengthAt(_input, 0);\\n }\\n\\n /// @notice Determines the length of an input from its scriptSig,\\n /// starting at the specified position\\n /// @dev 36 for outpoint, 1 for scriptSig length, 4 for sequence\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input in the array\\n /// @return The length of the input in bytes\\n function determineInputLengthAt(bytes memory _input, uint256 _at) internal pure returns (uint256) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLenAt(_input, _at);\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n return 36 + 1 + _varIntDataLen + _scriptSigLen + 4;\\n }\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The LEGACY input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLELegacy(bytes memory _input) internal pure returns (bytes4) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice4(36 + 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n /// @notice Extracts the sequence from the input\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The LEGACY input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceLegacy(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLELegacy(_input));\\n uint32 _beSequence = reverseUint32(_leSeqence);\\n return _beSequence;\\n }\\n /// @notice Extracts the VarInt-prepended scriptSig from the input in a tx\\n /// @dev Will return hex\\\"00\\\" if passed a witness input\\n /// @param _input The LEGACY input\\n /// @return The length-prepended scriptSig\\n function extractScriptSig(bytes memory _input) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _scriptSigLen;\\n (_varIntDataLen, _scriptSigLen) = extractScriptSigLen(_input);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Bad VarInt in scriptSig\\\");\\n return _input.slice(36, 1 + _varIntDataLen + _scriptSigLen);\\n }\\n\\n\\n /* ************* */\\n /* Witness Input */\\n /* ************* */\\n\\n /// @notice Extracts the LE sequence bytes from an input\\n /// @dev Sequence is used for relative time locks\\n /// @param _input The WITNESS input\\n /// @return The sequence bytes (LE uint)\\n function extractSequenceLEWitness(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(37);\\n }\\n\\n /// @notice Extracts the sequence from the input in a tx\\n /// @dev Sequence is a 4-byte little-endian number\\n /// @param _input The WITNESS input\\n /// @return The sequence number (big-endian uint)\\n function extractSequenceWitness(bytes memory _input) internal pure returns (uint32) {\\n uint32 _leSeqence = uint32(extractSequenceLEWitness(_input));\\n uint32 _inputeSequence = reverseUint32(_leSeqence);\\n return _inputeSequence;\\n }\\n\\n /// @notice Extracts the outpoint from the input in a tx\\n /// @dev 32-byte tx id with 4-byte index\\n /// @param _input The input\\n /// @return The outpoint (LE bytes of prev tx hash + LE bytes of prev tx index)\\n function extractOutpoint(bytes memory _input) internal pure returns (bytes memory) {\\n return _input.slice(0, 36);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// @dev 32-byte tx id\\n /// @param _input The input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLE(bytes memory _input) internal pure returns (bytes32) {\\n return _input.slice32(0);\\n }\\n\\n /// @notice Extracts the outpoint tx id from an input\\n /// starting at the specified position\\n /// @dev 32-byte tx id\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx id (little-endian bytes)\\n function extractInputTxIdLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes32) {\\n return _input.slice32(_at);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// @dev 4-byte tx index\\n /// @param _input The input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLE(bytes memory _input) internal pure returns (bytes4) {\\n return _input.slice4(32);\\n }\\n\\n /// @notice Extracts the LE tx input index from the input in a tx\\n /// starting at the specified position\\n /// @dev 4-byte tx index\\n /// @param _input The byte array containing the input\\n /// @param _at The position of the input\\n /// @return The tx index (little-endian bytes)\\n function extractTxIndexLeAt(bytes memory _input, uint256 _at) internal pure returns (bytes4) {\\n return _input.slice4(32 + _at);\\n }\\n\\n /* ****** */\\n /* Output */\\n /* ****** */\\n\\n /// @notice Determines the length of an output\\n /// @dev Works with any properly formatted output\\n /// @param _output The output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLength(bytes memory _output) internal pure returns (uint256) {\\n return determineOutputLengthAt(_output, 0);\\n }\\n\\n /// @notice Determines the length of an output\\n /// starting at the specified position\\n /// @dev Works with any properly formatted output\\n /// @param _output The byte array containing the output\\n /// @param _at The position of the output\\n /// @return The length indicated by the prefix, error if invalid length\\n function determineOutputLengthAt(bytes memory _output, uint256 _at) internal pure returns (uint256) {\\n if (_output.length < 9 + _at) {\\n return ERR_BAD_ARG;\\n }\\n uint256 _varIntDataLen;\\n uint256 _scriptPubkeyLength;\\n (_varIntDataLen, _scriptPubkeyLength) = parseVarIntAt(_output, 8 + _at);\\n\\n if (_varIntDataLen == ERR_BAD_ARG) {\\n return ERR_BAD_ARG;\\n }\\n\\n // 8-byte value, 1-byte for tag itself\\n return 8 + 1 + _varIntDataLen + _scriptPubkeyLength;\\n }\\n\\n /// @notice Extracts the output at a given index in the TxOuts vector\\n /// @dev Iterates over the vout. If you need to extract multiple, write a custom function\\n /// @param _vout The _vout to extract from\\n /// @param _index The 0-indexed location of the output to extract\\n /// @return The specified output\\n function extractOutputAtIndex(bytes memory _vout, uint256 _index) internal pure returns (bytes memory) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n require(_varIntDataLen != ERR_BAD_ARG, \\\"Read overrun during VarInt parsing\\\");\\n require(_index < _nOuts, \\\"Vout read overrun\\\");\\n\\n uint256 _len = 0;\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 _i = 0; _i < _index; _i ++) {\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n _offset += _len;\\n }\\n\\n _len = determineOutputLengthAt(_vout, _offset);\\n require(_len != ERR_BAD_ARG, \\\"Bad VarInt in scriptPubkey\\\");\\n return _vout.slice(_offset, _len);\\n }\\n\\n /// @notice Extracts the value bytes from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value as LE bytes\\n function extractValueLE(bytes memory _output) internal pure returns (bytes8) {\\n return _output.slice8(0);\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The output\\n /// @return The output value\\n function extractValue(bytes memory _output) internal pure returns (uint64) {\\n uint64 _leValue = uint64(extractValueLE(_output));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the value from the output in a tx\\n /// @dev Value is an 8-byte little-endian number\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output in the array\\n /// @return The output value\\n function extractValueAt(bytes memory _output, uint256 _at) internal pure returns (uint64) {\\n uint64 _leValue = uint64(_output.slice8(_at));\\n uint64 _beValue = reverseUint64(_leValue);\\n return _beValue;\\n }\\n\\n /// @notice Extracts the data from an op return output\\n /// @dev Returns hex\\\"\\\" if no data or not an op return\\n /// @param _output The output\\n /// @return Any data contained in the opreturn output, null if not an op return\\n function extractOpReturnData(bytes memory _output) internal pure returns (bytes memory) {\\n if (_output[9] != hex\\\"6a\\\") {\\n return hex\\\"\\\";\\n }\\n bytes1 _dataLen = _output[10];\\n return _output.slice(11, uint256(uint8(_dataLen)));\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The output\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHash(bytes memory _output) internal pure returns (bytes memory) {\\n return extractHashAt(_output, 8, _output.length - 8);\\n }\\n\\n /// @notice Extracts the hash from the output script\\n /// @dev Determines type by the length prefix and validates format\\n /// @param _output The byte array containing the output\\n /// @param _at The starting index of the output script in the array\\n /// (output start + 8)\\n /// @param _len The length of the output script\\n /// (output length - 8)\\n /// @return The hash committed to by the pk_script, or null for errors\\n function extractHashAt(\\n bytes memory _output,\\n uint256 _at,\\n uint256 _len\\n ) internal pure returns (bytes memory) {\\n uint8 _scriptLen = uint8(_output[_at]);\\n\\n // don't have to worry about overflow here.\\n // if _scriptLen + 1 overflows, then output length would have to be < 1\\n // for this check to pass. if it's < 1, then we errored when assigning\\n // _scriptLen\\n if (_scriptLen + 1 != _len) {\\n return hex\\\"\\\";\\n }\\n\\n if (uint8(_output[_at + 1]) == 0) {\\n if (_scriptLen < 2) {\\n return hex\\\"\\\";\\n }\\n uint256 _payloadLen = uint8(_output[_at + 2]);\\n // Check for maliciously formatted witness outputs.\\n // No need to worry about underflow as long b/c of the `< 2` check\\n if (_payloadLen != _scriptLen - 2 || (_payloadLen != 0x20 && _payloadLen != 0x14)) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, _payloadLen);\\n } else {\\n bytes3 _tag = _output.slice3(_at);\\n // p2pkh\\n if (_tag == hex\\\"1976a9\\\") {\\n // Check for maliciously formatted p2pkh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + 3]) != 0x14 ||\\n _output.slice2(_at + _len - 2) != hex\\\"88ac\\\") {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 4, 20);\\n //p2sh\\n } else if (_tag == hex\\\"17a914\\\") {\\n // Check for maliciously formatted p2sh\\n // No need to worry about underflow, b/c of _scriptLen check\\n if (uint8(_output[_at + _len - 1]) != 0x87) {\\n return hex\\\"\\\";\\n }\\n return _output.slice(_at + 3, 20);\\n }\\n }\\n return hex\\\"\\\"; /* NB: will trigger on OPRETURN and any non-standard that doesn't overrun */\\n }\\n\\n /* ********** */\\n /* Witness TX */\\n /* ********** */\\n\\n\\n /// @notice Checks that the vin passed up is properly formatted\\n /// @dev Consider a vin with a valid vout in its scriptsig\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @return True if it represents a validly formatted vin\\n function validateVin(bytes memory _vin) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nIns;\\n\\n (_varIntDataLen, _nIns) = parseVarInt(_vin);\\n\\n // Not valid if it says there are too many or no inputs\\n if (_nIns == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nIns; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vin.length) {\\n return false;\\n }\\n\\n // Grab the next input and determine its length.\\n uint256 _nextLen = determineInputLengthAt(_vin, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n // Increase the offset by that much\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vin.length;\\n }\\n\\n /// @notice Checks that the vout passed up is properly formatted\\n /// @dev Consider a vout with a valid scriptpubkey\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @return True if it represents a validly formatted vout\\n function validateVout(bytes memory _vout) internal pure returns (bool) {\\n uint256 _varIntDataLen;\\n uint256 _nOuts;\\n\\n (_varIntDataLen, _nOuts) = parseVarInt(_vout);\\n\\n // Not valid if it says there are too many or no outputs\\n if (_nOuts == 0 || _varIntDataLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n uint256 _offset = 1 + _varIntDataLen;\\n\\n for (uint256 i = 0; i < _nOuts; i++) {\\n // If we're at the end, but still expect more\\n if (_offset >= _vout.length) {\\n return false;\\n }\\n\\n // Grab the next output and determine its length.\\n // Increase the offset by that much\\n uint256 _nextLen = determineOutputLengthAt(_vout, _offset);\\n if (_nextLen == ERR_BAD_ARG) {\\n return false;\\n }\\n\\n _offset += _nextLen;\\n }\\n\\n // Returns false if we're not exactly at the end\\n return _offset == _vout.length;\\n }\\n\\n\\n\\n /* ************ */\\n /* Block Header */\\n /* ************ */\\n\\n /// @notice Extracts the transaction merkle root from a block header\\n /// @dev Use verifyHash256Merkle to verify proofs with this root\\n /// @param _header The header\\n /// @return The merkle root (little-endian)\\n function extractMerkleRootLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(36);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The header\\n /// @return The target threshold\\n function extractTarget(bytes memory _header) internal pure returns (uint256) {\\n return extractTargetAt(_header, 0);\\n }\\n\\n /// @notice Extracts the target from a block header\\n /// @dev Target is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The target threshold\\n function extractTargetAt(bytes memory _header, uint256 at) internal pure returns (uint256) {\\n uint24 _m = uint24(_header.slice3(72 + at));\\n uint8 _e = uint8(_header[75 + at]);\\n uint256 _mantissa = uint256(reverseUint24(_m));\\n uint _exponent = _e - 3;\\n\\n return _mantissa * (256 ** _exponent);\\n }\\n\\n /// @notice Calculate difficulty from the difficulty 1 target and current target\\n /// @dev Difficulty 1 is 0x1d00ffff on mainnet and testnet\\n /// @dev Difficulty 1 is a 256-bit number encoded as a 3-byte mantissa and 1-byte exponent\\n /// @param _target The current target\\n /// @return The block difficulty (bdiff)\\n function calculateDifficulty(uint256 _target) internal pure returns (uint256) {\\n // Difficulty 1 calculated from 0x1d00ffff\\n return DIFF1_TARGET.div(_target);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLE(bytes memory _header) internal pure returns (bytes32) {\\n return _header.slice32(4);\\n }\\n\\n /// @notice Extracts the previous block's hash from a block header\\n /// @dev Block headers do NOT include block number :(\\n /// @param _header The array containing the header\\n /// @param at The start of the header\\n /// @return The previous block's hash (little-endian)\\n function extractPrevBlockLEAt(\\n bytes memory _header,\\n uint256 at\\n ) internal pure returns (bytes32) {\\n return _header.slice32(4 + at);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (little-endian bytes)\\n function extractTimestampLE(bytes memory _header) internal pure returns (bytes4) {\\n return _header.slice4(68);\\n }\\n\\n /// @notice Extracts the timestamp from a block header\\n /// @dev Time is not 100% reliable\\n /// @param _header The header\\n /// @return The timestamp (uint)\\n function extractTimestamp(bytes memory _header) internal pure returns (uint32) {\\n return reverseUint32(uint32(extractTimestampLE(_header)));\\n }\\n\\n /// @notice Extracts the expected difficulty from a block header\\n /// @dev Does NOT verify the work\\n /// @param _header The header\\n /// @return The difficulty as an integer\\n function extractDifficulty(bytes memory _header) internal pure returns (uint256) {\\n return calculateDifficulty(extractTarget(_header));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes memory _a, bytes memory _b) internal view returns (bytes32) {\\n return hash256View(abi.encodePacked(_a, _b));\\n }\\n\\n /// @notice Concatenates and hashes two inputs for merkle proving\\n /// @param _a The first hash\\n /// @param _b The second hash\\n /// @return The double-sha256 of the concatenated hashes\\n function _hash256MerkleStep(bytes32 _a, bytes32 _b) internal view returns (bytes32) {\\n return hash256Pair(_a, _b);\\n }\\n\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Inefficient version.\\n /// @param _proof The proof. Tightly packed LE sha256 hashes. The last hash is the root\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(bytes memory _proof, uint _index) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_proof.length % 32 != 0) {\\n return false;\\n }\\n\\n // Special case for coinbase-only blocks\\n if (_proof.length == 32) {\\n return true;\\n }\\n\\n // Should never occur\\n if (_proof.length == 64) {\\n return false;\\n }\\n\\n bytes32 _root = _proof.slice32(_proof.length - 32);\\n bytes32 _current = _proof.slice32(0);\\n bytes memory _tree = _proof.slice(32, _proof.length - 64);\\n\\n return verifyHash256Merkle(_current, _tree, _root, _index);\\n }\\n\\n /// @notice Verifies a Bitcoin-style merkle tree\\n /// @dev Leaves are 0-indexed. Efficient version.\\n /// @param _leaf The leaf of the proof. LE sha256 hash.\\n /// @param _tree The intermediate nodes in the proof.\\n /// Tightly packed LE sha256 hashes.\\n /// @param _root The root of the proof. LE sha256 hash.\\n /// @param _index The index of the leaf\\n /// @return true if the proof is valid, else false\\n function verifyHash256Merkle(\\n bytes32 _leaf,\\n bytes memory _tree,\\n bytes32 _root,\\n uint _index\\n ) internal view returns (bool) {\\n // Not an even number of hashes\\n if (_tree.length % 32 != 0) {\\n return false;\\n }\\n\\n // Should never occur\\n if (_tree.length == 0) {\\n return false;\\n }\\n\\n uint _idx = _index;\\n bytes32 _current = _leaf;\\n\\n // i moves in increments of 32\\n for (uint i = 0; i < _tree.length; i += 32) {\\n if (_idx % 2 == 1) {\\n _current = _hash256MerkleStep(_tree.slice32(i), _current);\\n } else {\\n _current = _hash256MerkleStep(_current, _tree.slice32(i));\\n }\\n _idx = _idx >> 1;\\n }\\n return _current == _root;\\n }\\n\\n /*\\n NB: https://github.com/bitcoin/bitcoin/blob/78dae8caccd82cfbfd76557f1fb7d7557c7b5edb/src/pow.cpp#L49-L72\\n NB: We get a full-bitlength target from this. For comparison with\\n header-encoded targets we need to mask it with the header target\\n e.g. (full & truncated) == truncated\\n */\\n /// @notice performs the bitcoin difficulty retarget\\n /// @dev implements the Bitcoin algorithm precisely\\n /// @param _previousTarget the target of the previous period\\n /// @param _firstTimestamp the timestamp of the first block in the difficulty period\\n /// @param _secondTimestamp the timestamp of the last block in the difficulty period\\n /// @return the new period's target threshold\\n function retargetAlgorithm(\\n uint256 _previousTarget,\\n uint256 _firstTimestamp,\\n uint256 _secondTimestamp\\n ) internal pure returns (uint256) {\\n uint256 _elapsedTime = _secondTimestamp.sub(_firstTimestamp);\\n\\n // Normalize ratio to factor of 4 if very long or very short\\n if (_elapsedTime < RETARGET_PERIOD.div(4)) {\\n _elapsedTime = RETARGET_PERIOD.div(4);\\n }\\n if (_elapsedTime > RETARGET_PERIOD.mul(4)) {\\n _elapsedTime = RETARGET_PERIOD.mul(4);\\n }\\n\\n /*\\n NB: high targets e.g. ffff0020 can cause overflows here\\n so we divide it by 256**2, then multiply by 256**2 later\\n we know the target is evenly divisible by 256**2, so this isn't an issue\\n */\\n\\n uint256 _adjusted = _previousTarget.div(65536).mul(_elapsedTime);\\n return _adjusted.div(RETARGET_PERIOD).mul(65536);\\n }\\n}\\n\",\"keccak256\":\"0x439eaa97e9239705f3d31e8d39dccbad32311f1f119e295d53c65e0ae3c5a5fc\"},\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\n\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\n\\nThis is free and unencumbered software released into the public domain.\\n\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\n\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\n\\nFor more information, please refer to \\n*/\\n\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(0x40, and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n ))\\n }\\n\\n return tempBytes;\\n }\\n\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let mlengthmod := mod(mlength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function slice(bytes memory _bytes, uint _start, uint _length) internal pure returns (bytes memory res) {\\n if (_length == 0) {\\n return hex\\\"\\\";\\n }\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n /// @notice Take a slice of the byte array, overwriting the destination.\\n /// The length of the slice will equal the length of the destination array.\\n /// @dev Make sure the destination array has afterspace if required.\\n /// @param _bytes The source array\\n /// @param _dest The destination array.\\n /// @param _start The location to start in the source array.\\n function sliceInPlace(\\n bytes memory _bytes,\\n bytes memory _dest,\\n uint _start\\n ) internal pure {\\n uint _length = _dest.length;\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let res := add(_dest, 32)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n res := add(res, 32)\\n } {\\n mstore(res, mload(src))\\n }\\n }\\n }\\n\\n // Static slice functions, no bounds checking\\n /// @notice take a 32-byte slice from the specified position\\n function slice32(bytes memory _bytes, uint _start) internal pure returns (bytes32 res) {\\n assembly {\\n res := mload(add(add(_bytes, 32), _start))\\n }\\n }\\n\\n /// @notice take a 20-byte slice from the specified position\\n function slice20(bytes memory _bytes, uint _start) internal pure returns (bytes20) {\\n return bytes20(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 8-byte slice from the specified position\\n function slice8(bytes memory _bytes, uint _start) internal pure returns (bytes8) {\\n return bytes8(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 4-byte slice from the specified position\\n function slice4(bytes memory _bytes, uint _start) internal pure returns (bytes4) {\\n return bytes4(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 3-byte slice from the specified position\\n function slice3(bytes memory _bytes, uint _start) internal pure returns (bytes3) {\\n return bytes3(slice32(_bytes, _start));\\n }\\n\\n /// @notice take a 2-byte slice from the specified position\\n function slice2(bytes memory _bytes, uint _start) internal pure returns (bytes2) {\\n return bytes2(slice32(_bytes, _start));\\n }\\n\\n function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) {\\n uint _totalLen = _start + 20;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Address conversion out of bounds.\\\");\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint(bytes memory _bytes, uint _start) internal pure returns (uint256) {\\n uint _totalLen = _start + 32;\\n require(_totalLen > _start && _bytes.length >= _totalLen, \\\"Uint conversion out of bounds.\\\");\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {} eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source) pure internal returns (bytes32 result) {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(bytes memory _bytes, uint _start, uint _length) pure internal returns (bytes32 result) {\\n uint _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x43e0f3b3b23c861bd031588bf410dfdd02e2af17941a89aa38d70e534e0380d1\"},\"@keep-network/bitcoin-spv-sol/contracts/CheckBitcoinSigs.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title CheckBitcoinSigs */\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {BTCUtils} from \\\"./BTCUtils.sol\\\";\\n\\n\\nlibrary CheckBitcoinSigs {\\n\\n using BytesLib for bytes;\\n using BTCUtils for bytes;\\n\\n /// @notice Derives an Ethereum Account address from a pubkey\\n /// @dev The address is the last 20 bytes of the keccak256 of the address\\n /// @param _pubkey The public key X & Y. Unprefixed, as a 64-byte array\\n /// @return The account address\\n function accountFromPubkey(bytes memory _pubkey) internal pure returns (address) {\\n require(_pubkey.length == 64, \\\"Pubkey must be 64-byte raw, uncompressed key.\\\");\\n\\n // keccak hash of uncompressed unprefixed pubkey\\n bytes32 _digest = keccak256(_pubkey);\\n return address(uint160(uint256(_digest)));\\n }\\n\\n /// @notice Calculates the p2wpkh output script of a pubkey\\n /// @dev Compresses keys to 33 bytes as required by Bitcoin\\n /// @param _pubkey The public key, compressed or uncompressed\\n /// @return The p2wkph output script\\n function p2wpkhFromPubkey(bytes memory _pubkey) internal view returns (bytes memory) {\\n bytes memory _compressedPubkey;\\n uint8 _prefix;\\n\\n if (_pubkey.length == 64) {\\n _prefix = uint8(_pubkey[_pubkey.length - 1]) % 2 == 1 ? 3 : 2;\\n _compressedPubkey = abi.encodePacked(_prefix, _pubkey.slice32(0));\\n } else if (_pubkey.length == 65) {\\n _prefix = uint8(_pubkey[_pubkey.length - 1]) % 2 == 1 ? 3 : 2;\\n _compressedPubkey = abi.encodePacked(_prefix, _pubkey.slice32(1));\\n } else {\\n _compressedPubkey = _pubkey;\\n }\\n\\n require(_compressedPubkey.length == 33, \\\"Witness PKH requires compressed keys\\\");\\n\\n bytes20 _pubkeyHash = _compressedPubkey.hash160View();\\n return abi.encodePacked(hex\\\"0014\\\", _pubkeyHash);\\n }\\n\\n /// @notice checks a signed message's validity under a pubkey\\n /// @dev does this using ecrecover because Ethereum has no soul\\n /// @param _pubkey the public key to check (64 bytes)\\n /// @param _digest the message digest signed\\n /// @param _v the signature recovery value\\n /// @param _r the signature r value\\n /// @param _s the signature s value\\n /// @return true if signature is valid, else false\\n function checkSig(\\n bytes memory _pubkey,\\n bytes32 _digest,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) internal pure returns (bool) {\\n require(_pubkey.length == 64, \\\"Requires uncompressed unprefixed pubkey\\\");\\n address _expected = accountFromPubkey(_pubkey);\\n address _actual = ecrecover(_digest, _v, _r, _s);\\n return _actual == _expected;\\n }\\n\\n /// @notice checks a signed message against a bitcoin p2wpkh output script\\n /// @dev does this my verifying the p2wpkh matches an ethereum account\\n /// @param _p2wpkhOutputScript the bitcoin output script\\n /// @param _pubkey the uncompressed, unprefixed public key to check\\n /// @param _digest the message digest signed\\n /// @param _v the signature recovery value\\n /// @param _r the signature r value\\n /// @param _s the signature s value\\n /// @return true if signature is valid, else false\\n function checkBitcoinSig(\\n bytes memory _p2wpkhOutputScript,\\n bytes memory _pubkey,\\n bytes32 _digest,\\n uint8 _v,\\n bytes32 _r,\\n bytes32 _s\\n ) internal view returns (bool) {\\n require(_pubkey.length == 64, \\\"Requires uncompressed unprefixed pubkey\\\");\\n\\n bool _isExpectedSigner = keccak256(p2wpkhFromPubkey(_pubkey)) == keccak256(_p2wpkhOutputScript); // is it the expected signer?\\n if (!_isExpectedSigner) {return false;}\\n\\n bool _sigResult = checkSig(_pubkey, _digest, _v, _r, _s);\\n return _sigResult;\\n }\\n\\n /// @notice checks if a message is the sha256 preimage of a digest\\n /// @dev this is NOT the hash256! this step is necessary for ECDSA security!\\n /// @param _digest the digest\\n /// @param _candidate the purported preimage\\n /// @return true if the preimage matches the digest, else false\\n function isSha256Preimage(\\n bytes memory _candidate,\\n bytes32 _digest\\n ) internal pure returns (bool) {\\n return sha256(_candidate) == _digest;\\n }\\n\\n /// @notice checks if a message is the keccak256 preimage of a digest\\n /// @dev this step is necessary for ECDSA security!\\n /// @param _digest the digest\\n /// @param _candidate the purported preimage\\n /// @return true if the preimage matches the digest, else false\\n function isKeccak256Preimage(\\n bytes memory _candidate,\\n bytes32 _digest\\n ) internal pure returns (bool) {\\n return keccak256(_candidate) == _digest;\\n }\\n\\n /// @notice calculates the signature hash of a Bitcoin transaction with the provided details\\n /// @dev documented in bip143. many values are hardcoded here\\n /// @param _outpoint the bitcoin UTXO id (32-byte txid + 4-byte output index)\\n /// @param _inputPKH the input pubkeyhash (hash160(sender_pubkey))\\n /// @param _inputValue the value of the input in satoshi\\n /// @param _outputValue the value of the output in satoshi\\n /// @param _outputScript the length-prefixed output script\\n /// @return the double-sha256 (hash256) signature hash as defined by bip143\\n function wpkhSpendSighash(\\n bytes memory _outpoint, // 36-byte UTXO id\\n bytes20 _inputPKH, // 20-byte hash160\\n bytes8 _inputValue, // 8-byte LE\\n bytes8 _outputValue, // 8-byte LE\\n bytes memory _outputScript // lenght-prefixed output script\\n ) internal view returns (bytes32) {\\n // Fixes elements to easily make a 1-in 1-out sighash digest\\n // Does not support timelocks\\n // bytes memory _scriptCode = abi.encodePacked(\\n // hex\\\"1976a914\\\", // length, dup, hash160, pkh_length\\n // _inputPKH,\\n // hex\\\"88ac\\\"); // equal, checksig\\n\\n bytes32 _hashOutputs = abi.encodePacked(\\n _outputValue, // 8-byte LE\\n _outputScript).hash256View();\\n\\n bytes memory _sighashPreimage = abi.encodePacked(\\n hex\\\"01000000\\\", // version\\n _outpoint.hash256View(), // hashPrevouts\\n hex\\\"8cb9012517c817fead650287d61bdd9c68803b6bf9c64133dcab3e65b5a50cb9\\\", // hashSequence(00000000)\\n _outpoint, // outpoint\\n // p2wpkh script code\\n hex\\\"1976a914\\\", // length, dup, hash160, pkh_length\\n _inputPKH,\\n hex\\\"88ac\\\", // equal, checksig\\n // end script code\\n _inputValue, // value of the input in 8-byte LE\\n hex\\\"00000000\\\", // input nSequence\\n _hashOutputs, // hash of the single output\\n hex\\\"00000000\\\", // nLockTime\\n hex\\\"01000000\\\" // SIGHASH_ALL\\n );\\n return _sighashPreimage.hash256View();\\n }\\n\\n /// @notice calculates the signature hash of a Bitcoin transaction with the provided details\\n /// @dev documented in bip143. many values are hardcoded here\\n /// @param _outpoint the bitcoin UTXO id (32-byte txid + 4-byte output index)\\n /// @param _inputPKH the input pubkeyhash (hash160(sender_pubkey))\\n /// @param _inputValue the value of the input in satoshi\\n /// @param _outputValue the value of the output in satoshi\\n /// @param _outputPKH the output pubkeyhash (hash160(recipient_pubkey))\\n /// @return the double-sha256 (hash256) signature hash as defined by bip143\\n function wpkhToWpkhSighash(\\n bytes memory _outpoint, // 36-byte UTXO id\\n bytes20 _inputPKH, // 20-byte hash160\\n bytes8 _inputValue, // 8-byte LE\\n bytes8 _outputValue, // 8-byte LE\\n bytes20 _outputPKH // 20-byte hash160\\n ) internal view returns (bytes32) {\\n return wpkhSpendSighash(\\n _outpoint,\\n _inputPKH,\\n _inputValue,\\n _outputValue,\\n abi.encodePacked(\\n hex\\\"160014\\\", // wpkh tag\\n _outputPKH)\\n );\\n }\\n\\n /// @notice Preserved for API compatibility with older version\\n /// @dev documented in bip143. many values are hardcoded here\\n /// @param _outpoint the bitcoin UTXO id (32-byte txid + 4-byte output index)\\n /// @param _inputPKH the input pubkeyhash (hash160(sender_pubkey))\\n /// @param _inputValue the value of the input in satoshi\\n /// @param _outputValue the value of the output in satoshi\\n /// @param _outputPKH the output pubkeyhash (hash160(recipient_pubkey))\\n /// @return the double-sha256 (hash256) signature hash as defined by bip143\\n function oneInputOneOutputSighash(\\n bytes memory _outpoint, // 36-byte UTXO id\\n bytes20 _inputPKH, // 20-byte hash160\\n bytes8 _inputValue, // 8-byte LE\\n bytes8 _outputValue, // 8-byte LE\\n bytes20 _outputPKH // 20-byte hash160\\n ) internal view returns (bytes32) {\\n return wpkhToWpkhSighash(_outpoint, _inputPKH, _inputValue, _outputValue, _outputPKH);\\n }\\n\\n}\\n\",\"keccak256\":\"0xfffbd5486af77058fe9385d63d433da914a043994b1affdfcb87248aa10a234c\"},\"@keep-network/bitcoin-spv-sol/contracts/SafeMath.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/*\\nThe MIT License (MIT)\\n\\nCopyright (c) 2016 Smart Contract Solutions, Inc.\\n\\nPermission is hereby granted, free of charge, to any person obtaining\\na copy of this software and associated documentation files (the\\n\\\"Software\\\"), to deal in the Software without restriction, including\\nwithout limitation the rights to use, copy, modify, merge, publish,\\ndistribute, sublicense, and/or sell copies of the Software, and to\\npermit persons to whom the Software is furnished to do so, subject to\\nthe following conditions:\\n\\nThe above copyright notice and this permission notice shall be included\\nin all copies or substantial portions of the Software.\\n\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\\nOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\\n*/\\n\\n\\n/**\\n * @title SafeMath\\n * @dev Math operations with safety checks that throw on error\\n */\\nlibrary SafeMath {\\n\\n /**\\n * @dev Multiplies two numbers, throws on overflow.\\n */\\n function mul(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n // Gas optimization: this is cheaper than asserting 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\\n if (_a == 0) {\\n return 0;\\n }\\n\\n c = _a * _b;\\n require(c / _a == _b, \\\"Overflow during multiplication.\\\");\\n return c;\\n }\\n\\n /**\\n * @dev Integer division of two numbers, truncating the quotient.\\n */\\n function div(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n // assert(_b > 0); // Solidity automatically throws when dividing by 0\\n // uint256 c = _a / _b;\\n // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold\\n return _a / _b;\\n }\\n\\n /**\\n * @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).\\n */\\n function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {\\n require(_b <= _a, \\\"Underflow during subtraction.\\\");\\n return _a - _b;\\n }\\n\\n /**\\n * @dev Adds two numbers, throws on overflow.\\n */\\n function add(uint256 _a, uint256 _b) internal pure returns (uint256 c) {\\n c = _a + _b;\\n require(c >= _a, \\\"Overflow during addition.\\\");\\n return c;\\n }\\n}\\n\",\"keccak256\":\"0x35930d982394c7ffde439b82e5e696c5b21a6f09699d44861dfe409ef64084a3\"},\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\":{\"content\":\"pragma solidity ^0.8.4;\\n\\n/** @title ValidateSPV*/\\n/** @author Summa (https://summa.one) */\\n\\nimport {BytesLib} from \\\"./BytesLib.sol\\\";\\nimport {SafeMath} from \\\"./SafeMath.sol\\\";\\nimport {BTCUtils} from \\\"./BTCUtils.sol\\\";\\n\\n\\nlibrary ValidateSPV {\\n\\n using BTCUtils for bytes;\\n using BTCUtils for uint256;\\n using BytesLib for bytes;\\n using SafeMath for uint256;\\n\\n enum InputTypes { NONE, LEGACY, COMPATIBILITY, WITNESS }\\n enum OutputTypes { NONE, WPKH, WSH, OP_RETURN, PKH, SH, NONSTANDARD }\\n\\n uint256 constant ERR_BAD_LENGTH = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;\\n uint256 constant ERR_INVALID_CHAIN = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe;\\n uint256 constant ERR_LOW_WORK = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd;\\n\\n function getErrBadLength() internal pure returns (uint256) {\\n return ERR_BAD_LENGTH;\\n }\\n\\n function getErrInvalidChain() internal pure returns (uint256) {\\n return ERR_INVALID_CHAIN;\\n }\\n\\n function getErrLowWork() internal pure returns (uint256) {\\n return ERR_LOW_WORK;\\n }\\n\\n /// @notice Validates a tx inclusion in the block\\n /// @dev `index` is not a reliable indicator of location within a block\\n /// @param _txid The txid (LE)\\n /// @param _merkleRoot The merkle root (as in the block header)\\n /// @param _intermediateNodes The proof's intermediate nodes (digests between leaf and root)\\n /// @param _index The leaf's index in the tree (0-indexed)\\n /// @return true if fully valid, false otherwise\\n function prove(\\n bytes32 _txid,\\n bytes32 _merkleRoot,\\n bytes memory _intermediateNodes,\\n uint _index\\n ) internal view returns (bool) {\\n // Shortcut the empty-block case\\n if (_txid == _merkleRoot && _index == 0 && _intermediateNodes.length == 0) {\\n return true;\\n }\\n\\n // If the Merkle proof failed, bubble up error\\n return BTCUtils.verifyHash256Merkle(\\n _txid,\\n _intermediateNodes,\\n _merkleRoot,\\n _index\\n );\\n }\\n\\n /// @notice Hashes transaction to get txid\\n /// @dev Supports Legacy and Witness\\n /// @param _version 4-bytes version\\n /// @param _vin Raw bytes length-prefixed input vector\\n /// @param _vout Raw bytes length-prefixed output vector\\n /// @param _locktime 4-byte tx locktime\\n /// @return 32-byte transaction id, little endian\\n function calculateTxId(\\n bytes4 _version,\\n bytes memory _vin,\\n bytes memory _vout,\\n bytes4 _locktime\\n ) internal view returns (bytes32) {\\n // Get transaction hash double-Sha256(version + nIns + inputs + nOuts + outputs + locktime)\\n return abi.encodePacked(_version, _vin, _vout, _locktime).hash256View();\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @notice Compares the hash of each header to the prevHash in the next header\\n /// @param headers Raw byte array of header chain\\n /// @return totalDifficulty The total accumulated difficulty of the header chain, or an error code\\n function validateHeaderChain(\\n bytes memory headers\\n ) internal view returns (uint256 totalDifficulty) {\\n\\n // Check header chain length\\n if (headers.length % 80 != 0) {return ERR_BAD_LENGTH;}\\n\\n // Initialize header start index\\n bytes32 digest;\\n\\n totalDifficulty = 0;\\n\\n for (uint256 start = 0; start < headers.length; start += 80) {\\n\\n // After the first header, check that headers are in a chain\\n if (start != 0) {\\n if (!validateHeaderPrevHash(headers, start, digest)) {return ERR_INVALID_CHAIN;}\\n }\\n\\n // ith header target\\n uint256 target = headers.extractTargetAt(start);\\n\\n // Require that the header has sufficient work\\n digest = headers.hash256Slice(start, 80);\\n if(uint256(digest).reverseUint256() > target) {\\n return ERR_LOW_WORK;\\n }\\n\\n // Add ith header difficulty to difficulty sum\\n totalDifficulty = totalDifficulty + target.calculateDifficulty();\\n }\\n }\\n\\n /// @notice Checks validity of header work\\n /// @param digest Header digest\\n /// @param target The target threshold\\n /// @return true if header work is valid, false otherwise\\n function validateHeaderWork(\\n bytes32 digest,\\n uint256 target\\n ) internal pure returns (bool) {\\n if (digest == bytes32(0)) {return false;}\\n return (uint256(digest).reverseUint256() < target);\\n }\\n\\n /// @notice Checks validity of header chain\\n /// @dev Compares current header prevHash to previous header's digest\\n /// @param headers The raw bytes array containing the header\\n /// @param at The position of the header\\n /// @param prevHeaderDigest The previous header's digest\\n /// @return true if the connect is valid, false otherwise\\n function validateHeaderPrevHash(\\n bytes memory headers,\\n uint256 at,\\n bytes32 prevHeaderDigest\\n ) internal pure returns (bool) {\\n\\n // Extract prevHash of current header\\n bytes32 prevHash = headers.extractPrevBlockLEAt(at);\\n\\n // Compare prevHash of current header to previous header's digest\\n if (prevHash != prevHeaderDigest) {return false;}\\n\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0xce3febbf3ad3a7ff8a8effd0c7ccaf7ccfa2719578b537d49ea196f0bae8062b\"},\"@keep-network/ecdsa/contracts/EcdsaDkgValidator.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\n// Initial version copied from Keep Network Random Beacon:\\n// https://github.com/keep-network/keep-core/blob/5138c7628868dbeed3ae2164f76fccc6c1fbb9e8/solidity/random-beacon/contracts/DKGValidator.sol\\n//\\n// With the following differences:\\n// - group public key length,\\n// - group size and related thresholds,\\n// - documentation.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/libraries/BytesLib.sol\\\";\\nimport \\\"@keep-network/sortition-pools/contracts/SortitionPool.sol\\\";\\nimport \\\"./libraries/EcdsaDkg.sol\\\";\\n\\n/// @title DKG result validator\\n/// @notice EcdsaDkgValidator allows performing a full validation of DKG result,\\n/// including checking the format of fields in the result, declared\\n/// selected group members, and signatures of operators supporting the\\n/// result. The operator submitting the result should perform the\\n/// validation using a free contract call before submitting the result\\n/// to ensure their result is valid and can not be challenged. All other\\n/// network operators should perform validation of the submitted result\\n/// using a free contract call and challenge the result if the\\n/// validation fails.\\ncontract EcdsaDkgValidator {\\n using BytesLib for bytes;\\n using ECDSA for bytes32;\\n\\n /// @dev Size of a group in DKG.\\n uint256 public constant groupSize = 100;\\n\\n /// @dev The minimum number of group members needed to interact according to\\n /// the protocol to produce a signature. The adversary can not learn\\n /// anything about the key as long as it does not break into\\n /// groupThreshold+1 of members.\\n uint256 public constant groupThreshold = 51;\\n\\n /// @dev The minimum number of active and properly behaving group members\\n /// during the DKG needed to accept the result. This number is higher\\n /// than `groupThreshold` to keep a safety margin for members becoming\\n /// inactive after DKG so that the group can still produce signature.\\n uint256 public constant activeThreshold = 90; // 90% of groupSize\\n\\n /// @dev Size in bytes of a public key produced by group members during the\\n /// the DKG. The length assumes uncompressed ECDSA public key.\\n uint256 public constant publicKeyByteSize = 64;\\n\\n /// @dev Size in bytes of a single signature produced by operator supporting\\n /// DKG result.\\n uint256 public constant signatureByteSize = 65;\\n\\n SortitionPool public immutable sortitionPool;\\n\\n constructor(SortitionPool _sortitionPool) {\\n sortitionPool = _sortitionPool;\\n }\\n\\n /// @notice Performs a full validation of DKG result, including checking the\\n /// format of fields in the result, declared selected group members,\\n /// and signatures of operators supporting the result.\\n /// @param seed seed used to start the DKG and select group members\\n /// @param startBlock DKG start block\\n /// @return isValid true if the result is valid, false otherwise\\n /// @return errorMsg validation error message; empty for a valid result\\n function validate(\\n EcdsaDkg.Result calldata result,\\n uint256 seed,\\n uint256 startBlock\\n ) external view returns (bool isValid, string memory errorMsg) {\\n (bool hasValidFields, string memory error) = validateFields(result);\\n if (!hasValidFields) {\\n return (false, error);\\n }\\n\\n if (!validateSignatures(result, startBlock)) {\\n return (false, \\\"Invalid signatures\\\");\\n }\\n\\n if (!validateGroupMembers(result, seed)) {\\n return (false, \\\"Invalid group members\\\");\\n }\\n\\n // At this point all group members and misbehaved members were verified\\n if (!validateMembersHash(result)) {\\n return (false, \\\"Invalid members hash\\\");\\n }\\n\\n return (true, \\\"\\\");\\n }\\n\\n /// @notice Performs a static validation of DKG result fields: lengths,\\n /// ranges, and order of arrays.\\n /// @return isValid true if the result is valid, false otherwise\\n /// @return errorMsg validation error message; empty for a valid result\\n function validateFields(EcdsaDkg.Result calldata result)\\n public\\n pure\\n returns (bool isValid, string memory errorMsg)\\n {\\n if (result.groupPubKey.length != publicKeyByteSize) {\\n return (false, \\\"Malformed group public key\\\");\\n }\\n\\n // The number of misbehaved members can not exceed the threshold.\\n // Misbehaved member indices needs to be unique, between [1, groupSize],\\n // and sorted in ascending order.\\n uint8[] calldata misbehavedMembersIndices = result\\n .misbehavedMembersIndices;\\n if (groupSize - misbehavedMembersIndices.length < activeThreshold) {\\n return (false, \\\"Too many members misbehaving during DKG\\\");\\n }\\n if (misbehavedMembersIndices.length > 1) {\\n if (\\n misbehavedMembersIndices[0] < 1 ||\\n misbehavedMembersIndices[misbehavedMembersIndices.length - 1] >\\n groupSize\\n ) {\\n return (false, \\\"Corrupted misbehaved members indices\\\");\\n }\\n for (uint256 i = 1; i < misbehavedMembersIndices.length; i++) {\\n if (\\n misbehavedMembersIndices[i - 1] >=\\n misbehavedMembersIndices[i]\\n ) {\\n return (false, \\\"Corrupted misbehaved members indices\\\");\\n }\\n }\\n }\\n\\n // Each signature needs to have a correct length and signatures need to\\n // be provided.\\n uint256 signaturesCount = result.signatures.length / signatureByteSize;\\n if (result.signatures.length == 0) {\\n return (false, \\\"No signatures provided\\\");\\n }\\n if (result.signatures.length % signatureByteSize != 0) {\\n return (false, \\\"Malformed signatures array\\\");\\n }\\n\\n // We expect the same amount of signatures as the number of declared\\n // group member indices that signed the result.\\n uint256[] calldata signingMembersIndices = result.signingMembersIndices;\\n if (signaturesCount != signingMembersIndices.length) {\\n return (false, \\\"Unexpected signatures count\\\");\\n }\\n if (signaturesCount < groupThreshold) {\\n return (false, \\\"Too few signatures\\\");\\n }\\n if (signaturesCount > groupSize) {\\n return (false, \\\"Too many signatures\\\");\\n }\\n\\n // Signing member indices needs to be unique, between [1,groupSize],\\n // and sorted in ascending order.\\n if (\\n signingMembersIndices[0] < 1 ||\\n signingMembersIndices[signingMembersIndices.length - 1] > groupSize\\n ) {\\n return (false, \\\"Corrupted signing member indices\\\");\\n }\\n for (uint256 i = 1; i < signingMembersIndices.length; i++) {\\n if (signingMembersIndices[i - 1] >= signingMembersIndices[i]) {\\n return (false, \\\"Corrupted signing member indices\\\");\\n }\\n }\\n\\n return (true, \\\"\\\");\\n }\\n\\n /// @notice Performs validation of group members as declared in DKG\\n /// result against group members selected by the sortition pool.\\n /// @param seed seed used to start the DKG and select group members\\n /// @return true if group members matches; false otherwise\\n function validateGroupMembers(EcdsaDkg.Result calldata result, uint256 seed)\\n public\\n view\\n returns (bool)\\n {\\n uint32[] calldata resultMembers = result.members;\\n uint32[] memory actualGroupMembers = sortitionPool.selectGroup(\\n groupSize,\\n bytes32(seed)\\n );\\n if (resultMembers.length != actualGroupMembers.length) {\\n return false;\\n }\\n for (uint256 i = 0; i < resultMembers.length; i++) {\\n if (resultMembers[i] != actualGroupMembers[i]) {\\n return false;\\n }\\n }\\n return true;\\n }\\n\\n /// @notice Performs validation of signatures supplied in DKG result.\\n /// Note that this function does not check if addresses which\\n /// supplied signatures supporting the result are the ones selected\\n /// to the group by sortition pool. This function should be used\\n /// together with `validateGroupMembers`.\\n /// @param startBlock DKG start block\\n /// @return true if group members matches; false otherwise\\n function validateSignatures(\\n EcdsaDkg.Result calldata result,\\n uint256 startBlock\\n ) public view returns (bool) {\\n bytes32 hash = keccak256(\\n abi.encode(\\n block.chainid,\\n result.groupPubKey,\\n result.misbehavedMembersIndices,\\n startBlock\\n )\\n ).toEthSignedMessageHash();\\n\\n uint256[] calldata signingMembersIndices = result.signingMembersIndices;\\n uint32[] memory signingMemberIds = new uint32[](\\n signingMembersIndices.length\\n );\\n for (uint256 i = 0; i < signingMembersIndices.length; i++) {\\n signingMemberIds[i] = result.members[signingMembersIndices[i] - 1];\\n }\\n\\n address[] memory signingMemberAddresses = sortitionPool.getIDOperators(\\n signingMemberIds\\n );\\n\\n bytes memory current; // Current signature to be checked.\\n\\n uint256 signaturesCount = result.signatures.length / signatureByteSize;\\n for (uint256 i = 0; i < signaturesCount; i++) {\\n current = result.signatures.slice(\\n signatureByteSize * i,\\n signatureByteSize\\n );\\n address recoveredAddress = hash.recover(current);\\n\\n if (signingMemberAddresses[i] != recoveredAddress) {\\n return false;\\n }\\n }\\n\\n return true;\\n }\\n\\n /// @notice Performs validation of hashed group members that actively took\\n /// part in DKG.\\n /// @param result DKG result\\n /// @return true if calculated result's group members hash matches with the\\n /// one that is challenged.\\n function validateMembersHash(EcdsaDkg.Result calldata result)\\n public\\n pure\\n returns (bool)\\n {\\n if (result.misbehavedMembersIndices.length > 0) {\\n // members that generated a group signing key\\n uint32[] memory groupMembers = new uint32[](\\n result.members.length - result.misbehavedMembersIndices.length\\n );\\n uint256 k = 0; // misbehaved members counter\\n uint256 j = 0; // group members counter\\n for (uint256 i = 0; i < result.members.length; i++) {\\n // misbehaved member indices start from 1, so we need to -1 on misbehaved\\n if (i != result.misbehavedMembersIndices[k] - 1) {\\n groupMembers[j] = result.members[i];\\n j++;\\n } else if (k < result.misbehavedMembersIndices.length - 1) {\\n k++;\\n }\\n }\\n\\n return keccak256(abi.encode(groupMembers)) == result.membersHash;\\n }\\n\\n return keccak256(abi.encode(result.members)) == result.membersHash;\\n }\\n}\\n\",\"keccak256\":\"0xe8f3d63ef4213ac71d447726be3971c5ed6b0b0eb145763d324faecdce707bf6\",\"license\":\"GPL-3.0-only\"},\"@keep-network/ecdsa/contracts/api/IWalletOwner.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\npragma solidity 0.8.17;\\n\\ninterface IWalletOwner {\\n /// @notice Callback function executed once a new wallet is created.\\n /// @dev Should be callable only by the Wallet Registry.\\n /// @param walletID Wallet's unique identifier.\\n /// @param publicKeyY Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n function __ecdsaWalletCreatedCallback(\\n bytes32 walletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external;\\n\\n /// @notice Callback function executed once a wallet heartbeat failure\\n /// is detected.\\n /// @dev Should be callable only by the Wallet Registry.\\n /// @param walletID Wallet's unique identifier.\\n /// @param publicKeyY Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n function __ecdsaWalletHeartbeatFailedCallback(\\n bytes32 walletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external;\\n}\\n\",\"keccak256\":\"0x8d4654269ab20710e8a729c225c2c69edae7f01ddbd5e037ab591df65e32faa8\",\"license\":\"GPL-3.0-only\"},\"@keep-network/ecdsa/contracts/api/IWalletRegistry.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"../libraries/EcdsaDkg.sol\\\";\\n\\ninterface IWalletRegistry {\\n /// @notice Requests a new wallet creation.\\n /// @dev Only the Wallet Owner can call this function.\\n function requestNewWallet() external;\\n\\n /// @notice Closes an existing wallet.\\n /// @param walletID ID of the wallet.\\n /// @dev Only the Wallet Owner can call this function.\\n function closeWallet(bytes32 walletID) external;\\n\\n /// @notice Adds all signing group members of the wallet with the given ID\\n /// to the slashing queue of the staking contract. The notifier will\\n /// receive reward per each group member from the staking contract\\n /// notifiers treasury. The reward is scaled by the\\n /// `rewardMultiplier` provided as a parameter.\\n /// @param amount Amount of tokens to seize from each signing group member\\n /// @param rewardMultiplier Fraction of the staking contract notifiers\\n /// reward the notifier should receive; should be between [0, 100]\\n /// @param notifier Address of the misbehavior notifier\\n /// @param walletID ID of the wallet\\n /// @param walletMembersIDs Identifiers of the wallet signing group members\\n /// @dev Only the Wallet Owner can call this function.\\n /// Requirements:\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events.\\n /// - `rewardMultiplier` must be between [0, 100].\\n /// - This function does revert if staking contract call reverts.\\n /// The calling code needs to handle the potential revert.\\n function seize(\\n uint96 amount,\\n uint256 rewardMultiplier,\\n address notifier,\\n bytes32 walletID,\\n uint32[] calldata walletMembersIDs\\n ) external;\\n\\n /// @notice Gets public key of a wallet with a given wallet ID.\\n /// The public key is returned in an uncompressed format as a 64-byte\\n /// concatenation of X and Y coordinates.\\n /// @param walletID ID of the wallet.\\n /// @return Uncompressed public key of the wallet.\\n function getWalletPublicKey(bytes32 walletID)\\n external\\n view\\n returns (bytes memory);\\n\\n /// @notice Check current wallet creation state.\\n function getWalletCreationState() external view returns (EcdsaDkg.State);\\n\\n /// @notice Checks whether the given operator is a member of the given\\n /// wallet signing group.\\n /// @param walletID ID of the wallet\\n /// @param walletMembersIDs Identifiers of the wallet signing group members\\n /// @param operator Address of the checked operator\\n /// @param walletMemberIndex Position of the operator in the wallet signing\\n /// group members list\\n /// @return True - if the operator is a member of the given wallet signing\\n /// group. False - otherwise.\\n /// @dev Requirements:\\n /// - The `operator` parameter must be an actual sortition pool operator.\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events.\\n /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length]\\n function isWalletMember(\\n bytes32 walletID,\\n uint32[] calldata walletMembersIDs,\\n address operator,\\n uint256 walletMemberIndex\\n ) external view returns (bool);\\n}\\n\",\"keccak256\":\"0xb97ece7c12601396fed705386a4e3337ee3a4809dca090a5acb62c2949337c68\",\"license\":\"GPL-3.0-only\"},\"@keep-network/ecdsa/contracts/libraries/EcdsaDkg.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n//\\n\\n// Initial version copied from Keep Network Random Beacon:\\n// https://github.com/keep-network/keep-core/blob/5138c7628868dbeed3ae2164f76fccc6c1fbb9e8/solidity/random-beacon/contracts/libraries/DKG.sol\\n//\\n// With the following differences:\\n// - the group size was set to 100,\\n// - offchainDkgTimeout was removed,\\n// - submission eligibility verification is not performed on-chain,\\n// - submission eligibility delay was replaced with a submission timeout,\\n// - seed timeout notification requires seedTimeout period to pass.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol\\\";\\nimport \\\"@keep-network/sortition-pools/contracts/SortitionPool.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/libraries/BytesLib.sol\\\";\\nimport \\\"../EcdsaDkgValidator.sol\\\";\\n\\nlibrary EcdsaDkg {\\n using BytesLib for bytes;\\n using ECDSAUpgradeable for bytes32;\\n\\n struct Parameters {\\n // Time in blocks during which a seed is expected to be delivered.\\n // DKG starts only after a seed is delivered. The time the contract\\n // awaits for a seed is not included in the DKG timeout.\\n uint256 seedTimeout;\\n // Time in blocks during which a submitted result can be challenged.\\n uint256 resultChallengePeriodLength;\\n // Extra gas required to be left at the end of the challenge DKG result\\n // transaction.\\n uint256 resultChallengeExtraGas;\\n // Time in blocks during which a result is expected to be submitted.\\n uint256 resultSubmissionTimeout;\\n // Time in blocks during which only the result submitter is allowed to\\n // approve it. Once this period ends and the submitter have not approved\\n // the result, anyone can do it.\\n uint256 submitterPrecedencePeriodLength;\\n // This struct doesn't contain `__gap` property as the structure is\\n // stored inside `Data` struct, that already have a gap that can be used\\n // on upgrade.\\n }\\n\\n struct Data {\\n // Address of the Sortition Pool contract.\\n SortitionPool sortitionPool;\\n // Address of the EcdsaDkgValidator contract.\\n EcdsaDkgValidator dkgValidator;\\n // DKG parameters. The parameters should persist between DKG executions.\\n // They should be updated with dedicated set functions only when DKG is not\\n // in progress.\\n Parameters parameters;\\n // Time in block at which DKG state was locked.\\n uint256 stateLockBlock;\\n // Time in blocks at which DKG started.\\n uint256 startBlock;\\n // Seed used to start DKG.\\n uint256 seed;\\n // Time in blocks that should be added to result submission eligibility\\n // delay calculation. It is used in case of a challenge to adjust\\n // DKG timeout calculation.\\n uint256 resultSubmissionStartBlockOffset;\\n // Hash of submitted DKG result.\\n bytes32 submittedResultHash;\\n // Block number from the moment of the DKG result submission.\\n uint256 submittedResultBlock;\\n // Reserved storage space in case we need to add more variables.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[38] __gap;\\n }\\n\\n /// @notice DKG result.\\n struct Result {\\n // Claimed submitter candidate group member index.\\n // Must be in range [1, groupSize].\\n uint256 submitterMemberIndex;\\n // Generated candidate group public key\\n bytes groupPubKey;\\n // Array of misbehaved members indices (disqualified or inactive).\\n // Indices must be in range [1, groupSize], unique, and sorted in ascending\\n // order.\\n uint8[] misbehavedMembersIndices;\\n // Concatenation of signatures from members supporting the result.\\n // The message to be signed by each member is keccak256 hash of the\\n // calculated group public key, misbehaved members indices and DKG\\n // start block. The calculated hash should be prefixed with prefixed with\\n // `\\\\x19Ethereum signed message:\\\\n` before signing, so the message to\\n // sign is:\\n // `\\\\x19Ethereum signed message:\\\\n${keccak256(\\n // groupPubKey, misbehavedMembersIndices, dkgStartBlock\\n // )}`\\n bytes signatures;\\n // Indices of members corresponding to each signature. Indices must be\\n // be in range [1, groupSize], unique, and sorted in ascending order.\\n uint256[] signingMembersIndices;\\n // Identifiers of candidate group members as outputted by the group\\n // selection protocol.\\n uint32[] members;\\n // Keccak256 hash of group members identifiers that actively took part\\n // in DKG (excluding IA/DQ members).\\n bytes32 membersHash;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice States for phases of group creation. The states doesn't include\\n /// timeouts which should be tracked and notified individually.\\n enum State {\\n // Group creation is not in progress. It is a state set after group creation\\n // completion either by timeout or by a result approval.\\n IDLE,\\n // Group creation is awaiting the seed and sortition pool is locked.\\n AWAITING_SEED,\\n // DKG protocol execution is in progress. A result is being calculated\\n // by the clients in this state and the contract awaits a result submission.\\n // This is a state to which group creation returns in case of a result\\n // challenge notification.\\n AWAITING_RESULT,\\n // DKG result was submitted and awaits an approval or a challenge. If a result\\n // gets challenge the state returns to `AWAITING_RESULT`. If a result gets\\n // approval the state changes to `IDLE`.\\n CHALLENGE\\n }\\n\\n /// @dev Size of a group in ECDSA wallet.\\n uint256 public constant groupSize = 100;\\n\\n event DkgStarted(uint256 indexed seed);\\n\\n // To recreate the members that actively took part in dkg, the selected members\\n // array should be filtered out from misbehavedMembersIndices.\\n event DkgResultSubmitted(\\n bytes32 indexed resultHash,\\n uint256 indexed seed,\\n Result result\\n );\\n\\n event DkgTimedOut();\\n\\n event DkgResultApproved(\\n bytes32 indexed resultHash,\\n address indexed approver\\n );\\n\\n event DkgResultChallenged(\\n bytes32 indexed resultHash,\\n address indexed challenger,\\n string reason\\n );\\n\\n event DkgStateLocked();\\n\\n event DkgSeedTimedOut();\\n\\n /// @notice Initializes SortitionPool and EcdsaDkgValidator addresses.\\n /// Can be performed only once.\\n /// @param _sortitionPool Sortition Pool reference\\n /// @param _dkgValidator EcdsaDkgValidator reference\\n function init(\\n Data storage self,\\n SortitionPool _sortitionPool,\\n EcdsaDkgValidator _dkgValidator\\n ) internal {\\n require(\\n address(self.sortitionPool) == address(0),\\n \\\"Sortition Pool address already set\\\"\\n );\\n\\n require(\\n address(self.dkgValidator) == address(0),\\n \\\"DKG Validator address already set\\\"\\n );\\n\\n self.sortitionPool = _sortitionPool;\\n self.dkgValidator = _dkgValidator;\\n }\\n\\n /// @notice Determines the current state of group creation. It doesn't take\\n /// timeouts into consideration. The timeouts should be tracked and\\n /// notified separately.\\n function currentState(Data storage self)\\n internal\\n view\\n returns (State state)\\n {\\n state = State.IDLE;\\n\\n if (self.sortitionPool.isLocked()) {\\n state = State.AWAITING_SEED;\\n\\n if (self.startBlock > 0) {\\n state = State.AWAITING_RESULT;\\n\\n if (self.submittedResultBlock > 0) {\\n state = State.CHALLENGE;\\n }\\n }\\n }\\n }\\n\\n /// @notice Locks the sortition pool and starts awaiting for the\\n /// group creation seed.\\n function lockState(Data storage self) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n emit DkgStateLocked();\\n\\n self.sortitionPool.lock();\\n\\n self.stateLockBlock = block.number;\\n }\\n\\n function start(Data storage self, uint256 seed) internal {\\n require(\\n currentState(self) == State.AWAITING_SEED,\\n \\\"Current state is not AWAITING_SEED\\\"\\n );\\n\\n emit DkgStarted(seed);\\n\\n self.startBlock = block.number;\\n self.seed = seed;\\n }\\n\\n /// @notice Allows to submit a DKG result. The submitted result does not go\\n /// through a validation and before it gets accepted, it needs to\\n /// wait through the challenge period during which everyone has\\n /// a chance to challenge the result as invalid one. Submitter of\\n /// the result needs to be in the sortition pool and if the result\\n /// gets challenged, the submitter will get slashed.\\n function submitResult(Data storage self, Result calldata result) internal {\\n require(\\n currentState(self) == State.AWAITING_RESULT,\\n \\\"Current state is not AWAITING_RESULT\\\"\\n );\\n require(!hasDkgTimedOut(self), \\\"DKG timeout already passed\\\");\\n\\n SortitionPool sortitionPool = self.sortitionPool;\\n\\n // Submitter must be an operator in the sortition pool.\\n // Declared submitter's member index in the DKG result needs to match\\n // the address calling this function.\\n require(\\n sortitionPool.isOperatorInPool(msg.sender),\\n \\\"Submitter not in the sortition pool\\\"\\n );\\n require(\\n sortitionPool.getIDOperator(\\n result.members[result.submitterMemberIndex - 1]\\n ) == msg.sender,\\n \\\"Unexpected submitter index\\\"\\n );\\n\\n self.submittedResultHash = keccak256(abi.encode(result));\\n self.submittedResultBlock = block.number;\\n\\n emit DkgResultSubmitted(self.submittedResultHash, self.seed, result);\\n }\\n\\n /// @notice Checks if awaiting seed timed out.\\n /// @return True if awaiting seed timed out, false otherwise.\\n function hasSeedTimedOut(Data storage self) internal view returns (bool) {\\n return\\n currentState(self) == State.AWAITING_SEED &&\\n block.number > (self.stateLockBlock + self.parameters.seedTimeout);\\n }\\n\\n /// @notice Checks if DKG timed out. The DKG timeout period includes time required\\n /// for off-chain protocol execution and time for the result publication.\\n /// After this time a result cannot be submitted and DKG can be notified\\n /// about the timeout. DKG period is adjusted by result submission\\n /// offset that include blocks that were mined while invalid result\\n /// has been registered until it got challenged.\\n /// @return True if DKG timed out, false otherwise.\\n function hasDkgTimedOut(Data storage self) internal view returns (bool) {\\n return\\n currentState(self) == State.AWAITING_RESULT &&\\n block.number >\\n (self.startBlock +\\n self.resultSubmissionStartBlockOffset +\\n self.parameters.resultSubmissionTimeout);\\n }\\n\\n /// @notice Notifies about the seed was not delivered and restores the\\n /// initial DKG state (IDLE).\\n function notifySeedTimeout(Data storage self) internal {\\n require(hasSeedTimedOut(self), \\\"Awaiting seed has not timed out\\\");\\n\\n emit DkgSeedTimedOut();\\n\\n complete(self);\\n }\\n\\n /// @notice Notifies about DKG timeout.\\n function notifyDkgTimeout(Data storage self) internal {\\n require(hasDkgTimedOut(self), \\\"DKG has not timed out\\\");\\n\\n emit DkgTimedOut();\\n\\n complete(self);\\n }\\n\\n /// @notice Approves DKG result. Can be called when the challenge period for\\n /// the submitted result is finished. Considers the submitted result\\n /// as valid. For the first `submitterPrecedencePeriodLength`\\n /// blocks after the end of the challenge period can be called only\\n /// by the DKG result submitter. After that time, can be called by\\n /// anyone.\\n /// @dev Can be called after a challenge period for the submitted result.\\n /// @param result Result to approve. Must match the submitted result stored\\n /// during `submitResult`.\\n /// @return misbehavedMembers Identifiers of members who misbehaved during DKG.\\n function approveResult(Data storage self, Result calldata result)\\n internal\\n returns (uint32[] memory misbehavedMembers)\\n {\\n require(\\n currentState(self) == State.CHALLENGE,\\n \\\"Current state is not CHALLENGE\\\"\\n );\\n\\n uint256 challengePeriodEnd = self.submittedResultBlock +\\n self.parameters.resultChallengePeriodLength;\\n\\n require(\\n block.number > challengePeriodEnd,\\n \\\"Challenge period has not passed yet\\\"\\n );\\n\\n require(\\n keccak256(abi.encode(result)) == self.submittedResultHash,\\n \\\"Result under approval is different than the submitted one\\\"\\n );\\n\\n // Extract submitter member address. Submitter member index is in\\n // range [1, groupSize] so we need to -1 when fetching identifier from members\\n // array.\\n address submitterMember = self.sortitionPool.getIDOperator(\\n result.members[result.submitterMemberIndex - 1]\\n );\\n\\n require(\\n msg.sender == submitterMember ||\\n block.number >\\n challengePeriodEnd +\\n self.parameters.submitterPrecedencePeriodLength,\\n \\\"Only the DKG result submitter can approve the result at this moment\\\"\\n );\\n\\n // Extract misbehaved members identifiers. Misbehaved members indices\\n // are in range [1, groupSize], so we need to -1 when fetching identifiers from\\n // members array.\\n misbehavedMembers = new uint32[](\\n result.misbehavedMembersIndices.length\\n );\\n for (uint256 i = 0; i < result.misbehavedMembersIndices.length; i++) {\\n misbehavedMembers[i] = result.members[\\n result.misbehavedMembersIndices[i] - 1\\n ];\\n }\\n\\n emit DkgResultApproved(self.submittedResultHash, msg.sender);\\n\\n return misbehavedMembers;\\n }\\n\\n /// @notice Challenges DKG result. If the submitted result is proved to be\\n /// invalid it reverts the DKG back to the result submission phase.\\n /// @dev Can be called during a challenge period for the submitted result.\\n /// @param result Result to challenge. Must match the submitted result\\n /// stored during `submitResult`.\\n /// @return maliciousResultHash Hash of the malicious result.\\n /// @return maliciousSubmitter Identifier of the malicious submitter.\\n function challengeResult(Data storage self, Result calldata result)\\n internal\\n returns (bytes32 maliciousResultHash, uint32 maliciousSubmitter)\\n {\\n require(\\n currentState(self) == State.CHALLENGE,\\n \\\"Current state is not CHALLENGE\\\"\\n );\\n\\n require(\\n block.number <=\\n self.submittedResultBlock +\\n self.parameters.resultChallengePeriodLength,\\n \\\"Challenge period has already passed\\\"\\n );\\n\\n require(\\n keccak256(abi.encode(result)) == self.submittedResultHash,\\n \\\"Result under challenge is different than the submitted one\\\"\\n );\\n\\n // https://github.com/crytic/slither/issues/982\\n // slither-disable-next-line unused-return\\n try\\n self.dkgValidator.validate(result, self.seed, self.startBlock)\\n returns (\\n // slither-disable-next-line uninitialized-local,variable-scope\\n bool isValid,\\n // slither-disable-next-line uninitialized-local,variable-scope\\n string memory errorMsg\\n ) {\\n if (isValid) {\\n revert(\\\"unjustified challenge\\\");\\n }\\n\\n emit DkgResultChallenged(\\n self.submittedResultHash,\\n msg.sender,\\n errorMsg\\n );\\n } catch {\\n // if the validation reverted we consider the DKG result as invalid\\n emit DkgResultChallenged(\\n self.submittedResultHash,\\n msg.sender,\\n \\\"validation reverted\\\"\\n );\\n }\\n\\n // Consider result hash as malicious.\\n maliciousResultHash = self.submittedResultHash;\\n maliciousSubmitter = result.members[result.submitterMemberIndex - 1];\\n\\n // Adjust DKG result submission block start, so submission stage starts\\n // from the beginning.\\n self.resultSubmissionStartBlockOffset = block.number - self.startBlock;\\n\\n submittedResultCleanup(self);\\n\\n return (maliciousResultHash, maliciousSubmitter);\\n }\\n\\n /// @notice Due to EIP150, 1/64 of the gas is not forwarded to the call, and\\n /// will be kept to execute the remaining operations in the function\\n /// after the call inside the try-catch.\\n ///\\n /// To ensure there is no way for the caller to manipulate gas limit\\n /// in such a way that the call inside try-catch fails with out-of-gas\\n /// and the rest of the function is executed with the remaining\\n /// 1/64 of gas, we require an extra gas amount to be left at the\\n /// end of the call to the function challenging DKG result and\\n /// wrapping the call to EcdsaDkgValidator and TokenStaking\\n /// contracts inside a try-catch.\\n function requireChallengeExtraGas(Data storage self) internal view {\\n require(\\n gasleft() >= self.parameters.resultChallengeExtraGas,\\n \\\"Not enough extra gas left\\\"\\n );\\n }\\n\\n /// @notice Checks if DKG result is valid for the current DKG.\\n /// @param result DKG result.\\n /// @return True if the result is valid. If the result is invalid it returns\\n /// false and an error message.\\n function isResultValid(Data storage self, Result calldata result)\\n internal\\n view\\n returns (bool, string memory)\\n {\\n require(self.startBlock > 0, \\\"DKG has not been started\\\");\\n\\n return self.dkgValidator.validate(result, self.seed, self.startBlock);\\n }\\n\\n /// @notice Set setSeedTimeout parameter.\\n function setSeedTimeout(Data storage self, uint256 newSeedTimeout)\\n internal\\n {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(newSeedTimeout > 0, \\\"New value should be greater than zero\\\");\\n\\n self.parameters.seedTimeout = newSeedTimeout;\\n }\\n\\n /// @notice Set resultChallengePeriodLength parameter.\\n function setResultChallengePeriodLength(\\n Data storage self,\\n uint256 newResultChallengePeriodLength\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(\\n newResultChallengePeriodLength > 0,\\n \\\"New value should be greater than zero\\\"\\n );\\n\\n self\\n .parameters\\n .resultChallengePeriodLength = newResultChallengePeriodLength;\\n }\\n\\n /// @notice Set resultChallengeExtraGas parameter.\\n function setResultChallengeExtraGas(\\n Data storage self,\\n uint256 newResultChallengeExtraGas\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n self.parameters.resultChallengeExtraGas = newResultChallengeExtraGas;\\n }\\n\\n /// @notice Set resultSubmissionTimeout parameter.\\n function setResultSubmissionTimeout(\\n Data storage self,\\n uint256 newResultSubmissionTimeout\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(\\n newResultSubmissionTimeout > 0,\\n \\\"New value should be greater than zero\\\"\\n );\\n\\n self.parameters.resultSubmissionTimeout = newResultSubmissionTimeout;\\n }\\n\\n /// @notice Set submitterPrecedencePeriodLength parameter.\\n function setSubmitterPrecedencePeriodLength(\\n Data storage self,\\n uint256 newSubmitterPrecedencePeriodLength\\n ) internal {\\n require(currentState(self) == State.IDLE, \\\"Current state is not IDLE\\\");\\n\\n require(\\n newSubmitterPrecedencePeriodLength <\\n self.parameters.resultSubmissionTimeout,\\n \\\"New value should be less than result submission period length\\\"\\n );\\n\\n self\\n .parameters\\n .submitterPrecedencePeriodLength = newSubmitterPrecedencePeriodLength;\\n }\\n\\n /// @notice Completes DKG by cleaning up state.\\n /// @dev Should be called after DKG times out or a result is approved.\\n function complete(Data storage self) internal {\\n delete self.startBlock;\\n delete self.seed;\\n delete self.resultSubmissionStartBlockOffset;\\n submittedResultCleanup(self);\\n self.sortitionPool.unlock();\\n }\\n\\n /// @notice Cleans up submitted result state either after DKG completion\\n /// (as part of `complete` method) or after justified challenge.\\n function submittedResultCleanup(Data storage self) private {\\n delete self.submittedResultHash;\\n delete self.submittedResultBlock;\\n }\\n}\\n\",\"keccak256\":\"0xd6c442e1db2dc95730443fb6496d47889a69bed2fbace466b27f9727484c25ec\",\"license\":\"GPL-3.0-only\"},\"@keep-network/random-beacon/contracts/Governable.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\npragma solidity 0.8.17;\\n\\n/// @notice Governable contract.\\n/// @dev A constructor is not defined, which makes the contract compatible with\\n/// upgradable proxies. This requires calling explicitly `_transferGovernance`\\n/// function in a child contract.\\nabstract contract Governable {\\n // Governance of the contract\\n // The variable should be initialized by the implementing contract.\\n // slither-disable-next-line uninitialized-state\\n address public governance;\\n\\n // Reserved storage space in case we need to add more variables,\\n // since there are upgradeable contracts that inherit from this one.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[49] private __gap;\\n\\n event GovernanceTransferred(address oldGovernance, address newGovernance);\\n\\n modifier onlyGovernance() virtual {\\n require(governance == msg.sender, \\\"Caller is not the governance\\\");\\n _;\\n }\\n\\n /// @notice Transfers governance of the contract to `newGovernance`.\\n function transferGovernance(address newGovernance)\\n external\\n virtual\\n onlyGovernance\\n {\\n require(\\n newGovernance != address(0),\\n \\\"New governance is the zero address\\\"\\n );\\n _transferGovernance(newGovernance);\\n }\\n\\n function _transferGovernance(address newGovernance) internal virtual {\\n address oldGovernance = governance;\\n governance = newGovernance;\\n emit GovernanceTransferred(oldGovernance, newGovernance);\\n }\\n}\\n\",\"keccak256\":\"0xcc6a0fe8fdf05a805d2874dc7dd76dede1eb16e3ab77f2d0069dbb92272ab0a3\",\"license\":\"GPL-3.0-only\"},\"@keep-network/random-beacon/contracts/ReimbursementPool.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n// Trust math, not hardware.\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/security/ReentrancyGuard.sol\\\";\\n\\ncontract ReimbursementPool is Ownable, ReentrancyGuard {\\n /// @notice Authorized contracts that can interact with the reimbursment pool.\\n /// Authorization can be granted and removed by the owner.\\n mapping(address => bool) public isAuthorized;\\n\\n /// @notice Static gas includes:\\n /// - cost of the refund function\\n /// - base transaction cost\\n uint256 public staticGas;\\n\\n /// @notice Max gas price used to reimburse a transaction submitter. Protects\\n /// against malicious operator-miners.\\n uint256 public maxGasPrice;\\n\\n event StaticGasUpdated(uint256 newStaticGas);\\n\\n event MaxGasPriceUpdated(uint256 newMaxGasPrice);\\n\\n event SendingEtherFailed(uint256 refundAmount, address receiver);\\n\\n event AuthorizedContract(address thirdPartyContract);\\n\\n event UnauthorizedContract(address thirdPartyContract);\\n\\n event FundsWithdrawn(uint256 withdrawnAmount, address receiver);\\n\\n constructor(uint256 _staticGas, uint256 _maxGasPrice) {\\n staticGas = _staticGas;\\n maxGasPrice = _maxGasPrice;\\n }\\n\\n /// @notice Receive ETH\\n receive() external payable {}\\n\\n /// @notice Refunds ETH to a spender for executing specific transactions.\\n /// @dev Ignoring the result of sending ETH to a receiver is made on purpose.\\n /// For EOA receiving ETH should always work. If a receiver is a smart\\n /// contract, then we do not want to fail a transaction, because in some\\n /// cases the refund is done at the very end of multiple calls where all\\n /// the previous calls were already paid off. It is a receiver's smart\\n /// contract resposibility to make sure it can receive ETH.\\n /// @dev Only authorized contracts are allowed calling this function.\\n /// @param gasSpent Gas spent on a transaction that needs to be reimbursed.\\n /// @param receiver Address where the reimbursment is sent.\\n function refund(uint256 gasSpent, address receiver) external nonReentrant {\\n require(\\n isAuthorized[msg.sender],\\n \\\"Contract is not authorized for a refund\\\"\\n );\\n require(receiver != address(0), \\\"Receiver's address cannot be zero\\\");\\n\\n uint256 gasPrice = tx.gasprice < maxGasPrice\\n ? tx.gasprice\\n : maxGasPrice;\\n\\n uint256 refundAmount = (gasSpent + staticGas) * gasPrice;\\n\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,unchecked-lowlevel\\n (bool sent, ) = receiver.call{value: refundAmount}(\\\"\\\");\\n /* solhint-enable avoid-low-level-calls */\\n if (!sent) {\\n // slither-disable-next-line reentrancy-events\\n emit SendingEtherFailed(refundAmount, receiver);\\n }\\n }\\n\\n /// @notice Authorize a contract that can interact with this reimbursment pool.\\n /// Can be authorized by the owner only.\\n /// @param _contract Authorized contract.\\n function authorize(address _contract) external onlyOwner {\\n isAuthorized[_contract] = true;\\n\\n emit AuthorizedContract(_contract);\\n }\\n\\n /// @notice Unauthorize a contract that was previously authorized to interact\\n /// with this reimbursment pool. Can be unauthorized by the\\n /// owner only.\\n /// @param _contract Authorized contract.\\n function unauthorize(address _contract) external onlyOwner {\\n delete isAuthorized[_contract];\\n\\n emit UnauthorizedContract(_contract);\\n }\\n\\n /// @notice Setting a static gas cost for executing a transaction. Can be set\\n /// by the owner only.\\n /// @param _staticGas Static gas cost.\\n function setStaticGas(uint256 _staticGas) external onlyOwner {\\n staticGas = _staticGas;\\n\\n emit StaticGasUpdated(_staticGas);\\n }\\n\\n /// @notice Setting a max gas price for transactions. Can be set by the\\n /// owner only.\\n /// @param _maxGasPrice Max gas price used to reimburse tx submitters.\\n function setMaxGasPrice(uint256 _maxGasPrice) external onlyOwner {\\n maxGasPrice = _maxGasPrice;\\n\\n emit MaxGasPriceUpdated(_maxGasPrice);\\n }\\n\\n /// @notice Withdraws all ETH from this pool which are sent to a given\\n /// address. Can be set by the owner only.\\n /// @param receiver An address where ETH is sent.\\n function withdrawAll(address receiver) external onlyOwner {\\n withdraw(address(this).balance, receiver);\\n }\\n\\n /// @notice Withdraws ETH amount from this pool which are sent to a given\\n /// address. Can be set by the owner only.\\n /// @param amount Amount to withdraw from the pool.\\n /// @param receiver An address where ETH is sent.\\n function withdraw(uint256 amount, address receiver) public onlyOwner {\\n require(\\n address(this).balance >= amount,\\n \\\"Insufficient contract balance\\\"\\n );\\n require(receiver != address(0), \\\"Receiver's address cannot be zero\\\");\\n\\n emit FundsWithdrawn(amount, receiver);\\n\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,arbitrary-send\\n (bool sent, ) = receiver.call{value: amount}(\\\"\\\");\\n /* solhint-enable avoid-low-level-calls */\\n require(sent, \\\"Failed to send Ether\\\");\\n }\\n}\\n\",\"keccak256\":\"0xd6c24368cc4c6349b8b614e878ca961cad8254b8e8db1cc0abe452a70022ce50\",\"license\":\"GPL-3.0-only\"},\"@keep-network/random-beacon/contracts/libraries/BytesLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n//\\n// \\u2593\\u2593\\u258c \\u2593\\u2593 \\u2590\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584\\u2584\\u2584\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\u2580\\u2580\\u2580 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2580\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2580\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2584 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u258c\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2588\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n// \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2590\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593 \\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\u2593\\n//\\n//\\n\\npragma solidity 0.8.17;\\n\\n/*\\nVersion pulled from keep-core v1:\\nhttps://github.com/keep-network/keep-core/blob/f297202db00c027978ad8e7103a356503de5773c/solidity-v1/contracts/utils/BytesLib.sol\\n\\nTo compile it with solidity 0.8 `_preBytes_slot` was replaced with `_preBytes.slot`.\\n*/\\n\\n/*\\nhttps://github.com/GNSPS/solidity-bytes-utils/\\nThis is free and unencumbered software released into the public domain.\\nAnyone is free to copy, modify, publish, use, compile, sell, or\\ndistribute this software, either in source code form or as a compiled\\nbinary, for any purpose, commercial or non-commercial, and by any\\nmeans.\\nIn jurisdictions that recognize copyright laws, the author or authors\\nof this software dedicate any and all copyright interest in the\\nsoftware to the public domain. We make this dedication for the benefit\\nof the public at large and to the detriment of our heirs and\\nsuccessors. We intend this dedication to be an overt act of\\nrelinquishment in perpetuity of all present and future rights to this\\nsoftware under copyright law.\\nTHE SOFTWARE IS PROVIDED \\\"AS IS\\\", WITHOUT WARRANTY OF ANY KIND,\\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\\nIN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR\\nOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,\\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\\nOTHER DEALINGS IN THE SOFTWARE.\\nFor more information, please refer to \\n*/\\n\\n/** @title BytesLib **/\\n/** @author https://github.com/GNSPS **/\\n\\nlibrary BytesLib {\\n function concatStorage(bytes storage _preBytes, bytes memory _postBytes)\\n internal\\n {\\n assembly {\\n // Read the first 32 bytes of _preBytes storage, which is the length\\n // of the array. (We don't need to use the offset into the slot\\n // because arrays use the entire slot.)\\n let fslot := sload(_preBytes.slot)\\n // Arrays of 31 bytes or less have an even value in their slot,\\n // while longer arrays have an odd value. The actual length is\\n // the slot divided by two for odd values, and the lowest order\\n // byte divided by two for even values.\\n // If the slot is even, bitwise and the slot with 255 and divide by\\n // two to get the length. If the slot is odd, bitwise and the slot\\n // with -1 and divide by two.\\n let slength := div(\\n and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)),\\n 2\\n )\\n let mlength := mload(_postBytes)\\n let newlength := add(slength, mlength)\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n switch add(lt(slength, 32), lt(newlength, 32))\\n case 2 {\\n // Since the new array still fits in the slot, we just need to\\n // update the contents of the slot.\\n // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length\\n sstore(\\n _preBytes.slot,\\n // all the modifications to the slot are inside this\\n // next block\\n add(\\n // we can just add to the slot contents because the\\n // bytes we want to change are the LSBs\\n fslot,\\n add(\\n mul(\\n div(\\n // load the bytes from memory\\n mload(add(_postBytes, 0x20)),\\n // zero all bytes to the right\\n exp(0x100, sub(32, mlength))\\n ),\\n // and now shift left the number of bytes to\\n // leave space for the length in the slot\\n exp(0x100, sub(32, newlength))\\n ),\\n // increase length by the double of the memory\\n // bytes length\\n mul(mlength, 2)\\n )\\n )\\n )\\n }\\n case 1 {\\n // The stored value fits in the slot, but the combined value\\n // will exceed it.\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // The contents of the _postBytes array start 32 bytes into\\n // the structure. Our first read should obtain the `submod`\\n // bytes that can fit into the unused space in the last word\\n // of the stored array. To get this, we read 32 bytes starting\\n // from `submod`, so the data we read overlaps with the array\\n // contents by `submod` bytes. Masking the lowest-order\\n // `submod` bytes allows us to add that value directly to the\\n // stored value.\\n\\n let submod := sub(32, slength)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(\\n sc,\\n add(\\n and(\\n fslot,\\n 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00\\n ),\\n and(mload(mc), mask)\\n )\\n )\\n\\n for {\\n mc := add(mc, 0x20)\\n sc := add(sc, 1)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n default {\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n // Start copying to the last used word of the stored array.\\n let sc := add(keccak256(0x0, 0x20), div(slength, 32))\\n\\n // save new length\\n sstore(_preBytes.slot, add(mul(newlength, 2), 1))\\n\\n // Copy over the first `submod` bytes of the new data as in\\n // case 1 above.\\n let slengthmod := mod(slength, 32)\\n let submod := sub(32, slengthmod)\\n let mc := add(_postBytes, submod)\\n let end := add(_postBytes, mlength)\\n let mask := sub(exp(0x100, submod), 1)\\n\\n sstore(sc, add(sload(sc), and(mload(mc), mask)))\\n\\n for {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } lt(mc, end) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n sstore(sc, mload(mc))\\n }\\n\\n mask := exp(0x100, sub(mc, end))\\n\\n sstore(sc, mul(div(mload(mc), mask), mask))\\n }\\n }\\n }\\n\\n function equalStorage(bytes storage _preBytes, bytes memory _postBytes)\\n internal\\n view\\n returns (bool)\\n {\\n bool success = true;\\n\\n assembly {\\n // we know _preBytes_offset is 0\\n let fslot := sload(_preBytes.slot)\\n // Decode the length of the stored array like in concatStorage().\\n let slength := div(\\n and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)),\\n 2\\n )\\n let mlength := mload(_postBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(slength, mlength)\\n case 1 {\\n // slength can contain both the length and contents of the array\\n // if length < 32 bytes so let's prepare for that\\n // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage\\n if iszero(iszero(slength)) {\\n switch lt(slength, 32)\\n case 1 {\\n // blank the last byte which is the length\\n fslot := mul(div(fslot, 0x100), 0x100)\\n\\n if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {\\n // unsuccess:\\n success := 0\\n }\\n }\\n default {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n // get the keccak hash to get the contents of the array\\n mstore(0x0, _preBytes.slot)\\n let sc := keccak256(0x0, 0x20)\\n\\n let mc := add(_postBytes, 0x20)\\n let end := add(mc, mlength)\\n\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n for {\\n\\n } eq(add(lt(mc, end), cb), 2) {\\n sc := add(sc, 1)\\n mc := add(mc, 0x20)\\n } {\\n if iszero(eq(sload(sc), mload(mc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function concat(bytes memory _preBytes, bytes memory _postBytes)\\n internal\\n pure\\n returns (bytes memory)\\n {\\n bytes memory tempBytes;\\n\\n assembly {\\n // Get a location of some free memory and store it in tempBytes as\\n // Solidity does for memory variables.\\n tempBytes := mload(0x40)\\n\\n // Store the length of the first bytes array at the beginning of\\n // the memory for tempBytes.\\n let length := mload(_preBytes)\\n mstore(tempBytes, length)\\n\\n // Maintain a memory counter for the current write location in the\\n // temp bytes array by adding the 32 bytes for the array length to\\n // the starting location.\\n let mc := add(tempBytes, 0x20)\\n // Stop copying when the memory counter reaches the length of the\\n // first bytes array.\\n let end := add(mc, length)\\n\\n for {\\n // Initialize a copy counter to the start of the _preBytes data,\\n // 32 bytes into its memory.\\n let cc := add(_preBytes, 0x20)\\n } lt(mc, end) {\\n // Increase both counters by 32 bytes each iteration.\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // Write the _preBytes data into the tempBytes memory 32 bytes\\n // at a time.\\n mstore(mc, mload(cc))\\n }\\n\\n // Add the length of _postBytes to the current length of tempBytes\\n // and store it as the new length in the first 32 bytes of the\\n // tempBytes memory.\\n length := mload(_postBytes)\\n mstore(tempBytes, add(length, mload(tempBytes)))\\n\\n // Move the memory counter back from a multiple of 0x20 to the\\n // actual end of the _preBytes data.\\n mc := end\\n // Stop copying when the memory counter reaches the new combined\\n // length of the arrays.\\n end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n } lt(mc, end) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n mstore(mc, mload(cc))\\n }\\n\\n // Update the free-memory pointer by padding our last write location\\n // to 32 bytes: add 31 bytes to the end of tempBytes to move to the\\n // next 32 byte block, then round down to the nearest multiple of\\n // 32. If the sum of the length of the two arrays is zero then add\\n // one before rounding down to leave a blank 32 bytes (the length block with 0).\\n mstore(\\n 0x40,\\n and(\\n add(add(end, iszero(add(length, mload(_preBytes)))), 31),\\n not(31) // Round down to the nearest 32 bytes.\\n )\\n )\\n }\\n\\n return tempBytes;\\n }\\n\\n function slice(\\n bytes memory _bytes,\\n uint256 _start,\\n uint256 _length\\n ) internal pure returns (bytes memory res) {\\n uint256 _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n // Alloc bytes array with additional 32 bytes afterspace and assign it's size\\n res := mload(0x40)\\n mstore(0x40, add(add(res, 64), _length))\\n mstore(res, _length)\\n\\n // Compute distance between source and destination pointers\\n let diff := sub(res, add(_bytes, _start))\\n\\n for {\\n let src := add(add(_bytes, 32), _start)\\n let end := add(src, _length)\\n } lt(src, end) {\\n src := add(src, 32)\\n } {\\n mstore(add(src, diff), mload(src))\\n }\\n }\\n }\\n\\n function toAddress(bytes memory _bytes, uint256 _start)\\n internal\\n pure\\n returns (address)\\n {\\n uint256 _totalLen = _start + 20;\\n require(\\n _totalLen > _start && _bytes.length >= _totalLen,\\n \\\"Address conversion out of bounds.\\\"\\n );\\n address tempAddress;\\n\\n assembly {\\n tempAddress := div(\\n mload(add(add(_bytes, 0x20), _start)),\\n 0x1000000000000000000000000\\n )\\n }\\n\\n return tempAddress;\\n }\\n\\n function toUint8(bytes memory _bytes, uint256 _start)\\n internal\\n pure\\n returns (uint8)\\n {\\n require(\\n _bytes.length >= (_start + 1),\\n \\\"Uint8 conversion out of bounds.\\\"\\n );\\n uint8 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x1), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function toUint(bytes memory _bytes, uint256 _start)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 _totalLen = _start + 32;\\n require(\\n _totalLen > _start && _bytes.length >= _totalLen,\\n \\\"Uint conversion out of bounds.\\\"\\n );\\n uint256 tempUint;\\n\\n assembly {\\n tempUint := mload(add(add(_bytes, 0x20), _start))\\n }\\n\\n return tempUint;\\n }\\n\\n function equal(bytes memory _preBytes, bytes memory _postBytes)\\n internal\\n pure\\n returns (bool)\\n {\\n bool success = true;\\n\\n assembly {\\n let length := mload(_preBytes)\\n\\n // if lengths don't match the arrays are not equal\\n switch eq(length, mload(_postBytes))\\n case 1 {\\n // cb is a circuit breaker in the for loop since there's\\n // no said feature for inline assembly loops\\n // cb = 1 - don't breaker\\n // cb = 0 - break\\n let cb := 1\\n\\n let mc := add(_preBytes, 0x20)\\n let end := add(mc, length)\\n\\n for {\\n let cc := add(_postBytes, 0x20)\\n // the next line is the loop condition:\\n // while(uint(mc < end) + cb == 2)\\n } eq(add(lt(mc, end), cb), 2) {\\n mc := add(mc, 0x20)\\n cc := add(cc, 0x20)\\n } {\\n // if any of these checks fails then arrays are not equal\\n if iszero(eq(mload(mc), mload(cc))) {\\n // unsuccess:\\n success := 0\\n cb := 0\\n }\\n }\\n }\\n default {\\n // unsuccess:\\n success := 0\\n }\\n }\\n\\n return success;\\n }\\n\\n function toBytes32(bytes memory _source)\\n internal\\n pure\\n returns (bytes32 result)\\n {\\n if (_source.length == 0) {\\n return 0x0;\\n }\\n\\n assembly {\\n result := mload(add(_source, 32))\\n }\\n }\\n\\n function keccak256Slice(\\n bytes memory _bytes,\\n uint256 _start,\\n uint256 _length\\n ) internal pure returns (bytes32 result) {\\n uint256 _end = _start + _length;\\n require(_end > _start && _bytes.length >= _end, \\\"Slice out of bounds\\\");\\n\\n assembly {\\n result := keccak256(add(add(_bytes, 32), _start), _length)\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3b76e2fe36eb777440250dcf2ea7a689375e8af22f3cc33521095ff6954becdb\",\"license\":\"GPL-3.0-only\"},\"@keep-network/sortition-pools/contracts/Branch.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Constants.sol\\\";\\n\\n/// @notice The implicit 8-ary trees of the sortition pool\\n/// rely on packing 8 \\\"slots\\\" of 32-bit values into each uint256.\\n/// The Branch library permits efficient calculations on these slots.\\nlibrary Branch {\\n /// @notice Calculate the right shift required\\n /// to make the 32 least significant bits of an uint256\\n /// be the bits of the `position`th slot\\n /// when treating the uint256 as a uint32[8].\\n ///\\n /// @dev Not used for efficiency reasons,\\n /// but left to illustrate the meaning of a common pattern.\\n /// I wish solidity had macros, even C macros.\\n function slotShift(uint256 position) internal pure returns (uint256) {\\n unchecked {\\n return position * Constants.SLOT_WIDTH;\\n }\\n }\\n\\n /// @notice Return the `position`th slot of the `node`,\\n /// treating `node` as a uint32[32].\\n function getSlot(uint256 node, uint256 position)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n uint256 shiftBits = position * Constants.SLOT_WIDTH;\\n // Doing a bitwise AND with `SLOT_MAX`\\n // clears all but the 32 least significant bits.\\n // Because of the right shift by `slotShift(position)` bits,\\n // those 32 bits contain the 32 bits in the `position`th slot of `node`.\\n return (node >> shiftBits) & Constants.SLOT_MAX;\\n }\\n }\\n\\n /// @notice Return `node` with the `position`th slot set to zero.\\n function clearSlot(uint256 node, uint256 position)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n uint256 shiftBits = position * Constants.SLOT_WIDTH;\\n // Shifting `SLOT_MAX` left by `slotShift(position)` bits\\n // gives us a number where all bits of the `position`th slot are set,\\n // and all other bits are unset.\\n //\\n // Using a bitwise NOT on this number,\\n // we get a uint256 where all bits are set\\n // except for those of the `position`th slot.\\n //\\n // Bitwise ANDing the original `node` with this number\\n // sets the bits of `position`th slot to zero,\\n // leaving all other bits unchanged.\\n return node & ~(Constants.SLOT_MAX << shiftBits);\\n }\\n }\\n\\n /// @notice Return `node` with the `position`th slot set to `weight`.\\n ///\\n /// @param weight The weight of of the node.\\n /// Safely truncated to a 32-bit number,\\n /// but this should never be called with an overflowing weight regardless.\\n function setSlot(\\n uint256 node,\\n uint256 position,\\n uint256 weight\\n ) internal pure returns (uint256) {\\n unchecked {\\n uint256 shiftBits = position * Constants.SLOT_WIDTH;\\n // Clear the `position`th slot like in `clearSlot()`.\\n uint256 clearedNode = node & ~(Constants.SLOT_MAX << shiftBits);\\n // Bitwise AND `weight` with `SLOT_MAX`\\n // to clear all but the 32 least significant bits.\\n //\\n // Shift this left by `slotShift(position)` bits\\n // to obtain a uint256 with all bits unset\\n // except in the `position`th slot\\n // which contains the 32-bit value of `weight`.\\n uint256 shiftedWeight = (weight & Constants.SLOT_MAX) << shiftBits;\\n // When we bitwise OR these together,\\n // all other slots except the `position`th one come from the left argument,\\n // and the `position`th gets filled with `weight` from the right argument.\\n return clearedNode | shiftedWeight;\\n }\\n }\\n\\n /// @notice Calculate the summed weight of all slots in the `node`.\\n function sumWeight(uint256 node) internal pure returns (uint256 sum) {\\n unchecked {\\n sum = node & Constants.SLOT_MAX;\\n // Iterate through each slot\\n // by shifting `node` right in increments of 32 bits,\\n // and adding the 32 least significant bits to the `sum`.\\n uint256 newNode = node >> Constants.SLOT_WIDTH;\\n while (newNode > 0) {\\n sum += (newNode & Constants.SLOT_MAX);\\n newNode = newNode >> Constants.SLOT_WIDTH;\\n }\\n return sum;\\n }\\n }\\n\\n /// @notice Pick a slot in `node` that corresponds to `index`.\\n /// Treats the node like an array of virtual stakers,\\n /// the number of virtual stakers in each slot corresponding to its weight,\\n /// and picks which slot contains the `index`th virtual staker.\\n ///\\n /// @dev Requires that `index` be lower than `sumWeight(node)`.\\n /// However, this is not enforced for performance reasons.\\n /// If `index` exceeds the permitted range,\\n /// `pickWeightedSlot()` returns the rightmost slot\\n /// and an excessively high `newIndex`.\\n ///\\n /// @return slot The slot of `node` containing the `index`th virtual staker.\\n ///\\n /// @return newIndex The index of the `index`th virtual staker of `node`\\n /// within the returned slot.\\n function pickWeightedSlot(uint256 node, uint256 index)\\n internal\\n pure\\n returns (uint256 slot, uint256 newIndex)\\n {\\n unchecked {\\n newIndex = index;\\n uint256 newNode = node;\\n uint256 currentSlotWeight = newNode & Constants.SLOT_MAX;\\n while (newIndex >= currentSlotWeight) {\\n newIndex -= currentSlotWeight;\\n slot++;\\n newNode = newNode >> Constants.SLOT_WIDTH;\\n currentSlotWeight = newNode & Constants.SLOT_MAX;\\n }\\n return (slot, newIndex);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa7fb1c9c9789f30493e9a40e24a24f46875dc5e7630b4f67478167759f6d1882\"},\"@keep-network/sortition-pools/contracts/Chaosnet.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\n/// @title Chaosnet\\n/// @notice This is a beta staker program for stakers willing to go the extra\\n/// mile with monitoring, share their logs with the dev team, and allow to more\\n/// carefully monitor the bootstrapping network. As the network matures, the\\n/// beta program will be ended.\\ncontract Chaosnet {\\n /// @notice Indicates if the chaosnet is active. The chaosnet is active\\n /// after the contract deployment and can be ended with a call to\\n /// `deactivateChaosnet()`. Once deactivated chaosnet can not be activated\\n /// again.\\n bool public isChaosnetActive;\\n\\n /// @notice Indicates if the given operator is a beta operator for chaosnet.\\n mapping(address => bool) public isBetaOperator;\\n\\n /// @notice Address controlling chaosnet status and beta operator addresses.\\n address public chaosnetOwner;\\n\\n event BetaOperatorsAdded(address[] operators);\\n\\n event ChaosnetOwnerRoleTransferred(\\n address oldChaosnetOwner,\\n address newChaosnetOwner\\n );\\n\\n event ChaosnetDeactivated();\\n\\n constructor() {\\n _transferChaosnetOwner(msg.sender);\\n isChaosnetActive = true;\\n }\\n\\n modifier onlyChaosnetOwner() {\\n require(msg.sender == chaosnetOwner, \\\"Not the chaosnet owner\\\");\\n _;\\n }\\n\\n modifier onlyOnChaosnet() {\\n require(isChaosnetActive, \\\"Chaosnet is not active\\\");\\n _;\\n }\\n\\n /// @notice Adds beta operator to chaosnet. Can be called only by the\\n /// chaosnet owner when the chaosnet is active. Once the operator is added\\n /// as a beta operator, it can not be removed.\\n function addBetaOperators(address[] calldata operators)\\n public\\n onlyOnChaosnet\\n onlyChaosnetOwner\\n {\\n for (uint256 i = 0; i < operators.length; i++) {\\n isBetaOperator[operators[i]] = true;\\n }\\n\\n emit BetaOperatorsAdded(operators);\\n }\\n\\n /// @notice Deactivates the chaosnet. Can be called only by the chaosnet\\n /// owner. Once deactivated chaosnet can not be activated again.\\n function deactivateChaosnet() public onlyOnChaosnet onlyChaosnetOwner {\\n isChaosnetActive = false;\\n emit ChaosnetDeactivated();\\n }\\n\\n /// @notice Transfers the chaosnet owner role to another non-zero address.\\n function transferChaosnetOwnerRole(address newChaosnetOwner)\\n public\\n onlyChaosnetOwner\\n {\\n require(\\n newChaosnetOwner != address(0),\\n \\\"New chaosnet owner must not be zero address\\\"\\n );\\n _transferChaosnetOwner(newChaosnetOwner);\\n }\\n\\n function _transferChaosnetOwner(address newChaosnetOwner) internal {\\n address oldChaosnetOwner = chaosnetOwner;\\n chaosnetOwner = newChaosnetOwner;\\n emit ChaosnetOwnerRoleTransferred(oldChaosnetOwner, newChaosnetOwner);\\n }\\n}\\n\",\"keccak256\":\"0xeaf7bdd5626f88c329793a012621039692ce1b6e1f13013997ddb13d7e3032df\"},\"@keep-network/sortition-pools/contracts/Constants.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nlibrary Constants {\\n ////////////////////////////////////////////////////////////////////////////\\n // Parameters for configuration\\n\\n // How many bits a position uses per level of the tree;\\n // each branch of the tree contains 2**SLOT_BITS slots.\\n uint256 constant SLOT_BITS = 3;\\n uint256 constant LEVELS = 7;\\n ////////////////////////////////////////////////////////////////////////////\\n\\n ////////////////////////////////////////////////////////////////////////////\\n // Derived constants, do not touch\\n uint256 constant SLOT_COUNT = 2**SLOT_BITS;\\n uint256 constant SLOT_WIDTH = 256 / SLOT_COUNT;\\n uint256 constant LAST_SLOT = SLOT_COUNT - 1;\\n uint256 constant SLOT_MAX = (2**SLOT_WIDTH) - 1;\\n uint256 constant POOL_CAPACITY = SLOT_COUNT**LEVELS;\\n\\n uint256 constant ID_WIDTH = SLOT_WIDTH;\\n uint256 constant ID_MAX = SLOT_MAX;\\n\\n uint256 constant BLOCKHEIGHT_WIDTH = 96 - ID_WIDTH;\\n uint256 constant BLOCKHEIGHT_MAX = (2**BLOCKHEIGHT_WIDTH) - 1;\\n\\n uint256 constant SLOT_POINTER_MAX = (2**SLOT_BITS) - 1;\\n uint256 constant LEAF_FLAG = 1 << 255;\\n\\n uint256 constant WEIGHT_WIDTH = 256 / SLOT_COUNT;\\n ////////////////////////////////////////////////////////////////////////////\\n}\\n\",\"keccak256\":\"0xaef690ced707935745ff1482b7bb9bd9eb77bf6a39c717465e64cf12db8a7d39\"},\"@keep-network/sortition-pools/contracts/Leaf.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Constants.sol\\\";\\n\\nlibrary Leaf {\\n function make(\\n address _operator,\\n uint256 _creationBlock,\\n uint256 _id\\n ) internal pure returns (uint256) {\\n assert(_creationBlock <= type(uint64).max);\\n assert(_id <= type(uint32).max);\\n // Converting a bytesX type into a larger type\\n // adds zero bytes on the right.\\n uint256 op = uint256(bytes32(bytes20(_operator)));\\n // Bitwise AND the id to erase\\n // all but the 32 least significant bits\\n uint256 uid = _id & Constants.ID_MAX;\\n // Erase all but the 64 least significant bits,\\n // then shift left by 32 bits to make room for the id\\n uint256 cb = (_creationBlock & Constants.BLOCKHEIGHT_MAX) <<\\n Constants.ID_WIDTH;\\n // Bitwise OR them all together to get\\n // [address operator || uint64 creationBlock || uint32 id]\\n return (op | cb | uid);\\n }\\n\\n function operator(uint256 leaf) internal pure returns (address) {\\n // Converting a bytesX type into a smaller type\\n // truncates it on the right.\\n return address(bytes20(bytes32(leaf)));\\n }\\n\\n /// @notice Return the block number the leaf was created in.\\n function creationBlock(uint256 leaf) internal pure returns (uint256) {\\n return ((leaf >> Constants.ID_WIDTH) & Constants.BLOCKHEIGHT_MAX);\\n }\\n\\n function id(uint256 leaf) internal pure returns (uint32) {\\n // Id is stored in the 32 least significant bits.\\n // Bitwise AND ensures that we only get the contents of those bits.\\n return uint32(leaf & Constants.ID_MAX);\\n }\\n}\\n\",\"keccak256\":\"0xbd107a1a43e48884885e5e966ffcbcd8fa5e89863715d717bb4006e9f89cdc2b\"},\"@keep-network/sortition-pools/contracts/Position.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Constants.sol\\\";\\n\\nlibrary Position {\\n // Return the last 3 bits of a position number,\\n // corresponding to its slot in its parent\\n function slot(uint256 a) internal pure returns (uint256) {\\n return a & Constants.SLOT_POINTER_MAX;\\n }\\n\\n // Return the parent of a position number\\n function parent(uint256 a) internal pure returns (uint256) {\\n return a >> Constants.SLOT_BITS;\\n }\\n\\n // Return the location of the child of a at the given slot\\n function child(uint256 a, uint256 s) internal pure returns (uint256) {\\n return (a << Constants.SLOT_BITS) | (s & Constants.SLOT_POINTER_MAX); // slot(s)\\n }\\n\\n // Return the uint p as a flagged position uint:\\n // the least significant 21 bits contain the position\\n // and the 22nd bit is set as a flag\\n // to distinguish the position 0x000000 from an empty field.\\n function setFlag(uint256 p) internal pure returns (uint256) {\\n return p | Constants.LEAF_FLAG;\\n }\\n\\n // Turn a flagged position into an unflagged position\\n // by removing the flag at the 22nd least significant bit.\\n //\\n // We shouldn't _actually_ need this\\n // as all position-manipulating code should ignore non-position bits anyway\\n // but it's cheap to call so might as well do it.\\n function unsetFlag(uint256 p) internal pure returns (uint256) {\\n return p & (~Constants.LEAF_FLAG);\\n }\\n}\\n\",\"keccak256\":\"0xd3a927908080ac21353a92a6bce3d69e94a5c30f6b51f16b271b6cc679f110e2\"},\"@keep-network/sortition-pools/contracts/RNG.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Leaf.sol\\\";\\nimport \\\"./Constants.sol\\\";\\n\\nlibrary RNG {\\n /// @notice Get an index in the range `[0 .. range-1]`\\n /// and the new state of the RNG,\\n /// using the provided `state` of the RNG.\\n ///\\n /// @param range The upper bound of the index, exclusive.\\n ///\\n /// @param state The previous state of the RNG.\\n /// The initial state needs to be obtained\\n /// from a trusted randomness oracle (the random beacon),\\n /// or from a chain of earlier calls to `RNG.getIndex()`\\n /// on an originally trusted seed.\\n ///\\n /// @dev Calculates the number of bits required for the desired range,\\n /// takes the least significant bits of `state`\\n /// and checks if the obtained index is within the desired range.\\n /// The original state is hashed with `keccak256` to get a new state.\\n /// If the index is outside the range,\\n /// the function retries until it gets a suitable index.\\n ///\\n /// @return index A random integer between `0` and `range - 1`, inclusive.\\n ///\\n /// @return newState The new state of the RNG.\\n /// When `getIndex()` is called one or more times,\\n /// care must be taken to always use the output `state`\\n /// of the most recent call as the input `state` of a subsequent call.\\n /// At the end of a transaction calling `RNG.getIndex()`,\\n /// the previous stored state must be overwritten with the latest output.\\n function getIndex(\\n uint256 range,\\n bytes32 state,\\n uint256 bits\\n ) internal view returns (uint256, bytes32) {\\n bool found = false;\\n uint256 index = 0;\\n bytes32 newState = state;\\n while (!found) {\\n index = truncate(bits, uint256(newState));\\n newState = keccak256(abi.encodePacked(newState, address(this)));\\n if (index < range) {\\n found = true;\\n }\\n }\\n return (index, newState);\\n }\\n\\n /// @notice Calculate how many bits are required\\n /// for an index in the range `[0 .. range-1]`.\\n ///\\n /// @param range The upper bound of the desired range, exclusive.\\n ///\\n /// @return uint The smallest number of bits\\n /// that can contain the number `range-1`.\\n function bitsRequired(uint256 range) internal pure returns (uint256) {\\n unchecked {\\n if (range == 1) {\\n return 0;\\n }\\n\\n uint256 bits = Constants.WEIGHT_WIDTH - 1;\\n\\n // Left shift by `bits`,\\n // so we have a 1 in the (bits + 1)th least significant bit\\n // and 0 in other bits.\\n // If this number is equal or greater than `range`,\\n // the range [0, range-1] fits in `bits` bits.\\n //\\n // Because we loop from high bits to low bits,\\n // we find the highest number of bits that doesn't fit the range,\\n // and return that number + 1.\\n while (1 << bits >= range) {\\n bits--;\\n }\\n\\n return bits + 1;\\n }\\n }\\n\\n /// @notice Truncate `input` to the `bits` least significant bits.\\n function truncate(uint256 bits, uint256 input)\\n internal\\n pure\\n returns (uint256)\\n {\\n unchecked {\\n return input & ((1 << bits) - 1);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x67f87f589cd5123ffa32f883ea2f09b0e56258508bae82b8c655b3c27c71eb5e\"},\"@keep-network/sortition-pools/contracts/Rewards.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\n/// @title Rewards\\n/// @notice Rewards are allocated proportionally to operators\\n/// present in the pool at payout based on their weight in the pool.\\n///\\n/// To facilitate this, we use a global accumulator value\\n/// to track the total rewards one unit of weight would've earned\\n/// since the creation of the pool.\\n///\\n/// Whenever a reward is paid, the accumulator is increased\\n/// by the size of the reward divided by the total weight\\n/// of all eligible operators in the pool.\\n///\\n/// Each operator has an individual accumulator value,\\n/// set to equal the global accumulator when the operator joins the pool.\\n/// This accumulator reflects the amount of rewards\\n/// that have already been accounted for with that operator.\\n///\\n/// Whenever an operator's weight in the pool changes,\\n/// we can update the amount of rewards the operator has earned\\n/// by subtracting the operator's accumulator from the global accumulator.\\n/// This gives us the amount of rewards one unit of weight has earned\\n/// since the last time the operator's rewards have been updated.\\n/// Then we multiply that by the operator's previous (pre-change) weight\\n/// to determine how much rewards in total the operator has earned,\\n/// and add this to the operator's earned rewards.\\n/// Finally, we set the operator's accumulator to the global accumulator value.\\ncontract Rewards {\\n struct OperatorRewards {\\n // The state of the global accumulator\\n // when the operator's rewards were last updated\\n uint96 accumulated;\\n // The amount of rewards collected by the operator after the latest update.\\n // The amount the operator could withdraw may equal `available`\\n // or it may be greater, if more rewards have been paid in since then.\\n // To evaulate the most recent amount including rewards potentially paid\\n // since the last update, use `availableRewards` function.\\n uint96 available;\\n // If nonzero, the operator is ineligible for rewards\\n // and may only re-enable rewards after the specified timestamp.\\n // XXX: unsigned 32-bit integer unix seconds, will break around 2106\\n uint32 ineligibleUntil;\\n // Locally cached weight of the operator,\\n // used to reduce the cost of setting operators ineligible.\\n uint32 weight;\\n }\\n\\n // The global accumulator of how much rewards\\n // a hypothetical operator of weight 1 would have earned\\n // since the creation of the pool.\\n uint96 internal globalRewardAccumulator;\\n // If the amount of reward tokens paid in\\n // does not divide cleanly by pool weight,\\n // the difference is recorded as rounding dust\\n // and added to the next reward.\\n uint96 internal rewardRoundingDust;\\n\\n // The amount of rewards that would've been earned by ineligible operators\\n // had they not been ineligible.\\n uint96 public ineligibleEarnedRewards;\\n\\n // Ineligibility times are calculated from this offset,\\n // set at contract creation.\\n uint256 internal immutable ineligibleOffsetStart;\\n\\n mapping(uint32 => OperatorRewards) internal operatorRewards;\\n\\n constructor() {\\n // solhint-disable-next-line not-rely-on-time\\n ineligibleOffsetStart = block.timestamp;\\n }\\n\\n /// @notice Return whether the operator is eligible for rewards or not.\\n function isEligibleForRewards(uint32 operator) internal view returns (bool) {\\n return operatorRewards[operator].ineligibleUntil == 0;\\n }\\n\\n /// @notice Return the time the operator's reward eligibility can be restored.\\n function rewardsEligibilityRestorableAt(uint32 operator)\\n internal\\n view\\n returns (uint256)\\n {\\n uint32 until = operatorRewards[operator].ineligibleUntil;\\n require(until != 0, \\\"Operator already eligible\\\");\\n return (uint256(until) + ineligibleOffsetStart);\\n }\\n\\n /// @notice Return whether the operator is able to restore their eligibility\\n /// for rewards right away.\\n function canRestoreRewardEligibility(uint32 operator)\\n internal\\n view\\n returns (bool)\\n {\\n // solhint-disable-next-line not-rely-on-time\\n return rewardsEligibilityRestorableAt(operator) <= block.timestamp;\\n }\\n\\n /// @notice Internal function for updating the global state of rewards.\\n function addRewards(uint96 rewardAmount, uint32 currentPoolWeight) internal {\\n require(currentPoolWeight > 0, \\\"No recipients in pool\\\");\\n\\n uint96 totalAmount = rewardAmount + rewardRoundingDust;\\n uint96 perWeightReward = totalAmount / currentPoolWeight;\\n uint96 newRoundingDust = totalAmount % currentPoolWeight;\\n\\n globalRewardAccumulator += perWeightReward;\\n rewardRoundingDust = newRoundingDust;\\n }\\n\\n /// @notice Internal function for updating the operator's reward state.\\n function updateOperatorRewards(uint32 operator, uint32 newWeight) internal {\\n uint96 acc = globalRewardAccumulator;\\n OperatorRewards memory o = operatorRewards[operator];\\n uint96 accruedRewards = (acc - o.accumulated) * uint96(o.weight);\\n if (o.ineligibleUntil == 0) {\\n // If operator is not ineligible, update their earned rewards\\n o.available += accruedRewards;\\n } else {\\n // If ineligible, put the rewards into the ineligible pot\\n ineligibleEarnedRewards += accruedRewards;\\n }\\n // In any case, update their accumulator and weight\\n o.accumulated = acc;\\n o.weight = newWeight;\\n operatorRewards[operator] = o;\\n }\\n\\n /// @notice Set the amount of withdrawable tokens to zero\\n /// and return the previous withdrawable amount.\\n /// @dev Does not update the withdrawable amount,\\n /// but should usually be accompanied by an update.\\n function withdrawOperatorRewards(uint32 operator)\\n internal\\n returns (uint96 withdrawable)\\n {\\n OperatorRewards storage o = operatorRewards[operator];\\n withdrawable = o.available;\\n o.available = 0;\\n }\\n\\n /// @notice Set the amount of ineligible-earned tokens to zero\\n /// and return the previous amount.\\n function withdrawIneligibleRewards() internal returns (uint96 withdrawable) {\\n withdrawable = ineligibleEarnedRewards;\\n ineligibleEarnedRewards = 0;\\n }\\n\\n /// @notice Set the given operators as ineligible for rewards.\\n /// The operators can restore their eligibility at the given time.\\n function setIneligible(uint32[] memory operators, uint256 until) internal {\\n OperatorRewards memory o = OperatorRewards(0, 0, 0, 0);\\n uint96 globalAcc = globalRewardAccumulator;\\n uint96 accrued = 0;\\n // Record ineligibility as seconds after contract creation\\n uint32 _until = uint32(until - ineligibleOffsetStart);\\n\\n for (uint256 i = 0; i < operators.length; i++) {\\n uint32 operator = operators[i];\\n OperatorRewards storage r = operatorRewards[operator];\\n o.available = r.available;\\n o.accumulated = r.accumulated;\\n o.ineligibleUntil = r.ineligibleUntil;\\n o.weight = r.weight;\\n\\n if (o.ineligibleUntil != 0) {\\n // If operator is already ineligible,\\n // don't earn rewards or shorten its ineligibility\\n if (o.ineligibleUntil < _until) {\\n o.ineligibleUntil = _until;\\n }\\n } else {\\n // The operator becomes ineligible -> earn rewards\\n o.ineligibleUntil = _until;\\n accrued = (globalAcc - o.accumulated) * uint96(o.weight);\\n o.available += accrued;\\n }\\n o.accumulated = globalAcc;\\n\\n r.available = o.available;\\n r.accumulated = o.accumulated;\\n r.ineligibleUntil = o.ineligibleUntil;\\n r.weight = o.weight;\\n }\\n }\\n\\n /// @notice Restore the given operator's eligibility for rewards.\\n function restoreEligibility(uint32 operator) internal {\\n // solhint-disable-next-line not-rely-on-time\\n require(canRestoreRewardEligibility(operator), \\\"Operator still ineligible\\\");\\n uint96 acc = globalRewardAccumulator;\\n OperatorRewards memory o = operatorRewards[operator];\\n uint96 accruedRewards = (acc - o.accumulated) * uint96(o.weight);\\n ineligibleEarnedRewards += accruedRewards;\\n o.accumulated = acc;\\n o.ineligibleUntil = 0;\\n operatorRewards[operator] = o;\\n }\\n\\n /// @notice Returns the amount of rewards currently available for withdrawal\\n /// for the given operator.\\n function availableRewards(uint32 operator) internal view returns (uint96) {\\n uint96 acc = globalRewardAccumulator;\\n OperatorRewards memory o = operatorRewards[operator];\\n if (o.ineligibleUntil == 0) {\\n // If operator is not ineligible, calculate newly accrued rewards and add\\n // them to the available ones, calculated during the last update.\\n uint96 accruedRewards = (acc - o.accumulated) * uint96(o.weight);\\n return o.available + accruedRewards;\\n } else {\\n // If ineligible, return only the rewards calculated during the last\\n // update.\\n return o.available;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x3a10abb408b44335a092387b2c7ee01db3b27997f1f2c888d9b7a2d92934c4e2\"},\"@keep-network/sortition-pools/contracts/SortitionPool.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./RNG.sol\\\";\\nimport \\\"./SortitionTree.sol\\\";\\nimport \\\"./Rewards.sol\\\";\\nimport \\\"./Chaosnet.sol\\\";\\n\\n/// @title Sortition Pool\\n/// @notice A logarithmic data structure used to store the pool of eligible\\n/// operators weighted by their stakes. It allows to select a group of operators\\n/// based on the provided pseudo-random seed.\\ncontract SortitionPool is\\n SortitionTree,\\n Rewards,\\n Ownable,\\n Chaosnet,\\n IReceiveApproval\\n{\\n using Branch for uint256;\\n using Leaf for uint256;\\n using Position for uint256;\\n\\n IERC20WithPermit public immutable rewardToken;\\n\\n uint256 public immutable poolWeightDivisor;\\n\\n bool public isLocked;\\n\\n event IneligibleForRewards(uint32[] ids, uint256 until);\\n\\n event RewardEligibilityRestored(address indexed operator, uint32 indexed id);\\n\\n /// @notice Reverts if called while pool is locked.\\n modifier onlyUnlocked() {\\n require(!isLocked, \\\"Sortition pool locked\\\");\\n _;\\n }\\n\\n /// @notice Reverts if called while pool is unlocked.\\n modifier onlyLocked() {\\n require(isLocked, \\\"Sortition pool unlocked\\\");\\n _;\\n }\\n\\n constructor(IERC20WithPermit _rewardToken, uint256 _poolWeightDivisor) {\\n rewardToken = _rewardToken;\\n poolWeightDivisor = _poolWeightDivisor;\\n }\\n\\n function receiveApproval(\\n address sender,\\n uint256 amount,\\n address token,\\n bytes calldata\\n ) external override {\\n require(token == address(rewardToken), \\\"Unsupported token\\\");\\n rewardToken.transferFrom(sender, address(this), amount);\\n Rewards.addRewards(uint96(amount), uint32(root.sumWeight()));\\n }\\n\\n /// @notice Withdraws all available rewards for the given operator to the\\n /// given beneficiary.\\n /// @dev Can be called only be the owner. Does not validate if the provided\\n /// beneficiary is associated with the provided operator - this needs to\\n /// be done by the owner calling this function.\\n /// @return The amount of rewards withdrawn in this call.\\n function withdrawRewards(address operator, address beneficiary)\\n public\\n onlyOwner\\n returns (uint96)\\n {\\n uint32 id = getOperatorID(operator);\\n Rewards.updateOperatorRewards(id, uint32(getPoolWeight(operator)));\\n uint96 earned = Rewards.withdrawOperatorRewards(id);\\n rewardToken.transfer(beneficiary, uint256(earned));\\n return earned;\\n }\\n\\n /// @notice Withdraws rewards not allocated to operators marked as ineligible\\n /// to the given recipient address.\\n /// @dev Can be called only by the owner.\\n function withdrawIneligible(address recipient) public onlyOwner {\\n uint96 earned = Rewards.withdrawIneligibleRewards();\\n rewardToken.transfer(recipient, uint256(earned));\\n }\\n\\n /// @notice Locks the sortition pool. In locked state, members cannot be\\n /// inserted and removed from the pool. Members statuses cannot\\n /// be updated as well.\\n /// @dev Can be called only by the contract owner.\\n function lock() public onlyOwner {\\n isLocked = true;\\n }\\n\\n /// @notice Unlocks the sortition pool. Removes all restrictions set by\\n /// the `lock` method.\\n /// @dev Can be called only by the contract owner.\\n function unlock() public onlyOwner {\\n isLocked = false;\\n }\\n\\n /// @notice Inserts an operator to the pool. Reverts if the operator is\\n /// already present. Reverts if the operator is not eligible because of their\\n /// authorized stake. Reverts if the chaosnet is active and the operator is\\n /// not a beta operator.\\n /// @dev Can be called only by the contract owner.\\n /// @param operator Address of the inserted operator.\\n /// @param authorizedStake Inserted operator's authorized stake for the application.\\n function insertOperator(address operator, uint256 authorizedStake)\\n public\\n onlyOwner\\n onlyUnlocked\\n {\\n uint256 weight = getWeight(authorizedStake);\\n require(weight > 0, \\\"Operator not eligible\\\");\\n\\n if (isChaosnetActive) {\\n require(isBetaOperator[operator], \\\"Not beta operator for chaosnet\\\");\\n }\\n\\n _insertOperator(operator, weight);\\n uint32 id = getOperatorID(operator);\\n Rewards.updateOperatorRewards(id, uint32(weight));\\n }\\n\\n /// @notice Update the operator's weight if present and eligible,\\n /// or remove from the pool if present and ineligible.\\n /// @dev Can be called only by the contract owner.\\n /// @param operator Address of the updated operator.\\n /// @param authorizedStake Operator's authorized stake for the application.\\n function updateOperatorStatus(address operator, uint256 authorizedStake)\\n public\\n onlyOwner\\n onlyUnlocked\\n {\\n uint256 weight = getWeight(authorizedStake);\\n\\n uint32 id = getOperatorID(operator);\\n Rewards.updateOperatorRewards(id, uint32(weight));\\n\\n if (weight == 0) {\\n _removeOperator(operator);\\n } else {\\n updateOperator(operator, weight);\\n }\\n }\\n\\n /// @notice Set the given operators as ineligible for rewards.\\n /// The operators can restore their eligibility at the given time.\\n function setRewardIneligibility(uint32[] calldata operators, uint256 until)\\n public\\n onlyOwner\\n {\\n Rewards.setIneligible(operators, until);\\n emit IneligibleForRewards(operators, until);\\n }\\n\\n /// @notice Restores reward eligibility for the operator.\\n function restoreRewardEligibility(address operator) public {\\n uint32 id = getOperatorID(operator);\\n Rewards.restoreEligibility(id);\\n emit RewardEligibilityRestored(operator, id);\\n }\\n\\n /// @notice Returns whether the operator is eligible for rewards or not.\\n function isEligibleForRewards(address operator) public view returns (bool) {\\n uint32 id = getOperatorID(operator);\\n return Rewards.isEligibleForRewards(id);\\n }\\n\\n /// @notice Returns the time the operator's reward eligibility can be restored.\\n function rewardsEligibilityRestorableAt(address operator)\\n public\\n view\\n returns (uint256)\\n {\\n uint32 id = getOperatorID(operator);\\n return Rewards.rewardsEligibilityRestorableAt(id);\\n }\\n\\n /// @notice Returns whether the operator is able to restore their eligibility\\n /// for rewards right away.\\n function canRestoreRewardEligibility(address operator)\\n public\\n view\\n returns (bool)\\n {\\n uint32 id = getOperatorID(operator);\\n return Rewards.canRestoreRewardEligibility(id);\\n }\\n\\n /// @notice Returns the amount of rewards withdrawable for the given operator.\\n function getAvailableRewards(address operator) public view returns (uint96) {\\n uint32 id = getOperatorID(operator);\\n return availableRewards(id);\\n }\\n\\n /// @notice Return whether the operator is present in the pool.\\n function isOperatorInPool(address operator) public view returns (bool) {\\n return getFlaggedLeafPosition(operator) != 0;\\n }\\n\\n /// @notice Return whether the operator's weight in the pool\\n /// matches their eligible weight.\\n function isOperatorUpToDate(address operator, uint256 authorizedStake)\\n public\\n view\\n returns (bool)\\n {\\n return getWeight(authorizedStake) == getPoolWeight(operator);\\n }\\n\\n /// @notice Return the weight of the operator in the pool,\\n /// which may or may not be out of date.\\n function getPoolWeight(address operator) public view returns (uint256) {\\n uint256 flaggedPosition = getFlaggedLeafPosition(operator);\\n if (flaggedPosition == 0) {\\n return 0;\\n } else {\\n uint256 leafPosition = flaggedPosition.unsetFlag();\\n uint256 leafWeight = getLeafWeight(leafPosition);\\n return leafWeight;\\n }\\n }\\n\\n /// @notice Selects a new group of operators of the provided size based on\\n /// the provided pseudo-random seed. At least one operator has to be\\n /// registered in the pool, otherwise the function fails reverting the\\n /// transaction.\\n /// @param groupSize Size of the requested group\\n /// @param seed Pseudo-random number used to select operators to group\\n /// @return selected Members of the selected group\\n function selectGroup(uint256 groupSize, bytes32 seed)\\n public\\n view\\n onlyLocked\\n returns (uint32[] memory)\\n {\\n uint256 _root = root;\\n\\n bytes32 rngState = seed;\\n uint256 rngRange = _root.sumWeight();\\n require(rngRange > 0, \\\"Not enough operators in pool\\\");\\n uint256 currentIndex;\\n\\n uint256 bits = RNG.bitsRequired(rngRange);\\n\\n uint32[] memory selected = new uint32[](groupSize);\\n\\n for (uint256 i = 0; i < groupSize; i++) {\\n (currentIndex, rngState) = RNG.getIndex(rngRange, rngState, bits);\\n\\n uint256 leafPosition = pickWeightedLeaf(currentIndex, _root);\\n\\n uint256 leaf = leaves[leafPosition];\\n selected[i] = leaf.id();\\n }\\n return selected;\\n }\\n\\n function getWeight(uint256 authorization) internal view returns (uint256) {\\n return authorization / poolWeightDivisor;\\n }\\n}\\n\",\"keccak256\":\"0xab42e7c5b1828f42a73f699eb2dc96d4f793572a6323b8b1fbd7c5e0c065bda7\"},\"@keep-network/sortition-pools/contracts/SortitionTree.sol\":{\"content\":\"pragma solidity 0.8.17;\\n\\nimport \\\"./Branch.sol\\\";\\nimport \\\"./Position.sol\\\";\\nimport \\\"./Leaf.sol\\\";\\nimport \\\"./Constants.sol\\\";\\n\\ncontract SortitionTree {\\n using Branch for uint256;\\n using Position for uint256;\\n using Leaf for uint256;\\n\\n // implicit tree\\n // root 8\\n // level2 64\\n // level3 512\\n // level4 4k\\n // level5 32k\\n // level6 256k\\n // level7 2M\\n uint256 internal root;\\n\\n // A 2-index mapping from layer => (index (0-index) => branch). For example,\\n // to access the 6th branch in the 2nd layer (right below the root node; the\\n // first branch layer), call branches[2][5]. Mappings are used in place of\\n // arrays for efficiency. The root is the first layer, the branches occupy\\n // layers 2 through 7, and layer 8 is for the leaves. Following this\\n // convention, the first index in `branches` is `2`, and the last index is\\n // `7`.\\n mapping(uint256 => mapping(uint256 => uint256)) internal branches;\\n\\n // A 0-index mapping from index => leaf, acting as an array. For example, to\\n // access the 42nd leaf, call leaves[41].\\n mapping(uint256 => uint256) internal leaves;\\n\\n // the flagged (see setFlag() and unsetFlag() in Position.sol) positions\\n // of all operators present in the pool\\n mapping(address => uint256) internal flaggedLeafPosition;\\n\\n // the leaf after the rightmost occupied leaf of each stack\\n uint256 internal rightmostLeaf;\\n\\n // the empty leaves in each stack\\n // between 0 and the rightmost occupied leaf\\n uint256[] internal emptyLeaves;\\n\\n // Each operator has an uint32 ID number\\n // which is allocated when they first join the pool\\n // and remains unchanged even if they leave and rejoin the pool.\\n mapping(address => uint32) internal operatorID;\\n\\n // The idAddress array records the address corresponding to each ID number.\\n // The ID number 0 is initialized with a zero address and is not used.\\n address[] internal idAddress;\\n\\n constructor() {\\n root = 0;\\n rightmostLeaf = 0;\\n idAddress.push();\\n }\\n\\n /// @notice Return the ID number of the given operator address. An ID number\\n /// of 0 means the operator has not been allocated an ID number yet.\\n /// @param operator Address of the operator.\\n /// @return the ID number of the given operator address\\n function getOperatorID(address operator) public view returns (uint32) {\\n return operatorID[operator];\\n }\\n\\n /// @notice Get the operator address corresponding to the given ID number. A\\n /// zero address means the ID number has not been allocated yet.\\n /// @param id ID of the operator\\n /// @return the address of the operator\\n function getIDOperator(uint32 id) public view returns (address) {\\n return idAddress.length > id ? idAddress[id] : address(0);\\n }\\n\\n /// @notice Gets the operator addresses corresponding to the given ID\\n /// numbers. A zero address means the ID number has not been allocated yet.\\n /// This function works just like getIDOperator except that it allows to fetch\\n /// operator addresses for multiple IDs in one call.\\n /// @param ids the array of the operator ids\\n /// @return an array of the associated operator addresses\\n function getIDOperators(uint32[] calldata ids)\\n public\\n view\\n returns (address[] memory)\\n {\\n uint256 idCount = idAddress.length;\\n\\n address[] memory operators = new address[](ids.length);\\n for (uint256 i = 0; i < ids.length; i++) {\\n uint32 id = ids[i];\\n operators[i] = idCount > id ? idAddress[id] : address(0);\\n }\\n return operators;\\n }\\n\\n /// @notice Checks if operator is already registered in the pool.\\n /// @param operator the address of the operator\\n /// @return whether or not the operator is already registered in the pool\\n function isOperatorRegistered(address operator) public view returns (bool) {\\n return getFlaggedLeafPosition(operator) != 0;\\n }\\n\\n /// @notice Sum the number of operators in each trunk.\\n /// @return the number of operators in the pool\\n function operatorsInPool() public view returns (uint256) {\\n // Get the number of leaves that might be occupied;\\n // if `rightmostLeaf` equals `firstLeaf()` the tree must be empty,\\n // otherwise the difference between these numbers\\n // gives the number of leaves that may be occupied.\\n uint256 nPossiblyUsedLeaves = rightmostLeaf;\\n // Get the number of empty leaves\\n // not accounted for by the `rightmostLeaf`\\n uint256 nEmptyLeaves = emptyLeaves.length;\\n\\n return (nPossiblyUsedLeaves - nEmptyLeaves);\\n }\\n\\n /// @notice Convenience method to return the total weight of the pool\\n /// @return the total weight of the pool\\n function totalWeight() public view returns (uint256) {\\n return root.sumWeight();\\n }\\n\\n /// @notice Give the operator a new ID number.\\n /// Does not check if the operator already has an ID number.\\n /// @param operator the address of the operator\\n /// @return a new ID for that operator\\n function allocateOperatorID(address operator) internal returns (uint256) {\\n uint256 id = idAddress.length;\\n\\n require(id <= type(uint32).max, \\\"Pool capacity exceeded\\\");\\n\\n operatorID[operator] = uint32(id);\\n idAddress.push(operator);\\n return id;\\n }\\n\\n /// @notice Inserts an operator into the sortition pool\\n /// @param operator the address of an operator to insert\\n /// @param weight how much weight that operator has in the pool\\n function _insertOperator(address operator, uint256 weight) internal {\\n require(\\n !isOperatorRegistered(operator),\\n \\\"Operator is already registered in the pool\\\"\\n );\\n\\n // Fetch the operator's ID, and if they don't have one, allocate them one.\\n uint256 id = getOperatorID(operator);\\n if (id == 0) {\\n id = allocateOperatorID(operator);\\n }\\n\\n // Determine which leaf to insert them into\\n uint256 position = getEmptyLeafPosition();\\n // Record the block the operator was inserted in\\n uint256 theLeaf = Leaf.make(operator, block.number, id);\\n\\n // Update the leaf, and propagate the weight changes all the way up to the\\n // root.\\n root = setLeaf(position, theLeaf, weight, root);\\n\\n // Without position flags,\\n // the position 0x000000 would be treated as empty\\n flaggedLeafPosition[operator] = position.setFlag();\\n }\\n\\n /// @notice Remove an operator (and their weight) from the pool.\\n /// @param operator the address of the operator to remove\\n function _removeOperator(address operator) internal {\\n uint256 flaggedPosition = getFlaggedLeafPosition(operator);\\n require(flaggedPosition != 0, \\\"Operator is not registered in the pool\\\");\\n uint256 unflaggedPosition = flaggedPosition.unsetFlag();\\n\\n // Update the leaf, and propagate the weight changes all the way up to the\\n // root.\\n root = removeLeaf(unflaggedPosition, root);\\n removeLeafPositionRecord(operator);\\n }\\n\\n /// @notice Update an operator's weight in the pool.\\n /// @param operator the address of the operator to update\\n /// @param weight the new weight\\n function updateOperator(address operator, uint256 weight) internal {\\n require(\\n isOperatorRegistered(operator),\\n \\\"Operator is not registered in the pool\\\"\\n );\\n\\n uint256 flaggedPosition = getFlaggedLeafPosition(operator);\\n uint256 unflaggedPosition = flaggedPosition.unsetFlag();\\n root = updateLeaf(unflaggedPosition, weight, root);\\n }\\n\\n /// @notice Helper method to remove a leaf position record for an operator.\\n /// @param operator the address of the operator to remove the record for\\n function removeLeafPositionRecord(address operator) internal {\\n flaggedLeafPosition[operator] = 0;\\n }\\n\\n /// @notice Removes the data and weight from a particular leaf.\\n /// @param position the leaf index to remove\\n /// @param _root the root node containing the leaf\\n /// @return the updated root node\\n function removeLeaf(uint256 position, uint256 _root)\\n internal\\n returns (uint256)\\n {\\n uint256 rightmostSubOne = rightmostLeaf - 1;\\n bool isRightmost = position == rightmostSubOne;\\n\\n // Clears out the data in the leaf node, and then propagates the weight\\n // changes all the way up to the root.\\n uint256 newRoot = setLeaf(position, 0, 0, _root);\\n\\n // Infer if need to fall back on emptyLeaves yet\\n if (isRightmost) {\\n rightmostLeaf = rightmostSubOne;\\n } else {\\n emptyLeaves.push(position);\\n }\\n return newRoot;\\n }\\n\\n /// @notice Updates the tree to give a particular leaf a new weight.\\n /// @param position the index of the leaf to update\\n /// @param weight the new weight\\n /// @param _root the root node containing the leaf\\n /// @return the updated root node\\n function updateLeaf(\\n uint256 position,\\n uint256 weight,\\n uint256 _root\\n ) internal returns (uint256) {\\n if (getLeafWeight(position) != weight) {\\n return updateTree(position, weight, _root);\\n } else {\\n return _root;\\n }\\n }\\n\\n /// @notice Places a leaf into a particular position, with a given weight and\\n /// propagates that change.\\n /// @param position the index to place the leaf in\\n /// @param theLeaf the new leaf to place in the position\\n /// @param leafWeight the weight of the leaf\\n /// @param _root the root containing the new leaf\\n /// @return the updated root node\\n function setLeaf(\\n uint256 position,\\n uint256 theLeaf,\\n uint256 leafWeight,\\n uint256 _root\\n ) internal returns (uint256) {\\n // set leaf\\n leaves[position] = theLeaf;\\n\\n return (updateTree(position, leafWeight, _root));\\n }\\n\\n /// @notice Propagates a weight change at a position through the tree,\\n /// eventually returning the updated root.\\n /// @param position the index of leaf to update\\n /// @param weight the new weight of the leaf\\n /// @param _root the root node containing the leaf\\n /// @return the updated root node\\n function updateTree(\\n uint256 position,\\n uint256 weight,\\n uint256 _root\\n ) internal returns (uint256) {\\n uint256 childSlot;\\n uint256 treeNode;\\n uint256 newNode;\\n uint256 nodeWeight = weight;\\n\\n uint256 parent = position;\\n // set levels 7 to 2\\n for (uint256 level = Constants.LEVELS; level >= 2; level--) {\\n childSlot = parent.slot();\\n parent = parent.parent();\\n treeNode = branches[level][parent];\\n newNode = treeNode.setSlot(childSlot, nodeWeight);\\n branches[level][parent] = newNode;\\n nodeWeight = newNode.sumWeight();\\n }\\n\\n // set level Root\\n childSlot = parent.slot();\\n return _root.setSlot(childSlot, nodeWeight);\\n }\\n\\n /// @notice Retrieves the next available empty leaf position. Tries to fill\\n /// left to right first, ignoring leaf removals, and then fills\\n /// most-recent-removals first.\\n /// @return the position of the empty leaf\\n function getEmptyLeafPosition() internal returns (uint256) {\\n uint256 rLeaf = rightmostLeaf;\\n bool spaceOnRight = (rLeaf + 1) < Constants.POOL_CAPACITY;\\n if (spaceOnRight) {\\n rightmostLeaf = rLeaf + 1;\\n return rLeaf;\\n } else {\\n uint256 emptyLeafCount = emptyLeaves.length;\\n require(emptyLeafCount > 0, \\\"Pool is full\\\");\\n uint256 emptyLeaf = emptyLeaves[emptyLeafCount - 1];\\n emptyLeaves.pop();\\n return emptyLeaf;\\n }\\n }\\n\\n /// @notice Gets the flagged leaf position for an operator.\\n /// @param operator the address of the operator\\n /// @return the leaf position of that operator\\n function getFlaggedLeafPosition(address operator)\\n internal\\n view\\n returns (uint256)\\n {\\n return flaggedLeafPosition[operator];\\n }\\n\\n /// @notice Gets the weight of a leaf at a particular position.\\n /// @param position the index of the leaf\\n /// @return the weight of the leaf at that position\\n function getLeafWeight(uint256 position) internal view returns (uint256) {\\n uint256 slot = position.slot();\\n uint256 parent = position.parent();\\n\\n // A leaf's weight information is stored a 32-bit slot in the branch layer\\n // directly above the leaf layer. To access it, we calculate that slot and\\n // parent position, and always know the hard-coded layer index.\\n uint256 node = branches[Constants.LEVELS][parent];\\n return node.getSlot(slot);\\n }\\n\\n /// @notice Picks a leaf given a random index.\\n /// @param index a number in `[0, _root.totalWeight())` used to decide\\n /// between leaves\\n /// @param _root the root of the tree\\n function pickWeightedLeaf(uint256 index, uint256 _root)\\n internal\\n view\\n returns (uint256 leafPosition)\\n {\\n uint256 currentIndex = index;\\n uint256 currentNode = _root;\\n uint256 currentPosition = 0;\\n uint256 currentSlot;\\n\\n require(index < currentNode.sumWeight(), \\\"Index exceeds weight\\\");\\n\\n // get root slot\\n (currentSlot, currentIndex) = currentNode.pickWeightedSlot(currentIndex);\\n\\n // get slots from levels 2 to 7\\n for (uint256 level = 2; level <= Constants.LEVELS; level++) {\\n currentPosition = currentPosition.child(currentSlot);\\n currentNode = branches[level][currentPosition];\\n (currentSlot, currentIndex) = currentNode.pickWeightedSlot(currentIndex);\\n }\\n\\n // get leaf position\\n leafPosition = currentPosition.child(currentSlot);\\n }\\n}\\n\",\"keccak256\":\"0x51daeca62ef52be78a1a9de4d2a1c5900c873165f59eda14d5965d7d7da90a03\"},\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)\\n\\npragma solidity ^0.8.2;\\n\\nimport \\\"../../utils/AddressUpgradeable.sol\\\";\\n\\n/**\\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\\n *\\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\\n * reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in\\n * case an upgrade adds a module that needs to be initialized.\\n *\\n * For example:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * contract MyToken is ERC20Upgradeable {\\n * function initialize() initializer public {\\n * __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\");\\n * }\\n * }\\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\\n * function initializeV2() reinitializer(2) public {\\n * __ERC20Permit_init(\\\"MyToken\\\");\\n * }\\n * }\\n * ```\\n *\\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\\n *\\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\\n *\\n * [CAUTION]\\n * ====\\n * Avoid leaving a contract uninitialized.\\n *\\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\\n *\\n * [.hljs-theme-light.nopadding]\\n * ```\\n * /// @custom:oz-upgrades-unsafe-allow constructor\\n * constructor() {\\n * _disableInitializers();\\n * }\\n * ```\\n * ====\\n */\\nabstract contract Initializable {\\n /**\\n * @dev Indicates that the contract has been initialized.\\n * @custom:oz-retyped-from bool\\n */\\n uint8 private _initialized;\\n\\n /**\\n * @dev Indicates that the contract is in the process of being initialized.\\n */\\n bool private _initializing;\\n\\n /**\\n * @dev Triggered when the contract has been initialized or reinitialized.\\n */\\n event Initialized(uint8 version);\\n\\n /**\\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\\n * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\\n */\\n modifier initializer() {\\n bool isTopLevelCall = _setInitializedVersion(1);\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(1);\\n }\\n }\\n\\n /**\\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\\n * used to initialize parent contracts.\\n *\\n * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\\n * initialization step. This is essential to configure modules that are added through upgrades and that require\\n * initialization.\\n *\\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\\n * a contract, executing them in the right order is up to the developer or operator.\\n */\\n modifier reinitializer(uint8 version) {\\n bool isTopLevelCall = _setInitializedVersion(version);\\n if (isTopLevelCall) {\\n _initializing = true;\\n }\\n _;\\n if (isTopLevelCall) {\\n _initializing = false;\\n emit Initialized(version);\\n }\\n }\\n\\n /**\\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\\n */\\n modifier onlyInitializing() {\\n require(_initializing, \\\"Initializable: contract is not initializing\\\");\\n _;\\n }\\n\\n /**\\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\\n * through proxies.\\n */\\n function _disableInitializers() internal virtual {\\n _setInitializedVersion(type(uint8).max);\\n }\\n\\n function _setInitializedVersion(uint8 version) private returns (bool) {\\n // If the contract is initializing we ignore whether _initialized is set in order to support multiple\\n // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level\\n // of initializers, because in other contexts the contract may have been reentered.\\n if (_initializing) {\\n require(\\n version == 1 && !AddressUpgradeable.isContract(address(this)),\\n \\\"Initializable: contract is already initialized\\\"\\n );\\n return false;\\n } else {\\n require(_initialized < version, \\\"Initializable: contract is already initialized\\\");\\n _initialized = version;\\n return true;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x7454006cccb737612b00104d2f606d728e2818b778e7e55542f063c614ce46ba\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary AddressUpgradeable {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x55cf2bd9fc76704ddcdc19834cd288b7de00fc0f298a40ea16a954ae8991db2d\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary StringsUpgradeable {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x398d3323c1932a5986bf36be7c57593e121e69d5db5b6574b4ee0d031443de37\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../StringsUpgradeable.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSAUpgradeable {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n // Check the signature length\\n // - case 65: r,s,v signature (standard)\\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else if (signature.length == 64) {\\n bytes32 r;\\n bytes32 vs;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n vs := mload(add(signature, 0x40))\\n }\\n return tryRecover(hash, r, vs);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", StringsUpgradeable.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0x6602a65e0277f31f45cad4c7a15b024fd182f2f0e01eaa1954103b0d57848a27\",\"license\":\"MIT\"},\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow\\n * checks.\\n *\\n * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can\\n * easily result in undesired exploitation or bugs, since developers usually\\n * assume that overflows raise errors. `SafeCast` restores this intuition by\\n * reverting the transaction when such an operation overflows.\\n *\\n * Using this library instead of the unchecked operations eliminates an entire\\n * class of bugs, so it's recommended to use it always.\\n *\\n * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing\\n * all math on `uint256` and `int256` and then downcasting.\\n */\\nlibrary SafeCastUpgradeable {\\n /**\\n * @dev Returns the downcasted uint224 from uint256, reverting on\\n * overflow (when the input is greater than largest uint224).\\n *\\n * Counterpart to Solidity's `uint224` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 224 bits\\n */\\n function toUint224(uint256 value) internal pure returns (uint224) {\\n require(value <= type(uint224).max, \\\"SafeCast: value doesn't fit in 224 bits\\\");\\n return uint224(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint128 from uint256, reverting on\\n * overflow (when the input is greater than largest uint128).\\n *\\n * Counterpart to Solidity's `uint128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n */\\n function toUint128(uint256 value) internal pure returns (uint128) {\\n require(value <= type(uint128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return uint128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint96 from uint256, reverting on\\n * overflow (when the input is greater than largest uint96).\\n *\\n * Counterpart to Solidity's `uint96` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 96 bits\\n */\\n function toUint96(uint256 value) internal pure returns (uint96) {\\n require(value <= type(uint96).max, \\\"SafeCast: value doesn't fit in 96 bits\\\");\\n return uint96(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint64 from uint256, reverting on\\n * overflow (when the input is greater than largest uint64).\\n *\\n * Counterpart to Solidity's `uint64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n */\\n function toUint64(uint256 value) internal pure returns (uint64) {\\n require(value <= type(uint64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return uint64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint32 from uint256, reverting on\\n * overflow (when the input is greater than largest uint32).\\n *\\n * Counterpart to Solidity's `uint32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n */\\n function toUint32(uint256 value) internal pure returns (uint32) {\\n require(value <= type(uint32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return uint32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint16 from uint256, reverting on\\n * overflow (when the input is greater than largest uint16).\\n *\\n * Counterpart to Solidity's `uint16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n */\\n function toUint16(uint256 value) internal pure returns (uint16) {\\n require(value <= type(uint16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return uint16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted uint8 from uint256, reverting on\\n * overflow (when the input is greater than largest uint8).\\n *\\n * Counterpart to Solidity's `uint8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n */\\n function toUint8(uint256 value) internal pure returns (uint8) {\\n require(value <= type(uint8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return uint8(value);\\n }\\n\\n /**\\n * @dev Converts a signed int256 into an unsigned uint256.\\n *\\n * Requirements:\\n *\\n * - input must be greater than or equal to 0.\\n */\\n function toUint256(int256 value) internal pure returns (uint256) {\\n require(value >= 0, \\\"SafeCast: value must be positive\\\");\\n return uint256(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int128 from int256, reverting on\\n * overflow (when the input is less than smallest int128 or\\n * greater than largest int128).\\n *\\n * Counterpart to Solidity's `int128` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 128 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt128(int256 value) internal pure returns (int128) {\\n require(value >= type(int128).min && value <= type(int128).max, \\\"SafeCast: value doesn't fit in 128 bits\\\");\\n return int128(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int64 from int256, reverting on\\n * overflow (when the input is less than smallest int64 or\\n * greater than largest int64).\\n *\\n * Counterpart to Solidity's `int64` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 64 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt64(int256 value) internal pure returns (int64) {\\n require(value >= type(int64).min && value <= type(int64).max, \\\"SafeCast: value doesn't fit in 64 bits\\\");\\n return int64(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int32 from int256, reverting on\\n * overflow (when the input is less than smallest int32 or\\n * greater than largest int32).\\n *\\n * Counterpart to Solidity's `int32` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 32 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt32(int256 value) internal pure returns (int32) {\\n require(value >= type(int32).min && value <= type(int32).max, \\\"SafeCast: value doesn't fit in 32 bits\\\");\\n return int32(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int16 from int256, reverting on\\n * overflow (when the input is less than smallest int16 or\\n * greater than largest int16).\\n *\\n * Counterpart to Solidity's `int16` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 16 bits\\n *\\n * _Available since v3.1._\\n */\\n function toInt16(int256 value) internal pure returns (int16) {\\n require(value >= type(int16).min && value <= type(int16).max, \\\"SafeCast: value doesn't fit in 16 bits\\\");\\n return int16(value);\\n }\\n\\n /**\\n * @dev Returns the downcasted int8 from int256, reverting on\\n * overflow (when the input is less than smallest int8 or\\n * greater than largest int8).\\n *\\n * Counterpart to Solidity's `int8` operator.\\n *\\n * Requirements:\\n *\\n * - input must fit into 8 bits.\\n *\\n * _Available since v3.1._\\n */\\n function toInt8(int256 value) internal pure returns (int8) {\\n require(value >= type(int8).min && value <= type(int8).max, \\\"SafeCast: value doesn't fit in 8 bits\\\");\\n return int8(value);\\n }\\n\\n /**\\n * @dev Converts an unsigned uint256 into a signed int256.\\n *\\n * Requirements:\\n *\\n * - input must be less than or equal to maxInt256.\\n */\\n function toInt256(uint256 value) internal pure returns (int256) {\\n // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive\\n require(value <= uint256(type(int256).max), \\\"SafeCast: value doesn't fit in an int256\\\");\\n return int256(value);\\n }\\n}\\n\",\"keccak256\":\"0xcec885ecdf113b4265ed0856972d7ff167bfeb3802604b18cbb782bf47ecc4ae\",\"license\":\"MIT\"},\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * By default, the owner account will be the one that deploys the contract. This\\n * can later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the deployer as the initial owner.\\n */\\n constructor() {\\n _transferOwnership(_msgSender());\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n require(owner() == _msgSender(), \\\"Ownable: caller is not the owner\\\");\\n _;\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions anymore. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby removing any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n require(newOwner != address(0), \\\"Ownable: new owner is the zero address\\\");\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0x24e0364e503a9bbde94c715d26573a76f14cd2a202d45f96f52134ab806b67b9\",\"license\":\"MIT\"},\"@openzeppelin/contracts/security/ReentrancyGuard.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Contract module that helps prevent reentrant calls to a function.\\n *\\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\\n * available, which can be applied to functions to make sure there are no nested\\n * (reentrant) calls to them.\\n *\\n * Note that because there is a single `nonReentrant` guard, functions marked as\\n * `nonReentrant` may not call one another. This can be worked around by making\\n * those functions `private`, and then adding `external` `nonReentrant` entry\\n * points to them.\\n *\\n * TIP: If you would like to learn more about reentrancy and alternative ways\\n * to protect against it, check out our blog post\\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\\n */\\nabstract contract ReentrancyGuard {\\n // Booleans are more expensive than uint256 or any type that takes up a full\\n // word because each write operation emits an extra SLOAD to first read the\\n // slot's contents, replace the bits taken up by the boolean, and then write\\n // back. This is the compiler's defense against contract upgrades and\\n // pointer aliasing, and it cannot be disabled.\\n\\n // The values being non-zero value makes deployment a bit more expensive,\\n // but in exchange the refund on every call to nonReentrant will be lower in\\n // amount. Since refunds are capped to a percentage of the total\\n // transaction's gas, it is best to keep them low in cases like this one, to\\n // increase the likelihood of the full refund coming into effect.\\n uint256 private constant _NOT_ENTERED = 1;\\n uint256 private constant _ENTERED = 2;\\n\\n uint256 private _status;\\n\\n constructor() {\\n _status = _NOT_ENTERED;\\n }\\n\\n /**\\n * @dev Prevents a contract from calling itself, directly or indirectly.\\n * Calling a `nonReentrant` function from another `nonReentrant`\\n * function is not supported. It is possible to prevent this from happening\\n * by making the `nonReentrant` function external, and making it call a\\n * `private` function that does the actual work.\\n */\\n modifier nonReentrant() {\\n // On the first call to nonReentrant, _notEntered will be true\\n require(_status != _ENTERED, \\\"ReentrancyGuard: reentrant call\\\");\\n\\n // Any calls to nonReentrant after this point will fail\\n _status = _ENTERED;\\n\\n _;\\n\\n // By storing the original value once again, a refund is triggered (see\\n // https://eips.ethereum.org/EIPS/eip-2200)\\n _status = _NOT_ENTERED;\\n }\\n}\\n\",\"keccak256\":\"0x0e9621f60b2faabe65549f7ed0f24e8853a45c1b7990d47e8160e523683f3935\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC20 standard as defined in the EIP.\\n */\\ninterface IERC20 {\\n /**\\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\\n * another (`to`).\\n *\\n * Note that `value` may be zero.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 value);\\n\\n /**\\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\\n * a call to {approve}. `value` is the new allowance.\\n */\\n event Approval(address indexed owner, address indexed spender, uint256 value);\\n\\n /**\\n * @dev Returns the amount of tokens in existence.\\n */\\n function totalSupply() external view returns (uint256);\\n\\n /**\\n * @dev Returns the amount of tokens owned by `account`.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * @dev Moves `amount` tokens from the caller's account to `to`.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transfer(address to, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Returns the remaining number of tokens that `spender` will be\\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\\n * zero by default.\\n *\\n * This value changes when {approve} or {transferFrom} are called.\\n */\\n function allowance(address owner, address spender) external view returns (uint256);\\n\\n /**\\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\\n * that someone may use both the old and the new allowance by unfortunate\\n * transaction ordering. One possible solution to mitigate this race\\n * condition is to first reduce the spender's allowance to 0 and set the\\n * desired value afterwards:\\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address spender, uint256 amount) external returns (bool);\\n\\n /**\\n * @dev Moves `amount` tokens from `from` to `to` using the\\n * allowance mechanism. `amount` is then deducted from the caller's\\n * allowance.\\n *\\n * Returns a boolean value indicating whether the operation succeeded.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 amount\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x9750c6b834f7b43000631af5cc30001c5f547b3ceb3635488f140f60e897ea6b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\n\\n/**\\n * @dev Interface for the optional metadata functions from the ERC20 standard.\\n *\\n * _Available since v4.1._\\n */\\ninterface IERC20Metadata is IERC20 {\\n /**\\n * @dev Returns the name of the token.\\n */\\n function name() external view returns (string memory);\\n\\n /**\\n * @dev Returns the symbol of the token.\\n */\\n function symbol() external view returns (string memory);\\n\\n /**\\n * @dev Returns the decimals places of the token.\\n */\\n function decimals() external view returns (uint8);\\n}\\n\",\"keccak256\":\"0x8de418a5503946cabe331f35fe242d3201a73f67f77aaeb7110acb1f30423aca\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../IERC20.sol\\\";\\nimport \\\"../../../utils/Address.sol\\\";\\n\\n/**\\n * @title SafeERC20\\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\\n * contract returns false). Tokens that return no value (and instead revert or\\n * throw on failure) are also supported, non-reverting calls are assumed to be\\n * successful.\\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\\n */\\nlibrary SafeERC20 {\\n using Address for address;\\n\\n function safeTransfer(\\n IERC20 token,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\\n }\\n\\n function safeTransferFrom(\\n IERC20 token,\\n address from,\\n address to,\\n uint256 value\\n ) internal {\\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\\n }\\n\\n /**\\n * @dev Deprecated. This function has issues similar to the ones found in\\n * {IERC20-approve}, and its usage is discouraged.\\n *\\n * Whenever possible, use {safeIncreaseAllowance} and\\n * {safeDecreaseAllowance} instead.\\n */\\n function safeApprove(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n // safeApprove should only be called when setting an initial allowance,\\n // or when resetting it to zero. To increase and decrease it, use\\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\\n require(\\n (value == 0) || (token.allowance(address(this), spender) == 0),\\n \\\"SafeERC20: approve from non-zero to non-zero allowance\\\"\\n );\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\\n }\\n\\n function safeIncreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n uint256 newAllowance = token.allowance(address(this), spender) + value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n\\n function safeDecreaseAllowance(\\n IERC20 token,\\n address spender,\\n uint256 value\\n ) internal {\\n unchecked {\\n uint256 oldAllowance = token.allowance(address(this), spender);\\n require(oldAllowance >= value, \\\"SafeERC20: decreased allowance below zero\\\");\\n uint256 newAllowance = oldAllowance - value;\\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\\n }\\n }\\n\\n /**\\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\\n * on the return value: the return value is optional (but if data is returned, it must not be false).\\n * @param token The token targeted by the call.\\n * @param data The call data (encoded using abi.encode or one of its variants).\\n */\\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\\n // the target address contains contract code and also asserts for success in the low-level call.\\n\\n bytes memory returndata = address(token).functionCall(data, \\\"SafeERC20: low-level call failed\\\");\\n if (returndata.length > 0) {\\n // Return data is optional\\n require(abi.decode(returndata, (bool)), \\\"SafeERC20: ERC20 operation did not succeed\\\");\\n }\\n }\\n}\\n\",\"keccak256\":\"0xc3d946432c0ddbb1f846a0d3985be71299df331b91d06732152117f62f0be2b5\",\"license\":\"MIT\"},\"@openzeppelin/contracts/token/ERC721/IERC721.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../../utils/introspection/IERC165.sol\\\";\\n\\n/**\\n * @dev Required interface of an ERC721 compliant contract.\\n */\\ninterface IERC721 is IERC165 {\\n /**\\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\\n */\\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\\n */\\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\\n\\n /**\\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\\n */\\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\\n\\n /**\\n * @dev Returns the number of tokens in ``owner``'s account.\\n */\\n function balanceOf(address owner) external view returns (uint256 balance);\\n\\n /**\\n * @dev Returns the owner of the `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function ownerOf(uint256 tokenId) external view returns (address owner);\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId,\\n bytes calldata data\\n ) external;\\n\\n /**\\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must exist and be owned by `from`.\\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\\n *\\n * Emits a {Transfer} event.\\n */\\n function safeTransferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Transfers `tokenId` token from `from` to `to`.\\n *\\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\\n *\\n * Requirements:\\n *\\n * - `from` cannot be the zero address.\\n * - `to` cannot be the zero address.\\n * - `tokenId` token must be owned by `from`.\\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\\n *\\n * Emits a {Transfer} event.\\n */\\n function transferFrom(\\n address from,\\n address to,\\n uint256 tokenId\\n ) external;\\n\\n /**\\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\\n * The approval is cleared when the token is transferred.\\n *\\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\\n *\\n * Requirements:\\n *\\n * - The caller must own the token or be an approved operator.\\n * - `tokenId` must exist.\\n *\\n * Emits an {Approval} event.\\n */\\n function approve(address to, uint256 tokenId) external;\\n\\n /**\\n * @dev Approve or remove `operator` as an operator for the caller.\\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\\n *\\n * Requirements:\\n *\\n * - The `operator` cannot be the caller.\\n *\\n * Emits an {ApprovalForAll} event.\\n */\\n function setApprovalForAll(address operator, bool _approved) external;\\n\\n /**\\n * @dev Returns the account approved for `tokenId` token.\\n *\\n * Requirements:\\n *\\n * - `tokenId` must exist.\\n */\\n function getApproved(uint256 tokenId) external view returns (address operator);\\n\\n /**\\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\\n *\\n * See {setApprovalForAll}\\n */\\n function isApprovedForAll(address owner, address operator) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x0d4de01fe5360c38b4ad2b0822a12722958428f5138a7ff47c1720eb6fa52bba\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Address.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\\n\\npragma solidity ^0.8.1;\\n\\n/**\\n * @dev Collection of functions related to the address type\\n */\\nlibrary Address {\\n /**\\n * @dev Returns true if `account` is a contract.\\n *\\n * [IMPORTANT]\\n * ====\\n * It is unsafe to assume that an address for which this function returns\\n * false is an externally-owned account (EOA) and not a contract.\\n *\\n * Among others, `isContract` will return false for the following\\n * types of addresses:\\n *\\n * - an externally-owned account\\n * - a contract in construction\\n * - an address where a contract will be created\\n * - an address where a contract lived, but was destroyed\\n * ====\\n *\\n * [IMPORTANT]\\n * ====\\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\\n *\\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\\n * constructor.\\n * ====\\n */\\n function isContract(address account) internal view returns (bool) {\\n // This method relies on extcodesize/address.code.length, which returns 0\\n // for contracts in construction, since the code is only stored at the end\\n // of the constructor execution.\\n\\n return account.code.length > 0;\\n }\\n\\n /**\\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\\n * `recipient`, forwarding all available gas and reverting on errors.\\n *\\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\\n * imposed by `transfer`, making them unable to receive funds via\\n * `transfer`. {sendValue} removes this limitation.\\n *\\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\\n *\\n * IMPORTANT: because control is transferred to `recipient`, care must be\\n * taken to not create reentrancy vulnerabilities. Consider using\\n * {ReentrancyGuard} or the\\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\\n */\\n function sendValue(address payable recipient, uint256 amount) internal {\\n require(address(this).balance >= amount, \\\"Address: insufficient balance\\\");\\n\\n (bool success, ) = recipient.call{value: amount}(\\\"\\\");\\n require(success, \\\"Address: unable to send value, recipient may have reverted\\\");\\n }\\n\\n /**\\n * @dev Performs a Solidity function call using a low level `call`. A\\n * plain `call` is an unsafe replacement for a function call: use this\\n * function instead.\\n *\\n * If `target` reverts with a revert reason, it is bubbled up by this\\n * function (like regular Solidity function calls).\\n *\\n * Returns the raw returned data. To convert to the expected return value,\\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\\n *\\n * Requirements:\\n *\\n * - `target` must be a contract.\\n * - calling `target` with `data` must not revert.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionCall(target, data, \\\"Address: low-level call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\\n * `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, 0, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but also transferring `value` wei to `target`.\\n *\\n * Requirements:\\n *\\n * - the calling contract must have an ETH balance of at least `value`.\\n * - the called Solidity function must be `payable`.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value\\n ) internal returns (bytes memory) {\\n return functionCallWithValue(target, data, value, \\\"Address: low-level call with value failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\\n * with `errorMessage` as a fallback revert reason when `target` reverts.\\n *\\n * _Available since v3.1._\\n */\\n function functionCallWithValue(\\n address target,\\n bytes memory data,\\n uint256 value,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(address(this).balance >= value, \\\"Address: insufficient balance for call\\\");\\n require(isContract(target), \\\"Address: call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.call{value: value}(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\\n return functionStaticCall(target, data, \\\"Address: low-level static call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a static call.\\n *\\n * _Available since v3.3._\\n */\\n function functionStaticCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal view returns (bytes memory) {\\n require(isContract(target), \\\"Address: static call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.staticcall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\\n return functionDelegateCall(target, data, \\\"Address: low-level delegate call failed\\\");\\n }\\n\\n /**\\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\\n * but performing a delegate call.\\n *\\n * _Available since v3.4._\\n */\\n function functionDelegateCall(\\n address target,\\n bytes memory data,\\n string memory errorMessage\\n ) internal returns (bytes memory) {\\n require(isContract(target), \\\"Address: delegate call to non-contract\\\");\\n\\n (bool success, bytes memory returndata) = target.delegatecall(data);\\n return verifyCallResult(success, returndata, errorMessage);\\n }\\n\\n /**\\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\\n * revert reason using the provided one.\\n *\\n * _Available since v4.3._\\n */\\n function verifyCallResult(\\n bool success,\\n bytes memory returndata,\\n string memory errorMessage\\n ) internal pure returns (bytes memory) {\\n if (success) {\\n return returndata;\\n } else {\\n // Look for revert reason and bubble it up if present\\n if (returndata.length > 0) {\\n // The easiest way to bubble the revert reason is using memory via assembly\\n\\n assembly {\\n let returndata_size := mload(returndata)\\n revert(add(32, returndata), returndata_size)\\n }\\n } else {\\n revert(errorMessage);\\n }\\n }\\n }\\n}\\n\",\"keccak256\":\"0x2ccf9d2313a313d41a791505f2b5abfdc62191b5d4334f7f7a82691c088a1c87\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0xe2e337e6dde9ef6b680e07338c493ebea1b5fd09b43424112868e9cc1706bca7\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant _HEX_SYMBOLS = \\\"0123456789abcdef\\\";\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n // Inspired by OraclizeAPI's implementation - MIT licence\\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\\n\\n if (value == 0) {\\n return \\\"0\\\";\\n }\\n uint256 temp = value;\\n uint256 digits;\\n while (temp != 0) {\\n digits++;\\n temp /= 10;\\n }\\n bytes memory buffer = new bytes(digits);\\n while (value != 0) {\\n digits -= 1;\\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\\n value /= 10;\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n if (value == 0) {\\n return \\\"0x00\\\";\\n }\\n uint256 temp = value;\\n uint256 length = 0;\\n while (temp != 0) {\\n length++;\\n temp >>= 8;\\n }\\n return toHexString(value, length);\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\\n value >>= 4;\\n }\\n require(value == 0, \\\"Strings: hex length insufficient\\\");\\n return string(buffer);\\n }\\n}\\n\",\"keccak256\":\"0x32c202bd28995dd20c4347b7c6467a6d3241c74c8ad3edcbb610cd9205916c45\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.0;\\n\\nimport \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS,\\n InvalidSignatureV\\n }\\n\\n function _throwError(RecoverError error) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert(\\\"ECDSA: invalid signature\\\");\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert(\\\"ECDSA: invalid signature length\\\");\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert(\\\"ECDSA: invalid signature 's' value\\\");\\n } else if (error == RecoverError.InvalidSignatureV) {\\n revert(\\\"ECDSA: invalid signature 'v' value\\\");\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature` or error string. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\\n // Check the signature length\\n // - case 65: r,s,v signature (standard)\\n // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else if (signature.length == 64) {\\n bytes32 r;\\n bytes32 vs;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n assembly {\\n r := mload(add(signature, 0x20))\\n vs := mload(add(signature, 0x40))\\n }\\n return tryRecover(hash, r, vs);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength);\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, signature);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address, RecoverError) {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n *\\n * _Available since v4.2._\\n */\\n function recover(\\n bytes32 hash,\\n bytes32 r,\\n bytes32 vs\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n *\\n * _Available since v4.3._\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS);\\n }\\n if (v != 27 && v != 28) {\\n return (address(0), RecoverError.InvalidSignatureV);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature);\\n }\\n\\n return (signer, RecoverError.NoError);\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address) {\\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\\n _throwError(error);\\n return recovered;\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\\n // 32 is the length in bytes of hash,\\n // enforced by the type signature above\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\", hash));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Message, created from `s`. This\\n * produces hash corresponding to the one signed with the\\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\\n * JSON-RPC method as part of EIP-191.\\n *\\n * See {recover}.\\n */\\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", Strings.toString(s.length), s));\\n }\\n\\n /**\\n * @dev Returns an Ethereum Signed Typed Data, created from a\\n * `domainSeparator` and a `structHash`. This produces hash corresponding\\n * to the one signed with the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\\n * JSON-RPC method as part of EIP-712.\\n *\\n * See {recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(\\\"\\\\x19\\\\x01\\\", domainSeparator, structHash));\\n }\\n}\\n\",\"keccak256\":\"0x3c07f43e60e099b3b157243b3152722e73b80eeb7985c2cd73712828d7f7da29\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x447a5f3ddc18419d41ff92b3773fb86471b1db25773e07f877f548918a185bf1\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.0;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a >= b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds up instead\\n * of rounding down.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a / b + (a % b == 0 ? 0 : 1);\\n }\\n}\\n\",\"keccak256\":\"0xc995bddbca1ae19788db9f8b61e63385edd3fddf89693b612d5abd1a275974d2\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IERC20WithPermit.sol\\\";\\nimport \\\"./IReceiveApproval.sol\\\";\\n\\n/// @title ERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ncontract ERC20WithPermit is IERC20WithPermit, Ownable {\\n /// @notice The amount of tokens owned by the given account.\\n mapping(address => uint256) public override balanceOf;\\n\\n /// @notice The remaining number of tokens that spender will be\\n /// allowed to spend on behalf of owner through `transferFrom` and\\n /// `burnFrom`. This is zero by default.\\n mapping(address => mapping(address => uint256)) public override allowance;\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n mapping(address => uint256) public override nonce;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n bytes32 public constant override PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n /// @notice The amount of tokens in existence.\\n uint256 public override totalSupply;\\n\\n /// @notice The name of the token.\\n string public override name;\\n\\n /// @notice The symbol of the token.\\n string public override symbol;\\n\\n /// @notice The decimals places of the token.\\n uint8 public constant override decimals = 18;\\n\\n constructor(string memory _name, string memory _symbol) {\\n name = _name;\\n symbol = _symbol;\\n\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Moves `amount` tokens from the caller's account to `recipient`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n function transfer(address recipient, uint256 amount)\\n external\\n override\\n returns (bool)\\n {\\n _transfer(msg.sender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice Moves `amount` tokens from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @return True if the operation succeeded, reverts otherwise.\\n /// @dev Requirements:\\n /// - `spender` and `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `spender`'s tokens of at least\\n /// `amount`.\\n function transferFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external override returns (bool) {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n _approve(spender, msg.sender, currentAllowance - amount);\\n }\\n _transfer(spender, recipient, amount);\\n return true;\\n }\\n\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferFrom` and `burnFrom` will\\n /// not reduce an allowance.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external override {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonce[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approve(owner, spender, amount);\\n }\\n\\n /// @notice Creates `amount` tokens and assigns them to `account`,\\n /// increasing the total supply.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address.\\n function mint(address recipient, uint256 amount) external onlyOwner {\\n require(recipient != address(0), \\\"Mint to the zero address\\\");\\n\\n beforeTokenTransfer(address(0), recipient, amount);\\n\\n totalSupply += amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(address(0), recipient, amount);\\n }\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n /// @dev Requirements:\\n /// - the caller must have a balance of at least `amount`.\\n function burn(uint256 amount) external override {\\n _burn(msg.sender, amount);\\n }\\n\\n /// @notice Destroys `amount` of tokens from `account` using the allowance\\n /// mechanism. `amount` is then deducted from the caller's allowance\\n /// unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `account` must have a balance of at least `amount`,\\n /// - the caller must have allowance for `account`'s tokens of at least\\n /// `amount`.\\n function burnFrom(address account, uint256 amount) external override {\\n uint256 currentAllowance = allowance[account][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Burn amount exceeds allowance\\\"\\n );\\n _approve(account, msg.sender, currentAllowance - amount);\\n }\\n _burn(account, amount);\\n }\\n\\n /// @notice Calls `receiveApproval` function on spender previously approving\\n /// the spender to withdraw from the caller multiple times, up to\\n /// the `amount` amount. If this function is called again, it\\n /// overwrites the current allowance with `amount`. Reverts if the\\n /// approval reverted or if `receiveApproval` call on the spender\\n /// reverted.\\n /// @return True if both approval and `receiveApproval` calls succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external override returns (bool) {\\n if (approve(spender, amount)) {\\n IReceiveApproval(spender).receiveApproval(\\n msg.sender,\\n amount,\\n address(this),\\n extraData\\n );\\n return true;\\n }\\n return false;\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// tokens.\\n /// @return True if the operation succeeded.\\n /// @dev If the `amount` is set to `type(uint256).max` then\\n /// `transferFrom` and `burnFrom` will not reduce an allowance.\\n /// Beware that changing an allowance with this method brings the risk\\n /// that someone may use both the old and the new allowance by\\n /// unfortunate transaction ordering. One possible solution to mitigate\\n /// this race condition is to first reduce the spender's allowance to 0\\n /// and set the desired value afterwards:\\n /// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\\n function approve(address spender, uint256 amount)\\n public\\n override\\n returns (bool)\\n {\\n _approve(msg.sender, spender, amount);\\n return true;\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view override returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n /// @dev Hook that is called before any transfer of tokens. This includes\\n /// minting and burning.\\n ///\\n /// Calling conditions:\\n /// - when `from` and `to` are both non-zero, `amount` of `from`'s tokens\\n /// will be to transferred to `to`.\\n /// - when `from` is zero, `amount` tokens will be minted for `to`.\\n /// - when `to` is zero, `amount` of ``from``'s tokens will be burned.\\n /// - `from` and `to` are never both zero.\\n // slither-disable-next-line dead-code\\n function beforeTokenTransfer(\\n address from,\\n address to,\\n uint256 amount\\n ) internal virtual {}\\n\\n function _burn(address account, uint256 amount) internal {\\n uint256 currentBalance = balanceOf[account];\\n require(currentBalance >= amount, \\\"Burn amount exceeds balance\\\");\\n\\n beforeTokenTransfer(account, address(0), amount);\\n\\n balanceOf[account] = currentBalance - amount;\\n totalSupply -= amount;\\n emit Transfer(account, address(0), amount);\\n }\\n\\n function _transfer(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Transfer from the zero address\\\");\\n require(recipient != address(0), \\\"Transfer to the zero address\\\");\\n require(recipient != address(this), \\\"Transfer to the token address\\\");\\n\\n beforeTokenTransfer(spender, recipient, amount);\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n balanceOf[spender] = spenderBalance - amount;\\n balanceOf[recipient] += amount;\\n emit Transfer(spender, recipient, amount);\\n }\\n\\n function _approve(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(owner != address(0), \\\"Approve from the zero address\\\");\\n require(spender != address(0), \\\"Approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit Approval(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(name)),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x1e1bf4ec5c9d6fe70f6f834316482aeff3f122ff4ffaa7178099e7ae71a0b16d\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IApproveAndCall.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by tokens supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IApproveAndCall {\\n /// @notice Executes `receiveApproval` function on spender as specified in\\n /// `IReceiveApproval` interface. Approves spender to withdraw from\\n /// the caller multiple times, up to the `amount`. If this\\n /// function is called again, it overwrites the current allowance\\n /// with `amount`. Reverts if the approval reverted or if\\n /// `receiveApproval` call on the spender reverted.\\n function approveAndCall(\\n address spender,\\n uint256 amount,\\n bytes memory extraData\\n ) external returns (bool);\\n}\\n\",\"keccak256\":\"0x393d18ef81a57dcc96fff4c340cc2945deaebb37b9796c322cf2bc96872c3df8\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IERC20WithPermit.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\\\";\\n\\nimport \\\"./IApproveAndCall.sol\\\";\\n\\n/// @title IERC20WithPermit\\n/// @notice Burnable ERC20 token with EIP2612 permit functionality. User can\\n/// authorize a transfer of their token with a signature conforming\\n/// EIP712 standard instead of an on-chain transaction from their\\n/// address. Anyone can submit this signature on the user's behalf by\\n/// calling the permit function, as specified in EIP2612 standard,\\n/// paying gas fees, and possibly performing other actions in the same\\n/// transaction.\\ninterface IERC20WithPermit is IERC20, IERC20Metadata, IApproveAndCall {\\n /// @notice EIP2612 approval made with secp256k1 signature.\\n /// Users can authorize a transfer of their tokens with a signature\\n /// conforming EIP712 standard, rather than an on-chain transaction\\n /// from their address. Anyone can submit this signature on the\\n /// user's behalf by calling the permit function, paying gas fees,\\n /// and possibly performing other actions in the same transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external;\\n\\n /// @notice Destroys `amount` tokens from the caller.\\n function burn(uint256 amount) external;\\n\\n /// @notice Destroys `amount` of tokens from `account`, deducting the amount\\n /// from caller's allowance.\\n function burnFrom(address account, uint256 amount) external;\\n\\n /// @notice Returns hash of EIP712 Domain struct with the token name as\\n /// a signing domain and token contract as a verifying contract.\\n /// Used to construct EIP2612 signature provided to `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() external view returns (bytes32);\\n\\n /// @notice Returns the current nonce for EIP2612 permission for the\\n /// provided token owner for a replay protection. Used to construct\\n /// EIP2612 signature provided to `permit` function.\\n function nonce(address owner) external view returns (uint256);\\n\\n /// @notice Returns EIP2612 Permit message hash. Used to construct EIP2612\\n /// signature provided to `permit` function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function PERMIT_TYPEHASH() external pure returns (bytes32);\\n}\\n\",\"keccak256\":\"0xdac9a5086c19a7128b505a7be1ab0ac1aa314f6989cb88d2417e9d7383f89fa9\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/IReceiveApproval.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\n/// @notice An interface that should be implemented by contracts supporting\\n/// `approveAndCall`/`receiveApproval` pattern.\\ninterface IReceiveApproval {\\n /// @notice Receives approval to spend tokens. Called as a result of\\n /// `approveAndCall` call on the token.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x6a30d83ad230548b1e7839737affc8489a035314209de14b89dbef7fb0f66395\",\"license\":\"MIT\"},\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n\\npragma solidity ^0.8.4;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/IERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\\\";\\nimport \\\"@openzeppelin/contracts/token/ERC721/IERC721.sol\\\";\\n\\n/// @title MisfundRecovery\\n/// @notice Allows the owner of the token contract extending MisfundRecovery\\n/// to recover any ERC20 and ERC721 sent mistakenly to the token\\n/// contract address.\\ncontract MisfundRecovery is Ownable {\\n using SafeERC20 for IERC20;\\n\\n function recoverERC20(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n token.safeTransfer(recipient, amount);\\n }\\n\\n function recoverERC721(\\n IERC721 token,\\n address recipient,\\n uint256 tokenId,\\n bytes calldata data\\n ) external onlyOwner {\\n token.safeTransferFrom(address(this), recipient, tokenId, data);\\n }\\n}\\n\",\"keccak256\":\"0xbbfea02bf20e2a6df5a497bbc05c7540a3b7c7dfb8b1feeaffef7f6b8ba65d65\",\"license\":\"MIT\"},\"contracts/GovernanceUtils.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nlibrary GovernanceUtils {\\n /// @notice Reverts if the governance delay has not passed since\\n /// the change initiated time or if the change has not been\\n /// initiated.\\n /// @param changeInitiatedTimestamp The timestamp at which the change has\\n /// been initiated.\\n /// @param delay Governance delay.\\n function onlyAfterGovernanceDelay(\\n uint256 changeInitiatedTimestamp,\\n uint256 delay\\n ) internal view {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp - changeInitiatedTimestamp >= delay,\\n \\\"Governance delay has not elapsed\\\"\\n );\\n }\\n\\n /// @notice Gets the time remaining until the governable parameter update\\n /// can be committed.\\n /// @param changeInitiatedTimestamp Timestamp indicating the beginning of\\n /// the change.\\n /// @param delay Governance delay.\\n /// @return Remaining time in seconds.\\n function getRemainingGovernanceDelay(\\n uint256 changeInitiatedTimestamp,\\n uint256 delay\\n ) internal view returns (uint256) {\\n require(changeInitiatedTimestamp > 0, \\\"Change not initiated\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n uint256 elapsed = block.timestamp - changeInitiatedTimestamp;\\n if (elapsed >= delay) {\\n return 0;\\n } else {\\n return delay - elapsed;\\n }\\n }\\n}\\n\",\"keccak256\":\"0x9d16501e1b7c368ced397fd2eff0ab1bd1db8d26cc3700d0b7740942ee3c3c31\",\"license\":\"GPL-3.0-only\"},\"contracts/bank/Bank.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IReceiveBalanceApproval.sol\\\";\\nimport \\\"../vault/IVault.sol\\\";\\n\\n/// @title Bitcoin Bank\\n/// @notice Bank is a central component tracking Bitcoin balances. Balances can\\n/// be transferred between balance owners, and balance owners can\\n/// approve their balances to be spent by others. Balances in the Bank\\n/// are updated for depositors who deposited their Bitcoin into the\\n/// Bridge and only the Bridge can increase balances.\\n/// @dev Bank is a governable contract and the Governance can upgrade the Bridge\\n/// address.\\ncontract Bank is Ownable {\\n address public bridge;\\n\\n /// @notice The balance of the given account in the Bank. Zero by default.\\n mapping(address => uint256) public balanceOf;\\n\\n /// @notice The remaining amount of balance a spender will be\\n /// allowed to transfer on behalf of an owner using\\n /// `transferBalanceFrom`. Zero by default.\\n mapping(address => mapping(address => uint256)) public allowance;\\n\\n /// @notice Returns the current nonce for an EIP2612 permission for the\\n /// provided balance owner to protect against replay attacks. Used\\n /// to construct an EIP2612 signature provided to the `permit`\\n /// function.\\n mapping(address => uint256) public nonces;\\n\\n uint256 public immutable cachedChainId;\\n bytes32 public immutable cachedDomainSeparator;\\n\\n /// @notice Returns an EIP2612 Permit message hash. Used to construct\\n /// an EIP2612 signature provided to the `permit` function.\\n bytes32 public constant PERMIT_TYPEHASH =\\n keccak256(\\n \\\"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\\\"\\n );\\n\\n event BalanceTransferred(\\n address indexed from,\\n address indexed to,\\n uint256 amount\\n );\\n\\n event BalanceApproved(\\n address indexed owner,\\n address indexed spender,\\n uint256 amount\\n );\\n\\n event BalanceIncreased(address indexed owner, uint256 amount);\\n\\n event BalanceDecreased(address indexed owner, uint256 amount);\\n\\n event BridgeUpdated(address newBridge);\\n\\n modifier onlyBridge() {\\n require(msg.sender == address(bridge), \\\"Caller is not the bridge\\\");\\n _;\\n }\\n\\n constructor() {\\n cachedChainId = block.chainid;\\n cachedDomainSeparator = buildDomainSeparator();\\n }\\n\\n /// @notice Allows the Governance to upgrade the Bridge address.\\n /// @dev The function does not implement any governance delay and does not\\n /// check the status of the Bridge. The Governance implementation needs\\n /// to ensure all requirements for the upgrade are satisfied before\\n /// executing this function.\\n /// Requirements:\\n /// - The new Bridge address must not be zero.\\n /// @param _bridge The new Bridge address.\\n function updateBridge(address _bridge) external onlyOwner {\\n require(_bridge != address(0), \\\"Bridge address must not be 0x0\\\");\\n bridge = _bridge;\\n emit BridgeUpdated(_bridge);\\n }\\n\\n /// @notice Moves the given `amount` of balance from the caller to\\n /// `recipient`.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - the caller must have a balance of at least `amount`.\\n /// @param recipient The recipient of the balance.\\n /// @param amount The amount of the balance transferred.\\n function transferBalance(address recipient, uint256 amount) external {\\n _transferBalance(msg.sender, recipient, amount);\\n }\\n\\n /// @notice Sets `amount` as the allowance of `spender` over the caller's\\n /// balance. Does not allow updating an existing allowance to\\n /// a value that is non-zero to avoid someone using both the old and\\n /// the new allowance by unfortunate transaction ordering. To update\\n /// an allowance to a non-zero value please set it to zero first or\\n /// use `increaseBalanceAllowance` or `decreaseBalanceAllowance` for\\n /// an atomic update.\\n /// @dev If the `amount` is set to `type(uint256).max`,\\n /// `transferBalanceFrom` will not reduce an allowance.\\n /// @param spender The address that will be allowed to spend the balance.\\n /// @param amount The amount the spender is allowed to spend.\\n function approveBalance(address spender, uint256 amount) external {\\n require(\\n amount == 0 || allowance[msg.sender][spender] == 0,\\n \\\"Non-atomic allowance change not allowed\\\"\\n );\\n _approveBalance(msg.sender, spender, amount);\\n }\\n\\n /// @notice Sets the `amount` as an allowance of a smart contract `spender`\\n /// over the caller's balance and calls the `spender` via\\n /// `receiveBalanceApproval`.\\n /// @dev If the `amount` is set to `type(uint256).max`, the potential\\n /// `transferBalanceFrom` executed in `receiveBalanceApproval` of\\n /// `spender` will not reduce an allowance. Beware that changing an\\n /// allowance with this function brings the risk that `spender` may use\\n /// both the old and the new allowance by unfortunate transaction\\n /// ordering. Please use `increaseBalanceAllowance` and\\n /// `decreaseBalanceAllowance` to eliminate the risk.\\n /// @param spender The smart contract that will be allowed to spend the\\n /// balance.\\n /// @param amount The amount the spender contract is allowed to spend.\\n /// @param extraData Extra data passed to the `spender` contract via\\n /// `receiveBalanceApproval` call.\\n function approveBalanceAndCall(\\n address spender,\\n uint256 amount,\\n bytes calldata extraData\\n ) external {\\n _approveBalance(msg.sender, spender, amount);\\n IReceiveBalanceApproval(spender).receiveBalanceApproval(\\n msg.sender,\\n amount,\\n extraData\\n );\\n }\\n\\n /// @notice Atomically increases the caller's balance allowance granted to\\n /// `spender` by the given `addedValue`.\\n /// @param spender The spender address for which the allowance is increased.\\n /// @param addedValue The amount by which the allowance is increased.\\n function increaseBalanceAllowance(address spender, uint256 addedValue)\\n external\\n {\\n _approveBalance(\\n msg.sender,\\n spender,\\n allowance[msg.sender][spender] + addedValue\\n );\\n }\\n\\n /// @notice Atomically decreases the caller's balance allowance granted to\\n /// `spender` by the given `subtractedValue`.\\n /// @dev Requirements:\\n /// - `spender` must not be the zero address,\\n /// - the current allowance for `spender` must not be lower than\\n /// the `subtractedValue`.\\n /// @param spender The spender address for which the allowance is decreased.\\n /// @param subtractedValue The amount by which the allowance is decreased.\\n function decreaseBalanceAllowance(address spender, uint256 subtractedValue)\\n external\\n {\\n uint256 currentAllowance = allowance[msg.sender][spender];\\n require(\\n currentAllowance >= subtractedValue,\\n \\\"Can not decrease balance allowance below zero\\\"\\n );\\n unchecked {\\n _approveBalance(\\n msg.sender,\\n spender,\\n currentAllowance - subtractedValue\\n );\\n }\\n }\\n\\n /// @notice Moves `amount` of balance from `spender` to `recipient` using the\\n /// allowance mechanism. `amount` is then deducted from the caller's\\n /// allowance unless the allowance was made for `type(uint256).max`.\\n /// @dev Requirements:\\n /// - `recipient` cannot be the zero address,\\n /// - `spender` must have a balance of at least `amount`,\\n /// - the caller must have an allowance for `spender`'s balance of at\\n /// least `amount`.\\n /// @param spender The address from which the balance is transferred.\\n /// @param recipient The address to which the balance is transferred.\\n /// @param amount The amount of balance that is transferred.\\n function transferBalanceFrom(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) external {\\n uint256 currentAllowance = allowance[spender][msg.sender];\\n if (currentAllowance != type(uint256).max) {\\n require(\\n currentAllowance >= amount,\\n \\\"Transfer amount exceeds allowance\\\"\\n );\\n unchecked {\\n _approveBalance(spender, msg.sender, currentAllowance - amount);\\n }\\n }\\n _transferBalance(spender, recipient, amount);\\n }\\n\\n /// @notice An EIP2612 approval made with secp256k1 signature. Users can\\n /// authorize a transfer of their balance with a signature\\n /// conforming to the EIP712 standard, rather than an on-chain\\n /// transaction from their address. Anyone can submit this signature\\n /// on the user's behalf by calling the `permit` function, paying\\n /// gas fees, and possibly performing other actions in the same\\n /// transaction.\\n /// @dev The deadline argument can be set to `type(uint256).max to create\\n /// permits that effectively never expire. If the `amount` is set\\n /// to `type(uint256).max` then `transferBalanceFrom` will not\\n /// reduce an allowance. Beware that changing an allowance with this\\n /// function brings the risk that someone may use both the old and the\\n /// new allowance by unfortunate transaction ordering. Please use\\n /// `increaseBalanceAllowance` and `decreaseBalanceAllowance` to\\n /// eliminate the risk.\\n /// @param owner The balance owner who signed the permission.\\n /// @param spender The address that will be allowed to spend the balance.\\n /// @param amount The amount the spender is allowed to spend.\\n /// @param deadline The UNIX time until which the permit is valid.\\n /// @param v V part of the permit signature.\\n /// @param r R part of the permit signature.\\n /// @param s S part of the permit signature.\\n function permit(\\n address owner,\\n address spender,\\n uint256 amount,\\n uint256 deadline,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) external {\\n /* solhint-disable-next-line not-rely-on-time */\\n require(deadline >= block.timestamp, \\\"Permission expired\\\");\\n\\n // Validate `s` and `v` values for a malleability concern described in EIP2.\\n // Only signatures with `s` value in the lower half of the secp256k1\\n // curve's order and `v` value of 27 or 28 are considered valid.\\n require(\\n uint256(s) <=\\n 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\\n \\\"Invalid signature 's' value\\\"\\n );\\n require(v == 27 || v == 28, \\\"Invalid signature 'v' value\\\");\\n\\n bytes32 digest = keccak256(\\n abi.encodePacked(\\n \\\"\\\\x19\\\\x01\\\",\\n DOMAIN_SEPARATOR(),\\n keccak256(\\n abi.encode(\\n PERMIT_TYPEHASH,\\n owner,\\n spender,\\n amount,\\n nonces[owner]++,\\n deadline\\n )\\n )\\n )\\n );\\n address recoveredAddress = ecrecover(digest, v, r, s);\\n require(\\n recoveredAddress != address(0) && recoveredAddress == owner,\\n \\\"Invalid signature\\\"\\n );\\n _approveBalance(owner, spender, amount);\\n }\\n\\n /// @notice Increases balances of the provided `recipients` by the provided\\n /// `amounts`. Can only be called by the Bridge.\\n /// @dev Requirements:\\n /// - length of `recipients` and `amounts` must be the same,\\n /// - none of `recipients` addresses must point to the Bank.\\n /// @param recipients Balance increase recipients.\\n /// @param amounts Amounts by which balances are increased.\\n function increaseBalances(\\n address[] calldata recipients,\\n uint256[] calldata amounts\\n ) external onlyBridge {\\n require(\\n recipients.length == amounts.length,\\n \\\"Arrays must have the same length\\\"\\n );\\n for (uint256 i = 0; i < recipients.length; i++) {\\n _increaseBalance(recipients[i], amounts[i]);\\n }\\n }\\n\\n /// @notice Increases balance of the provided `recipient` by the provided\\n /// `amount`. Can only be called by the Bridge.\\n /// @dev Requirements:\\n /// - `recipient` address must not point to the Bank.\\n /// @param recipient Balance increase recipient.\\n /// @param amount Amount by which the balance is increased.\\n function increaseBalance(address recipient, uint256 amount)\\n external\\n onlyBridge\\n {\\n _increaseBalance(recipient, amount);\\n }\\n\\n /// @notice Increases the given smart contract `vault`'s balance and\\n /// notifies the `vault` contract about it.\\n /// Can be called only by the Bridge.\\n /// @dev Requirements:\\n /// - `vault` must implement `IVault` interface,\\n /// - length of `recipients` and `amounts` must be the same.\\n /// @param vault Address of `IVault` recipient contract.\\n /// @param recipients Balance increase recipients.\\n /// @param amounts Amounts by which balances are increased.\\n function increaseBalanceAndCall(\\n address vault,\\n address[] calldata recipients,\\n uint256[] calldata amounts\\n ) external onlyBridge {\\n require(\\n recipients.length == amounts.length,\\n \\\"Arrays must have the same length\\\"\\n );\\n uint256 totalAmount = 0;\\n for (uint256 i = 0; i < amounts.length; i++) {\\n totalAmount += amounts[i];\\n }\\n _increaseBalance(vault, totalAmount);\\n IVault(vault).receiveBalanceIncrease(recipients, amounts);\\n }\\n\\n /// @notice Decreases caller's balance by the provided `amount`. There is no\\n /// way to restore the balance so do not call this function unless\\n /// you really know what you are doing!\\n /// @dev Requirements:\\n /// - The caller must have a balance of at least `amount`.\\n /// @param amount The amount by which the balance is decreased.\\n function decreaseBalance(uint256 amount) external {\\n balanceOf[msg.sender] -= amount;\\n emit BalanceDecreased(msg.sender, amount);\\n }\\n\\n /// @notice Returns hash of EIP712 Domain struct with `TBTC Bank` as\\n /// a signing domain and Bank contract as a verifying contract.\\n /// Used to construct an EIP2612 signature provided to the `permit`\\n /// function.\\n /* solhint-disable-next-line func-name-mixedcase */\\n function DOMAIN_SEPARATOR() public view returns (bytes32) {\\n // As explained in EIP-2612, if the DOMAIN_SEPARATOR contains the\\n // chainId and is defined at contract deployment instead of\\n // reconstructed for every signature, there is a risk of possible replay\\n // attacks between chains in the event of a future chain split.\\n // To address this issue, we check the cached chain ID against the\\n // current one and in case they are different, we build domain separator\\n // from scratch.\\n if (block.chainid == cachedChainId) {\\n return cachedDomainSeparator;\\n } else {\\n return buildDomainSeparator();\\n }\\n }\\n\\n function _increaseBalance(address recipient, uint256 amount) internal {\\n require(\\n recipient != address(this),\\n \\\"Can not increase balance for Bank\\\"\\n );\\n balanceOf[recipient] += amount;\\n emit BalanceIncreased(recipient, amount);\\n }\\n\\n function _transferBalance(\\n address spender,\\n address recipient,\\n uint256 amount\\n ) private {\\n require(\\n recipient != address(0),\\n \\\"Can not transfer to the zero address\\\"\\n );\\n require(\\n recipient != address(this),\\n \\\"Can not transfer to the Bank address\\\"\\n );\\n\\n uint256 spenderBalance = balanceOf[spender];\\n require(spenderBalance >= amount, \\\"Transfer amount exceeds balance\\\");\\n unchecked {\\n balanceOf[spender] = spenderBalance - amount;\\n }\\n balanceOf[recipient] += amount;\\n emit BalanceTransferred(spender, recipient, amount);\\n }\\n\\n function _approveBalance(\\n address owner,\\n address spender,\\n uint256 amount\\n ) private {\\n require(spender != address(0), \\\"Can not approve to the zero address\\\");\\n allowance[owner][spender] = amount;\\n emit BalanceApproved(owner, spender, amount);\\n }\\n\\n function buildDomainSeparator() private view returns (bytes32) {\\n return\\n keccak256(\\n abi.encode(\\n keccak256(\\n \\\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\\\"\\n ),\\n keccak256(bytes(\\\"TBTC Bank\\\")),\\n keccak256(bytes(\\\"1\\\")),\\n block.chainid,\\n address(this)\\n )\\n );\\n }\\n}\\n\",\"keccak256\":\"0x318005485bc8fb8a8fb6091bc4a3ca0e304693d8b372b61835bed2f1f735faf7\",\"license\":\"GPL-3.0-only\"},\"contracts/bank/IReceiveBalanceApproval.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\n/// @title IReceiveBalanceApproval\\n/// @notice `IReceiveBalanceApproval` is an interface for a smart contract\\n/// consuming Bank balances approved to them in the same transaction by\\n/// other contracts or externally owned accounts (EOA).\\ninterface IReceiveBalanceApproval {\\n /// @notice Called by the Bank in `approveBalanceAndCall` function after\\n /// the balance `owner` approved `amount` of their balance in the\\n /// Bank for the contract. This way, the depositor can approve\\n /// balance and call the contract to use the approved balance in\\n /// a single transaction.\\n /// @param owner Address of the Bank balance owner who approved their\\n /// balance to be used by the contract.\\n /// @param amount The amount of the Bank balance approved by the owner\\n /// to be used by the contract.\\n /// @param extraData The `extraData` passed to `Bank.approveBalanceAndCall`.\\n /// @dev The implementation must ensure this function can only be called\\n /// by the Bank. The Bank does _not_ guarantee that the `amount`\\n /// approved by the `owner` currently exists on their balance. That is,\\n /// the `owner` could approve more balance than they currently have.\\n /// This works the same as `Bank.approve` function. The contract must\\n /// ensure the actual balance is checked before performing any action\\n /// based on it.\\n function receiveBalanceApproval(\\n address owner,\\n uint256 amount,\\n bytes calldata extraData\\n ) external;\\n}\\n\",\"keccak256\":\"0x864f29d54d9d672348520b1f46bbce786994e07d86032987e4374a267a345c2b\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/BitcoinTx.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\nimport {ValidateSPV} from \\\"@keep-network/bitcoin-spv-sol/contracts/ValidateSPV.sol\\\";\\n\\nimport \\\"./BridgeState.sol\\\";\\n\\n/// @title Bitcoin transaction\\n/// @notice Allows to reference Bitcoin raw transaction in Solidity.\\n/// @dev See https://developer.bitcoin.org/reference/transactions.html#raw-transaction-format\\n///\\n/// Raw Bitcoin transaction data:\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|--------------|------------------------|---------------------------|\\n/// | 4 | version | int32_t (LE) | TX version number |\\n/// | varies | tx_in_count | compactSize uint (LE) | Number of TX inputs |\\n/// | varies | tx_in | txIn[] | TX inputs |\\n/// | varies | tx_out_count | compactSize uint (LE) | Number of TX outputs |\\n/// | varies | tx_out | txOut[] | TX outputs |\\n/// | 4 | lock_time | uint32_t (LE) | Unix time or block number |\\n///\\n//\\n/// Non-coinbase transaction input (txIn):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|------------------|------------------------|---------------------------------------------|\\n/// | 36 | previous_output | outpoint | The previous outpoint being spent |\\n/// | varies | script_bytes | compactSize uint (LE) | The number of bytes in the signature script |\\n/// | varies | signature_script | char[] | The signature script, empty for P2WSH |\\n/// | 4 | sequence | uint32_t (LE) | Sequence number |\\n///\\n///\\n/// The reference to transaction being spent (outpoint):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |-------|-------|---------------|------------------------------------------|\\n/// | 32 | hash | char[32] | Hash of the transaction to spend |\\n/// | 4 | index | uint32_t (LE) | Index of the specific output from the TX |\\n///\\n///\\n/// Transaction output (txOut):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|-----------------|-----------------------|--------------------------------------|\\n/// | 8 | value | int64_t (LE) | Number of satoshis to spend |\\n/// | 1+ | pk_script_bytes | compactSize uint (LE) | Number of bytes in the pubkey script |\\n/// | varies | pk_script | char[] | Pubkey script |\\n///\\n/// compactSize uint format:\\n///\\n/// | Value | Bytes | Format |\\n/// |-----------------------------------------|-------|----------------------------------------------|\\n/// | >= 0 && <= 252 | 1 | uint8_t |\\n/// | >= 253 && <= 0xffff | 3 | 0xfd followed by the number as uint16_t (LE) |\\n/// | >= 0x10000 && <= 0xffffffff | 5 | 0xfe followed by the number as uint32_t (LE) |\\n/// | >= 0x100000000 && <= 0xffffffffffffffff | 9 | 0xff followed by the number as uint64_t (LE) |\\n///\\n/// (*) compactSize uint is often references as VarInt)\\n///\\n/// Coinbase transaction input (txIn):\\n///\\n/// | Bytes | Name | BTC type | Description |\\n/// |--------|------------------|------------------------|---------------------------------------------|\\n/// | 32 | hash | char[32] | A 32-byte 0x0 null (no previous_outpoint) |\\n/// | 4 | index | uint32_t (LE) | 0xffffffff (no previous_outpoint) |\\n/// | varies | script_bytes | compactSize uint (LE) | The number of bytes in the coinbase script |\\n/// | varies | height | char[] | The block height of this block (BIP34) (*) |\\n/// | varies | coinbase_script | none | Arbitrary data, max 100 bytes |\\n/// | 4 | sequence | uint32_t (LE) | Sequence number\\n///\\n/// (*) Uses script language: starts with a data-pushing opcode that indicates how many bytes to push to\\n/// the stack followed by the block height as a little-endian unsigned integer. This script must be as\\n/// short as possible, otherwise it may be rejected. The data-pushing opcode will be 0x03 and the total\\n/// size four bytes until block 16,777,216 about 300 years from now.\\nlibrary BitcoinTx {\\n using BTCUtils for bytes;\\n using BTCUtils for uint256;\\n using BytesLib for bytes;\\n using ValidateSPV for bytes;\\n using ValidateSPV for bytes32;\\n\\n /// @notice Represents Bitcoin transaction data.\\n struct Info {\\n /// @notice Bitcoin transaction version.\\n /// @dev `version` from raw Bitcoin transaction data.\\n /// Encoded as 4-bytes signed integer, little endian.\\n bytes4 version;\\n /// @notice All Bitcoin transaction inputs, prepended by the number of\\n /// transaction inputs.\\n /// @dev `tx_in_count | tx_in` from raw Bitcoin transaction data.\\n ///\\n /// The number of transaction inputs encoded as compactSize\\n /// unsigned integer, little-endian.\\n ///\\n /// Note that some popular block explorers reverse the order of\\n /// bytes from `outpoint`'s `hash` and display it as big-endian.\\n /// Solidity code of Bridge expects hashes in little-endian, just\\n /// like they are represented in a raw Bitcoin transaction.\\n bytes inputVector;\\n /// @notice All Bitcoin transaction outputs prepended by the number of\\n /// transaction outputs.\\n /// @dev `tx_out_count | tx_out` from raw Bitcoin transaction data.\\n ///\\n /// The number of transaction outputs encoded as a compactSize\\n /// unsigned integer, little-endian.\\n bytes outputVector;\\n /// @notice Bitcoin transaction locktime.\\n ///\\n /// @dev `lock_time` from raw Bitcoin transaction data.\\n /// Encoded as 4-bytes unsigned integer, little endian.\\n bytes4 locktime;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents data needed to perform a Bitcoin SPV proof.\\n struct Proof {\\n /// @notice The merkle proof of transaction inclusion in a block.\\n bytes merkleProof;\\n /// @notice Transaction index in the block (0-indexed).\\n uint256 txIndexInBlock;\\n /// @notice Single byte-string of 80-byte bitcoin headers,\\n /// lowest height first.\\n bytes bitcoinHeaders;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents info about an unspent transaction output.\\n struct UTXO {\\n /// @notice Hash of the transaction the output belongs to.\\n /// @dev Byte order corresponds to the Bitcoin internal byte order.\\n bytes32 txHash;\\n /// @notice Index of the transaction output (0-indexed).\\n uint32 txOutputIndex;\\n /// @notice Value of the transaction output.\\n uint64 txOutputValue;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents Bitcoin signature in the R/S/V format.\\n struct RSVSignature {\\n /// @notice Signature r value.\\n bytes32 r;\\n /// @notice Signature s value.\\n bytes32 s;\\n /// @notice Signature recovery value.\\n uint8 v;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Validates the SPV proof of the Bitcoin transaction.\\n /// Reverts in case the validation or proof verification fail.\\n /// @param txInfo Bitcoin transaction data.\\n /// @param proof Bitcoin proof data.\\n /// @return txHash Proven 32-byte transaction hash.\\n function validateProof(\\n BridgeState.Storage storage self,\\n Info calldata txInfo,\\n Proof calldata proof\\n ) internal view returns (bytes32 txHash) {\\n require(\\n txInfo.inputVector.validateVin(),\\n \\\"Invalid input vector provided\\\"\\n );\\n require(\\n txInfo.outputVector.validateVout(),\\n \\\"Invalid output vector provided\\\"\\n );\\n\\n txHash = abi\\n .encodePacked(\\n txInfo.version,\\n txInfo.inputVector,\\n txInfo.outputVector,\\n txInfo.locktime\\n )\\n .hash256View();\\n\\n require(\\n txHash.prove(\\n proof.bitcoinHeaders.extractMerkleRootLE(),\\n proof.merkleProof,\\n proof.txIndexInBlock\\n ),\\n \\\"Tx merkle proof is not valid for provided header and tx hash\\\"\\n );\\n\\n evaluateProofDifficulty(self, proof.bitcoinHeaders);\\n\\n return txHash;\\n }\\n\\n /// @notice Evaluates the given Bitcoin proof difficulty against the actual\\n /// Bitcoin chain difficulty provided by the relay oracle.\\n /// Reverts in case the evaluation fails.\\n /// @param bitcoinHeaders Bitcoin headers chain being part of the SPV\\n /// proof. Used to extract the observed proof difficulty.\\n function evaluateProofDifficulty(\\n BridgeState.Storage storage self,\\n bytes memory bitcoinHeaders\\n ) internal view {\\n IRelay relay = self.relay;\\n uint256 currentEpochDifficulty = relay.getCurrentEpochDifficulty();\\n uint256 previousEpochDifficulty = relay.getPrevEpochDifficulty();\\n\\n uint256 requestedDiff = 0;\\n uint256 firstHeaderDiff = bitcoinHeaders\\n .extractTarget()\\n .calculateDifficulty();\\n\\n if (firstHeaderDiff == currentEpochDifficulty) {\\n requestedDiff = currentEpochDifficulty;\\n } else if (firstHeaderDiff == previousEpochDifficulty) {\\n requestedDiff = previousEpochDifficulty;\\n } else {\\n revert(\\\"Not at current or previous difficulty\\\");\\n }\\n\\n uint256 observedDiff = bitcoinHeaders.validateHeaderChain();\\n\\n require(\\n observedDiff != ValidateSPV.getErrBadLength(),\\n \\\"Invalid length of the headers chain\\\"\\n );\\n require(\\n observedDiff != ValidateSPV.getErrInvalidChain(),\\n \\\"Invalid headers chain\\\"\\n );\\n require(\\n observedDiff != ValidateSPV.getErrLowWork(),\\n \\\"Insufficient work in a header\\\"\\n );\\n\\n require(\\n observedDiff >= requestedDiff * self.txProofDifficultyFactor,\\n \\\"Insufficient accumulated difficulty in header chain\\\"\\n );\\n }\\n\\n /// @notice Extracts public key hash from the provided P2PKH or P2WPKH output.\\n /// Reverts if the validation fails.\\n /// @param output The transaction output.\\n /// @return pubKeyHash 20-byte public key hash the output locks funds on.\\n /// @dev Requirements:\\n /// - The output must be of P2PKH or P2WPKH type and lock the funds\\n /// on a 20-byte public key hash.\\n function extractPubKeyHash(BridgeState.Storage storage, bytes memory output)\\n internal\\n pure\\n returns (bytes20 pubKeyHash)\\n {\\n bytes memory pubKeyHashBytes = output.extractHash();\\n\\n require(\\n pubKeyHashBytes.length == 20,\\n \\\"Output's public key hash must have 20 bytes\\\"\\n );\\n\\n pubKeyHash = pubKeyHashBytes.slice20(0);\\n\\n // The output consists of an 8-byte value and a variable length script.\\n // To extract just the script, we ignore the first 8 bytes.\\n uint256 scriptLen = output.length - 8;\\n\\n // The P2PKH script is 26 bytes long.\\n // The P2WPKH script is 23 bytes long.\\n // A valid script must have one of these lengths,\\n // and we can identify the expected script type by the length.\\n require(\\n scriptLen == 26 || scriptLen == 23,\\n \\\"Output must be P2PKH or P2WPKH\\\"\\n );\\n\\n if (scriptLen == 26) {\\n // Compare to the expected P2PKH script.\\n bytes26 script = bytes26(output.slice32(8));\\n\\n require(\\n script == makeP2PKHScript(pubKeyHash),\\n \\\"Invalid P2PKH script\\\"\\n );\\n }\\n\\n if (scriptLen == 23) {\\n // Compare to the expected P2WPKH script.\\n bytes23 script = bytes23(output.slice32(8));\\n\\n require(\\n script == makeP2WPKHScript(pubKeyHash),\\n \\\"Invalid P2WPKH script\\\"\\n );\\n }\\n\\n return pubKeyHash;\\n }\\n\\n /// @notice Build the P2PKH script from the given public key hash.\\n /// @param pubKeyHash The 20-byte public key hash.\\n /// @return The P2PKH script.\\n /// @dev The P2PKH script has the following byte format:\\n /// <0x1976a914> <20-byte PKH> <0x88ac>. According to\\n /// https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n /// - 0x19: Byte length of the entire script\\n /// - 0x76: OP_DUP\\n /// - 0xa9: OP_HASH160\\n /// - 0x14: Byte length of the public key hash\\n /// - 0x88: OP_EQUALVERIFY\\n /// - 0xac: OP_CHECKSIG\\n /// which matches the P2PKH structure as per:\\n /// https://en.bitcoin.it/wiki/Transaction#Pay-to-PubkeyHash\\n function makeP2PKHScript(bytes20 pubKeyHash)\\n internal\\n pure\\n returns (bytes26)\\n {\\n bytes26 P2PKHScriptMask = hex\\\"1976a914000000000000000000000000000000000000000088ac\\\";\\n\\n return ((bytes26(pubKeyHash) >> 32) | P2PKHScriptMask);\\n }\\n\\n /// @notice Build the P2WPKH script from the given public key hash.\\n /// @param pubKeyHash The 20-byte public key hash.\\n /// @return The P2WPKH script.\\n /// @dev The P2WPKH script has the following format:\\n /// <0x160014> <20-byte PKH>. According to\\n /// https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n /// - 0x16: Byte length of the entire script\\n /// - 0x00: OP_0\\n /// - 0x14: Byte length of the public key hash\\n /// which matches the P2WPKH structure as per:\\n /// https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH\\n function makeP2WPKHScript(bytes20 pubKeyHash)\\n internal\\n pure\\n returns (bytes23)\\n {\\n bytes23 P2WPKHScriptMask = hex\\\"1600140000000000000000000000000000000000000000\\\";\\n\\n return ((bytes23(pubKeyHash) >> 24) | P2WPKHScriptMask);\\n }\\n}\\n\",\"keccak256\":\"0xb087cb5b364bcdcca63772a442c630e858c90555fc691521a212c068b89120a5\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Bridge.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@keep-network/random-beacon/contracts/Governable.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/ReimbursementPool.sol\\\";\\nimport {IWalletOwner as EcdsaWalletOwner} from \\\"@keep-network/ecdsa/contracts/api/IWalletOwner.sol\\\";\\n\\nimport \\\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\\\";\\nimport \\\"@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol\\\";\\n\\nimport \\\"./IRelay.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Deposit.sol\\\";\\nimport \\\"./DepositSweep.sol\\\";\\nimport \\\"./Redemption.sol\\\";\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./EcdsaLib.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\nimport \\\"./Fraud.sol\\\";\\nimport \\\"./MovingFunds.sol\\\";\\n\\nimport \\\"../bank/IReceiveBalanceApproval.sol\\\";\\nimport \\\"../bank/Bank.sol\\\";\\n\\n/// @title Bitcoin Bridge\\n/// @notice Bridge manages BTC deposit and redemption flow and is increasing and\\n/// decreasing balances in the Bank as a result of BTC deposit and\\n/// redemption operations performed by depositors and redeemers.\\n///\\n/// Depositors send BTC funds to the most recently created off-chain\\n/// ECDSA wallet of the bridge using pay-to-script-hash (P2SH) or\\n/// pay-to-witness-script-hash (P2WSH) containing hashed information\\n/// about the depositor\\u2019s Ethereum address. Then, the depositor reveals\\n/// their Ethereum address along with their deposit blinding factor,\\n/// refund public key hash and refund locktime to the Bridge on Ethereum\\n/// chain. The off-chain ECDSA wallet listens for these sorts of\\n/// messages and when it gets one, it checks the Bitcoin network to make\\n/// sure the deposit lines up. If it does, the off-chain ECDSA wallet\\n/// may decide to pick the deposit transaction for sweeping, and when\\n/// the sweep operation is confirmed on the Bitcoin network, the ECDSA\\n/// wallet informs the Bridge about the sweep increasing appropriate\\n/// balances in the Bank.\\n/// @dev Bridge is an upgradeable component of the Bank. The order of\\n/// functionalities in this contract is: deposit, sweep, redemption,\\n/// moving funds, wallet lifecycle, frauds, parameters.\\ncontract Bridge is\\n Governable,\\n EcdsaWalletOwner,\\n Initializable,\\n IReceiveBalanceApproval\\n{\\n using BridgeState for BridgeState.Storage;\\n using Deposit for BridgeState.Storage;\\n using DepositSweep for BridgeState.Storage;\\n using Redemption for BridgeState.Storage;\\n using MovingFunds for BridgeState.Storage;\\n using Wallets for BridgeState.Storage;\\n using Fraud for BridgeState.Storage;\\n\\n BridgeState.Storage internal self;\\n\\n event DepositRevealed(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex,\\n address indexed depositor,\\n uint64 amount,\\n bytes8 blindingFactor,\\n bytes20 indexed walletPubKeyHash,\\n bytes20 refundPubKeyHash,\\n bytes4 refundLocktime,\\n address vault\\n );\\n\\n event DepositsSwept(bytes20 walletPubKeyHash, bytes32 sweepTxHash);\\n\\n event RedemptionRequested(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript,\\n address indexed redeemer,\\n uint64 requestedAmount,\\n uint64 treasuryFee,\\n uint64 txMaxFee\\n );\\n\\n event RedemptionsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 redemptionTxHash\\n );\\n\\n event RedemptionTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript\\n );\\n\\n event WalletMovingFunds(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event MovingFundsCommitmentSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes20[] targetWallets,\\n address submitter\\n );\\n\\n event MovingFundsTimeoutReset(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash\\n );\\n\\n event MovingFundsTimedOut(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsBelowDustReported(bytes20 indexed walletPubKeyHash);\\n\\n event MovedFundsSwept(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sweepTxHash\\n );\\n\\n event MovedFundsSweepTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex\\n );\\n\\n event NewWalletRequested();\\n\\n event NewWalletRegistered(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosing(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosed(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletTerminated(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event FraudChallengeSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n );\\n\\n event FraudChallengeDefeated(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash\\n );\\n\\n event FraudChallengeDefeatTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash\\n );\\n\\n event VaultStatusUpdated(address indexed vault, bool isTrusted);\\n\\n event SpvMaintainerStatusUpdated(\\n address indexed spvMaintainer,\\n bool isTrusted\\n );\\n\\n event DepositParametersUpdated(\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n\\n event RedemptionParametersUpdated(\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n );\\n\\n event MovingFundsParametersUpdated(\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n\\n event WalletParametersUpdated(\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n );\\n\\n event FraudParametersUpdated(\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n );\\n\\n event TreasuryUpdated(address treasury);\\n\\n modifier onlySpvMaintainer() {\\n require(\\n self.isSpvMaintainer[msg.sender],\\n \\\"Caller is not SPV maintainer\\\"\\n );\\n _;\\n }\\n\\n /// @custom:oz-upgrades-unsafe-allow constructor\\n constructor() {\\n _disableInitializers();\\n }\\n\\n /// @dev Initializes upgradable contract on deployment.\\n /// @param _bank Address of the Bank the Bridge belongs to.\\n /// @param _relay Address of the Bitcoin relay providing the current Bitcoin\\n /// network difficulty.\\n /// @param _treasury Address where the deposit and redemption treasury fees\\n /// will be sent to.\\n /// @param _ecdsaWalletRegistry Address of the ECDSA Wallet Registry contract.\\n /// @param _reimbursementPool Address of the Reimbursement Pool contract.\\n /// @param _txProofDifficultyFactor The number of confirmations on the Bitcoin\\n /// chain required to successfully evaluate an SPV proof.\\n function initialize(\\n address _bank,\\n address _relay,\\n address _treasury,\\n address _ecdsaWalletRegistry,\\n address payable _reimbursementPool,\\n uint96 _txProofDifficultyFactor\\n ) external initializer {\\n require(_bank != address(0), \\\"Bank address cannot be zero\\\");\\n self.bank = Bank(_bank);\\n\\n require(_relay != address(0), \\\"Relay address cannot be zero\\\");\\n self.relay = IRelay(_relay);\\n\\n require(\\n _ecdsaWalletRegistry != address(0),\\n \\\"ECDSA Wallet Registry address cannot be zero\\\"\\n );\\n self.ecdsaWalletRegistry = EcdsaWalletRegistry(_ecdsaWalletRegistry);\\n\\n require(\\n _reimbursementPool != address(0),\\n \\\"Reimbursement Pool address cannot be zero\\\"\\n );\\n self.reimbursementPool = ReimbursementPool(_reimbursementPool);\\n\\n require(_treasury != address(0), \\\"Treasury address cannot be zero\\\");\\n self.treasury = _treasury;\\n\\n self.txProofDifficultyFactor = _txProofDifficultyFactor;\\n\\n //\\n // All parameters set in the constructor are initial ones, used at the\\n // moment contracts were deployed for the first time. Parameters are\\n // governable and values assigned in the constructor do not need to\\n // reflect the current ones. Keep in mind the initial parameters are\\n // pretty forgiving and valid only for the early stage of the network.\\n //\\n\\n self.depositDustThreshold = 1000000; // 1000000 satoshi = 0.01 BTC\\n self.depositTxMaxFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.depositRevealAheadPeriod = 15 days;\\n self.depositTreasuryFeeDivisor = 2000; // 1/2000 == 5bps == 0.05% == 0.0005\\n self.redemptionDustThreshold = 1000000; // 1000000 satoshi = 0.01 BTC\\n self.redemptionTreasuryFeeDivisor = 2000; // 1/2000 == 5bps == 0.05% == 0.0005\\n self.redemptionTxMaxFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.redemptionTxMaxTotalFee = 1000000; // 1000000 satoshi = 0.01 BTC\\n self.redemptionTimeout = 5 days;\\n self.redemptionTimeoutSlashingAmount = 100 * 1e18; // 100 T\\n self.redemptionTimeoutNotifierRewardMultiplier = 100; // 100%\\n self.movingFundsTxMaxTotalFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.movingFundsDustThreshold = 200000; // 200000 satoshi = 0.002 BTC\\n self.movingFundsTimeoutResetDelay = 6 days;\\n self.movingFundsTimeout = 7 days;\\n self.movingFundsTimeoutSlashingAmount = 100 * 1e18; // 100 T\\n self.movingFundsTimeoutNotifierRewardMultiplier = 100; //100%\\n self.movingFundsCommitmentGasOffset = 15000;\\n self.movedFundsSweepTxMaxTotalFee = 100000; // 100000 satoshi = 0.001 BTC\\n self.movedFundsSweepTimeout = 7 days;\\n self.movedFundsSweepTimeoutSlashingAmount = 100 * 1e18; // 100 T\\n self.movedFundsSweepTimeoutNotifierRewardMultiplier = 100; //100%\\n self.fraudChallengeDepositAmount = 5 ether;\\n self.fraudChallengeDefeatTimeout = 7 days;\\n self.fraudSlashingAmount = 100 * 1e18; // 100 T\\n self.fraudNotifierRewardMultiplier = 100; // 100%\\n self.walletCreationPeriod = 1 weeks;\\n self.walletCreationMinBtcBalance = 1e8; // 1 BTC\\n self.walletCreationMaxBtcBalance = 100e8; // 100 BTC\\n self.walletClosureMinBtcBalance = 5 * 1e7; // 0.5 BTC\\n self.walletMaxAge = 26 weeks; // ~6 months\\n self.walletMaxBtcTransfer = 10e8; // 10 BTC\\n self.walletClosingPeriod = 40 days;\\n\\n _transferGovernance(msg.sender);\\n }\\n\\n /// @notice Used by the depositor to reveal information about their P2(W)SH\\n /// Bitcoin deposit to the Bridge on Ethereum chain. The off-chain\\n /// wallet listens for revealed deposit events and may decide to\\n /// include the revealed deposit in the next executed sweep.\\n /// Information about the Bitcoin deposit can be revealed before or\\n /// after the Bitcoin transaction with P2(W)SH deposit is mined on\\n /// the Bitcoin chain. Worth noting, the gas cost of this function\\n /// scales with the number of P2(W)SH transaction inputs and\\n /// outputs. The deposit may be routed to one of the trusted vaults.\\n /// When a deposit is routed to a vault, vault gets notified when\\n /// the deposit gets swept and it may execute the appropriate action.\\n /// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`.\\n /// @param reveal Deposit reveal data, see `RevealInfo struct.\\n /// @dev Requirements:\\n /// - This function must be called by the same Ethereum address as the\\n /// one used in the P2(W)SH BTC deposit transaction as a depositor,\\n /// - `reveal.walletPubKeyHash` must identify a `Live` wallet,\\n /// - `reveal.vault` must be 0x0 or point to a trusted vault,\\n /// - `reveal.fundingOutputIndex` must point to the actual P2(W)SH\\n /// output of the BTC deposit transaction,\\n /// - `reveal.blindingFactor` must be the blinding factor used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - `reveal.walletPubKeyHash` must be the wallet pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundPubKeyHash` must be the refund pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundLocktime` must be the refund locktime used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n ///\\n /// If any of these requirements is not met, the wallet _must_ refuse\\n /// to sweep the deposit and the depositor has to wait until the\\n /// deposit script unlocks to receive their BTC back.\\n function revealDeposit(\\n BitcoinTx.Info calldata fundingTx,\\n Deposit.DepositRevealInfo calldata reveal\\n ) external {\\n self.revealDeposit(fundingTx, reveal);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC deposit sweep transaction\\n /// and to update Bank balances accordingly. Sweep is only accepted\\n /// if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by first\\n /// computing the Bitcoin fee for the sweep transaction. The fee is\\n /// divided evenly between all swept deposits. Each depositor\\n /// receives a balance in the bank equal to the amount inferred\\n /// during the reveal transaction, minus their fee share.\\n ///\\n /// It is possible to prove the given sweep only one time.\\n /// @param sweepTx Bitcoin sweep transaction data.\\n /// @param sweepProof Bitcoin sweep proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @param vault Optional address of the vault where all swept deposits\\n /// should be routed to. All deposits swept as part of the transaction\\n /// must have their `vault` parameters set to the same address.\\n /// If this parameter is set to an address of a trusted vault, swept\\n /// deposits are routed to that vault.\\n /// If this parameter is set to the zero address or to an address\\n /// of a non-trusted vault, swept deposits are not routed to a\\n /// vault but depositors' balances are increased in the Bank\\n /// individually.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with 1..n\\n /// inputs. If the wallet has no main UTXO, all n inputs should\\n /// correspond to P2(W)SH revealed deposits UTXOs. If the wallet has\\n /// an existing main UTXO, one of the n inputs must point to that\\n /// main UTXO and remaining n-1 inputs should correspond to P2(W)SH\\n /// revealed deposits UTXOs. That transaction must have only\\n /// one P2(W)PKH output locking funds on the 20-byte wallet public\\n /// key hash,\\n /// - All revealed deposits that are swept by `sweepTx` must have\\n /// their `vault` parameters set to the same address as the address\\n /// passed in the `vault` function parameter,\\n /// - `sweepProof` components must match the expected structure. See\\n /// `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored.\\n function submitDepositSweepProof(\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n address vault\\n ) external onlySpvMaintainer {\\n self.submitDepositSweepProof(sweepTx, sweepProof, mainUtxo, vault);\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script. Handles the\\n /// simplest case in which the redeemer's balance is decreased in\\n /// the Bank.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to process the request,\\n /// - Redeemer must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes calldata redeemerOutputScript,\\n uint64 amount\\n ) external {\\n self.requestRedemption(\\n walletPubKeyHash,\\n mainUtxo,\\n msg.sender,\\n redeemerOutputScript,\\n amount\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script. Used by\\n /// `Bank.approveBalanceAndCall`. Can handle more complex cases\\n /// where balance owner may be someone else than the redeemer.\\n /// For example, vault redeeming its balance for some depositor.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @param redemptionData ABI-encoded redemption data:\\n /// [\\n /// address redeemer,\\n /// bytes20 walletPubKeyHash,\\n /// bytes32 mainUtxoTxHash,\\n /// uint32 mainUtxoTxOutputIndex,\\n /// uint64 mainUtxoTxOutputValue,\\n /// bytes redeemerOutputScript\\n /// ]\\n ///\\n /// - redeemer: The Ethereum address of the redeemer who will be able\\n /// to claim Bank balance if anything goes wrong during the redemption.\\n /// In the most basic case, when someone redeems their balance\\n /// from the Bank, `balanceOwner` is the same as `redeemer`.\\n /// However, when a Vault is redeeming part of its balance for some\\n /// redeemer address (for example, someone who has earlier deposited\\n /// into that Vault), `balanceOwner` is the Vault, and `redeemer` is\\n /// the address for which the vault is redeeming its balance to,\\n /// - walletPubKeyHash: The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key),\\n /// - mainUtxoTxHash: Data of the wallet's main UTXO TX hash, as\\n /// currently known on the Ethereum chain,\\n /// - mainUtxoTxOutputIndex: Data of the wallet's main UTXO output\\n /// index, as currently known on Ethereum chain,\\n /// - mainUtxoTxOutputValue: Data of the wallet's main UTXO output\\n /// value, as currently known on Ethereum chain,\\n /// - redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @dev Requirements:\\n /// - The caller must be the Bank,\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to process the request.\\n ///\\n /// Note on upgradeability:\\n /// Bridge is an upgradeable contract deployed behind\\n /// a TransparentUpgradeableProxy. Accepting redemption data as bytes\\n /// provides great flexibility. The Bridge is just like any other\\n /// contract with a balance approved in the Bank and can be upgraded\\n /// to another version without being bound to a particular interface\\n /// forever. This flexibility comes with the cost - developers\\n /// integrating their vaults and dApps with `Bridge` using\\n /// `approveBalanceAndCall` need to pay extra attention to\\n /// `redemptionData` and adjust the code in case the expected structure\\n /// of `redemptionData` changes.\\n function receiveBalanceApproval(\\n address balanceOwner,\\n uint256 amount,\\n bytes calldata redemptionData\\n ) external override {\\n require(msg.sender == address(self.bank), \\\"Caller is not the bank\\\");\\n\\n self.requestRedemption(\\n balanceOwner,\\n SafeCastUpgradeable.toUint64(amount),\\n redemptionData\\n );\\n }\\n\\n /// @notice Used by the wallet to prove the BTC redemption transaction\\n /// and to make the necessary bookkeeping. Redemption is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by burning\\n /// the total redeemed Bitcoin amount from Bridge balance and\\n /// transferring the treasury fee sum to the treasury address.\\n ///\\n /// It is possible to prove the given redemption only one time.\\n /// @param redemptionTx Bitcoin redemption transaction data.\\n /// @param redemptionProof Bitcoin redemption proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @dev Requirements:\\n /// - `redemptionTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `redemptionTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs handling existing pending\\n /// redemption requests or pointing to reported timed out requests.\\n /// There can be also 1 optional output representing the\\n /// change and pointing back to the 20-byte wallet public key hash.\\n /// The change should be always present if the redeemed value sum\\n /// is lower than the total wallet's BTC balance,\\n /// - `redemptionProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input.\\n /// Other remarks:\\n /// - Putting the change output as the first transaction output can\\n /// save some gas because the output processing loop begins each\\n /// iteration by checking whether the given output is the change\\n /// thus uses some gas for making the comparison. Once the change\\n /// is identified, that check is omitted in further iterations.\\n function submitRedemptionProof(\\n BitcoinTx.Info calldata redemptionTx,\\n BitcoinTx.Proof calldata redemptionProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external onlySpvMaintainer {\\n self.submitRedemptionProof(\\n redemptionTx,\\n redemptionProof,\\n mainUtxo,\\n walletPubKeyHash\\n );\\n }\\n\\n /// @notice Notifies that there is a pending redemption request associated\\n /// with the given wallet, that has timed out. The redemption\\n /// request is identified by the key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The results of calling this function:\\n /// - The pending redemptions value for the wallet will be decreased\\n /// by the requested amount (minus treasury fee),\\n /// - The tokens taken from the redeemer on redemption request will\\n /// be returned to the redeemer,\\n /// - The request will be moved from pending redemptions to\\n /// timed-out redemptions,\\n /// - If the state of the wallet is `Live` or `MovingFunds`, the\\n /// wallet operators will be slashed and the notifier will be\\n /// rewarded,\\n /// - If the state of wallet is `Live`, the wallet will be closed or\\n /// marked as `MovingFunds` (depending on the presence or absence\\n /// of the wallet's main UTXO) and the wallet will no longer be\\n /// marked as the active wallet (if it was marked as such).\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH).\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Terminated state,\\n /// - The redemption request identified by `walletPubKeyHash` and\\n /// `redeemerOutputScript` must exist,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time defined by `redemptionTimeout` must have\\n /// passed since the redemption was requested (the request must be\\n /// timed-out).\\n function notifyRedemptionTimeout(\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs,\\n bytes calldata redeemerOutputScript\\n ) external {\\n self.notifyRedemptionTimeout(\\n walletPubKeyHash,\\n walletMembersIDs,\\n redeemerOutputScript\\n );\\n }\\n\\n /// @notice Submits the moving funds target wallets commitment.\\n /// Once all requirements are met, that function registers the\\n /// target wallets commitment and opens the way for moving funds\\n /// proof submission.\\n /// The caller is reimbursed for the transaction costs.\\n /// @param walletPubKeyHash 20-byte public key hash of the source wallet.\\n /// @param walletMainUtxo Data of the source wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletMembersIDs Identifiers of the source wallet signing group\\n /// members.\\n /// @param walletMemberIndex Position of the caller in the source wallet\\n /// signing group members list.\\n /// @param targetWallets List of 20-byte public key hashes of the target\\n /// wallets that the source wallet commits to move the funds to.\\n /// @dev Requirements:\\n /// - The source wallet must be in the MovingFunds state,\\n /// - The source wallet must not have pending redemption requests,\\n /// - The source wallet must not have pending moved funds sweep requests,\\n /// - The source wallet must not have submitted its commitment already,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given source wallet in the ECDSA registry. Those IDs are\\n /// not directly stored in the contract for gas efficiency purposes\\n /// but they can be read from appropriate `DkgResultSubmitted`\\n /// and `DkgResultApproved` events,\\n /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],\\n /// - The caller must be the member of the source wallet signing group\\n /// at the position indicated by `walletMemberIndex` parameter,\\n /// - The `walletMainUtxo` components must point to the recent main\\n /// UTXO of the source wallet, as currently known on the Ethereum\\n /// chain,\\n /// - Source wallet BTC balance must be greater than zero,\\n /// - At least one Live wallet must exist in the system,\\n /// - Submitted target wallets count must match the expected count\\n /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`\\n /// where `N > 0`,\\n /// - Each target wallet must be not equal to the source wallet,\\n /// - Each target wallet must follow the expected order i.e. all\\n /// target wallets 20-byte public key hashes represented as numbers\\n /// must form a strictly increasing sequence without duplicates,\\n /// - Each target wallet must be in Live state.\\n function submitMovingFundsCommitment(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo,\\n uint32[] calldata walletMembersIDs,\\n uint256 walletMemberIndex,\\n bytes20[] calldata targetWallets\\n ) external {\\n uint256 gasStart = gasleft();\\n\\n self.submitMovingFundsCommitment(\\n walletPubKeyHash,\\n walletMainUtxo,\\n walletMembersIDs,\\n walletMemberIndex,\\n targetWallets\\n );\\n\\n self.reimbursementPool.refund(\\n (gasStart - gasleft()) + self.movingFundsCommitmentGasOffset,\\n msg.sender\\n );\\n }\\n\\n /// @notice Resets the moving funds timeout for the given wallet if the\\n /// target wallet commitment cannot be submitted due to a lack\\n /// of live wallets in the system.\\n /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The target wallets commitment must not be already submitted for\\n /// the given moving funds wallet,\\n /// - Live wallets count must be zero,\\n /// - The moving funds timeout reset delay must be elapsed.\\n function resetMovingFundsTimeout(bytes20 walletPubKeyHash) external {\\n self.resetMovingFundsTimeout(walletPubKeyHash);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moving funds transaction\\n /// and to make the necessary state changes. Moving funds is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the moving funds transaction structure\\n /// by checking if it actually spends the main UTXO of the declared\\n /// wallet and locks the value on the pre-committed target wallets\\n /// using a reasonable transaction fee. If all preconditions are\\n /// met, this functions closes the source wallet.\\n ///\\n /// It is possible to prove the given moving funds transaction only\\n /// one time.\\n /// @param movingFundsTx Bitcoin moving funds transaction data.\\n /// @param movingFundsProof Bitcoin moving funds proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet\\n /// which performed the moving funds transaction.\\n /// @dev Requirements:\\n /// - `movingFundsTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `movingFundsTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs corresponding to the\\n /// pre-committed target wallets. Outputs must be ordered in the\\n /// same way as their corresponding target wallets are ordered\\n /// within the target wallets commitment,\\n /// - `movingFundsProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input,\\n /// - The wallet that `walletPubKeyHash` points to must be in the\\n /// MovingFunds state,\\n /// - The target wallets commitment must be submitted by the wallet\\n /// that `walletPubKeyHash` points to,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movingFundsTxMaxTotalFee` governable parameter.\\n function submitMovingFundsProof(\\n BitcoinTx.Info calldata movingFundsTx,\\n BitcoinTx.Proof calldata movingFundsProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external onlySpvMaintainer {\\n self.submitMovingFundsProof(\\n movingFundsTx,\\n movingFundsProof,\\n mainUtxo,\\n walletPubKeyHash\\n );\\n }\\n\\n /// @notice Notifies about a timed out moving funds process. Terminates\\n /// the wallet and slashes signing group members as a result.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The moving funds timeout must be actually exceeded,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovingFundsTimeout(\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n self.notifyMovingFundsTimeout(walletPubKeyHash, walletMembersIDs);\\n }\\n\\n /// @notice Notifies about a moving funds wallet whose BTC balance is\\n /// below the moving funds dust threshold. Ends the moving funds\\n /// process and begins wallet closing immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known\\n /// on the Ethereum chain.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If the wallet has no main UTXO, this parameter can be empty as it\\n /// is ignored,\\n /// - The wallet BTC balance must be below the moving funds threshold.\\n function notifyMovingFundsBelowDust(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external {\\n self.notifyMovingFundsBelowDust(walletPubKeyHash, mainUtxo);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moved funds sweep\\n /// transaction and to make the necessary state changes. Moved\\n /// funds sweep is only accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the sweep transaction structure by\\n /// checking if it actually spends the moved funds UTXO and the\\n /// sweeping wallet's main UTXO (optionally), and if it locks the\\n /// value on the sweeping wallet's 20-byte public key hash using a\\n /// reasonable transaction fee. If all preconditions are\\n /// met, this function updates the sweeping wallet main UTXO, thus\\n /// their BTC balance.\\n ///\\n /// It is possible to prove the given sweep transaction only\\n /// one time.\\n /// @param sweepTx Bitcoin sweep funds transaction data.\\n /// @param sweepProof Bitcoin sweep funds proof data.\\n /// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with\\n /// the first input pointing to a moved funds sweep request targeted\\n /// to the wallet, and optionally, the second input pointing to the\\n /// wallet's main UTXO, if the sweeping wallet has a main UTXO set.\\n /// There should be only one output locking funds on the sweeping\\n /// wallet 20-byte public key hash,\\n /// - `sweepProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the sweeping wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored,\\n /// - The sweeping wallet must be in the Live or MovingFunds state,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movedFundsSweepTxMaxTotalFee` governable parameter.\\n function submitMovedFundsSweepProof(\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external onlySpvMaintainer {\\n self.submitMovedFundsSweepProof(sweepTx, sweepProof, mainUtxo);\\n }\\n\\n /// @notice Notifies about a timed out moved funds sweep process. If the\\n /// wallet is not terminated yet, that function terminates\\n /// the wallet and slashes signing group members as a result.\\n /// Marks the given sweep request as TimedOut.\\n /// @param movingFundsTxHash 32-byte hash of the moving funds transaction\\n /// that caused the sweep request to be created.\\n /// @param movingFundsTxOutputIndex Index of the moving funds transaction\\n /// output that is subject of the sweep request.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The moved funds sweep request must be in the Pending state,\\n /// - The moved funds sweep timeout must be actually exceeded,\\n /// - The wallet must be either in the Live or MovingFunds or\\n /// Terminated state,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovedFundsSweepTimeout(\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n self.notifyMovedFundsSweepTimeout(\\n movingFundsTxHash,\\n movingFundsTxOutputIndex,\\n walletMembersIDs\\n );\\n }\\n\\n /// @notice Requests creation of a new wallet. This function just\\n /// forms a request and the creation process is performed\\n /// asynchronously. Once a wallet is created, the ECDSA Wallet\\n /// Registry will notify this contract by calling the\\n /// `__ecdsaWalletCreatedCallback` function.\\n /// @param activeWalletMainUtxo Data of the active wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `activeWalletMainUtxo` components must point to the recent main\\n /// UTXO of the given active wallet, as currently known on the\\n /// Ethereum chain. If there is no active wallet at the moment, or\\n /// the active wallet has no main UTXO, this parameter can be\\n /// empty as it is ignored,\\n /// - Wallet creation must not be in progress,\\n /// - If the active wallet is set, one of the following\\n /// conditions must be true:\\n /// - The active wallet BTC balance is above the minimum threshold\\n /// and the active wallet is old enough, i.e. the creation period\\n /// was elapsed since its creation time,\\n /// - The active wallet BTC balance is above the maximum threshold.\\n function requestNewWallet(BitcoinTx.UTXO calldata activeWalletMainUtxo)\\n external\\n {\\n self.requestNewWallet(activeWalletMainUtxo);\\n }\\n\\n /// @notice A callback function that is called by the ECDSA Wallet Registry\\n /// once a new ECDSA wallet is created.\\n /// @param ecdsaWalletID Wallet's unique identifier.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Given wallet data must not belong to an already registered wallet.\\n function __ecdsaWalletCreatedCallback(\\n bytes32 ecdsaWalletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external override {\\n self.registerNewWallet(ecdsaWalletID, publicKeyX, publicKeyY);\\n }\\n\\n /// @notice A callback function that is called by the ECDSA Wallet Registry\\n /// once a wallet heartbeat failure is detected.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Wallet must be in Live state.\\n function __ecdsaWalletHeartbeatFailedCallback(\\n bytes32,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external override {\\n self.notifyWalletHeartbeatFailed(publicKeyX, publicKeyY);\\n }\\n\\n /// @notice Notifies that the wallet is either old enough or has too few\\n /// satoshi left and qualifies to be closed.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMainUtxo Data of the wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - Wallet must not be set as the current active wallet,\\n /// - Wallet must exceed the wallet maximum age OR the wallet BTC\\n /// balance must be lesser than the minimum threshold. If the latter\\n /// case is true, the `walletMainUtxo` components must point to the\\n /// recent main UTXO of the given wallet, as currently known on the\\n /// Ethereum chain. If the wallet has no main UTXO, this parameter\\n /// can be empty as it is ignored since the wallet balance is\\n /// assumed to be zero,\\n /// - Wallet must be in Live state.\\n function notifyWalletCloseable(\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) external {\\n self.notifyWalletCloseable(walletPubKeyHash, walletMainUtxo);\\n }\\n\\n /// @notice Notifies about the end of the closing period for the given wallet.\\n /// Closes the wallet ultimately and notifies the ECDSA registry\\n /// about this fact.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the Closing state,\\n /// - The wallet closing period must have elapsed.\\n function notifyWalletClosingPeriodElapsed(bytes20 walletPubKeyHash)\\n external\\n {\\n self.notifyWalletClosingPeriodElapsed(walletPubKeyHash);\\n }\\n\\n /// @notice Submits a fraud challenge indicating that a UTXO being under\\n /// wallet control was unlocked by the wallet but was not used\\n /// according to the protocol rules. That means the wallet signed\\n /// a transaction input pointing to that UTXO and there is a unique\\n /// sighash and signature pair associated with that input. This\\n /// function uses those parameters to create a fraud accusation that\\n /// proves a given transaction input unlocking the given UTXO was\\n /// actually signed by the wallet. This function cannot determine\\n /// whether the transaction was actually broadcast and the input was\\n /// consumed in a fraudulent way so it just opens a challenge period\\n /// during which the wallet can defeat the challenge by submitting\\n /// proof of a transaction that consumes the given input according\\n /// to protocol rules. To prevent spurious allegations, the caller\\n /// must deposit ETH that is returned back upon justified fraud\\n /// challenge or confiscated otherwise.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @param signature Bitcoin signature in the R/S/V format.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPublicKey` must be in Live or MovingFunds\\n /// or Closing state,\\n /// - The challenger must send appropriate amount of ETH used as\\n /// fraud challenge deposit,\\n /// - The signature (represented by r, s and v) must be generated by\\n /// the wallet behind `walletPubKey` during signing of `sighash`\\n /// which was calculated from `preimageSha256`,\\n /// - Wallet can be challenged for the given signature only once.\\n function submitFraudChallenge(\\n bytes calldata walletPublicKey,\\n bytes memory preimageSha256,\\n BitcoinTx.RSVSignature calldata signature\\n ) external payable {\\n self.submitFraudChallenge(walletPublicKey, preimageSha256, signature);\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet if\\n /// the transaction that spends the UTXO follows the protocol rules.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during input signing.\\n /// The fraud challenge defeat attempt will only succeed if the\\n /// inputs in the preimage are considered honestly spent by the\\n /// wallet. Therefore the transaction spending the UTXO must be\\n /// proven in the Bridge before a challenge defeat is called.\\n /// If successfully defeated, the fraud challenge is marked as\\n /// resolved and the amount of ether deposited by the challenger is\\n /// sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference.\\n /// @param witness Flag indicating whether the preimage was produced for a\\n /// witness input. True for witness, false for non-witness input.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as `hash256(preimage)`\\n /// must identify an open fraud challenge,\\n /// - the preimage must be a valid preimage of a transaction generated\\n /// according to the protocol rules and already proved in the Bridge,\\n /// - before a defeat attempt is made the transaction that spends the\\n /// given UTXO must be proven in the Bridge.\\n function defeatFraudChallenge(\\n bytes calldata walletPublicKey,\\n bytes calldata preimage,\\n bool witness\\n ) external {\\n self.defeatFraudChallenge(walletPublicKey, preimage, witness);\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet by\\n /// proving the sighash and signature were produced for an off-chain\\n /// wallet heartbeat message following a strict format.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during heartbeat message\\n /// signing. The fraud challenge defeat attempt will only succeed if\\n /// the signed message follows a strict format required for\\n /// heartbeat messages. If successfully defeated, the fraud\\n /// challenge is marked as resolved and the amount of ether\\n /// deposited by the challenger is sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param heartbeatMessage Off-chain heartbeat message meeting the heartbeat\\n /// message format requirements which produces sighash used to\\n /// generate the ECDSA signature that is the subject of the fraud\\n /// claim.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as\\n /// `hash256(heartbeatMessage)` must identify an open fraud challenge,\\n /// - `heartbeatMessage` must follow a strict format of heartbeat\\n /// messages.\\n function defeatFraudChallengeWithHeartbeat(\\n bytes calldata walletPublicKey,\\n bytes calldata heartbeatMessage\\n ) external {\\n self.defeatFraudChallengeWithHeartbeat(\\n walletPublicKey,\\n heartbeatMessage\\n );\\n }\\n\\n /// @notice Notifies about defeat timeout for the given fraud challenge.\\n /// Can be called only if there was a fraud challenge identified by\\n /// the provided `walletPublicKey` and `sighash` and it was not\\n /// defeated on time. The amount of time that needs to pass after\\n /// a fraud challenge is reported is indicated by the\\n /// `challengeDefeatTimeout`. After a successful fraud challenge\\n /// defeat timeout notification the fraud challenge is marked as\\n /// resolved, the stake of each operator is slashed, the ether\\n /// deposited is returned to the challenger and the challenger is\\n /// rewarded.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Closing or\\n /// Terminated state,\\n /// - The `walletPublicKey` and `sighash` calculated from\\n /// `preimageSha256` must identify an open fraud challenge,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time indicated by `challengeDefeatTimeout` must pass\\n /// after the challenge was reported.\\n function notifyFraudChallengeDefeatTimeout(\\n bytes calldata walletPublicKey,\\n uint32[] calldata walletMembersIDs,\\n bytes memory preimageSha256\\n ) external {\\n self.notifyFraudChallengeDefeatTimeout(\\n walletPublicKey,\\n walletMembersIDs,\\n preimageSha256\\n );\\n }\\n\\n /// @notice Allows the Governance to mark the given vault address as trusted\\n /// or no longer trusted. Vaults are not trusted by default.\\n /// Trusted vault must meet the following criteria:\\n /// - `IVault.receiveBalanceIncrease` must have a known, low gas\\n /// cost,\\n /// - `IVault.receiveBalanceIncrease` must never revert.\\n /// @dev Without restricting reveal only to trusted vaults, malicious\\n /// vaults not meeting the criteria would be able to nuke sweep proof\\n /// transactions executed by ECDSA wallet with deposits routed to\\n /// them.\\n /// @param vault The address of the vault.\\n /// @param isTrusted flag indicating whether the vault is trusted or not.\\n /// @dev Can only be called by the Governance.\\n function setVaultStatus(address vault, bool isTrusted)\\n external\\n onlyGovernance\\n {\\n self.isVaultTrusted[vault] = isTrusted;\\n emit VaultStatusUpdated(vault, isTrusted);\\n }\\n\\n /// @notice Allows the Governance to mark the given address as trusted\\n /// or no longer trusted SPV maintainer. Addresses are not trusted\\n /// as SPV maintainers by default.\\n /// @dev The SPV proof does not check whether the transaction is a part of\\n /// the Bitcoin mainnet, it only checks whether the transaction has been\\n /// mined performing the required amount of work as on Bitcoin mainnet.\\n /// The possibility of submitting SPV proofs is limited to trusted SPV\\n /// maintainers. The system expects transaction confirmations with the\\n /// required work accumulated, so trusted SPV maintainers can not prove\\n /// the transaction without providing the required Bitcoin proof of work.\\n /// Trusted maintainers address the issue of an economic game between\\n /// tBTC and Bitcoin mainnet where large Bitcoin mining pools can decide\\n /// to use their hash power to mine fake Bitcoin blocks to prove them in\\n /// tBTC instead of receiving Bitcoin miner rewards.\\n /// @param spvMaintainer The address of the SPV maintainer.\\n /// @param isTrusted flag indicating whether the address is trusted or not.\\n /// @dev Can only be called by the Governance.\\n function setSpvMaintainerStatus(address spvMaintainer, bool isTrusted)\\n external\\n onlyGovernance\\n {\\n self.isSpvMaintainer[spvMaintainer] = isTrusted;\\n emit SpvMaintainerStatusUpdated(spvMaintainer, isTrusted);\\n }\\n\\n /// @notice Updates parameters of deposits.\\n /// @param depositDustThreshold New value of the deposit dust threshold in\\n /// satoshis. It is the minimal amount that can be requested to\\n //// deposit. Value of this parameter must take into account the value\\n /// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters\\n /// in order to make requests that can incur the treasury and\\n /// transaction fee and still satisfy the depositor.\\n /// @param depositTreasuryFeeDivisor New value of the treasury fee divisor.\\n /// It is the divisor used to compute the treasury fee taken from\\n /// each deposit and transferred to the treasury upon sweep proof\\n /// submission. That fee is computed as follows:\\n /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each deposit,\\n /// the `depositTreasuryFeeDivisor` should be set to `50`\\n /// because `1/50 = 0.02 = 2%`.\\n /// @param depositTxMaxFee New value of the deposit tx max fee in satoshis.\\n /// It is the maximum amount of BTC transaction fee that can\\n /// be incurred by each swept deposit being part of the given sweep\\n /// transaction. If the maximum BTC transaction fee is exceeded,\\n /// such transaction is considered a fraud.\\n /// @param depositRevealAheadPeriod New value of the deposit reveal ahead\\n /// period parameter in seconds. It defines the length of the period\\n /// that must be preserved between the deposit reveal time and the\\n /// deposit refund locktime.\\n /// @dev Requirements:\\n /// - Deposit dust threshold must be greater than zero,\\n /// - Deposit dust threshold must be greater than deposit TX max fee,\\n /// - Deposit transaction max fee must be greater than zero.\\n function updateDepositParameters(\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n ) external onlyGovernance {\\n self.updateDepositParameters(\\n depositDustThreshold,\\n depositTreasuryFeeDivisor,\\n depositTxMaxFee,\\n depositRevealAheadPeriod\\n );\\n }\\n\\n /// @notice Updates parameters of redemptions.\\n /// @param redemptionDustThreshold New value of the redemption dust\\n /// threshold in satoshis. It is the minimal amount that can be\\n /// requested for redemption. Value of this parameter must take into\\n /// account the value of `redemptionTreasuryFeeDivisor` and\\n /// `redemptionTxMaxFee` parameters in order to make requests that\\n /// can incur the treasury and transaction fee and still satisfy the\\n /// redeemer.\\n /// @param redemptionTreasuryFeeDivisor New value of the redemption\\n /// treasury fee divisor. It is the divisor used to compute the\\n /// treasury fee taken from each redemption request and transferred\\n /// to the treasury upon successful request finalization. That fee is\\n /// computed as follows:\\n /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each\\n /// redemption request, the `redemptionTreasuryFeeDivisor` should\\n /// be set to `50` because `1/50 = 0.02 = 2%`.\\n /// @param redemptionTxMaxFee New value of the redemption transaction max\\n /// fee in satoshis. It is the maximum amount of BTC transaction fee\\n /// that can be incurred by each redemption request being part of the\\n /// given redemption transaction. If the maximum BTC transaction fee\\n /// is exceeded, such transaction is considered a fraud.\\n /// This is a per-redemption output max fee for the redemption\\n /// transaction.\\n /// @param redemptionTxMaxTotalFee New value of the redemption transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single redemption\\n /// transaction. This is a _total_ max fee for the entire redemption\\n /// transaction.\\n /// @param redemptionTimeout New value of the redemption timeout in seconds.\\n /// It is the time after which the redemption request can be reported\\n /// as timed out. It is counted from the moment when the redemption\\n /// request was created via `requestRedemption` call. Reported timed\\n /// out requests are cancelled and locked balance is returned to the\\n /// redeemer in full amount.\\n /// @param redemptionTimeoutSlashingAmount New value of the redemption\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for redemption timeout.\\n /// @param redemptionTimeoutNotifierRewardMultiplier New value of the\\n /// redemption timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a redemption timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Redemption dust threshold must be greater than moving funds dust\\n /// threshold,\\n /// - Redemption dust threshold must be greater than the redemption TX\\n /// max fee,\\n /// - Redemption transaction max fee must be greater than zero,\\n /// - Redemption transaction max total fee must be greater than or\\n /// equal to the redemption transaction per-request max fee,\\n /// - Redemption timeout must be greater than zero,\\n /// - Redemption timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateRedemptionParameters(\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n ) external onlyGovernance {\\n self.updateRedemptionParameters(\\n redemptionDustThreshold,\\n redemptionTreasuryFeeDivisor,\\n redemptionTxMaxFee,\\n redemptionTxMaxTotalFee,\\n redemptionTimeout,\\n redemptionTimeoutSlashingAmount,\\n redemptionTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of moving funds.\\n /// @param movingFundsTxMaxTotalFee New value of the moving funds transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single moving funds\\n /// transaction. This is a _total_ max fee for the entire moving\\n /// funds transaction.\\n /// @param movingFundsDustThreshold New value of the moving funds dust\\n /// threshold. It is the minimal satoshi amount that makes sense to\\n /// be transferred during the moving funds process. Moving funds\\n /// wallets having their BTC balance below that value can begin\\n /// closing immediately as transferring such a low value may not be\\n /// possible due to BTC network fees.\\n /// @param movingFundsTimeoutResetDelay New value of the moving funds\\n /// timeout reset delay in seconds. It is the time after which the\\n /// moving funds timeout can be reset in case the target wallet\\n /// commitment cannot be submitted due to a lack of live wallets\\n /// in the system. It is counted from the moment when the wallet\\n /// was requested to move their funds and switched to the MovingFunds\\n /// state or from the moment the timeout was reset the last time.\\n /// @param movingFundsTimeout New value of the moving funds timeout in\\n /// seconds. It is the time after which the moving funds process can\\n /// be reported as timed out. It is counted from the moment when the\\n /// wallet was requested to move their funds and switched to the\\n /// MovingFunds state.\\n /// @param movingFundsTimeoutSlashingAmount New value of the moving funds\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for moving funds timeout.\\n /// @param movingFundsTimeoutNotifierRewardMultiplier New value of the\\n /// moving funds timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a moving funds timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @param movingFundsCommitmentGasOffset New value of the gas offset for\\n /// moving funds target wallet commitment transaction gas costs\\n /// reimbursement.\\n /// @param movedFundsSweepTxMaxTotalFee New value of the moved funds sweep\\n /// transaction max total fee in satoshis. It is the maximum amount\\n /// of the total BTC transaction fee that is acceptable in a single\\n /// moved funds sweep transaction. This is a _total_ max fee for the\\n /// entire moved funds sweep transaction.\\n /// @param movedFundsSweepTimeout New value of the moved funds sweep\\n /// timeout in seconds. It is the time after which the moved funds\\n /// sweep process can be reported as timed out. It is counted from\\n /// the moment when the wallet was requested to sweep the received\\n /// funds.\\n /// @param movedFundsSweepTimeoutSlashingAmount New value of the moved\\n /// funds sweep timeout slashing amount in T, it is the amount\\n /// slashed from each wallet member for moved funds sweep timeout.\\n /// @param movedFundsSweepTimeoutNotifierRewardMultiplier New value of\\n /// the moved funds sweep timeout notifier reward multiplier as\\n /// percentage, it determines the percentage of the notifier reward\\n /// from the staking contact the notifier of a moved funds sweep\\n /// timeout receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Moving funds transaction max total fee must be greater than zero,\\n /// - Moving funds dust threshold must be greater than zero and lower\\n /// than the redemption dust threshold,\\n /// - Moving funds timeout reset delay must be greater than zero,\\n /// - Moving funds timeout must be greater than the moving funds\\n /// timeout reset delay,\\n /// - Moving funds timeout notifier reward multiplier must be in the\\n /// range [0, 100],\\n /// - Moved funds sweep transaction max total fee must be greater than zero,\\n /// - Moved funds sweep timeout must be greater than zero,\\n /// - Moved funds sweep timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateMovingFundsParameters(\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n ) external onlyGovernance {\\n self.updateMovingFundsParameters(\\n movingFundsTxMaxTotalFee,\\n movingFundsDustThreshold,\\n movingFundsTimeoutResetDelay,\\n movingFundsTimeout,\\n movingFundsTimeoutSlashingAmount,\\n movingFundsTimeoutNotifierRewardMultiplier,\\n movingFundsCommitmentGasOffset,\\n movedFundsSweepTxMaxTotalFee,\\n movedFundsSweepTimeout,\\n movedFundsSweepTimeoutSlashingAmount,\\n movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of wallets.\\n /// @param walletCreationPeriod New value of the wallet creation period in\\n /// seconds, determines how frequently a new wallet creation can be\\n /// requested.\\n /// @param walletCreationMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param walletCreationMaxBtcBalance New value of the wallet maximum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param walletClosureMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet closure.\\n /// @param walletMaxAge New value of the wallet maximum age in seconds,\\n /// indicates the maximum age of a wallet in seconds, after which\\n /// the wallet moving funds process can be requested.\\n /// @param walletMaxBtcTransfer New value of the wallet maximum BTC transfer\\n /// in satoshi, determines the maximum amount that can be transferred\\n // to a single target wallet during the moving funds process.\\n /// @param walletClosingPeriod New value of the wallet closing period in\\n /// seconds, determines the length of the wallet closing period,\\n // i.e. the period when the wallet remains in the Closing state\\n // and can be subject of deposit fraud challenges.\\n /// @dev Requirements:\\n /// - Wallet maximum BTC balance must be greater than the wallet\\n /// minimum BTC balance,\\n /// - Wallet maximum BTC transfer must be greater than zero,\\n /// - Wallet closing period must be greater than zero.\\n function updateWalletParameters(\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n ) external onlyGovernance {\\n self.updateWalletParameters(\\n walletCreationPeriod,\\n walletCreationMinBtcBalance,\\n walletCreationMaxBtcBalance,\\n walletClosureMinBtcBalance,\\n walletMaxAge,\\n walletMaxBtcTransfer,\\n walletClosingPeriod\\n );\\n }\\n\\n /// @notice Updates parameters related to frauds.\\n /// @param fraudChallengeDepositAmount New value of the fraud challenge\\n /// deposit amount in wei, it is the amount of ETH the party\\n /// challenging the wallet for fraud needs to deposit.\\n /// @param fraudChallengeDefeatTimeout New value of the challenge defeat\\n /// timeout in seconds, it is the amount of time the wallet has to\\n /// defeat a fraud challenge. The value must be greater than zero.\\n /// @param fraudSlashingAmount New value of the fraud slashing amount in T,\\n /// it is the amount slashed from each wallet member for committing\\n /// a fraud.\\n /// @param fraudNotifierRewardMultiplier New value of the fraud notifier\\n /// reward multiplier as percentage, it determines the percentage of\\n /// the notifier reward from the staking contact the notifier of\\n /// a fraud receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Fraud challenge defeat timeout must be greater than 0,\\n /// - Fraud notifier reward multiplier must be in the range [0, 100].\\n function updateFraudParameters(\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n ) external onlyGovernance {\\n self.updateFraudParameters(\\n fraudChallengeDepositAmount,\\n fraudChallengeDefeatTimeout,\\n fraudSlashingAmount,\\n fraudNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates treasury address. The treasury receives the system fees.\\n /// @param treasury New value of the treasury address.\\n /// @dev The treasury address must not be 0x0.\\n // slither-disable-next-line shadowing-local\\n function updateTreasury(address treasury) external onlyGovernance {\\n self.updateTreasury(treasury);\\n }\\n\\n /// @notice Collection of all revealed deposits indexed by\\n /// keccak256(fundingTxHash | fundingOutputIndex).\\n /// The fundingTxHash is bytes32 (ordered as in Bitcoin internally)\\n /// and fundingOutputIndex an uint32. This mapping may contain valid\\n /// and invalid deposits and the wallet is responsible for\\n /// validating them before attempting to execute a sweep.\\n function deposits(uint256 depositKey)\\n external\\n view\\n returns (Deposit.DepositRequest memory)\\n {\\n return self.deposits[depositKey];\\n }\\n\\n /// @notice Collection of all pending redemption requests indexed by\\n /// redemption key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The walletPubKeyHash is the 20-byte wallet's public key hash\\n /// (computed using Bitcoin HASH160 over the compressed ECDSA\\n /// public key) and `redeemerOutputScript` is a Bitcoin script\\n /// (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC as requested by the redeemer. Requests are added\\n /// to this mapping by the `requestRedemption` method (duplicates\\n /// not allowed) and are removed by one of the following methods:\\n /// - `submitRedemptionProof` in case the request was handled\\n /// successfully,\\n /// - `notifyRedemptionTimeout` in case the request was reported\\n /// to be timed out.\\n function pendingRedemptions(uint256 redemptionKey)\\n external\\n view\\n returns (Redemption.RedemptionRequest memory)\\n {\\n return self.pendingRedemptions[redemptionKey];\\n }\\n\\n /// @notice Collection of all timed out redemptions requests indexed by\\n /// redemption key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The walletPubKeyHash is the 20-byte wallet's public key hash\\n /// (computed using Bitcoin HASH160 over the compressed ECDSA\\n /// public key) and `redeemerOutputScript` is the Bitcoin script\\n /// (P2PKH, P2WPKH, P2SH or P2WSH) that is involved in the timed\\n /// out request.\\n /// Only one method can add to this mapping:\\n /// - `notifyRedemptionTimeout` which puts the redemption key\\n /// to this mapping based on a timed out request stored\\n /// previously in `pendingRedemptions` mapping.\\n /// Only one method can remove entries from this mapping:\\n /// - `submitRedemptionProof` in case the timed out redemption\\n /// request was a part of the proven transaction.\\n function timedOutRedemptions(uint256 redemptionKey)\\n external\\n view\\n returns (Redemption.RedemptionRequest memory)\\n {\\n return self.timedOutRedemptions[redemptionKey];\\n }\\n\\n /// @notice Collection of main UTXOs that are honestly spent indexed by\\n /// keccak256(fundingTxHash | fundingOutputIndex). The fundingTxHash\\n /// is bytes32 (ordered as in Bitcoin internally) and\\n /// fundingOutputIndex an uint32. A main UTXO is considered honestly\\n /// spent if it was used as an input of a transaction that have been\\n /// proven in the Bridge.\\n function spentMainUTXOs(uint256 utxoKey) external view returns (bool) {\\n return self.spentMainUTXOs[utxoKey];\\n }\\n\\n /// @notice Gets details about a registered wallet.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @return Wallet details.\\n function wallets(bytes20 walletPubKeyHash)\\n external\\n view\\n returns (Wallets.Wallet memory)\\n {\\n return self.registeredWallets[walletPubKeyHash];\\n }\\n\\n /// @notice Gets the public key hash of the active wallet.\\n /// @return The 20-byte public key hash (computed using Bitcoin HASH160\\n /// over the compressed ECDSA public key) of the active wallet.\\n /// Returns bytes20(0) if there is no active wallet at the moment.\\n function activeWalletPubKeyHash() external view returns (bytes20) {\\n return self.activeWalletPubKeyHash;\\n }\\n\\n /// @notice Gets the live wallets count.\\n /// @return The current count of wallets being in the Live state.\\n function liveWalletsCount() external view returns (uint32) {\\n return self.liveWalletsCount;\\n }\\n\\n /// @notice Returns the fraud challenge identified by the given key built\\n /// as keccak256(walletPublicKey|sighash).\\n function fraudChallenges(uint256 challengeKey)\\n external\\n view\\n returns (Fraud.FraudChallenge memory)\\n {\\n return self.fraudChallenges[challengeKey];\\n }\\n\\n /// @notice Collection of all moved funds sweep requests indexed by\\n /// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.\\n /// The `movingFundsTxHash` is `bytes32` (ordered as in Bitcoin\\n /// internally) and `movingFundsOutputIndex` an `uint32`. Each entry\\n /// is actually an UTXO representing the moved funds and is supposed\\n /// to be swept with the current main UTXO of the recipient wallet.\\n /// @param requestKey Request key built as\\n /// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.\\n /// @return Details of the moved funds sweep request.\\n function movedFundsSweepRequests(uint256 requestKey)\\n external\\n view\\n returns (MovingFunds.MovedFundsSweepRequest memory)\\n {\\n return self.movedFundsSweepRequests[requestKey];\\n }\\n\\n /// @notice Indicates if the vault with the given address is trusted or not.\\n /// Depositors can route their revealed deposits only to trusted\\n /// vaults and have trusted vaults notified about new deposits as\\n /// soon as these deposits get swept. Vaults not trusted by the\\n /// Bridge can still be used by Bank balance owners on their own\\n /// responsibility - anyone can approve their Bank balance to any\\n /// address.\\n function isVaultTrusted(address vault) external view returns (bool) {\\n return self.isVaultTrusted[vault];\\n }\\n\\n /// @notice Returns the current values of Bridge deposit parameters.\\n /// @return depositDustThreshold The minimal amount that can be requested\\n /// to deposit. Value of this parameter must take into account the\\n /// value of `depositTreasuryFeeDivisor` and `depositTxMaxFee`\\n /// parameters in order to make requests that can incur the\\n /// treasury and transaction fee and still satisfy the depositor.\\n /// @return depositTreasuryFeeDivisor Divisor used to compute the treasury\\n /// fee taken from each deposit and transferred to the treasury upon\\n /// sweep proof submission. That fee is computed as follows:\\n /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each deposit,\\n /// the `depositTreasuryFeeDivisor` should be set to `50`\\n /// because `1/50 = 0.02 = 2%`.\\n /// @return depositTxMaxFee Maximum amount of BTC transaction fee that can\\n /// be incurred by each swept deposit being part of the given sweep\\n /// transaction. If the maximum BTC transaction fee is exceeded,\\n /// such transaction is considered a fraud.\\n /// @return depositRevealAheadPeriod Defines the length of the period that\\n /// must be preserved between the deposit reveal time and the\\n /// deposit refund locktime. For example, if the deposit become\\n /// refundable on August 1st, and the ahead period is 7 days, the\\n /// latest moment for deposit reveal is July 25th. Value in seconds.\\n function depositParameters()\\n external\\n view\\n returns (\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n )\\n {\\n depositDustThreshold = self.depositDustThreshold;\\n depositTreasuryFeeDivisor = self.depositTreasuryFeeDivisor;\\n depositTxMaxFee = self.depositTxMaxFee;\\n depositRevealAheadPeriod = self.depositRevealAheadPeriod;\\n }\\n\\n /// @notice Returns the current values of Bridge redemption parameters.\\n /// @return redemptionDustThreshold The minimal amount that can be requested\\n /// for redemption. Value of this parameter must take into account\\n /// the value of `redemptionTreasuryFeeDivisor` and `redemptionTxMaxFee`\\n /// parameters in order to make requests that can incur the\\n /// treasury and transaction fee and still satisfy the redeemer.\\n /// @return redemptionTreasuryFeeDivisor Divisor used to compute the treasury\\n /// fee taken from each redemption request and transferred to the\\n /// treasury upon successful request finalization. That fee is\\n /// computed as follows:\\n /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each\\n /// redemption request, the `redemptionTreasuryFeeDivisor` should\\n /// be set to `50` because `1/50 = 0.02 = 2%`.\\n /// @return redemptionTxMaxFee Maximum amount of BTC transaction fee that\\n /// can be incurred by each redemption request being part of the\\n /// given redemption transaction. If the maximum BTC transaction\\n /// fee is exceeded, such transaction is considered a fraud.\\n /// This is a per-redemption output max fee for the redemption\\n /// transaction.\\n /// @return redemptionTxMaxTotalFee Maximum amount of the total BTC\\n /// transaction fee that is acceptable in a single redemption\\n /// transaction. This is a _total_ max fee for the entire redemption\\n /// transaction.\\n /// @return redemptionTimeout Time after which the redemption request can be\\n /// reported as timed out. It is counted from the moment when the\\n /// redemption request was created via `requestRedemption` call.\\n /// Reported timed out requests are cancelled and locked balance is\\n /// returned to the redeemer in full amount.\\n /// @return redemptionTimeoutSlashingAmount The amount of stake slashed\\n /// from each member of a wallet for a redemption timeout.\\n /// @return redemptionTimeoutNotifierRewardMultiplier The percentage of the\\n /// notifier reward from the staking contract the notifier of a\\n /// redemption timeout receives. The value is in the range [0, 100].\\n function redemptionParameters()\\n external\\n view\\n returns (\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n )\\n {\\n redemptionDustThreshold = self.redemptionDustThreshold;\\n redemptionTreasuryFeeDivisor = self.redemptionTreasuryFeeDivisor;\\n redemptionTxMaxFee = self.redemptionTxMaxFee;\\n redemptionTxMaxTotalFee = self.redemptionTxMaxTotalFee;\\n redemptionTimeout = self.redemptionTimeout;\\n redemptionTimeoutSlashingAmount = self.redemptionTimeoutSlashingAmount;\\n redemptionTimeoutNotifierRewardMultiplier = self\\n .redemptionTimeoutNotifierRewardMultiplier;\\n }\\n\\n /// @notice Returns the current values of Bridge moving funds between\\n /// wallets parameters.\\n /// @return movingFundsTxMaxTotalFee Maximum amount of the total BTC\\n /// transaction fee that is acceptable in a single moving funds\\n /// transaction. This is a _total_ max fee for the entire moving\\n /// funds transaction.\\n /// @return movingFundsDustThreshold The minimal satoshi amount that makes\\n /// sense to be transferred during the moving funds process. Moving\\n /// funds wallets having their BTC balance below that value can\\n /// begin closing immediately as transferring such a low value may\\n /// not be possible due to BTC network fees.\\n /// @return movingFundsTimeoutResetDelay Time after which the moving funds\\n /// timeout can be reset in case the target wallet commitment\\n /// cannot be submitted due to a lack of live wallets in the system.\\n /// It is counted from the moment when the wallet was requested to\\n /// move their funds and switched to the MovingFunds state or from\\n /// the moment the timeout was reset the last time. Value in seconds\\n /// This value should be lower than the value of the\\n /// `movingFundsTimeout`.\\n /// @return movingFundsTimeout Time after which the moving funds process\\n /// can be reported as timed out. It is counted from the moment\\n /// when the wallet was requested to move their funds and switched\\n /// to the MovingFunds state. Value in seconds.\\n /// @return movingFundsTimeoutSlashingAmount The amount of stake slashed\\n /// from each member of a wallet for a moving funds timeout.\\n /// @return movingFundsTimeoutNotifierRewardMultiplier The percentage of the\\n /// notifier reward from the staking contract the notifier of a\\n /// moving funds timeout receives. The value is in the range [0, 100].\\n /// @return movingFundsCommitmentGasOffset The gas offset used for the\\n /// moving funds target wallet commitment transaction cost\\n /// reimbursement.\\n /// @return movedFundsSweepTxMaxTotalFee Maximum amount of the total BTC\\n /// transaction fee that is acceptable in a single moved funds\\n /// sweep transaction. This is a _total_ max fee for the entire\\n /// moved funds sweep transaction.\\n /// @return movedFundsSweepTimeout Time after which the moved funds sweep\\n /// process can be reported as timed out. It is counted from the\\n /// moment when the wallet was requested to sweep the received funds.\\n /// Value in seconds.\\n /// @return movedFundsSweepTimeoutSlashingAmount The amount of stake slashed\\n /// from each member of a wallet for a moved funds sweep timeout.\\n /// @return movedFundsSweepTimeoutNotifierRewardMultiplier The percentage\\n /// of the notifier reward from the staking contract the notifier\\n /// of a moved funds sweep timeout receives. The value is in the\\n /// range [0, 100].\\n function movingFundsParameters()\\n external\\n view\\n returns (\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n )\\n {\\n movingFundsTxMaxTotalFee = self.movingFundsTxMaxTotalFee;\\n movingFundsDustThreshold = self.movingFundsDustThreshold;\\n movingFundsTimeoutResetDelay = self.movingFundsTimeoutResetDelay;\\n movingFundsTimeout = self.movingFundsTimeout;\\n movingFundsTimeoutSlashingAmount = self\\n .movingFundsTimeoutSlashingAmount;\\n movingFundsTimeoutNotifierRewardMultiplier = self\\n .movingFundsTimeoutNotifierRewardMultiplier;\\n movingFundsCommitmentGasOffset = self.movingFundsCommitmentGasOffset;\\n movedFundsSweepTxMaxTotalFee = self.movedFundsSweepTxMaxTotalFee;\\n movedFundsSweepTimeout = self.movedFundsSweepTimeout;\\n movedFundsSweepTimeoutSlashingAmount = self\\n .movedFundsSweepTimeoutSlashingAmount;\\n movedFundsSweepTimeoutNotifierRewardMultiplier = self\\n .movedFundsSweepTimeoutNotifierRewardMultiplier;\\n }\\n\\n /// @return walletCreationPeriod Determines how frequently a new wallet\\n /// creation can be requested. Value in seconds.\\n /// @return walletCreationMinBtcBalance The minimum BTC threshold in satoshi\\n /// that is used to decide about wallet creation.\\n /// @return walletCreationMaxBtcBalance The maximum BTC threshold in satoshi\\n /// that is used to decide about wallet creation.\\n /// @return walletClosureMinBtcBalance The minimum BTC threshold in satoshi\\n /// that is used to decide about wallet closure.\\n /// @return walletMaxAge The maximum age of a wallet in seconds, after which\\n /// the wallet moving funds process can be requested.\\n /// @return walletMaxBtcTransfer The maximum BTC amount in satoshi than\\n /// can be transferred to a single target wallet during the moving\\n /// funds process.\\n /// @return walletClosingPeriod Determines the length of the wallet closing\\n /// period, i.e. the period when the wallet remains in the Closing\\n /// state and can be subject of deposit fraud challenges. Value\\n /// in seconds.\\n function walletParameters()\\n external\\n view\\n returns (\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n )\\n {\\n walletCreationPeriod = self.walletCreationPeriod;\\n walletCreationMinBtcBalance = self.walletCreationMinBtcBalance;\\n walletCreationMaxBtcBalance = self.walletCreationMaxBtcBalance;\\n walletClosureMinBtcBalance = self.walletClosureMinBtcBalance;\\n walletMaxAge = self.walletMaxAge;\\n walletMaxBtcTransfer = self.walletMaxBtcTransfer;\\n walletClosingPeriod = self.walletClosingPeriod;\\n }\\n\\n /// @notice Returns the current values of Bridge fraud parameters.\\n /// @return fraudChallengeDepositAmount The amount of ETH in wei the party\\n /// challenging the wallet for fraud needs to deposit.\\n /// @return fraudChallengeDefeatTimeout The amount of time the wallet has to\\n /// defeat a fraud challenge.\\n /// @return fraudSlashingAmount The amount slashed from each wallet member\\n /// for committing a fraud.\\n /// @return fraudNotifierRewardMultiplier The percentage of the notifier\\n /// reward from the staking contract the notifier of a fraud\\n /// receives. The value is in the range [0, 100].\\n function fraudParameters()\\n external\\n view\\n returns (\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n )\\n {\\n fraudChallengeDepositAmount = self.fraudChallengeDepositAmount;\\n fraudChallengeDefeatTimeout = self.fraudChallengeDefeatTimeout;\\n fraudSlashingAmount = self.fraudSlashingAmount;\\n fraudNotifierRewardMultiplier = self.fraudNotifierRewardMultiplier;\\n }\\n\\n /// @notice Returns the addresses of contracts Bridge is interacting with.\\n /// @return bank Address of the Bank the Bridge belongs to.\\n /// @return relay Address of the Bitcoin relay providing the current Bitcoin\\n /// network difficulty.\\n /// @return ecdsaWalletRegistry Address of the ECDSA Wallet Registry.\\n /// @return reimbursementPool Address of the Reimbursement Pool.\\n function contractReferences()\\n external\\n view\\n returns (\\n Bank bank,\\n IRelay relay,\\n EcdsaWalletRegistry ecdsaWalletRegistry,\\n ReimbursementPool reimbursementPool\\n )\\n {\\n bank = self.bank;\\n relay = self.relay;\\n ecdsaWalletRegistry = self.ecdsaWalletRegistry;\\n reimbursementPool = self.reimbursementPool;\\n }\\n\\n /// @notice Address where the deposit treasury fees will be sent to.\\n /// Treasury takes part in the operators rewarding process.\\n function treasury() external view returns (address) {\\n return self.treasury;\\n }\\n\\n /// @notice The number of confirmations on the Bitcoin chain required to\\n /// successfully evaluate an SPV proof.\\n function txProofDifficultyFactor() external view returns (uint256) {\\n return self.txProofDifficultyFactor;\\n }\\n}\\n\",\"keccak256\":\"0x0a6e8f890ba55fbd8671f4853c882e5c8c70e476d521013b21a30fa7d0f5bafd\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/BridgeState.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {IWalletRegistry as EcdsaWalletRegistry} from \\\"@keep-network/ecdsa/contracts/api/IWalletRegistry.sol\\\";\\nimport \\\"@keep-network/random-beacon/contracts/ReimbursementPool.sol\\\";\\n\\nimport \\\"./IRelay.sol\\\";\\nimport \\\"./Deposit.sol\\\";\\nimport \\\"./Redemption.sol\\\";\\nimport \\\"./Fraud.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\nimport \\\"./MovingFunds.sol\\\";\\n\\nimport \\\"../bank/Bank.sol\\\";\\n\\nlibrary BridgeState {\\n struct Storage {\\n // Address of the Bank the Bridge belongs to.\\n Bank bank;\\n // Bitcoin relay providing the current Bitcoin network difficulty.\\n IRelay relay;\\n // The number of confirmations on the Bitcoin chain required to\\n // successfully evaluate an SPV proof.\\n uint96 txProofDifficultyFactor;\\n // ECDSA Wallet Registry contract handle.\\n EcdsaWalletRegistry ecdsaWalletRegistry;\\n // Reimbursement Pool contract handle.\\n ReimbursementPool reimbursementPool;\\n // Address where the deposit and redemption treasury fees will be sent\\n // to. Treasury takes part in the operators rewarding process.\\n address treasury;\\n // Move depositDustThreshold to the next storage slot for a more\\n // efficient variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __treasuryAlignmentGap;\\n // The minimal amount that can be requested to deposit.\\n // Value of this parameter must take into account the value of\\n // `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters in order\\n // to make requests that can incur the treasury and transaction fee and\\n // still satisfy the depositor.\\n uint64 depositDustThreshold;\\n // Divisor used to compute the treasury fee taken from each deposit and\\n // transferred to the treasury upon sweep proof submission. That fee is\\n // computed as follows:\\n // `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n // For example, if the treasury fee needs to be 2% of each deposit,\\n // the `depositTreasuryFeeDivisor` should be set to `50` because\\n // `1/50 = 0.02 = 2%`.\\n uint64 depositTreasuryFeeDivisor;\\n // Maximum amount of BTC transaction fee that can be incurred by each\\n // swept deposit being part of the given sweep transaction. If the\\n // maximum BTC transaction fee is exceeded, such transaction is\\n // considered a fraud.\\n //\\n // This is a per-deposit input max fee for the sweep transaction.\\n uint64 depositTxMaxFee;\\n // Defines the length of the period that must be preserved between\\n // the deposit reveal time and the deposit refund locktime. For example,\\n // if the deposit become refundable on August 1st, and the ahead period\\n // is 7 days, the latest moment for deposit reveal is July 25th.\\n // Value in seconds. The value equal to zero disables the validation\\n // of this parameter.\\n uint32 depositRevealAheadPeriod;\\n // Move movingFundsTxMaxTotalFee to the next storage slot for a more\\n // efficient variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __depositAlignmentGap;\\n // Maximum amount of the total BTC transaction fee that is acceptable in\\n // a single moving funds transaction.\\n //\\n // This is a TOTAL max fee for the moving funds transaction. Note\\n // that `depositTxMaxFee` is per single deposit and `redemptionTxMaxFee`\\n // is per single redemption. `movingFundsTxMaxTotalFee` is a total\\n // fee for the entire transaction.\\n uint64 movingFundsTxMaxTotalFee;\\n // The minimal satoshi amount that makes sense to be transferred during\\n // the moving funds process. Moving funds wallets having their BTC\\n // balance below that value can begin closing immediately as\\n // transferring such a low value may not be possible due to\\n // BTC network fees. The value of this parameter must always be lower\\n // than `redemptionDustThreshold` in order to prevent redemption requests\\n // with values lower or equal to `movingFundsDustThreshold`.\\n uint64 movingFundsDustThreshold;\\n // Time after which the moving funds timeout can be reset in case the\\n // target wallet commitment cannot be submitted due to a lack of live\\n // wallets in the system. It is counted from the moment when the wallet\\n // was requested to move their funds and switched to the MovingFunds\\n // state or from the moment the timeout was reset the last time.\\n // Value in seconds. This value should be lower than the value\\n // of the `movingFundsTimeout`.\\n uint32 movingFundsTimeoutResetDelay;\\n // Time after which the moving funds process can be reported as\\n // timed out. It is counted from the moment when the wallet\\n // was requested to move their funds and switched to the MovingFunds\\n // state. Value in seconds.\\n uint32 movingFundsTimeout;\\n // The amount of stake slashed from each member of a wallet for a moving\\n // funds timeout.\\n uint96 movingFundsTimeoutSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a moving funds timeout receives. The value is in the\\n // range [0, 100].\\n uint32 movingFundsTimeoutNotifierRewardMultiplier;\\n // The gas offset used for the target wallet commitment transaction cost\\n // reimbursement.\\n uint16 movingFundsCommitmentGasOffset;\\n // Move movedFundsSweepTxMaxTotalFee to the next storage slot for a more\\n // efficient variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __movingFundsAlignmentGap;\\n // Maximum amount of the total BTC transaction fee that is acceptable in\\n // a single moved funds sweep transaction.\\n //\\n // This is a TOTAL max fee for the moved funds sweep transaction. Note\\n // that `depositTxMaxFee` is per single deposit and `redemptionTxMaxFee`\\n // is per single redemption. `movedFundsSweepTxMaxTotalFee` is a total\\n // fee for the entire transaction.\\n uint64 movedFundsSweepTxMaxTotalFee;\\n // Time after which the moved funds sweep process can be reported as\\n // timed out. It is counted from the moment when the recipient wallet\\n // was requested to sweep the received funds. Value in seconds.\\n uint32 movedFundsSweepTimeout;\\n // The amount of stake slashed from each member of a wallet for a moved\\n // funds sweep timeout.\\n uint96 movedFundsSweepTimeoutSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a moved funds sweep timeout receives. The value is\\n // in the range [0, 100].\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier;\\n // The minimal amount that can be requested for redemption.\\n // Value of this parameter must take into account the value of\\n // `redemptionTreasuryFeeDivisor` and `redemptionTxMaxFee`\\n // parameters in order to make requests that can incur the\\n // treasury and transaction fee and still satisfy the redeemer.\\n // Additionally, the value of this parameter must always be greater\\n // than `movingFundsDustThreshold` in order to prevent redemption\\n // requests with values lower or equal to `movingFundsDustThreshold`.\\n uint64 redemptionDustThreshold;\\n // Divisor used to compute the treasury fee taken from each\\n // redemption request and transferred to the treasury upon\\n // successful request finalization. That fee is computed as follows:\\n // `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n // For example, if the treasury fee needs to be 2% of each\\n // redemption request, the `redemptionTreasuryFeeDivisor` should\\n // be set to `50` because `1/50 = 0.02 = 2%`.\\n uint64 redemptionTreasuryFeeDivisor;\\n // Maximum amount of BTC transaction fee that can be incurred by\\n // each redemption request being part of the given redemption\\n // transaction. If the maximum BTC transaction fee is exceeded, such\\n // transaction is considered a fraud.\\n //\\n // This is a per-redemption output max fee for the redemption\\n // transaction.\\n uint64 redemptionTxMaxFee;\\n // Maximum amount of the total BTC transaction fee that is acceptable in\\n // a single redemption transaction.\\n //\\n // This is a TOTAL max fee for the redemption transaction. Note\\n // that the `redemptionTxMaxFee` is per single redemption.\\n // `redemptionTxMaxTotalFee` is a total fee for the entire transaction.\\n uint64 redemptionTxMaxTotalFee;\\n // Move redemptionTimeout to the next storage slot for a more efficient\\n // variable layout in the storage.\\n // slither-disable-next-line unused-state\\n bytes32 __redemptionAlignmentGap;\\n // Time after which the redemption request can be reported as\\n // timed out. It is counted from the moment when the redemption\\n // request was created via `requestRedemption` call. Reported\\n // timed out requests are cancelled and locked TBTC is returned\\n // to the redeemer in full amount.\\n uint32 redemptionTimeout;\\n // The amount of stake slashed from each member of a wallet for a\\n // redemption timeout.\\n uint96 redemptionTimeoutSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a redemption timeout receives. The value is in the\\n // range [0, 100].\\n uint32 redemptionTimeoutNotifierRewardMultiplier;\\n // The amount of ETH in wei the party challenging the wallet for fraud\\n // needs to deposit.\\n uint96 fraudChallengeDepositAmount;\\n // The amount of time the wallet has to defeat a fraud challenge.\\n uint32 fraudChallengeDefeatTimeout;\\n // The amount of stake slashed from each member of a wallet for a fraud.\\n uint96 fraudSlashingAmount;\\n // The percentage of the notifier reward from the staking contract\\n // the notifier of a fraud receives. The value is in the range [0, 100].\\n uint32 fraudNotifierRewardMultiplier;\\n // Determines how frequently a new wallet creation can be requested.\\n // Value in seconds.\\n uint32 walletCreationPeriod;\\n // The minimum BTC threshold in satoshi that is used to decide about\\n // wallet creation. Specifically, we allow for the creation of a new\\n // wallet if the active wallet is old enough and their amount of BTC\\n // is greater than or equal this threshold.\\n uint64 walletCreationMinBtcBalance;\\n // The maximum BTC threshold in satoshi that is used to decide about\\n // wallet creation. Specifically, we allow for the creation of a new\\n // wallet if the active wallet's amount of BTC is greater than or equal\\n // this threshold, regardless of the active wallet's age.\\n uint64 walletCreationMaxBtcBalance;\\n // The minimum BTC threshold in satoshi that is used to decide about\\n // wallet closing. Specifically, we allow for the closure of the given\\n // wallet if their amount of BTC is lesser than this threshold,\\n // regardless of the wallet's age.\\n uint64 walletClosureMinBtcBalance;\\n // The maximum age of a wallet in seconds, after which the wallet\\n // moving funds process can be requested.\\n uint32 walletMaxAge;\\n // 20-byte wallet public key hash being reference to the currently\\n // active wallet. Can be unset to the zero value under certain\\n // circumstances.\\n bytes20 activeWalletPubKeyHash;\\n // The current number of wallets in the Live state.\\n uint32 liveWalletsCount;\\n // The maximum BTC amount in satoshi than can be transferred to a single\\n // target wallet during the moving funds process.\\n uint64 walletMaxBtcTransfer;\\n // Determines the length of the wallet closing period, i.e. the period\\n // when the wallet remains in the Closing state and can be subject\\n // of deposit fraud challenges. This value is in seconds and should be\\n // greater than the deposit refund time plus some time margin.\\n uint32 walletClosingPeriod;\\n // Collection of all revealed deposits indexed by\\n // `keccak256(fundingTxHash | fundingOutputIndex)`.\\n // The `fundingTxHash` is `bytes32` (ordered as in Bitcoin internally)\\n // and `fundingOutputIndex` an `uint32`. This mapping may contain valid\\n // and invalid deposits and the wallet is responsible for validating\\n // them before attempting to execute a sweep.\\n mapping(uint256 => Deposit.DepositRequest) deposits;\\n // Indicates if the vault with the given address is trusted.\\n // Depositors can route their revealed deposits only to trusted vaults\\n // and have trusted vaults notified about new deposits as soon as these\\n // deposits get swept. Vaults not trusted by the Bridge can still be\\n // used by Bank balance owners on their own responsibility - anyone can\\n // approve their Bank balance to any address.\\n mapping(address => bool) isVaultTrusted;\\n // Indicates if the address is a trusted SPV maintainer.\\n // The SPV proof does not check whether the transaction is a part of the\\n // Bitcoin mainnet, it only checks whether the transaction has been\\n // mined performing the required amount of work as on Bitcoin mainnet.\\n // The possibility of submitting SPV proofs is limited to trusted SPV\\n // maintainers. The system expects transaction confirmations with the\\n // required work accumulated, so trusted SPV maintainers can not prove\\n // the transaction without providing the required Bitcoin proof of work.\\n // Trusted maintainers address the issue of an economic game between\\n // tBTC and Bitcoin mainnet where large Bitcoin mining pools can decide\\n // to use their hash power to mine fake Bitcoin blocks to prove them in\\n // tBTC instead of receiving Bitcoin miner rewards.\\n mapping(address => bool) isSpvMaintainer;\\n // Collection of all moved funds sweep requests indexed by\\n // `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.\\n // The `movingFundsTxHash` is `bytes32` (ordered as in Bitcoin\\n // internally) and `movingFundsOutputIndex` an `uint32`. Each entry\\n // is actually an UTXO representing the moved funds and is supposed\\n // to be swept with the current main UTXO of the recipient wallet.\\n mapping(uint256 => MovingFunds.MovedFundsSweepRequest) movedFundsSweepRequests;\\n // Collection of all pending redemption requests indexed by\\n // redemption key built as\\n // `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n // The `walletPubKeyHash` is the 20-byte wallet's public key hash\\n // (computed using Bitcoin HASH160 over the compressed ECDSA\\n // public key) and `redeemerOutputScript` is a Bitcoin script\\n // (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n // redeemed BTC as requested by the redeemer. Requests are added\\n // to this mapping by the `requestRedemption` method (duplicates\\n // not allowed) and are removed by one of the following methods:\\n // - `submitRedemptionProof` in case the request was handled\\n // successfully,\\n // - `notifyRedemptionTimeout` in case the request was reported\\n // to be timed out.\\n mapping(uint256 => Redemption.RedemptionRequest) pendingRedemptions;\\n // Collection of all timed out redemptions requests indexed by\\n // redemption key built as\\n // `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n // The `walletPubKeyHash` is the 20-byte wallet's public key hash\\n // (computed using Bitcoin HASH160 over the compressed ECDSA\\n // public key) and `redeemerOutputScript` is the Bitcoin script\\n // (P2PKH, P2WPKH, P2SH or P2WSH) that is involved in the timed\\n // out request.\\n // Only one method can add to this mapping:\\n // - `notifyRedemptionTimeout` which puts the redemption key to this\\n // mapping based on a timed out request stored previously in\\n // `pendingRedemptions` mapping.\\n // Only one method can remove entries from this mapping:\\n // - `submitRedemptionProof` in case the timed out redemption request\\n // was a part of the proven transaction.\\n mapping(uint256 => Redemption.RedemptionRequest) timedOutRedemptions;\\n // Collection of all submitted fraud challenges indexed by challenge\\n // key built as `keccak256(walletPublicKey|sighash)`.\\n mapping(uint256 => Fraud.FraudChallenge) fraudChallenges;\\n // Collection of main UTXOs that are honestly spent indexed by\\n // `keccak256(fundingTxHash | fundingOutputIndex)`. The `fundingTxHash`\\n // is `bytes32` (ordered as in Bitcoin internally) and\\n // `fundingOutputIndex` an `uint32`. A main UTXO is considered honestly\\n // spent if it was used as an input of a transaction that have been\\n // proven in the Bridge.\\n mapping(uint256 => bool) spentMainUTXOs;\\n // Maps the 20-byte wallet public key hash (computed using Bitcoin\\n // HASH160 over the compressed ECDSA public key) to the basic wallet\\n // information like state and pending redemptions value.\\n mapping(bytes20 => Wallets.Wallet) registeredWallets;\\n // Reserved storage space in case we need to add more variables.\\n // The convention from OpenZeppelin suggests the storage space should\\n // add up to 50 slots. Here we want to have more slots as there are\\n // planned upgrades of the Bridge contract. If more entires are added to\\n // the struct in the upcoming versions we need to reduce the array size.\\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\\n // slither-disable-next-line unused-state\\n uint256[50] __gap;\\n }\\n\\n event DepositParametersUpdated(\\n uint64 depositDustThreshold,\\n uint64 depositTreasuryFeeDivisor,\\n uint64 depositTxMaxFee,\\n uint32 depositRevealAheadPeriod\\n );\\n\\n event RedemptionParametersUpdated(\\n uint64 redemptionDustThreshold,\\n uint64 redemptionTreasuryFeeDivisor,\\n uint64 redemptionTxMaxFee,\\n uint64 redemptionTxMaxTotalFee,\\n uint32 redemptionTimeout,\\n uint96 redemptionTimeoutSlashingAmount,\\n uint32 redemptionTimeoutNotifierRewardMultiplier\\n );\\n\\n event MovingFundsParametersUpdated(\\n uint64 movingFundsTxMaxTotalFee,\\n uint64 movingFundsDustThreshold,\\n uint32 movingFundsTimeoutResetDelay,\\n uint32 movingFundsTimeout,\\n uint96 movingFundsTimeoutSlashingAmount,\\n uint32 movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 movingFundsCommitmentGasOffset,\\n uint64 movedFundsSweepTxMaxTotalFee,\\n uint32 movedFundsSweepTimeout,\\n uint96 movedFundsSweepTimeoutSlashingAmount,\\n uint32 movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n\\n event WalletParametersUpdated(\\n uint32 walletCreationPeriod,\\n uint64 walletCreationMinBtcBalance,\\n uint64 walletCreationMaxBtcBalance,\\n uint64 walletClosureMinBtcBalance,\\n uint32 walletMaxAge,\\n uint64 walletMaxBtcTransfer,\\n uint32 walletClosingPeriod\\n );\\n\\n event FraudParametersUpdated(\\n uint96 fraudChallengeDepositAmount,\\n uint32 fraudChallengeDefeatTimeout,\\n uint96 fraudSlashingAmount,\\n uint32 fraudNotifierRewardMultiplier\\n );\\n\\n event TreasuryUpdated(address treasury);\\n\\n /// @notice Updates parameters of deposits.\\n /// @param _depositDustThreshold New value of the deposit dust threshold in\\n /// satoshis. It is the minimal amount that can be requested to\\n //// deposit. Value of this parameter must take into account the value\\n /// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters\\n /// in order to make requests that can incur the treasury and\\n /// transaction fee and still satisfy the depositor.\\n /// @param _depositTreasuryFeeDivisor New value of the treasury fee divisor.\\n /// It is the divisor used to compute the treasury fee taken from\\n /// each deposit and transferred to the treasury upon sweep proof\\n /// submission. That fee is computed as follows:\\n /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each deposit,\\n /// the `depositTreasuryFeeDivisor` should be set to `50`\\n /// because `1/50 = 0.02 = 2%`.\\n /// @param _depositTxMaxFee New value of the deposit tx max fee in satoshis.\\n /// It is the maximum amount of BTC transaction fee that can\\n /// be incurred by each swept deposit being part of the given sweep\\n /// transaction. If the maximum BTC transaction fee is exceeded,\\n /// such transaction is considered a fraud.\\n /// @param _depositRevealAheadPeriod New value of the deposit reveal ahead\\n /// period parameter in seconds. It defines the length of the period\\n /// that must be preserved between the deposit reveal time and the\\n /// deposit refund locktime.\\n /// @dev Requirements:\\n /// - Deposit dust threshold must be greater than zero,\\n /// - Deposit dust threshold must be greater than deposit TX max fee,\\n /// - Deposit transaction max fee must be greater than zero.\\n function updateDepositParameters(\\n Storage storage self,\\n uint64 _depositDustThreshold,\\n uint64 _depositTreasuryFeeDivisor,\\n uint64 _depositTxMaxFee,\\n uint32 _depositRevealAheadPeriod\\n ) internal {\\n require(\\n _depositDustThreshold > 0,\\n \\\"Deposit dust threshold must be greater than zero\\\"\\n );\\n\\n require(\\n _depositDustThreshold > _depositTxMaxFee,\\n \\\"Deposit dust threshold must be greater than deposit TX max fee\\\"\\n );\\n\\n require(\\n _depositTxMaxFee > 0,\\n \\\"Deposit transaction max fee must be greater than zero\\\"\\n );\\n\\n self.depositDustThreshold = _depositDustThreshold;\\n self.depositTreasuryFeeDivisor = _depositTreasuryFeeDivisor;\\n self.depositTxMaxFee = _depositTxMaxFee;\\n self.depositRevealAheadPeriod = _depositRevealAheadPeriod;\\n\\n emit DepositParametersUpdated(\\n _depositDustThreshold,\\n _depositTreasuryFeeDivisor,\\n _depositTxMaxFee,\\n _depositRevealAheadPeriod\\n );\\n }\\n\\n /// @notice Updates parameters of redemptions.\\n /// @param _redemptionDustThreshold New value of the redemption dust\\n /// threshold in satoshis. It is the minimal amount that can be\\n /// requested for redemption. Value of this parameter must take into\\n /// account the value of `redemptionTreasuryFeeDivisor` and\\n /// `redemptionTxMaxFee` parameters in order to make requests that\\n /// can incur the treasury and transaction fee and still satisfy the\\n /// redeemer.\\n /// @param _redemptionTreasuryFeeDivisor New value of the redemption\\n /// treasury fee divisor. It is the divisor used to compute the\\n /// treasury fee taken from each redemption request and transferred\\n /// to the treasury upon successful request finalization. That fee is\\n /// computed as follows:\\n /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`\\n /// For example, if the treasury fee needs to be 2% of each\\n /// redemption request, the `redemptionTreasuryFeeDivisor` should\\n /// be set to `50` because `1/50 = 0.02 = 2%`.\\n /// @param _redemptionTxMaxFee New value of the redemption transaction max\\n /// fee in satoshis. It is the maximum amount of BTC transaction fee\\n /// that can be incurred by each redemption request being part of the\\n /// given redemption transaction. If the maximum BTC transaction fee\\n /// is exceeded, such transaction is considered a fraud.\\n /// This is a per-redemption output max fee for the redemption\\n /// transaction.\\n /// @param _redemptionTxMaxTotalFee New value of the redemption transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single redemption\\n /// transaction. This is a _total_ max fee for the entire redemption\\n /// transaction.\\n /// @param _redemptionTimeout New value of the redemption timeout in seconds.\\n /// It is the time after which the redemption request can be reported\\n /// as timed out. It is counted from the moment when the redemption\\n /// request was created via `requestRedemption` call. Reported timed\\n /// out requests are cancelled and locked TBTC is returned to the\\n /// redeemer in full amount.\\n /// @param _redemptionTimeoutSlashingAmount New value of the redemption\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for redemption timeout.\\n /// @param _redemptionTimeoutNotifierRewardMultiplier New value of the\\n /// redemption timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a redemption timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Redemption dust threshold must be greater than moving funds dust\\n /// threshold,\\n /// - Redemption dust threshold must be greater than the redemption TX\\n /// max fee,\\n /// - Redemption transaction max fee must be greater than zero,\\n /// - Redemption transaction max total fee must be greater than or\\n /// equal to the redemption transaction per-request max fee,\\n /// - Redemption timeout must be greater than zero,\\n /// - Redemption timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateRedemptionParameters(\\n Storage storage self,\\n uint64 _redemptionDustThreshold,\\n uint64 _redemptionTreasuryFeeDivisor,\\n uint64 _redemptionTxMaxFee,\\n uint64 _redemptionTxMaxTotalFee,\\n uint32 _redemptionTimeout,\\n uint96 _redemptionTimeoutSlashingAmount,\\n uint32 _redemptionTimeoutNotifierRewardMultiplier\\n ) internal {\\n require(\\n _redemptionDustThreshold > self.movingFundsDustThreshold,\\n \\\"Redemption dust threshold must be greater than moving funds dust threshold\\\"\\n );\\n\\n require(\\n _redemptionDustThreshold > _redemptionTxMaxFee,\\n \\\"Redemption dust threshold must be greater than redemption TX max fee\\\"\\n );\\n\\n require(\\n _redemptionTxMaxFee > 0,\\n \\\"Redemption transaction max fee must be greater than zero\\\"\\n );\\n\\n require(\\n _redemptionTxMaxTotalFee >= _redemptionTxMaxFee,\\n \\\"Redemption transaction max total fee must be greater than or equal to the redemption transaction per-request max fee\\\"\\n );\\n\\n require(\\n _redemptionTimeout > 0,\\n \\\"Redemption timeout must be greater than zero\\\"\\n );\\n\\n require(\\n _redemptionTimeoutNotifierRewardMultiplier <= 100,\\n \\\"Redemption timeout notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n self.redemptionDustThreshold = _redemptionDustThreshold;\\n self.redemptionTreasuryFeeDivisor = _redemptionTreasuryFeeDivisor;\\n self.redemptionTxMaxFee = _redemptionTxMaxFee;\\n self.redemptionTxMaxTotalFee = _redemptionTxMaxTotalFee;\\n self.redemptionTimeout = _redemptionTimeout;\\n self.redemptionTimeoutSlashingAmount = _redemptionTimeoutSlashingAmount;\\n self\\n .redemptionTimeoutNotifierRewardMultiplier = _redemptionTimeoutNotifierRewardMultiplier;\\n\\n emit RedemptionParametersUpdated(\\n _redemptionDustThreshold,\\n _redemptionTreasuryFeeDivisor,\\n _redemptionTxMaxFee,\\n _redemptionTxMaxTotalFee,\\n _redemptionTimeout,\\n _redemptionTimeoutSlashingAmount,\\n _redemptionTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of moving funds.\\n /// @param _movingFundsTxMaxTotalFee New value of the moving funds transaction\\n /// max total fee in satoshis. It is the maximum amount of the total\\n /// BTC transaction fee that is acceptable in a single moving funds\\n /// transaction. This is a _total_ max fee for the entire moving\\n /// funds transaction.\\n /// @param _movingFundsDustThreshold New value of the moving funds dust\\n /// threshold. It is the minimal satoshi amount that makes sense to\\n /// be transferred during the moving funds process. Moving funds\\n /// wallets having their BTC balance below that value can begin\\n /// closing immediately as transferring such a low value may not be\\n /// possible due to BTC network fees.\\n /// @param _movingFundsTimeoutResetDelay New value of the moving funds\\n /// timeout reset delay in seconds. It is the time after which the\\n /// moving funds timeout can be reset in case the target wallet\\n /// commitment cannot be submitted due to a lack of live wallets\\n /// in the system. It is counted from the moment when the wallet\\n /// was requested to move their funds and switched to the MovingFunds\\n /// state or from the moment the timeout was reset the last time.\\n /// @param _movingFundsTimeout New value of the moving funds timeout in\\n /// seconds. It is the time after which the moving funds process can\\n /// be reported as timed out. It is counted from the moment when the\\n /// wallet was requested to move their funds and switched to the\\n /// MovingFunds state.\\n /// @param _movingFundsTimeoutSlashingAmount New value of the moving funds\\n /// timeout slashing amount in T, it is the amount slashed from each\\n /// wallet member for moving funds timeout.\\n /// @param _movingFundsTimeoutNotifierRewardMultiplier New value of the\\n /// moving funds timeout notifier reward multiplier as percentage,\\n /// it determines the percentage of the notifier reward from the\\n /// staking contact the notifier of a moving funds timeout receives.\\n /// The value must be in the range [0, 100].\\n /// @param _movingFundsCommitmentGasOffset New value of the gas offset for\\n /// moving funds target wallet commitment transaction gas costs\\n /// reimbursement.\\n /// @param _movedFundsSweepTxMaxTotalFee New value of the moved funds sweep\\n /// transaction max total fee in satoshis. It is the maximum amount\\n /// of the total BTC transaction fee that is acceptable in a single\\n /// moved funds sweep transaction. This is a _total_ max fee for the\\n /// entire moved funds sweep transaction.\\n /// @param _movedFundsSweepTimeout New value of the moved funds sweep\\n /// timeout in seconds. It is the time after which the moved funds\\n /// sweep process can be reported as timed out. It is counted from\\n /// the moment when the wallet was requested to sweep the received\\n /// funds.\\n /// @param _movedFundsSweepTimeoutSlashingAmount New value of the moved\\n /// funds sweep timeout slashing amount in T, it is the amount\\n /// slashed from each wallet member for moved funds sweep timeout.\\n /// @param _movedFundsSweepTimeoutNotifierRewardMultiplier New value of\\n /// the moved funds sweep timeout notifier reward multiplier as\\n /// percentage, it determines the percentage of the notifier reward\\n /// from the staking contact the notifier of a moved funds sweep\\n /// timeout receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Moving funds transaction max total fee must be greater than zero,\\n /// - Moving funds dust threshold must be greater than zero and lower\\n /// than the redemption dust threshold,\\n /// - Moving funds timeout reset delay must be greater than zero,\\n /// - Moving funds timeout must be greater than the moving funds\\n /// timeout reset delay,\\n /// - Moving funds timeout notifier reward multiplier must be in the\\n /// range [0, 100],\\n /// - Moved funds sweep transaction max total fee must be greater than zero,\\n /// - Moved funds sweep timeout must be greater than zero,\\n /// - Moved funds sweep timeout notifier reward multiplier must be in the\\n /// range [0, 100].\\n function updateMovingFundsParameters(\\n Storage storage self,\\n uint64 _movingFundsTxMaxTotalFee,\\n uint64 _movingFundsDustThreshold,\\n uint32 _movingFundsTimeoutResetDelay,\\n uint32 _movingFundsTimeout,\\n uint96 _movingFundsTimeoutSlashingAmount,\\n uint32 _movingFundsTimeoutNotifierRewardMultiplier,\\n uint16 _movingFundsCommitmentGasOffset,\\n uint64 _movedFundsSweepTxMaxTotalFee,\\n uint32 _movedFundsSweepTimeout,\\n uint96 _movedFundsSweepTimeoutSlashingAmount,\\n uint32 _movedFundsSweepTimeoutNotifierRewardMultiplier\\n ) internal {\\n require(\\n _movingFundsTxMaxTotalFee > 0,\\n \\\"Moving funds transaction max total fee must be greater than zero\\\"\\n );\\n\\n require(\\n _movingFundsDustThreshold > 0 &&\\n _movingFundsDustThreshold < self.redemptionDustThreshold,\\n \\\"Moving funds dust threshold must be greater than zero and lower than redemption dust threshold\\\"\\n );\\n\\n require(\\n _movingFundsTimeoutResetDelay > 0,\\n \\\"Moving funds timeout reset delay must be greater than zero\\\"\\n );\\n\\n require(\\n _movingFundsTimeout > _movingFundsTimeoutResetDelay,\\n \\\"Moving funds timeout must be greater than its reset delay\\\"\\n );\\n\\n require(\\n _movingFundsTimeoutNotifierRewardMultiplier <= 100,\\n \\\"Moving funds timeout notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n require(\\n _movedFundsSweepTxMaxTotalFee > 0,\\n \\\"Moved funds sweep transaction max total fee must be greater than zero\\\"\\n );\\n\\n require(\\n _movedFundsSweepTimeout > 0,\\n \\\"Moved funds sweep timeout must be greater than zero\\\"\\n );\\n\\n require(\\n _movedFundsSweepTimeoutNotifierRewardMultiplier <= 100,\\n \\\"Moved funds sweep timeout notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n self.movingFundsTxMaxTotalFee = _movingFundsTxMaxTotalFee;\\n self.movingFundsDustThreshold = _movingFundsDustThreshold;\\n self.movingFundsTimeoutResetDelay = _movingFundsTimeoutResetDelay;\\n self.movingFundsTimeout = _movingFundsTimeout;\\n self\\n .movingFundsTimeoutSlashingAmount = _movingFundsTimeoutSlashingAmount;\\n self\\n .movingFundsTimeoutNotifierRewardMultiplier = _movingFundsTimeoutNotifierRewardMultiplier;\\n self.movingFundsCommitmentGasOffset = _movingFundsCommitmentGasOffset;\\n self.movedFundsSweepTxMaxTotalFee = _movedFundsSweepTxMaxTotalFee;\\n self.movedFundsSweepTimeout = _movedFundsSweepTimeout;\\n self\\n .movedFundsSweepTimeoutSlashingAmount = _movedFundsSweepTimeoutSlashingAmount;\\n self\\n .movedFundsSweepTimeoutNotifierRewardMultiplier = _movedFundsSweepTimeoutNotifierRewardMultiplier;\\n\\n emit MovingFundsParametersUpdated(\\n _movingFundsTxMaxTotalFee,\\n _movingFundsDustThreshold,\\n _movingFundsTimeoutResetDelay,\\n _movingFundsTimeout,\\n _movingFundsTimeoutSlashingAmount,\\n _movingFundsTimeoutNotifierRewardMultiplier,\\n _movingFundsCommitmentGasOffset,\\n _movedFundsSweepTxMaxTotalFee,\\n _movedFundsSweepTimeout,\\n _movedFundsSweepTimeoutSlashingAmount,\\n _movedFundsSweepTimeoutNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates parameters of wallets.\\n /// @param _walletCreationPeriod New value of the wallet creation period in\\n /// seconds, determines how frequently a new wallet creation can be\\n /// requested.\\n /// @param _walletCreationMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param _walletCreationMaxBtcBalance New value of the wallet maximum BTC\\n /// balance in satoshi, used to decide about wallet creation.\\n /// @param _walletClosureMinBtcBalance New value of the wallet minimum BTC\\n /// balance in satoshi, used to decide about wallet closure.\\n /// @param _walletMaxAge New value of the wallet maximum age in seconds,\\n /// indicates the maximum age of a wallet in seconds, after which\\n /// the wallet moving funds process can be requested.\\n /// @param _walletMaxBtcTransfer New value of the wallet maximum BTC transfer\\n /// in satoshi, determines the maximum amount that can be transferred\\n /// to a single target wallet during the moving funds process.\\n /// @param _walletClosingPeriod New value of the wallet closing period in\\n /// seconds, determines the length of the wallet closing period,\\n // i.e. the period when the wallet remains in the Closing state\\n // and can be subject of deposit fraud challenges.\\n /// @dev Requirements:\\n /// - Wallet maximum BTC balance must be greater than the wallet\\n /// minimum BTC balance,\\n /// - Wallet maximum BTC transfer must be greater than zero,\\n /// - Wallet closing period must be greater than zero.\\n function updateWalletParameters(\\n Storage storage self,\\n uint32 _walletCreationPeriod,\\n uint64 _walletCreationMinBtcBalance,\\n uint64 _walletCreationMaxBtcBalance,\\n uint64 _walletClosureMinBtcBalance,\\n uint32 _walletMaxAge,\\n uint64 _walletMaxBtcTransfer,\\n uint32 _walletClosingPeriod\\n ) internal {\\n require(\\n _walletCreationMaxBtcBalance > _walletCreationMinBtcBalance,\\n \\\"Wallet creation maximum BTC balance must be greater than the creation minimum BTC balance\\\"\\n );\\n require(\\n _walletMaxBtcTransfer > 0,\\n \\\"Wallet maximum BTC transfer must be greater than zero\\\"\\n );\\n require(\\n _walletClosingPeriod > 0,\\n \\\"Wallet closing period must be greater than zero\\\"\\n );\\n\\n self.walletCreationPeriod = _walletCreationPeriod;\\n self.walletCreationMinBtcBalance = _walletCreationMinBtcBalance;\\n self.walletCreationMaxBtcBalance = _walletCreationMaxBtcBalance;\\n self.walletClosureMinBtcBalance = _walletClosureMinBtcBalance;\\n self.walletMaxAge = _walletMaxAge;\\n self.walletMaxBtcTransfer = _walletMaxBtcTransfer;\\n self.walletClosingPeriod = _walletClosingPeriod;\\n\\n emit WalletParametersUpdated(\\n _walletCreationPeriod,\\n _walletCreationMinBtcBalance,\\n _walletCreationMaxBtcBalance,\\n _walletClosureMinBtcBalance,\\n _walletMaxAge,\\n _walletMaxBtcTransfer,\\n _walletClosingPeriod\\n );\\n }\\n\\n /// @notice Updates parameters related to frauds.\\n /// @param _fraudChallengeDepositAmount New value of the fraud challenge\\n /// deposit amount in wei, it is the amount of ETH the party\\n /// challenging the wallet for fraud needs to deposit.\\n /// @param _fraudChallengeDefeatTimeout New value of the challenge defeat\\n /// timeout in seconds, it is the amount of time the wallet has to\\n /// defeat a fraud challenge. The value must be greater than zero.\\n /// @param _fraudSlashingAmount New value of the fraud slashing amount in T,\\n /// it is the amount slashed from each wallet member for committing\\n /// a fraud.\\n /// @param _fraudNotifierRewardMultiplier New value of the fraud notifier\\n /// reward multiplier as percentage, it determines the percentage of\\n /// the notifier reward from the staking contact the notifier of\\n /// a fraud receives. The value must be in the range [0, 100].\\n /// @dev Requirements:\\n /// - Fraud challenge defeat timeout must be greater than 0,\\n /// - Fraud notifier reward multiplier must be in the range [0, 100].\\n function updateFraudParameters(\\n Storage storage self,\\n uint96 _fraudChallengeDepositAmount,\\n uint32 _fraudChallengeDefeatTimeout,\\n uint96 _fraudSlashingAmount,\\n uint32 _fraudNotifierRewardMultiplier\\n ) internal {\\n require(\\n _fraudChallengeDefeatTimeout > 0,\\n \\\"Fraud challenge defeat timeout must be greater than zero\\\"\\n );\\n\\n require(\\n _fraudNotifierRewardMultiplier <= 100,\\n \\\"Fraud notifier reward multiplier must be in the range [0, 100]\\\"\\n );\\n\\n self.fraudChallengeDepositAmount = _fraudChallengeDepositAmount;\\n self.fraudChallengeDefeatTimeout = _fraudChallengeDefeatTimeout;\\n self.fraudSlashingAmount = _fraudSlashingAmount;\\n self.fraudNotifierRewardMultiplier = _fraudNotifierRewardMultiplier;\\n\\n emit FraudParametersUpdated(\\n _fraudChallengeDepositAmount,\\n _fraudChallengeDefeatTimeout,\\n _fraudSlashingAmount,\\n _fraudNotifierRewardMultiplier\\n );\\n }\\n\\n /// @notice Updates treasury address. The treasury receives the system fees.\\n /// @param _treasury New value of the treasury address.\\n /// @dev The treasury address must not be 0x0.\\n function updateTreasury(Storage storage self, address _treasury) internal {\\n require(_treasury != address(0), \\\"Treasury address must not be 0x0\\\");\\n\\n self.treasury = _treasury;\\n emit TreasuryUpdated(_treasury);\\n }\\n}\\n\",\"keccak256\":\"0x0fe63c47a08ff0e56bd3bf4d2c9db4b09df717ac77ba5b18ab382a1e0bbb11c7\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Deposit.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\n/// @title Bridge deposit\\n/// @notice The library handles the logic for revealing Bitcoin deposits to\\n/// the Bridge.\\n/// @dev The depositor puts together a P2SH or P2WSH address to deposit the\\n/// funds. This script is unique to each depositor and looks like this:\\n///\\n/// ```\\n/// DROP\\n/// DROP\\n/// DUP HASH160 EQUAL\\n/// IF\\n/// CHECKSIG\\n/// ELSE\\n/// DUP HASH160 EQUALVERIFY\\n/// CHECKLOCKTIMEVERIFY DROP\\n/// CHECKSIG\\n/// ENDIF\\n/// ```\\n///\\n/// Since each depositor has their own Ethereum address and their own\\n/// blinding factor, each depositor\\u2019s script is unique, and the hash\\n/// of each depositor\\u2019s script is unique.\\nlibrary Deposit {\\n using BTCUtils for bytes;\\n using BytesLib for bytes;\\n\\n /// @notice Represents data which must be revealed by the depositor during\\n /// deposit reveal.\\n struct DepositRevealInfo {\\n // Index of the funding output belonging to the funding transaction.\\n uint32 fundingOutputIndex;\\n // The blinding factor as 8 bytes. Byte endianness doesn't matter\\n // as this factor is not interpreted as uint. The blinding factor allows\\n // to distinguish deposits from the same depositor.\\n bytes8 blindingFactor;\\n // The compressed Bitcoin public key (33 bytes and 02 or 03 prefix)\\n // of the deposit's wallet hashed in the HASH160 Bitcoin opcode style.\\n bytes20 walletPubKeyHash;\\n // The compressed Bitcoin public key (33 bytes and 02 or 03 prefix)\\n // that can be used to make the deposit refund after the refund\\n // locktime passes. Hashed in the HASH160 Bitcoin opcode style.\\n bytes20 refundPubKeyHash;\\n // The refund locktime (4-byte LE). Interpreted according to locktime\\n // parsing rules described in:\\n // https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number\\n // and used with OP_CHECKLOCKTIMEVERIFY opcode as described in:\\n // https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki\\n bytes4 refundLocktime;\\n // Address of the Bank vault to which the deposit is routed to.\\n // Optional, can be 0x0. The vault must be trusted by the Bridge.\\n address vault;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's calldata argument.\\n }\\n\\n /// @notice Represents tBTC deposit request data.\\n struct DepositRequest {\\n // Ethereum depositor address.\\n address depositor;\\n // Deposit amount in satoshi.\\n uint64 amount;\\n // UNIX timestamp the deposit was revealed at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 revealedAt;\\n // Address of the Bank vault the deposit is routed to.\\n // Optional, can be 0x0.\\n address vault;\\n // Treasury TBTC fee in satoshi at the moment of deposit reveal.\\n uint64 treasuryFee;\\n // UNIX timestamp the deposit was swept at. Note this is not the\\n // time when the deposit was swept on the Bitcoin chain but actually\\n // the time when the sweep proof was delivered to the Ethereum chain.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 sweptAt;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event DepositRevealed(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex,\\n address indexed depositor,\\n uint64 amount,\\n bytes8 blindingFactor,\\n bytes20 indexed walletPubKeyHash,\\n bytes20 refundPubKeyHash,\\n bytes4 refundLocktime,\\n address vault\\n );\\n\\n /// @notice Used by the depositor to reveal information about their P2(W)SH\\n /// Bitcoin deposit to the Bridge on Ethereum chain. The off-chain\\n /// wallet listens for revealed deposit events and may decide to\\n /// include the revealed deposit in the next executed sweep.\\n /// Information about the Bitcoin deposit can be revealed before or\\n /// after the Bitcoin transaction with P2(W)SH deposit is mined on\\n /// the Bitcoin chain. Worth noting, the gas cost of this function\\n /// scales with the number of P2(W)SH transaction inputs and\\n /// outputs. The deposit may be routed to one of the trusted vaults.\\n /// When a deposit is routed to a vault, vault gets notified when\\n /// the deposit gets swept and it may execute the appropriate action.\\n /// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`.\\n /// @param reveal Deposit reveal data, see `RevealInfo struct.\\n /// @dev Requirements:\\n /// - This function must be called by the same Ethereum address as the\\n /// one used in the P2(W)SH BTC deposit transaction as a depositor,\\n /// - `reveal.walletPubKeyHash` must identify a `Live` wallet,\\n /// - `reveal.vault` must be 0x0 or point to a trusted vault,\\n /// - `reveal.fundingOutputIndex` must point to the actual P2(W)SH\\n /// output of the BTC deposit transaction,\\n /// - `reveal.blindingFactor` must be the blinding factor used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - `reveal.walletPubKeyHash` must be the wallet pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundPubKeyHash` must be the refund pub key hash used in\\n /// the P2(W)SH BTC deposit transaction,\\n /// - `reveal.refundLocktime` must be the refund locktime used in the\\n /// P2(W)SH BTC deposit transaction,\\n /// - BTC deposit for the given `fundingTxHash`, `fundingOutputIndex`\\n /// can be revealed only one time.\\n ///\\n /// If any of these requirements is not met, the wallet _must_ refuse\\n /// to sweep the deposit and the depositor has to wait until the\\n /// deposit script unlocks to receive their BTC back.\\n function revealDeposit(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata fundingTx,\\n DepositRevealInfo calldata reveal\\n ) external {\\n require(\\n self.registeredWallets[reveal.walletPubKeyHash].state ==\\n Wallets.WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n require(\\n reveal.vault == address(0) || self.isVaultTrusted[reveal.vault],\\n \\\"Vault is not trusted\\\"\\n );\\n\\n if (self.depositRevealAheadPeriod > 0) {\\n validateDepositRefundLocktime(self, reveal.refundLocktime);\\n }\\n\\n bytes memory expectedScript = abi.encodePacked(\\n hex\\\"14\\\", // Byte length of depositor Ethereum address.\\n msg.sender,\\n hex\\\"75\\\", // OP_DROP\\n hex\\\"08\\\", // Byte length of blinding factor value.\\n reveal.blindingFactor,\\n hex\\\"75\\\", // OP_DROP\\n hex\\\"76\\\", // OP_DUP\\n hex\\\"a9\\\", // OP_HASH160\\n hex\\\"14\\\", // Byte length of a compressed Bitcoin public key hash.\\n reveal.walletPubKeyHash,\\n hex\\\"87\\\", // OP_EQUAL\\n hex\\\"63\\\", // OP_IF\\n hex\\\"ac\\\", // OP_CHECKSIG\\n hex\\\"67\\\", // OP_ELSE\\n hex\\\"76\\\", // OP_DUP\\n hex\\\"a9\\\", // OP_HASH160\\n hex\\\"14\\\", // Byte length of a compressed Bitcoin public key hash.\\n reveal.refundPubKeyHash,\\n hex\\\"88\\\", // OP_EQUALVERIFY\\n hex\\\"04\\\", // Byte length of refund locktime value.\\n reveal.refundLocktime,\\n hex\\\"b1\\\", // OP_CHECKLOCKTIMEVERIFY\\n hex\\\"75\\\", // OP_DROP\\n hex\\\"ac\\\", // OP_CHECKSIG\\n hex\\\"68\\\" // OP_ENDIF\\n );\\n\\n bytes memory fundingOutput = fundingTx\\n .outputVector\\n .extractOutputAtIndex(reveal.fundingOutputIndex);\\n bytes memory fundingOutputHash = fundingOutput.extractHash();\\n\\n if (fundingOutputHash.length == 20) {\\n // A 20-byte output hash is used by P2SH. That hash is constructed\\n // by applying OP_HASH160 on the locking script. A 20-byte output\\n // hash is used as well by P2PKH and P2WPKH (OP_HASH160 on the\\n // public key). However, since we compare the actual output hash\\n // with an expected locking script hash, this check will succeed only\\n // for P2SH transaction type with expected script hash value. For\\n // P2PKH and P2WPKH, it will fail on the output hash comparison with\\n // the expected locking script hash.\\n require(\\n fundingOutputHash.slice20(0) == expectedScript.hash160View(),\\n \\\"Wrong 20-byte script hash\\\"\\n );\\n } else if (fundingOutputHash.length == 32) {\\n // A 32-byte output hash is used by P2WSH. That hash is constructed\\n // by applying OP_SHA256 on the locking script.\\n require(\\n fundingOutputHash.toBytes32() == sha256(expectedScript),\\n \\\"Wrong 32-byte script hash\\\"\\n );\\n } else {\\n revert(\\\"Wrong script hash length\\\");\\n }\\n\\n // Resulting TX hash is in native Bitcoin little-endian format.\\n bytes32 fundingTxHash = abi\\n .encodePacked(\\n fundingTx.version,\\n fundingTx.inputVector,\\n fundingTx.outputVector,\\n fundingTx.locktime\\n )\\n .hash256View();\\n\\n DepositRequest storage deposit = self.deposits[\\n uint256(\\n keccak256(\\n abi.encodePacked(fundingTxHash, reveal.fundingOutputIndex)\\n )\\n )\\n ];\\n require(deposit.revealedAt == 0, \\\"Deposit already revealed\\\");\\n\\n uint64 fundingOutputAmount = fundingOutput.extractValue();\\n\\n require(\\n fundingOutputAmount >= self.depositDustThreshold,\\n \\\"Deposit amount too small\\\"\\n );\\n\\n deposit.amount = fundingOutputAmount;\\n deposit.depositor = msg.sender;\\n /* solhint-disable-next-line not-rely-on-time */\\n deposit.revealedAt = uint32(block.timestamp);\\n deposit.vault = reveal.vault;\\n deposit.treasuryFee = self.depositTreasuryFeeDivisor > 0\\n ? fundingOutputAmount / self.depositTreasuryFeeDivisor\\n : 0;\\n // slither-disable-next-line reentrancy-events\\n emit DepositRevealed(\\n fundingTxHash,\\n reveal.fundingOutputIndex,\\n msg.sender,\\n fundingOutputAmount,\\n reveal.blindingFactor,\\n reveal.walletPubKeyHash,\\n reveal.refundPubKeyHash,\\n reveal.refundLocktime,\\n reveal.vault\\n );\\n }\\n\\n /// @notice Validates the deposit refund locktime. The validation passes\\n /// successfully only if the deposit reveal is done respectively\\n /// earlier than the moment when the deposit refund locktime is\\n /// reached, i.e. the deposit become refundable. Reverts otherwise.\\n /// @param refundLocktime The deposit refund locktime as 4-byte LE.\\n /// @dev Requirements:\\n /// - `refundLocktime` as integer must be >= 500M\\n /// - `refundLocktime` must denote a timestamp that is at least\\n /// `depositRevealAheadPeriod` seconds later than the moment\\n /// of `block.timestamp`\\n function validateDepositRefundLocktime(\\n BridgeState.Storage storage self,\\n bytes4 refundLocktime\\n ) internal view {\\n // Convert the refund locktime byte array to a LE integer. This is\\n // the moment in time when the deposit become refundable.\\n uint32 depositRefundableTimestamp = BTCUtils.reverseUint32(\\n uint32(refundLocktime)\\n );\\n // According to https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number\\n // the locktime is parsed as a block number if less than 500M. We always\\n // want to parse the locktime as an Unix timestamp so we allow only for\\n // values bigger than or equal to 500M.\\n require(\\n depositRefundableTimestamp >= 500 * 1e6,\\n \\\"Refund locktime must be a value >= 500M\\\"\\n );\\n // The deposit must be revealed before it becomes refundable.\\n // This is because the sweeping wallet needs to have some time to\\n // sweep the deposit and avoid a potential competition with the\\n // depositor making the deposit refund.\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp + self.depositRevealAheadPeriod <=\\n depositRefundableTimestamp,\\n \\\"Deposit refund locktime is too close\\\"\\n );\\n }\\n}\\n\",\"keccak256\":\"0xc00d41ea9e98a6fa3d8d8701ad8554c459e0268c6bf413f0447bc1c68c6ab7e8\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/DepositSweep.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\nimport \\\"../bank/Bank.sol\\\";\\n\\n/// @title Bridge deposit sweep\\n/// @notice The library handles the logic for sweeping transactions revealed to\\n/// the Bridge\\n/// @dev Bridge active wallet periodically signs a transaction that unlocks all\\n/// of the valid, revealed deposits above the dust threshold, combines them\\n/// into a single UTXO with the existing main wallet UTXO, and relocks\\n/// those transactions without a 30-day refund clause to the same wallet.\\n/// This has two main effects: it consolidates the UTXO set and it disables\\n/// the refund. Balances of depositors in the Bank are increased when the\\n/// SPV sweep proof is submitted to the Bridge.\\nlibrary DepositSweep {\\n using BridgeState for BridgeState.Storage;\\n using BitcoinTx for BridgeState.Storage;\\n\\n using BTCUtils for bytes;\\n\\n /// @notice Represents temporary information needed during the processing\\n /// of the deposit sweep Bitcoin transaction inputs. This structure\\n /// is an internal one and should not be exported outside of the\\n /// deposit sweep transaction processing code.\\n /// @dev Allows to mitigate \\\"stack too deep\\\" errors on EVM.\\n struct DepositSweepTxInputsProcessingInfo {\\n // Input vector of the deposit sweep Bitcoin transaction. It is\\n // assumed the vector's structure is valid so it must be validated\\n // using e.g. `BTCUtils.validateVin` function before being used\\n // during the processing. The validation is usually done as part\\n // of the `BitcoinTx.validateProof` call that checks the SPV proof.\\n bytes sweepTxInputVector;\\n // Data of the wallet's main UTXO. If no main UTXO exists for the given\\n // sweeping wallet, this parameter's fields should be zeroed to bypass\\n // the main UTXO validation\\n BitcoinTx.UTXO mainUtxo;\\n // Address of the vault where all swept deposits should be routed to.\\n // It is used to validate whether all swept deposits have been revealed\\n // with the same `vault` parameter. It is an optional parameter.\\n // Set to zero address if deposits are not routed to a vault.\\n address vault;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n /// @notice Represents an outcome of the sweep Bitcoin transaction\\n /// inputs processing.\\n struct DepositSweepTxInputsInfo {\\n // Sum of all inputs values i.e. all deposits and main UTXO value,\\n // if present.\\n uint256 inputsTotalValue;\\n // Addresses of depositors who performed processed deposits. Ordered in\\n // the same order as deposits inputs in the input vector. Size of this\\n // array is either equal to the number of inputs (main UTXO doesn't\\n // exist) or less by one (main UTXO exists and is pointed by one of\\n // the inputs).\\n address[] depositors;\\n // Amounts of deposits corresponding to processed deposits. Ordered in\\n // the same order as deposits inputs in the input vector. Size of this\\n // array is either equal to the number of inputs (main UTXO doesn't\\n // exist) or less by one (main UTXO exists and is pointed by one of\\n // the inputs).\\n uint256[] depositedAmounts;\\n // Values of the treasury fee corresponding to processed deposits.\\n // Ordered in the same order as deposits inputs in the input vector.\\n // Size of this array is either equal to the number of inputs (main\\n // UTXO doesn't exist) or less by one (main UTXO exists and is pointed\\n // by one of the inputs).\\n uint256[] treasuryFees;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n event DepositsSwept(bytes20 walletPubKeyHash, bytes32 sweepTxHash);\\n\\n /// @notice Used by the wallet to prove the BTC deposit sweep transaction\\n /// and to update Bank balances accordingly. Sweep is only accepted\\n /// if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by first\\n /// computing the Bitcoin fee for the sweep transaction. The fee is\\n /// divided evenly between all swept deposits. Each depositor\\n /// receives a balance in the bank equal to the amount inferred\\n /// during the reveal transaction, minus their fee share.\\n ///\\n /// It is possible to prove the given sweep only one time.\\n /// @param sweepTx Bitcoin sweep transaction data.\\n /// @param sweepProof Bitcoin sweep proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @param vault Optional address of the vault where all swept deposits\\n /// should be routed to. All deposits swept as part of the transaction\\n /// must have their `vault` parameters set to the same address.\\n /// If this parameter is set to an address of a trusted vault, swept\\n /// deposits are routed to that vault.\\n /// If this parameter is set to the zero address or to an address\\n /// of a non-trusted vault, swept deposits are not routed to a\\n /// vault but depositors' balances are increased in the Bank\\n /// individually.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with 1..n\\n /// inputs. If the wallet has no main UTXO, all n inputs should\\n /// correspond to P2(W)SH revealed deposits UTXOs. If the wallet has\\n /// an existing main UTXO, one of the n inputs must point to that\\n /// main UTXO and remaining n-1 inputs should correspond to P2(W)SH\\n /// revealed deposits UTXOs. That transaction must have only\\n /// one P2(W)PKH output locking funds on the 20-byte wallet public\\n /// key hash,\\n /// - All revealed deposits that are swept by `sweepTx` must have\\n /// their `vault` parameters set to the same address as the address\\n /// passed in the `vault` function parameter,\\n /// - `sweepProof` components must match the expected structure. See\\n /// `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored.\\n function submitDepositSweepProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n address vault\\n ) external {\\n // Wallet state validation is performed in the\\n // `resolveDepositSweepingWallet` function.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 sweepTxHash = self.validateProof(sweepTx, sweepProof);\\n\\n // Process sweep transaction output and extract its target wallet\\n // public key hash and value.\\n (\\n bytes20 walletPubKeyHash,\\n uint64 sweepTxOutputValue\\n ) = processDepositSweepTxOutput(self, sweepTx.outputVector);\\n\\n (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n ) = resolveDepositSweepingWallet(self, walletPubKeyHash, mainUtxo);\\n\\n // Process sweep transaction inputs and extract all information needed\\n // to perform deposit bookkeeping.\\n DepositSweepTxInputsInfo\\n memory inputsInfo = processDepositSweepTxInputs(\\n self,\\n DepositSweepTxInputsProcessingInfo(\\n sweepTx.inputVector,\\n resolvedMainUtxo,\\n vault\\n )\\n );\\n\\n // Helper variable that will hold the sum of treasury fees paid by\\n // all deposits.\\n uint256 totalTreasuryFee = 0;\\n\\n // Determine the transaction fee that should be incurred by each deposit\\n // and the indivisible remainder that should be additionally incurred\\n // by the last deposit.\\n (\\n uint256 depositTxFee,\\n uint256 depositTxFeeRemainder\\n ) = depositSweepTxFeeDistribution(\\n inputsInfo.inputsTotalValue,\\n sweepTxOutputValue,\\n inputsInfo.depositedAmounts.length\\n );\\n\\n // Make sure the highest value of the deposit transaction fee does not\\n // exceed the maximum value limited by the governable parameter.\\n require(\\n depositTxFee + depositTxFeeRemainder <= self.depositTxMaxFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n // Reduce each deposit amount by treasury fee and transaction fee.\\n for (uint256 i = 0; i < inputsInfo.depositedAmounts.length; i++) {\\n // The last deposit should incur the deposit transaction fee\\n // remainder.\\n uint256 depositTxFeeIncurred = i ==\\n inputsInfo.depositedAmounts.length - 1\\n ? depositTxFee + depositTxFeeRemainder\\n : depositTxFee;\\n\\n // There is no need to check whether\\n // `inputsInfo.depositedAmounts[i] - inputsInfo.treasuryFees[i] - txFee > 0`\\n // since the `depositDustThreshold` should force that condition\\n // to be always true.\\n inputsInfo.depositedAmounts[i] =\\n inputsInfo.depositedAmounts[i] -\\n inputsInfo.treasuryFees[i] -\\n depositTxFeeIncurred;\\n totalTreasuryFee += inputsInfo.treasuryFees[i];\\n }\\n\\n // Record this sweep data and assign them to the wallet public key hash\\n // as new main UTXO. Transaction output index is always 0 as sweep\\n // transaction always contains only one output.\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(sweepTxHash, uint32(0), sweepTxOutputValue)\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit DepositsSwept(walletPubKeyHash, sweepTxHash);\\n\\n if (vault != address(0) && self.isVaultTrusted[vault]) {\\n // If the `vault` address is not zero and belongs to a trusted\\n // vault, route the deposits to that vault.\\n self.bank.increaseBalanceAndCall(\\n vault,\\n inputsInfo.depositors,\\n inputsInfo.depositedAmounts\\n );\\n } else {\\n // If the `vault` address is zero or belongs to a non-trusted\\n // vault, increase balances in the Bank individually for each\\n // depositor.\\n self.bank.increaseBalances(\\n inputsInfo.depositors,\\n inputsInfo.depositedAmounts\\n );\\n }\\n\\n // Pass the treasury fee to the treasury address.\\n if (totalTreasuryFee > 0) {\\n self.bank.increaseBalance(self.treasury, totalTreasuryFee);\\n }\\n }\\n\\n /// @notice Resolves sweeping wallet based on the provided wallet public key\\n /// hash. Validates the wallet state and current main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletPubKeyHash public key hash of the wallet proving the sweep\\n /// Bitcoin transaction.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @return wallet Data of the sweeping wallet.\\n /// @return resolvedMainUtxo The actual main UTXO of the sweeping wallet\\n /// resolved by cross-checking the `mainUtxo` parameter with\\n /// the chain state. If the validation went well, this is the\\n /// plain-text main UTXO corresponding to the `wallet.mainUtxoHash`.\\n /// @dev Requirements:\\n /// - Sweeping wallet must be either in Live or MovingFunds state,\\n /// - If the main UTXO of the sweeping wallet exists in the storage,\\n /// the passed `mainUTXO` parameter must be equal to the stored one.\\n function resolveDepositSweepingWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n )\\n internal\\n view\\n returns (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n )\\n {\\n wallet = self.registeredWallets[walletPubKeyHash];\\n\\n Wallets.WalletState walletState = wallet.state;\\n require(\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in Live or MovingFunds state\\\"\\n );\\n\\n // Check if the main UTXO for given wallet exists. If so, validate\\n // passed main UTXO data against the stored hash and use them for\\n // further processing. If no main UTXO exists, use empty data.\\n resolvedMainUtxo = BitcoinTx.UTXO(bytes32(0), 0, 0);\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n if (mainUtxoHash != bytes32(0)) {\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n resolvedMainUtxo = mainUtxo;\\n }\\n }\\n\\n /// @notice Processes the Bitcoin sweep transaction output vector by\\n /// extracting the single output and using it to gain additional\\n /// information required for further processing (e.g. value and\\n /// wallet public key hash).\\n /// @param sweepTxOutputVector Bitcoin sweep transaction output vector.\\n /// This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVout` function before\\n /// it is passed here.\\n /// @return walletPubKeyHash 20-byte wallet public key hash.\\n /// @return value 8-byte sweep transaction output value.\\n function processDepositSweepTxOutput(\\n BridgeState.Storage storage self,\\n bytes memory sweepTxOutputVector\\n ) internal view returns (bytes20 walletPubKeyHash, uint64 value) {\\n // To determine the total number of sweep transaction outputs, we need to\\n // parse the compactSize uint (VarInt) the output vector is prepended by.\\n // That compactSize uint encodes the number of vector elements using the\\n // format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVout` validation.\\n // See `BitcoinTx.outputVector` docs for more details.\\n (, uint256 outputsCount) = sweepTxOutputVector.parseVarInt();\\n require(\\n outputsCount == 1,\\n \\\"Sweep transaction must have a single output\\\"\\n );\\n\\n bytes memory output = sweepTxOutputVector.extractOutputAtIndex(0);\\n walletPubKeyHash = self.extractPubKeyHash(output);\\n value = output.extractValue();\\n\\n return (walletPubKeyHash, value);\\n }\\n\\n /// @notice Processes the Bitcoin sweep transaction input vector. It\\n /// extracts each input and tries to obtain associated deposit or\\n /// main UTXO data, depending on the input type. Reverts\\n /// if one of the inputs cannot be recognized as a pointer to a\\n /// revealed deposit or expected main UTXO.\\n /// This function also marks each processed deposit as swept.\\n /// @return resultInfo Outcomes of the processing.\\n function processDepositSweepTxInputs(\\n BridgeState.Storage storage self,\\n DepositSweepTxInputsProcessingInfo memory processInfo\\n ) internal returns (DepositSweepTxInputsInfo memory resultInfo) {\\n // If the passed `mainUtxo` parameter's values are zeroed, the main UTXO\\n // for the given wallet doesn't exist and it is not expected to be\\n // included in the sweep transaction input vector.\\n bool mainUtxoExpected = processInfo.mainUtxo.txHash != bytes32(0);\\n bool mainUtxoFound = false;\\n\\n // Determining the total number of sweep transaction inputs in the same\\n // way as for number of outputs. See `BitcoinTx.inputVector` docs for\\n // more details.\\n (uint256 inputsCompactSizeUintLength, uint256 inputsCount) = processInfo\\n .sweepTxInputVector\\n .parseVarInt();\\n\\n // To determine the first input starting index, we must jump over\\n // the compactSize uint which prepends the input vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 inputStartingIndex = 1 + inputsCompactSizeUintLength;\\n\\n // Determine the swept deposits count. If main UTXO is NOT expected,\\n // all inputs should be deposits. If main UTXO is expected, one input\\n // should point to that main UTXO.\\n resultInfo.depositors = new address[](\\n !mainUtxoExpected ? inputsCount : inputsCount - 1\\n );\\n resultInfo.depositedAmounts = new uint256[](\\n resultInfo.depositors.length\\n );\\n resultInfo.treasuryFees = new uint256[](resultInfo.depositors.length);\\n\\n // Initialize helper variables.\\n uint256 processedDepositsCount = 0;\\n\\n // Inputs processing loop.\\n for (uint256 i = 0; i < inputsCount; i++) {\\n (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex,\\n uint256 inputLength\\n ) = parseDepositSweepTxInputAt(\\n processInfo.sweepTxInputVector,\\n inputStartingIndex\\n );\\n\\n Deposit.DepositRequest storage deposit = self.deposits[\\n uint256(\\n keccak256(abi.encodePacked(outpointTxHash, outpointIndex))\\n )\\n ];\\n\\n if (deposit.revealedAt != 0) {\\n // If we entered here, that means the input was identified as\\n // a revealed deposit.\\n require(deposit.sweptAt == 0, \\\"Deposit already swept\\\");\\n\\n require(\\n deposit.vault == processInfo.vault,\\n \\\"Deposit should be routed to another vault\\\"\\n );\\n\\n if (processedDepositsCount == resultInfo.depositors.length) {\\n // If this condition is true, that means a deposit input\\n // took place of an expected main UTXO input.\\n // In other words, there is no expected main UTXO\\n // input and all inputs come from valid, revealed deposits.\\n revert(\\n \\\"Expected main UTXO not present in sweep transaction inputs\\\"\\n );\\n }\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n deposit.sweptAt = uint32(block.timestamp);\\n\\n resultInfo.depositors[processedDepositsCount] = deposit\\n .depositor;\\n resultInfo.depositedAmounts[processedDepositsCount] = deposit\\n .amount;\\n resultInfo.inputsTotalValue += resultInfo.depositedAmounts[\\n processedDepositsCount\\n ];\\n resultInfo.treasuryFees[processedDepositsCount] = deposit\\n .treasuryFee;\\n\\n processedDepositsCount++;\\n } else if (\\n mainUtxoExpected != mainUtxoFound &&\\n processInfo.mainUtxo.txHash == outpointTxHash &&\\n processInfo.mainUtxo.txOutputIndex == outpointIndex\\n ) {\\n // If we entered here, that means the input was identified as\\n // the expected main UTXO.\\n resultInfo.inputsTotalValue += processInfo\\n .mainUtxo\\n .txOutputValue;\\n mainUtxoFound = true;\\n\\n // Main UTXO used as an input, mark it as spent.\\n self.spentMainUTXOs[\\n uint256(\\n keccak256(\\n abi.encodePacked(outpointTxHash, outpointIndex)\\n )\\n )\\n ] = true;\\n } else {\\n revert(\\\"Unknown input type\\\");\\n }\\n\\n // Make the `inputStartingIndex` pointing to the next input by\\n // increasing it by current input's length.\\n inputStartingIndex += inputLength;\\n }\\n\\n // Construction of the input processing loop guarantees that:\\n // `processedDepositsCount == resultInfo.depositors.length == resultInfo.depositedAmounts.length`\\n // is always true at this point. We just use the first variable\\n // to assert the total count of swept deposit is bigger than zero.\\n require(\\n processedDepositsCount > 0,\\n \\\"Sweep transaction must process at least one deposit\\\"\\n );\\n\\n // Assert the main UTXO was used as one of current sweep's inputs if\\n // it was actually expected.\\n require(\\n mainUtxoExpected == mainUtxoFound,\\n \\\"Expected main UTXO not present in sweep transaction inputs\\\"\\n );\\n\\n return resultInfo;\\n }\\n\\n /// @notice Parses a Bitcoin transaction input starting at the given index.\\n /// @param inputVector Bitcoin transaction input vector.\\n /// @param inputStartingIndex Index the given input starts at.\\n /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is\\n /// pointed in the given input's outpoint.\\n /// @return outpointIndex 4-byte index of the Bitcoin transaction output\\n /// which is pointed in the given input's outpoint.\\n /// @return inputLength Byte length of the given input.\\n /// @dev This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVin` function before it\\n /// is passed here.\\n function parseDepositSweepTxInputAt(\\n bytes memory inputVector,\\n uint256 inputStartingIndex\\n )\\n internal\\n pure\\n returns (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex,\\n uint256 inputLength\\n )\\n {\\n outpointTxHash = inputVector.extractInputTxIdLeAt(inputStartingIndex);\\n\\n outpointIndex = BTCUtils.reverseUint32(\\n uint32(inputVector.extractTxIndexLeAt(inputStartingIndex))\\n );\\n\\n inputLength = inputVector.determineInputLengthAt(inputStartingIndex);\\n\\n return (outpointTxHash, outpointIndex, inputLength);\\n }\\n\\n /// @notice Determines the distribution of the sweep transaction fee\\n /// over swept deposits.\\n /// @param sweepTxInputsTotalValue Total value of all sweep transaction inputs.\\n /// @param sweepTxOutputValue Value of the sweep transaction output.\\n /// @param depositsCount Count of the deposits swept by the sweep transaction.\\n /// @return depositTxFee Transaction fee per deposit determined by evenly\\n /// spreading the divisible part of the sweep transaction fee\\n /// over all deposits.\\n /// @return depositTxFeeRemainder The indivisible part of the sweep\\n /// transaction fee than cannot be distributed over all deposits.\\n /// @dev It is up to the caller to decide how the remainder should be\\n /// counted in. This function only computes its value.\\n function depositSweepTxFeeDistribution(\\n uint256 sweepTxInputsTotalValue,\\n uint256 sweepTxOutputValue,\\n uint256 depositsCount\\n )\\n internal\\n pure\\n returns (uint256 depositTxFee, uint256 depositTxFeeRemainder)\\n {\\n // The sweep transaction fee is just the difference between inputs\\n // amounts sum and the output amount.\\n uint256 sweepTxFee = sweepTxInputsTotalValue - sweepTxOutputValue;\\n // Compute the indivisible remainder that remains after dividing the\\n // sweep transaction fee over all deposits evenly.\\n depositTxFeeRemainder = sweepTxFee % depositsCount;\\n // Compute the transaction fee per deposit by dividing the sweep\\n // transaction fee (reduced by the remainder) by the number of deposits.\\n depositTxFee = (sweepTxFee - depositTxFeeRemainder) / depositsCount;\\n\\n return (depositTxFee, depositTxFeeRemainder);\\n }\\n}\\n\",\"keccak256\":\"0xa5b6319960c51c1c5b1edf0539075b822e70d43035eb5f1d20325d0b57cbd73c\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/EcdsaLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nlibrary EcdsaLib {\\n using BytesLib for bytes;\\n\\n /// @notice Converts public key X and Y coordinates (32-byte each) to a\\n /// compressed public key (33-byte). Compressed public key is X\\n /// coordinate prefixed with `02` or `03` based on the Y coordinate parity.\\n /// It is expected that the uncompressed public key is stripped\\n /// (i.e. it is not prefixed with `04`).\\n /// @param x Wallet's public key's X coordinate.\\n /// @param y Wallet's public key's Y coordinate.\\n /// @return Compressed public key (33-byte), prefixed with `02` or `03`.\\n function compressPublicKey(bytes32 x, bytes32 y)\\n internal\\n pure\\n returns (bytes memory)\\n {\\n bytes1 prefix;\\n if (uint256(y) % 2 == 0) {\\n prefix = hex\\\"02\\\";\\n } else {\\n prefix = hex\\\"03\\\";\\n }\\n\\n return bytes.concat(prefix, x);\\n }\\n}\\n\",\"keccak256\":\"0x670d0fbeb088f78abfe7ae7f844784d774ca515480383378a602af707cace7ff\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Fraud.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {CheckBitcoinSigs} from \\\"@keep-network/bitcoin-spv-sol/contracts/CheckBitcoinSigs.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./EcdsaLib.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Heartbeat.sol\\\";\\nimport \\\"./MovingFunds.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\n/// @title Bridge fraud\\n/// @notice The library handles the logic for challenging Bridge wallets that\\n/// committed fraud.\\n/// @dev Anyone can submit a fraud challenge indicating that a UTXO being under\\n/// the wallet control was unlocked by the wallet but was not used\\n/// according to the protocol rules. That means the wallet signed\\n/// a transaction input pointing to that UTXO and there is a unique\\n/// sighash and signature pair associated with that input.\\n///\\n/// In order to defeat the challenge, the same wallet public key and\\n/// signature must be provided as were used to calculate the sighash during\\n/// the challenge. The wallet provides the preimage which produces sighash\\n/// used to generate the ECDSA signature that is the subject of the fraud\\n/// claim.\\n///\\n/// The fraud challenge defeat attempt will succeed if the inputs in the\\n/// preimage are considered honestly spent by the wallet. Therefore the\\n/// transaction spending the UTXO must be proven in the Bridge before\\n/// a challenge defeat is called.\\n///\\n/// Another option is when a malicious wallet member used a signed heartbeat\\n/// message periodically produced by the wallet off-chain to challenge the\\n/// wallet for a fraud. Anyone from the wallet can defeat the challenge by\\n/// proving the sighash and signature were produced for a heartbeat message\\n/// following a strict format.\\nlibrary Fraud {\\n using Wallets for BridgeState.Storage;\\n\\n using BytesLib for bytes;\\n using BTCUtils for bytes;\\n using BTCUtils for uint32;\\n using EcdsaLib for bytes;\\n\\n struct FraudChallenge {\\n // The address of the party challenging the wallet.\\n address challenger;\\n // The amount of ETH the challenger deposited.\\n uint256 depositAmount;\\n // The timestamp the challenge was submitted at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 reportedAt;\\n // The flag indicating whether the challenge has been resolved.\\n bool resolved;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event FraudChallengeSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n );\\n\\n event FraudChallengeDefeated(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sighash\\n );\\n\\n event FraudChallengeDefeatTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n // Sighash calculated as a Bitcoin's hash256 (double sha2) of:\\n // - a preimage of a transaction spending UTXO according to the protocol\\n // rules OR\\n // - a valid heartbeat message produced by the wallet off-chain.\\n bytes32 sighash\\n );\\n\\n /// @notice Submits a fraud challenge indicating that a UTXO being under\\n /// wallet control was unlocked by the wallet but was not used\\n /// according to the protocol rules. That means the wallet signed\\n /// a transaction input pointing to that UTXO and there is a unique\\n /// sighash and signature pair associated with that input. This\\n /// function uses those parameters to create a fraud accusation that\\n /// proves a given transaction input unlocking the given UTXO was\\n /// actually signed by the wallet. This function cannot determine\\n /// whether the transaction was actually broadcast and the input was\\n /// consumed in a fraudulent way so it just opens a challenge period\\n /// during which the wallet can defeat the challenge by submitting\\n /// proof of a transaction that consumes the given input according\\n /// to protocol rules. To prevent spurious allegations, the caller\\n /// must deposit ETH that is returned back upon justified fraud\\n /// challenge or confiscated otherwise.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @param signature Bitcoin signature in the R/S/V format\\n /// @dev Requirements:\\n /// - Wallet behind `walletPublicKey` must be in Live or MovingFunds\\n /// or Closing state,\\n /// - The challenger must send appropriate amount of ETH used as\\n /// fraud challenge deposit,\\n /// - The signature (represented by r, s and v) must be generated by\\n /// the wallet behind `walletPubKey` during signing of `sighash`\\n /// which was calculated from `preimageSha256`,\\n /// - Wallet can be challenged for the given signature only once.\\n function submitFraudChallenge(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n bytes memory preimageSha256,\\n BitcoinTx.RSVSignature calldata signature\\n ) external {\\n require(\\n msg.value >= self.fraudChallengeDepositAmount,\\n \\\"The amount of ETH deposited is too low\\\"\\n );\\n\\n // To prevent ECDSA signature forgery `sighash` must be calculated\\n // inside the function and not passed as a function parameter.\\n // Signature forgery could result in a wrongful fraud accusation\\n // against a wallet.\\n bytes32 sighash = sha256(preimageSha256);\\n\\n require(\\n CheckBitcoinSigs.checkSig(\\n walletPublicKey,\\n sighash,\\n signature.v,\\n signature.r,\\n signature.s\\n ),\\n \\\"Signature verification failure\\\"\\n );\\n\\n bytes memory compressedWalletPublicKey = EcdsaLib.compressPublicKey(\\n walletPublicKey.slice32(0),\\n walletPublicKey.slice32(32)\\n );\\n bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();\\n\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.Live ||\\n wallet.state == Wallets.WalletState.MovingFunds ||\\n wallet.state == Wallets.WalletState.Closing,\\n \\\"Wallet must be in Live or MovingFunds or Closing state\\\"\\n );\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n require(challenge.reportedAt == 0, \\\"Fraud challenge already exists\\\");\\n\\n challenge.challenger = msg.sender;\\n challenge.depositAmount = msg.value;\\n /* solhint-disable-next-line not-rely-on-time */\\n challenge.reportedAt = uint32(block.timestamp);\\n challenge.resolved = false;\\n // slither-disable-next-line reentrancy-events\\n emit FraudChallengeSubmitted(\\n walletPubKeyHash,\\n sighash,\\n signature.v,\\n signature.r,\\n signature.s\\n );\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet if\\n /// the transaction that spends the UTXO follows the protocol rules.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during input signing.\\n /// The fraud challenge defeat attempt will only succeed if the\\n /// inputs in the preimage are considered honestly spent by the\\n /// wallet. Therefore the transaction spending the UTXO must be\\n /// proven in the Bridge before a challenge defeat is called.\\n /// If successfully defeated, the fraud challenge is marked as\\n /// resolved and the amount of ether deposited by the challenger is\\n /// sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference.\\n /// @param witness Flag indicating whether the preimage was produced for a\\n /// witness input. True for witness, false for non-witness input.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as `hash256(preimage)`\\n /// must identify an open fraud challenge,\\n /// - the preimage must be a valid preimage of a transaction generated\\n /// according to the protocol rules and already proved in the Bridge,\\n /// - before a defeat attempt is made the transaction that spends the\\n /// given UTXO must be proven in the Bridge.\\n function defeatFraudChallenge(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n bytes calldata preimage,\\n bool witness\\n ) external {\\n bytes32 sighash = preimage.hash256();\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n\\n require(challenge.reportedAt > 0, \\\"Fraud challenge does not exist\\\");\\n require(\\n !challenge.resolved,\\n \\\"Fraud challenge has already been resolved\\\"\\n );\\n\\n // Ensure SIGHASH_ALL type was used during signing, which is represented\\n // by type value `1`.\\n require(extractSighashType(preimage) == 1, \\\"Wrong sighash type\\\");\\n\\n uint256 utxoKey = witness\\n ? extractUtxoKeyFromWitnessPreimage(preimage)\\n : extractUtxoKeyFromNonWitnessPreimage(preimage);\\n\\n // Check that the UTXO key identifies a correctly spent UTXO.\\n require(\\n self.deposits[utxoKey].sweptAt > 0 ||\\n self.spentMainUTXOs[utxoKey] ||\\n self.movedFundsSweepRequests[utxoKey].state ==\\n MovingFunds.MovedFundsSweepRequestState.Processed,\\n \\\"Spent UTXO not found among correctly spent UTXOs\\\"\\n );\\n\\n resolveFraudChallenge(self, walletPublicKey, challenge, sighash);\\n }\\n\\n /// @notice Allows to defeat a pending fraud challenge against a wallet by\\n /// proving the sighash and signature were produced for an off-chain\\n /// wallet heartbeat message following a strict format.\\n /// In order to defeat the challenge the same `walletPublicKey` and\\n /// signature (represented by `r`, `s` and `v`) must be provided as\\n /// were used to calculate the sighash during heartbeat message\\n /// signing. The fraud challenge defeat attempt will only succeed if\\n /// the signed message follows a strict format required for\\n /// heartbeat messages. If successfully defeated, the fraud\\n /// challenge is marked as resolved and the amount of ether\\n /// deposited by the challenger is sent to the treasury.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes),\\n /// @param heartbeatMessage Off-chain heartbeat message meeting the heartbeat\\n /// message format requirements which produces sighash used to\\n /// generate the ECDSA signature that is the subject of the fraud\\n /// claim.\\n /// @dev Requirements:\\n /// - `walletPublicKey` and `sighash` calculated as\\n /// `hash256(heartbeatMessage)` must identify an open fraud challenge,\\n /// - `heartbeatMessage` must follow a strict format of heartbeat\\n /// messages.\\n function defeatFraudChallengeWithHeartbeat(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n bytes calldata heartbeatMessage\\n ) external {\\n bytes32 sighash = heartbeatMessage.hash256();\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n\\n require(challenge.reportedAt > 0, \\\"Fraud challenge does not exist\\\");\\n require(\\n !challenge.resolved,\\n \\\"Fraud challenge has already been resolved\\\"\\n );\\n\\n require(\\n Heartbeat.isValidHeartbeatMessage(heartbeatMessage),\\n \\\"Not a valid heartbeat message\\\"\\n );\\n\\n resolveFraudChallenge(self, walletPublicKey, challenge, sighash);\\n }\\n\\n /// @notice Called only for successfully defeated fraud challenges.\\n /// The fraud challenge is marked as resolved and the amount of\\n /// ether deposited by the challenger is sent to the treasury.\\n /// @dev Requirements:\\n /// - Must be called only for successfully defeated fraud challenges.\\n function resolveFraudChallenge(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n FraudChallenge storage challenge,\\n bytes32 sighash\\n ) internal {\\n // Mark the challenge as resolved as it was successfully defeated\\n challenge.resolved = true;\\n\\n // Send the ether deposited by the challenger to the treasury\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,unchecked-lowlevel,arbitrary-send\\n self.treasury.call{gas: 100000, value: challenge.depositAmount}(\\\"\\\");\\n /* solhint-enable avoid-low-level-calls */\\n\\n bytes memory compressedWalletPublicKey = EcdsaLib.compressPublicKey(\\n walletPublicKey.slice32(0),\\n walletPublicKey.slice32(32)\\n );\\n bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();\\n\\n // slither-disable-next-line reentrancy-events\\n emit FraudChallengeDefeated(walletPubKeyHash, sighash);\\n }\\n\\n /// @notice Notifies about defeat timeout for the given fraud challenge.\\n /// Can be called only if there was a fraud challenge identified by\\n /// the provided `walletPublicKey` and `sighash` and it was not\\n /// defeated on time. The amount of time that needs to pass after\\n /// a fraud challenge is reported is indicated by the\\n /// `challengeDefeatTimeout`. After a successful fraud challenge\\n /// defeat timeout notification the fraud challenge is marked as\\n /// resolved, the stake of each operator is slashed, the ether\\n /// deposited is returned to the challenger and the challenger is\\n /// rewarded.\\n /// @param walletPublicKey The public key of the wallet in the uncompressed\\n /// and unprefixed format (64 bytes).\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param preimageSha256 The hash that was generated by applying SHA-256\\n /// one time over the preimage used during input signing. The preimage\\n /// is a serialized subset of the transaction and its structure\\n /// depends on the transaction input (see BIP-143 for reference).\\n /// Notice that applying SHA-256 over the `preimageSha256` results\\n /// in `sighash`. The path from `preimage` to `sighash` looks like\\n /// this:\\n /// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Closing or\\n /// Terminated state,\\n /// - The `walletPublicKey` and `sighash` calculated from\\n /// `preimageSha256` must identify an open fraud challenge,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time indicated by `challengeDefeatTimeout` must pass\\n /// after the challenge was reported.\\n function notifyFraudChallengeDefeatTimeout(\\n BridgeState.Storage storage self,\\n bytes calldata walletPublicKey,\\n uint32[] calldata walletMembersIDs,\\n bytes memory preimageSha256\\n ) external {\\n // Wallet state is validated in `notifyWalletFraudChallengeDefeatTimeout`.\\n\\n bytes32 sighash = sha256(preimageSha256);\\n\\n uint256 challengeKey = uint256(\\n keccak256(abi.encodePacked(walletPublicKey, sighash))\\n );\\n\\n FraudChallenge storage challenge = self.fraudChallenges[challengeKey];\\n\\n require(challenge.reportedAt > 0, \\\"Fraud challenge does not exist\\\");\\n\\n require(\\n !challenge.resolved,\\n \\\"Fraud challenge has already been resolved\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >=\\n challenge.reportedAt + self.fraudChallengeDefeatTimeout,\\n \\\"Fraud challenge defeat period did not time out yet\\\"\\n );\\n\\n challenge.resolved = true;\\n // Return the ether deposited by the challenger\\n /* solhint-disable avoid-low-level-calls */\\n // slither-disable-next-line low-level-calls,unchecked-lowlevel\\n challenge.challenger.call{gas: 100000, value: challenge.depositAmount}(\\n \\\"\\\"\\n );\\n /* solhint-enable avoid-low-level-calls */\\n\\n bytes memory compressedWalletPublicKey = EcdsaLib.compressPublicKey(\\n walletPublicKey.slice32(0),\\n walletPublicKey.slice32(32)\\n );\\n bytes20 walletPubKeyHash = compressedWalletPublicKey.hash160View();\\n\\n self.notifyWalletFraudChallengeDefeatTimeout(\\n walletPubKeyHash,\\n walletMembersIDs,\\n challenge.challenger\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit FraudChallengeDefeatTimedOut(walletPubKeyHash, sighash);\\n }\\n\\n /// @notice Extracts the UTXO keys from the given preimage used during\\n /// signing of a witness input.\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference\\n /// @return utxoKey UTXO key that identifies spent input.\\n function extractUtxoKeyFromWitnessPreimage(bytes calldata preimage)\\n internal\\n pure\\n returns (uint256 utxoKey)\\n {\\n // The expected structure of the preimage created during signing of a\\n // witness input:\\n // - transaction version (4 bytes)\\n // - hash of previous outpoints of all inputs (32 bytes)\\n // - hash of sequences of all inputs (32 bytes)\\n // - outpoint (hash + index) of the input being signed (36 bytes)\\n // - the unlocking script of the input (variable length)\\n // - value of the outpoint (8 bytes)\\n // - sequence of the input being signed (4 bytes)\\n // - hash of all outputs (32 bytes)\\n // - transaction locktime (4 bytes)\\n // - sighash type (4 bytes)\\n\\n // See Bitcoin's BIP-143 for reference:\\n // https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki.\\n\\n // The outpoint (hash and index) is located at the constant offset of\\n // 68 (4 + 32 + 32).\\n bytes32 outpointTxHash = preimage.extractInputTxIdLeAt(68);\\n uint32 outpointIndex = BTCUtils.reverseUint32(\\n uint32(preimage.extractTxIndexLeAt(68))\\n );\\n\\n return\\n uint256(keccak256(abi.encodePacked(outpointTxHash, outpointIndex)));\\n }\\n\\n /// @notice Extracts the UTXO key from the given preimage used during\\n /// signing of a non-witness input.\\n /// @param preimage The preimage which produces sighash used to generate the\\n /// ECDSA signature that is the subject of the fraud claim. It is a\\n /// serialized subset of the transaction. The exact subset used as\\n /// the preimage depends on the transaction input the signature is\\n /// produced for. See BIP-143 for reference.\\n /// @return utxoKey UTXO key that identifies spent input.\\n function extractUtxoKeyFromNonWitnessPreimage(bytes calldata preimage)\\n internal\\n pure\\n returns (uint256 utxoKey)\\n {\\n // The expected structure of the preimage created during signing of a\\n // non-witness input:\\n // - transaction version (4 bytes)\\n // - number of inputs written as compactSize uint (1 byte, 3 bytes,\\n // 5 bytes or 9 bytes)\\n // - for each input\\n // - outpoint (hash and index) (36 bytes)\\n // - unlocking script for the input being signed (variable length)\\n // or `00` for all other inputs (1 byte)\\n // - input sequence (4 bytes)\\n // - number of outputs written as compactSize uint (1 byte, 3 bytes,\\n // 5 bytes or 9 bytes)\\n // - outputs (variable length)\\n // - transaction locktime (4 bytes)\\n // - sighash type (4 bytes)\\n\\n // See example for reference:\\n // https://en.bitcoin.it/wiki/OP_CHECKSIG#Code_samples_and_raw_dumps.\\n\\n // The input data begins at the constant offset of 4 (the first 4 bytes\\n // are for the transaction version).\\n (uint256 inputsCompactSizeUintLength, uint256 inputsCount) = preimage\\n .parseVarIntAt(4);\\n\\n // To determine the first input starting index, we must jump 4 bytes\\n // over the transaction version length and the compactSize uint which\\n // prepends the input vector. One byte must be added because\\n // `BtcUtils.parseVarInt` does not include compactSize uint tag in the\\n // returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 inputStartingIndex = 4 + 1 + inputsCompactSizeUintLength;\\n\\n for (uint256 i = 0; i < inputsCount; i++) {\\n uint256 inputLength = preimage.determineInputLengthAt(\\n inputStartingIndex\\n );\\n\\n (, uint256 scriptSigLength) = preimage.extractScriptSigLenAt(\\n inputStartingIndex\\n );\\n\\n if (scriptSigLength > 0) {\\n // The input this preimage was generated for was found.\\n // All the other inputs in the preimage are marked with a null\\n // scriptSig (\\\"00\\\") which has length of 1.\\n bytes32 outpointTxHash = preimage.extractInputTxIdLeAt(\\n inputStartingIndex\\n );\\n uint32 outpointIndex = BTCUtils.reverseUint32(\\n uint32(preimage.extractTxIndexLeAt(inputStartingIndex))\\n );\\n\\n utxoKey = uint256(\\n keccak256(abi.encodePacked(outpointTxHash, outpointIndex))\\n );\\n\\n break;\\n }\\n\\n inputStartingIndex += inputLength;\\n }\\n\\n return utxoKey;\\n }\\n\\n /// @notice Extracts the sighash type from the given preimage.\\n /// @param preimage Serialized subset of the transaction. See BIP-143 for\\n /// reference.\\n /// @dev Sighash type is stored as the last 4 bytes in the preimage (little\\n /// endian).\\n /// @return sighashType Sighash type as a 32-bit integer.\\n function extractSighashType(bytes calldata preimage)\\n internal\\n pure\\n returns (uint32 sighashType)\\n {\\n bytes4 sighashTypeBytes = preimage.slice4(preimage.length - 4);\\n uint32 sighashTypeLE = uint32(sighashTypeBytes);\\n return sighashTypeLE.reverseUint32();\\n }\\n}\\n\",\"keccak256\":\"0x5b976a45cbee8e5d8e65fc748820e36c692d8fb26a8532319a87e6a614733c58\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Heartbeat.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\n/// @title Bridge wallet heartbeat\\n/// @notice The library establishes expected format for heartbeat messages\\n/// signed by wallet ECDSA signing group. Heartbeat messages are\\n/// constructed in such a way that they can not be used as a Bitcoin\\n/// transaction preimages.\\n/// @dev The smallest Bitcoin non-coinbase transaction is a one spending an\\n/// OP_TRUE anyonecanspend output and creating 1 OP_TRUE anyonecanspend\\n/// output. Such a transaction has 61 bytes (see `BitcoinTx` documentation):\\n/// 4 bytes for version\\n/// 1 byte for tx_in_count\\n/// 36 bytes for tx_in.previous_output\\n/// 1 byte for tx_in.script_bytes (value: 0)\\n/// 0 bytes for tx_in.signature_script\\n/// 4 bytes for tx_in.sequence\\n/// 1 byte for tx_out_count\\n/// 8 bytes for tx_out.value\\n/// 1 byte for tx_out.pk_script_bytes\\n/// 1 byte for tx_out.pk_script\\n/// 4 bytes for lock_time\\n///\\n///\\n/// The smallest Bitcoin coinbase transaction is a one creating\\n/// 1 OP_TRUE anyonecanspend output and having an empty coinbase script.\\n/// Such a transaction has 65 bytes:\\n/// 4 bytes for version\\n/// 1 byte for tx_in_count\\n/// 32 bytes for tx_in.hash (all 0x00)\\n/// 4 bytes for tx_in.index (all 0xff)\\n/// 1 byte for tx_in.script_bytes (value: 0)\\n/// 4 bytes for tx_in.height\\n/// 0 byte for tx_in.coinbase_script\\n/// 4 bytes for tx_in.sequence\\n/// 1 byte for tx_out_count\\n/// 8 bytes for tx_out.value\\n/// 1 byte for tx_out.pk_script_bytes\\n/// 1 byte for tx_out.pk_script\\n/// 4 bytes for lock_time\\n///\\n///\\n/// A SIGHASH flag is used to indicate which part of the transaction is\\n/// signed by the ECDSA signature. There are currently 3 flags:\\n/// SIGHASH_ALL, SIGHASH_NONE, SIGHASH_SINGLE, and different combinations\\n/// of these flags.\\n///\\n/// No matter the SIGHASH flag and no matter the combination, the following\\n/// fields from the transaction are always included in the constructed\\n/// preimage:\\n/// 4 bytes for version\\n/// 36 bytes for tx_in.previous_output (or tx_in.hash + tx_in.index for coinbase)\\n/// 4 bytes for lock_time\\n///\\n/// Additionally, the last 4 bytes of the preimage determines the SIGHASH\\n/// flag.\\n///\\n/// This is enough to say there is no way the preimage could be shorter\\n/// than 4 + 36 + 4 + 4 = 48 bytes.\\n///\\n/// For this reason, we construct the heartbeat message, as a 16-byte\\n/// message. The first 8 bytes are 0xffffffffffffffff. The last 8 bytes\\n/// are for an arbitrary uint64, being a signed heartbeat nonce (for\\n/// example, the last Ethereum block hash).\\n///\\n/// The message being signed by the wallet when executing the heartbeat\\n/// protocol should be Bitcoin's hash256 (double SHA-256) of the heartbeat\\n/// message:\\n/// heartbeat_sighash = hash256(heartbeat_message)\\nlibrary Heartbeat {\\n using BytesLib for bytes;\\n\\n /// @notice Determines if the signed byte array is a valid, non-fraudulent\\n /// heartbeat message.\\n /// @param message Message signed by the wallet. It is a potential heartbeat\\n /// message, Bitcoin transaction preimage, or an arbitrary signed\\n /// bytes.\\n /// @dev Wallet heartbeat message must be exactly 16 bytes long with the first\\n /// 8 bytes set to 0xffffffffffffffff.\\n /// @return True if valid heartbeat message, false otherwise.\\n function isValidHeartbeatMessage(bytes calldata message)\\n internal\\n pure\\n returns (bool)\\n {\\n if (message.length != 16) {\\n return false;\\n }\\n\\n if (message.slice8(0) != 0xffffffffffffffff) {\\n return false;\\n }\\n\\n return true;\\n }\\n}\\n\",\"keccak256\":\"0x2f3ad70beadc4dfb6414064fd7b3621b1edcd2713f186853b4a5fd36fb4502ba\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/IRelay.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\n/// @title Interface for the Bitcoin relay\\n/// @notice Contains only the methods needed by tBTC v2. The Bitcoin relay\\n/// provides the difficulty of the previous and current epoch. One\\n/// difficulty epoch spans 2016 blocks.\\ninterface IRelay {\\n /// @notice Returns the difficulty of the current epoch.\\n function getCurrentEpochDifficulty() external view returns (uint256);\\n\\n /// @notice Returns the difficulty of the previous epoch.\\n function getPrevEpochDifficulty() external view returns (uint256);\\n}\\n\",\"keccak256\":\"0xf70c723fc0a1824d92061b5dc76c65c38c22eff6b18ef6a2057f511183ce3c5b\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/MovingFunds.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Redemption.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\n/// @title Moving Bridge wallet funds\\n/// @notice The library handles the logic for moving Bitcoin between Bridge\\n/// wallets.\\n/// @dev A wallet that failed a heartbeat, did not process requested redemption\\n/// on time, or qualifies to be closed, begins the procedure of moving\\n/// funds to other wallets in the Bridge. The wallet needs to commit to\\n/// which other Live wallets it is moving the funds to and then, provide an\\n/// SPV proof of moving funds to the previously committed wallets.\\n/// Once the proof is submitted, all target wallets are supposed to\\n/// sweep the received UTXOs with their own main UTXOs in order to\\n/// update their BTC balances.\\nlibrary MovingFunds {\\n using BridgeState for BridgeState.Storage;\\n using Wallets for BridgeState.Storage;\\n using BitcoinTx for BridgeState.Storage;\\n\\n using BTCUtils for bytes;\\n using BytesLib for bytes;\\n\\n /// @notice Represents temporary information needed during the processing\\n /// of the moving funds Bitcoin transaction outputs. This structure\\n /// is an internal one and should not be exported outside of the\\n /// moving funds transaction processing code.\\n /// @dev Allows to mitigate \\\"stack too deep\\\" errors on EVM.\\n struct MovingFundsTxOutputsProcessingInfo {\\n // 32-byte hash of the moving funds Bitcoin transaction.\\n bytes32 movingFundsTxHash;\\n // Output vector of the moving funds Bitcoin transaction. It is\\n // assumed the vector's structure is valid so it must be validated\\n // using e.g. `BTCUtils.validateVout` function before being used\\n // during the processing. The validation is usually done as part\\n // of the `BitcoinTx.validateProof` call that checks the SPV proof.\\n bytes movingFundsTxOutputVector;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n /// @notice Represents moved funds sweep request state.\\n enum MovedFundsSweepRequestState {\\n /// @dev The request is unknown to the Bridge.\\n Unknown,\\n /// @dev Request is pending and can become either processed or timed out.\\n Pending,\\n /// @dev Request was processed by the target wallet.\\n Processed,\\n /// @dev Request was not processed in the given time window and\\n /// the timeout was reported.\\n TimedOut\\n }\\n\\n /// @notice Represents a moved funds sweep request. The request is\\n /// registered in `submitMovingFundsProof` where we know funds\\n /// have been moved to the target wallet and the only step left is\\n /// to have the target wallet sweep them.\\n struct MovedFundsSweepRequest {\\n // 20-byte public key hash of the wallet supposed to sweep the UTXO\\n // representing the received funds with their own main UTXO\\n bytes20 walletPubKeyHash;\\n // Value of the received funds.\\n uint64 value;\\n // UNIX timestamp the request was created at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 createdAt;\\n // The current state of the request.\\n MovedFundsSweepRequestState state;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event MovingFundsCommitmentSubmitted(\\n bytes20 indexed walletPubKeyHash,\\n bytes20[] targetWallets,\\n address submitter\\n );\\n\\n event MovingFundsTimeoutReset(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash\\n );\\n\\n event MovingFundsTimedOut(bytes20 indexed walletPubKeyHash);\\n\\n event MovingFundsBelowDustReported(bytes20 indexed walletPubKeyHash);\\n\\n event MovedFundsSwept(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 sweepTxHash\\n );\\n\\n event MovedFundsSweepTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex\\n );\\n\\n /// @notice Submits the moving funds target wallets commitment.\\n /// Once all requirements are met, that function registers the\\n /// target wallets commitment and opens the way for moving funds\\n /// proof submission.\\n /// @param walletPubKeyHash 20-byte public key hash of the source wallet.\\n /// @param walletMainUtxo Data of the source wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletMembersIDs Identifiers of the source wallet signing group\\n /// members.\\n /// @param walletMemberIndex Position of the caller in the source wallet\\n /// signing group members list.\\n /// @param targetWallets List of 20-byte public key hashes of the target\\n /// wallets that the source wallet commits to move the funds to.\\n /// @dev Requirements:\\n /// - The source wallet must be in the MovingFunds state,\\n /// - The source wallet must not have pending redemption requests,\\n /// - The source wallet must not have pending moved funds sweep requests,\\n /// - The source wallet must not have submitted its commitment already,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given source wallet in the ECDSA registry. Those IDs are\\n /// not directly stored in the contract for gas efficiency purposes\\n /// but they can be read from appropriate `DkgResultSubmitted`\\n /// and `DkgResultApproved` events,\\n /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],\\n /// - The caller must be the member of the source wallet signing group\\n /// at the position indicated by `walletMemberIndex` parameter,\\n /// - The `walletMainUtxo` components must point to the recent main\\n /// UTXO of the source wallet, as currently known on the Ethereum\\n /// chain,\\n /// - Source wallet BTC balance must be greater than zero,\\n /// - At least one Live wallet must exist in the system,\\n /// - Submitted target wallets count must match the expected count\\n /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`\\n /// where `N > 0`,\\n /// - Each target wallet must be not equal to the source wallet,\\n /// - Each target wallet must follow the expected order i.e. all\\n /// target wallets 20-byte public key hashes represented as numbers\\n /// must form a strictly increasing sequence without duplicates,\\n /// - Each target wallet must be in Live state.\\n function submitMovingFundsCommitment(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo,\\n uint32[] calldata walletMembersIDs,\\n uint256 walletMemberIndex,\\n bytes20[] calldata targetWallets\\n ) external {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.MovingFunds,\\n \\\"Source wallet must be in MovingFunds state\\\"\\n );\\n\\n require(\\n wallet.pendingRedemptionsValue == 0,\\n \\\"Source wallet must handle all pending redemptions first\\\"\\n );\\n\\n require(\\n wallet.pendingMovedFundsSweepRequestsCount == 0,\\n \\\"Source wallet must handle all pending moved funds sweep requests first\\\"\\n );\\n\\n require(\\n wallet.movingFundsTargetWalletsCommitmentHash == bytes32(0),\\n \\\"Target wallets commitment already submitted\\\"\\n );\\n\\n require(\\n self.ecdsaWalletRegistry.isWalletMember(\\n wallet.ecdsaWalletID,\\n walletMembersIDs,\\n msg.sender,\\n walletMemberIndex\\n ),\\n \\\"Caller is not a member of the source wallet\\\"\\n );\\n\\n uint64 walletBtcBalance = self.getWalletBtcBalance(\\n walletPubKeyHash,\\n walletMainUtxo\\n );\\n\\n require(walletBtcBalance > 0, \\\"Wallet BTC balance is zero\\\");\\n\\n uint256 expectedTargetWalletsCount = Math.min(\\n self.liveWalletsCount,\\n Math.ceilDiv(walletBtcBalance, self.walletMaxBtcTransfer)\\n );\\n\\n // This requirement fails only when `liveWalletsCount` is zero. In\\n // that case, the system cannot accept the commitment and must provide\\n // new wallets first. However, the wallet supposed to submit the\\n // commitment can keep resetting the moving funds timeout until then.\\n require(expectedTargetWalletsCount > 0, \\\"No target wallets available\\\");\\n\\n require(\\n targetWallets.length == expectedTargetWalletsCount,\\n \\\"Submitted target wallets count is other than expected\\\"\\n );\\n\\n uint160 lastProcessedTargetWallet = 0;\\n\\n for (uint256 i = 0; i < targetWallets.length; i++) {\\n bytes20 targetWallet = targetWallets[i];\\n\\n require(\\n targetWallet != walletPubKeyHash,\\n \\\"Submitted target wallet cannot be equal to the source wallet\\\"\\n );\\n\\n require(\\n uint160(targetWallet) > lastProcessedTargetWallet,\\n \\\"Submitted target wallet breaks the expected order\\\"\\n );\\n\\n require(\\n self.registeredWallets[targetWallet].state ==\\n Wallets.WalletState.Live,\\n \\\"Submitted target wallet must be in Live state\\\"\\n );\\n\\n lastProcessedTargetWallet = uint160(targetWallet);\\n }\\n\\n wallet.movingFundsTargetWalletsCommitmentHash = keccak256(\\n abi.encodePacked(targetWallets)\\n );\\n\\n emit MovingFundsCommitmentSubmitted(\\n walletPubKeyHash,\\n targetWallets,\\n msg.sender\\n );\\n }\\n\\n /// @notice Resets the moving funds timeout for the given wallet if the\\n /// target wallet commitment cannot be submitted due to a lack\\n /// of live wallets in the system.\\n /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The target wallets commitment must not be already submitted for\\n /// the given moving funds wallet,\\n /// - Live wallets count must be zero,\\n /// - The moving funds timeout reset delay must be elapsed.\\n function resetMovingFundsTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) external {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n // If the moving funds wallet already submitted their target wallets\\n // commitment, there is no point to reset the timeout since the\\n // wallet can make the BTC transaction and submit the proof.\\n require(\\n wallet.movingFundsTargetWalletsCommitmentHash == bytes32(0),\\n \\\"Target wallets commitment already submitted\\\"\\n );\\n\\n require(self.liveWalletsCount == 0, \\\"Live wallets count must be zero\\\");\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >\\n wallet.movingFundsRequestedAt +\\n self.movingFundsTimeoutResetDelay,\\n \\\"Moving funds timeout cannot be reset yet\\\"\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.movingFundsRequestedAt = uint32(block.timestamp);\\n\\n emit MovingFundsTimeoutReset(walletPubKeyHash);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moving funds transaction\\n /// and to make the necessary state changes. Moving funds is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the moving funds transaction structure\\n /// by checking if it actually spends the main UTXO of the declared\\n /// wallet and locks the value on the pre-committed target wallets\\n /// using a reasonable transaction fee. If all preconditions are\\n /// met, this functions closes the source wallet.\\n ///\\n /// It is possible to prove the given moving funds transaction only\\n /// one time.\\n /// @param movingFundsTx Bitcoin moving funds transaction data.\\n /// @param movingFundsProof Bitcoin moving funds proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet\\n /// which performed the moving funds transaction.\\n /// @dev Requirements:\\n /// - `movingFundsTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `movingFundsTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs corresponding to the\\n /// pre-committed target wallets. Outputs must be ordered in the\\n /// same way as their corresponding target wallets are ordered\\n /// within the target wallets commitment,\\n /// - `movingFundsProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input,\\n /// - The wallet that `walletPubKeyHash` points to must be in the\\n /// MovingFunds state,\\n /// - The target wallets commitment must be submitted by the wallet\\n /// that `walletPubKeyHash` points to,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movingFundsTxMaxTotalFee` governable parameter.\\n function submitMovingFundsProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata movingFundsTx,\\n BitcoinTx.Proof calldata movingFundsProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external {\\n // Wallet state is validated in `notifyWalletFundsMoved`.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 movingFundsTxHash = self.validateProof(\\n movingFundsTx,\\n movingFundsProof\\n );\\n\\n // Assert that main UTXO for passed wallet exists in storage.\\n bytes32 mainUtxoHash = self\\n .registeredWallets[walletPubKeyHash]\\n .mainUtxoHash;\\n require(mainUtxoHash != bytes32(0), \\\"No main UTXO for given wallet\\\");\\n\\n // Assert that passed main UTXO parameter is the same as in storage and\\n // can be used for further processing.\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n\\n // Process the moving funds transaction input. Specifically, check if\\n // it refers to the expected wallet's main UTXO.\\n OutboundTx.processWalletOutboundTxInput(\\n self,\\n movingFundsTx.inputVector,\\n mainUtxo\\n );\\n\\n (\\n bytes32 targetWalletsHash,\\n uint256 outputsTotalValue\\n ) = processMovingFundsTxOutputs(\\n self,\\n MovingFundsTxOutputsProcessingInfo(\\n movingFundsTxHash,\\n movingFundsTx.outputVector\\n )\\n );\\n\\n require(\\n mainUtxo.txOutputValue - outputsTotalValue <=\\n self.movingFundsTxMaxTotalFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n self.notifyWalletFundsMoved(walletPubKeyHash, targetWalletsHash);\\n // slither-disable-next-line reentrancy-events\\n emit MovingFundsCompleted(walletPubKeyHash, movingFundsTxHash);\\n }\\n\\n /// @notice Processes the moving funds Bitcoin transaction output vector\\n /// and extracts information required for further processing.\\n /// @param processInfo Processing info containing the moving funds tx\\n /// hash and output vector.\\n /// @return targetWalletsHash keccak256 hash over the list of actual\\n /// target wallets used in the transaction.\\n /// @return outputsTotalValue Sum of all outputs values.\\n /// @dev Requirements:\\n /// - The `movingFundsTxOutputVector` must be parseable, i.e. must\\n /// be validated by the caller as stated in their parameter doc,\\n /// - Each output must refer to a 20-byte public key hash,\\n /// - The total outputs value must be evenly divided over all outputs.\\n function processMovingFundsTxOutputs(\\n BridgeState.Storage storage self,\\n MovingFundsTxOutputsProcessingInfo memory processInfo\\n ) internal returns (bytes32 targetWalletsHash, uint256 outputsTotalValue) {\\n // Determining the total number of Bitcoin transaction outputs in\\n // the same way as for number of inputs. See `BitcoinTx.outputVector`\\n // docs for more details.\\n (\\n uint256 outputsCompactSizeUintLength,\\n uint256 outputsCount\\n ) = processInfo.movingFundsTxOutputVector.parseVarInt();\\n\\n // To determine the first output starting index, we must jump over\\n // the compactSize uint which prepends the output vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 outputStartingIndex = 1 + outputsCompactSizeUintLength;\\n\\n bytes20[] memory targetWallets = new bytes20[](outputsCount);\\n uint64[] memory outputsValues = new uint64[](outputsCount);\\n\\n // Outputs processing loop. Note that the `outputIndex` must be\\n // `uint32` to build proper `movedFundsSweepRequests` keys.\\n for (\\n uint32 outputIndex = 0;\\n outputIndex < outputsCount;\\n outputIndex++\\n ) {\\n uint256 outputLength = processInfo\\n .movingFundsTxOutputVector\\n .determineOutputLengthAt(outputStartingIndex);\\n\\n bytes memory output = processInfo.movingFundsTxOutputVector.slice(\\n outputStartingIndex,\\n outputLength\\n );\\n\\n bytes20 targetWalletPubKeyHash = self.extractPubKeyHash(output);\\n\\n // Add the wallet public key hash to the list that will be used\\n // to build the result list hash. There is no need to check if\\n // given output is a change here because the actual target wallet\\n // list must be exactly the same as the pre-committed target wallet\\n // list which is guaranteed to be valid.\\n targetWallets[outputIndex] = targetWalletPubKeyHash;\\n\\n // Extract the value from given output.\\n outputsValues[outputIndex] = output.extractValue();\\n outputsTotalValue += outputsValues[outputIndex];\\n\\n // Register a moved funds sweep request that must be handled\\n // by the target wallet. The target wallet must sweep the\\n // received funds with their own main UTXO in order to update\\n // their BTC balance. Worth noting there is no need to check\\n // if the sweep request already exists in the system because\\n // the moving funds wallet is moved to the Closing state after\\n // submitting the moving funds proof so there is no possibility\\n // to submit the proof again and register the sweep request twice.\\n self.movedFundsSweepRequests[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n processInfo.movingFundsTxHash,\\n outputIndex\\n )\\n )\\n )\\n ] = MovedFundsSweepRequest(\\n targetWalletPubKeyHash,\\n outputsValues[outputIndex],\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp),\\n MovedFundsSweepRequestState.Pending\\n );\\n // We added a new moved funds sweep request for the target wallet\\n // so we must increment their request counter.\\n self\\n .registeredWallets[targetWalletPubKeyHash]\\n .pendingMovedFundsSweepRequestsCount++;\\n\\n // Make the `outputStartingIndex` pointing to the next output by\\n // increasing it by current output's length.\\n outputStartingIndex += outputLength;\\n }\\n\\n // Compute the indivisible remainder that remains after dividing the\\n // outputs total value over all outputs evenly.\\n uint256 outputsTotalValueRemainder = outputsTotalValue % outputsCount;\\n // Compute the minimum allowed output value by dividing the outputs\\n // total value (reduced by the remainder) by the number of outputs.\\n uint256 minOutputValue = (outputsTotalValue -\\n outputsTotalValueRemainder) / outputsCount;\\n // Maximum possible value is the minimum value with the remainder included.\\n uint256 maxOutputValue = minOutputValue + outputsTotalValueRemainder;\\n\\n for (uint256 i = 0; i < outputsCount; i++) {\\n require(\\n minOutputValue <= outputsValues[i] &&\\n outputsValues[i] <= maxOutputValue,\\n \\\"Transaction amount is not distributed evenly\\\"\\n );\\n }\\n\\n targetWalletsHash = keccak256(abi.encodePacked(targetWallets));\\n\\n return (targetWalletsHash, outputsTotalValue);\\n }\\n\\n /// @notice Notifies about a timed out moving funds process. Terminates\\n /// the wallet and slashes signing group members as a result.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The moving funds timeout must be actually exceeded,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovingFundsTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n // Wallet state is validated in `notifyWalletMovingFundsTimeout`.\\n\\n uint32 movingFundsRequestedAt = self\\n .registeredWallets[walletPubKeyHash]\\n .movingFundsRequestedAt;\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp > movingFundsRequestedAt + self.movingFundsTimeout,\\n \\\"Moving funds has not timed out yet\\\"\\n );\\n\\n self.notifyWalletMovingFundsTimeout(walletPubKeyHash, walletMembersIDs);\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovingFundsTimedOut(walletPubKeyHash);\\n }\\n\\n /// @notice Notifies about a moving funds wallet whose BTC balance is\\n /// below the moving funds dust threshold. Ends the moving funds\\n /// process and begins wallet closing immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known\\n /// on the Ethereum chain.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state,\\n /// - The `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If the wallet has no main UTXO, this parameter can be empty as it\\n /// is ignored,\\n /// - The wallet BTC balance must be below the moving funds threshold.\\n function notifyMovingFundsBelowDust(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external {\\n // Wallet state is validated in `notifyWalletMovingFundsBelowDust`.\\n\\n uint64 walletBtcBalance = self.getWalletBtcBalance(\\n walletPubKeyHash,\\n mainUtxo\\n );\\n\\n require(\\n walletBtcBalance < self.movingFundsDustThreshold,\\n \\\"Wallet BTC balance must be below the moving funds dust threshold\\\"\\n );\\n\\n self.notifyWalletMovingFundsBelowDust(walletPubKeyHash);\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovingFundsBelowDustReported(walletPubKeyHash);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC moved funds sweep\\n /// transaction and to make the necessary state changes. Moved\\n /// funds sweep is only accepted if it satisfies SPV proof.\\n ///\\n /// The function validates the sweep transaction structure by\\n /// checking if it actually spends the moved funds UTXO and the\\n /// sweeping wallet's main UTXO (optionally), and if it locks the\\n /// value on the sweeping wallet's 20-byte public key hash using a\\n /// reasonable transaction fee. If all preconditions are\\n /// met, this function updates the sweeping wallet main UTXO, thus\\n /// their BTC balance.\\n ///\\n /// It is possible to prove the given sweep transaction only\\n /// one time.\\n /// @param sweepTx Bitcoin sweep funds transaction data.\\n /// @param sweepProof Bitcoin sweep funds proof data.\\n /// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `sweepTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `sweepTx` should represent a Bitcoin transaction with\\n /// the first input pointing to a wallet's sweep Pending request and,\\n /// optionally, the second input pointing to the wallet's main UTXO,\\n /// if the sweeping wallet has a main UTXO set. There should be only\\n /// one output locking funds on the sweeping wallet 20-byte public\\n /// key hash,\\n /// - `sweepProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the sweeping wallet, as currently known on the Ethereum chain.\\n /// If there is no main UTXO, this parameter is ignored,\\n /// - The sweeping wallet must be in the Live or MovingFunds state,\\n /// - The total Bitcoin transaction fee must be lesser or equal\\n /// to `movedFundsSweepTxMaxTotalFee` governable parameter.\\n function submitMovedFundsSweepProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata sweepTx,\\n BitcoinTx.Proof calldata sweepProof,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) external {\\n // Wallet state validation is performed in the\\n // `resolveMovedFundsSweepingWallet` function.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 sweepTxHash = self.validateProof(sweepTx, sweepProof);\\n\\n (\\n bytes20 walletPubKeyHash,\\n uint64 sweepTxOutputValue\\n ) = processMovedFundsSweepTxOutput(self, sweepTx.outputVector);\\n\\n (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n ) = resolveMovedFundsSweepingWallet(self, walletPubKeyHash, mainUtxo);\\n\\n uint256 sweepTxInputsTotalValue = processMovedFundsSweepTxInputs(\\n self,\\n sweepTx.inputVector,\\n resolvedMainUtxo,\\n walletPubKeyHash\\n );\\n\\n require(\\n sweepTxInputsTotalValue - sweepTxOutputValue <=\\n self.movedFundsSweepTxMaxTotalFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n // Use the sweep transaction output as the new sweeping wallet's main UTXO.\\n // Transaction output index is always 0 as sweep transaction always\\n // contains only one output.\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(sweepTxHash, uint32(0), sweepTxOutputValue)\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovedFundsSwept(walletPubKeyHash, sweepTxHash);\\n }\\n\\n /// @notice Processes the Bitcoin moved funds sweep transaction output vector\\n /// by extracting the single output and using it to gain additional\\n /// information required for further processing (e.g. value and\\n /// wallet public key hash).\\n /// @param sweepTxOutputVector Bitcoin moved funds sweep transaction output\\n /// vector.\\n /// This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVout` function before\\n /// it is passed here.\\n /// @return walletPubKeyHash 20-byte wallet public key hash.\\n /// @return value 8-byte moved funds sweep transaction output value.\\n /// @dev Requirements:\\n /// - Output vector must contain only one output,\\n /// - The single output must be of P2PKH or P2WPKH type and lock the\\n /// funds on a 20-byte public key hash.\\n function processMovedFundsSweepTxOutput(\\n BridgeState.Storage storage self,\\n bytes memory sweepTxOutputVector\\n ) internal view returns (bytes20 walletPubKeyHash, uint64 value) {\\n // To determine the total number of sweep transaction outputs, we need to\\n // parse the compactSize uint (VarInt) the output vector is prepended by.\\n // That compactSize uint encodes the number of vector elements using the\\n // format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVout` validation performed as\\n // part of the `BitcoinTx.validateProof` call.\\n // See `BitcoinTx.outputVector` docs for more details.\\n (, uint256 outputsCount) = sweepTxOutputVector.parseVarInt();\\n require(\\n outputsCount == 1,\\n \\\"Moved funds sweep transaction must have a single output\\\"\\n );\\n\\n bytes memory output = sweepTxOutputVector.extractOutputAtIndex(0);\\n walletPubKeyHash = self.extractPubKeyHash(output);\\n value = output.extractValue();\\n\\n return (walletPubKeyHash, value);\\n }\\n\\n /// @notice Resolves sweeping wallet based on the provided wallet public key\\n /// hash. Validates the wallet state and current main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletPubKeyHash public key hash of the wallet proving the sweep\\n /// Bitcoin transaction.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain. If no main UTXO exists for the given wallet,\\n /// this parameter is ignored.\\n /// @return wallet Data of the sweeping wallet.\\n /// @return resolvedMainUtxo The actual main UTXO of the sweeping wallet\\n /// resolved by cross-checking the `mainUtxo` parameter with\\n /// the chain state. If the validation went well, this is the\\n /// plain-text main UTXO corresponding to the `wallet.mainUtxoHash`.\\n /// @dev Requirements:\\n /// - Sweeping wallet must be either in Live or MovingFunds state,\\n /// - If the main UTXO of the sweeping wallet exists in the storage,\\n /// the passed `mainUTXO` parameter must be equal to the stored one.\\n function resolveMovedFundsSweepingWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n )\\n internal\\n view\\n returns (\\n Wallets.Wallet storage wallet,\\n BitcoinTx.UTXO memory resolvedMainUtxo\\n )\\n {\\n wallet = self.registeredWallets[walletPubKeyHash];\\n\\n Wallets.WalletState walletState = wallet.state;\\n require(\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in Live or MovingFunds state\\\"\\n );\\n\\n // Check if the main UTXO for given wallet exists. If so, validate\\n // passed main UTXO data against the stored hash and use them for\\n // further processing. If no main UTXO exists, use empty data.\\n resolvedMainUtxo = BitcoinTx.UTXO(bytes32(0), 0, 0);\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n if (mainUtxoHash != bytes32(0)) {\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n resolvedMainUtxo = mainUtxo;\\n }\\n }\\n\\n /// @notice Processes the Bitcoin moved funds sweep transaction input vector.\\n /// It extracts the first input and tries to match it with one of\\n /// the moved funds sweep requests targeting the sweeping wallet.\\n /// If the sweep request is an existing Pending request, this\\n /// function marks it as Processed. If the sweeping wallet has a\\n /// main UTXO, this function extracts the second input, makes sure\\n /// it refers to the wallet main UTXO, and marks that main UTXO as\\n /// correctly spent.\\n /// @param sweepTxInputVector Bitcoin moved funds sweep transaction input vector.\\n /// This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVin` function before\\n /// it is passed here.\\n /// @param mainUtxo Data of the sweeping wallet's main UTXO. If no main UTXO\\n /// exists for the given the wallet, this parameter's fields should\\n /// be zeroed to bypass the main UTXO validation.\\n /// @param walletPubKeyHash 20-byte public key hash of the sweeping wallet.\\n /// @return inputsTotalValue Total inputs value sum.\\n /// @dev Requirements:\\n /// - The input vector must consist of one mandatory and one optional\\n /// input,\\n /// - The mandatory input must be the first input in the vector,\\n /// - The mandatory input must point to a Pending moved funds sweep\\n /// request that is targeted to the sweeping wallet,\\n /// - The optional output must be the second input in the vector,\\n /// - The optional input is required if the sweeping wallet has a\\n /// main UTXO (i.e. the `mainUtxo` is not zeroed). In that case,\\n /// that input must point the the sweeping wallet main UTXO.\\n function processMovedFundsSweepTxInputs(\\n BridgeState.Storage storage self,\\n bytes memory sweepTxInputVector,\\n BitcoinTx.UTXO memory mainUtxo,\\n bytes20 walletPubKeyHash\\n ) internal returns (uint256 inputsTotalValue) {\\n // To determine the total number of Bitcoin transaction inputs,\\n // we need to parse the compactSize uint (VarInt) the input vector is\\n // prepended by. That compactSize uint encodes the number of vector\\n // elements using the format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVin` validation performed as\\n // part of the `BitcoinTx.validateProof` call.\\n // See `BitcoinTx.inputVector` docs for more details.\\n (\\n uint256 inputsCompactSizeUintLength,\\n uint256 inputsCount\\n ) = sweepTxInputVector.parseVarInt();\\n\\n // To determine the first input starting index, we must jump over\\n // the compactSize uint which prepends the input vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 inputStartingIndex = 1 + inputsCompactSizeUintLength;\\n\\n // We always expect the first input to be the swept UTXO. Additionally,\\n // if the sweeping wallet has a main UTXO, that main UTXO should be\\n // pointed by the second input.\\n require(\\n inputsCount == (mainUtxo.txHash != bytes32(0) ? 2 : 1),\\n \\\"Moved funds sweep transaction must have a proper inputs count\\\"\\n );\\n\\n // Parse the first input and extract its outpoint tx hash and index.\\n (\\n bytes32 firstInputOutpointTxHash,\\n uint32 firstInputOutpointIndex,\\n uint256 firstInputLength\\n ) = parseMovedFundsSweepTxInputAt(\\n sweepTxInputVector,\\n inputStartingIndex\\n );\\n\\n // Build the request key and fetch the corresponding moved funds sweep\\n // request from contract storage.\\n MovedFundsSweepRequest storage sweepRequest = self\\n .movedFundsSweepRequests[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n firstInputOutpointTxHash,\\n firstInputOutpointIndex\\n )\\n )\\n )\\n ];\\n\\n require(\\n sweepRequest.state == MovedFundsSweepRequestState.Pending,\\n \\\"Sweep request must be in Pending state\\\"\\n );\\n // We must check if the wallet extracted from the moved funds sweep\\n // transaction output is truly the owner of the sweep request connected\\n // with the swept UTXO. This is needed to prevent a case when a wallet\\n // handles its own sweep request but locks the funds on another\\n // wallet public key hash.\\n require(\\n sweepRequest.walletPubKeyHash == walletPubKeyHash,\\n \\\"Sweep request belongs to another wallet\\\"\\n );\\n // If the validation passed, the sweep request must be marked as\\n // processed and its value should be counted into the total inputs\\n // value sum.\\n sweepRequest.state = MovedFundsSweepRequestState.Processed;\\n inputsTotalValue += sweepRequest.value;\\n\\n self\\n .registeredWallets[walletPubKeyHash]\\n .pendingMovedFundsSweepRequestsCount--;\\n\\n // If the main UTXO for the sweeping wallet exists, it must be processed.\\n if (mainUtxo.txHash != bytes32(0)) {\\n // The second input is supposed to point to that sweeping wallet\\n // main UTXO. We need to parse that input.\\n (\\n bytes32 secondInputOutpointTxHash,\\n uint32 secondInputOutpointIndex,\\n\\n ) = parseMovedFundsSweepTxInputAt(\\n sweepTxInputVector,\\n inputStartingIndex + firstInputLength\\n );\\n // Make sure the second input refers to the sweeping wallet main UTXO.\\n require(\\n mainUtxo.txHash == secondInputOutpointTxHash &&\\n mainUtxo.txOutputIndex == secondInputOutpointIndex,\\n \\\"Second input must point to the wallet's main UTXO\\\"\\n );\\n\\n // If the validation passed, count the main UTXO value into the\\n // total inputs value sum.\\n inputsTotalValue += mainUtxo.txOutputValue;\\n\\n // Main UTXO used as an input, mark it as spent. This is needed\\n // to defend against fraud challenges referring to this main UTXO.\\n self.spentMainUTXOs[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n secondInputOutpointTxHash,\\n secondInputOutpointIndex\\n )\\n )\\n )\\n ] = true;\\n }\\n\\n return inputsTotalValue;\\n }\\n\\n /// @notice Parses a Bitcoin transaction input starting at the given index.\\n /// @param inputVector Bitcoin transaction input vector.\\n /// @param inputStartingIndex Index the given input starts at.\\n /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is\\n /// pointed in the given input's outpoint.\\n /// @return outpointIndex 4-byte index of the Bitcoin transaction output\\n /// which is pointed in the given input's outpoint.\\n /// @return inputLength Byte length of the given input.\\n /// @dev This function assumes vector's structure is valid so it must be\\n /// validated using e.g. `BTCUtils.validateVin` function before it\\n /// is passed here.\\n function parseMovedFundsSweepTxInputAt(\\n bytes memory inputVector,\\n uint256 inputStartingIndex\\n )\\n internal\\n pure\\n returns (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex,\\n uint256 inputLength\\n )\\n {\\n outpointTxHash = inputVector.extractInputTxIdLeAt(inputStartingIndex);\\n\\n outpointIndex = BTCUtils.reverseUint32(\\n uint32(inputVector.extractTxIndexLeAt(inputStartingIndex))\\n );\\n\\n inputLength = inputVector.determineInputLengthAt(inputStartingIndex);\\n\\n return (outpointTxHash, outpointIndex, inputLength);\\n }\\n\\n /// @notice Notifies about a timed out moved funds sweep process. If the\\n /// wallet is not terminated yet, that function terminates\\n /// the wallet and slashes signing group members as a result.\\n /// Marks the given sweep request as TimedOut.\\n /// @param movingFundsTxHash 32-byte hash of the moving funds transaction\\n /// that caused the sweep request to be created.\\n /// @param movingFundsTxOutputIndex Index of the moving funds transaction\\n /// output that is subject of the sweep request.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The moved funds sweep request must be in the Pending state,\\n /// - The moved funds sweep timeout must be actually exceeded,\\n /// - The wallet must be either in the Live or MovingFunds or\\n /// Terminated state,,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract.\\n function notifyMovedFundsSweepTimeout(\\n BridgeState.Storage storage self,\\n bytes32 movingFundsTxHash,\\n uint32 movingFundsTxOutputIndex,\\n uint32[] calldata walletMembersIDs\\n ) external {\\n // Wallet state is validated in `notifyWalletMovedFundsSweepTimeout`.\\n\\n MovedFundsSweepRequest storage sweepRequest = self\\n .movedFundsSweepRequests[\\n uint256(\\n keccak256(\\n abi.encodePacked(\\n movingFundsTxHash,\\n movingFundsTxOutputIndex\\n )\\n )\\n )\\n ];\\n\\n require(\\n sweepRequest.state == MovedFundsSweepRequestState.Pending,\\n \\\"Sweep request must be in Pending state\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >\\n sweepRequest.createdAt + self.movedFundsSweepTimeout,\\n \\\"Sweep request has not timed out yet\\\"\\n );\\n\\n bytes20 walletPubKeyHash = sweepRequest.walletPubKeyHash;\\n\\n self.notifyWalletMovedFundsSweepTimeout(\\n walletPubKeyHash,\\n walletMembersIDs\\n );\\n\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n sweepRequest.state = MovedFundsSweepRequestState.TimedOut;\\n wallet.pendingMovedFundsSweepRequestsCount--;\\n\\n // slither-disable-next-line reentrancy-events\\n emit MovedFundsSweepTimedOut(\\n walletPubKeyHash,\\n movingFundsTxHash,\\n movingFundsTxOutputIndex\\n );\\n }\\n}\\n\",\"keccak256\":\"0xce1afc1875d364e64cfa088558ee166a441e55ef6727f38002934654ac14b25d\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Redemption.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {BytesLib} from \\\"@keep-network/bitcoin-spv-sol/contracts/BytesLib.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\nimport \\\"./Wallets.sol\\\";\\n\\nimport \\\"../bank/Bank.sol\\\";\\n\\n/// @notice Aggregates functions common to the redemption transaction proof\\n/// validation and to the moving funds transaction proof validation.\\nlibrary OutboundTx {\\n using BTCUtils for bytes;\\n\\n /// @notice Checks whether an outbound Bitcoin transaction performed from\\n /// the given wallet has an input vector that contains a single\\n /// input referring to the wallet's main UTXO. Marks that main UTXO\\n /// as correctly spent if the validation succeeds. Reverts otherwise.\\n /// There are two outbound transactions from a wallet possible: a\\n /// redemption transaction or a moving funds to another wallet\\n /// transaction.\\n /// @param walletOutboundTxInputVector Bitcoin outbound transaction's input\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVin` function\\n /// before it is passed here.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n function processWalletOutboundTxInput(\\n BridgeState.Storage storage self,\\n bytes memory walletOutboundTxInputVector,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) internal {\\n // Assert that the single outbound transaction input actually\\n // refers to the wallet's main UTXO.\\n (\\n bytes32 outpointTxHash,\\n uint32 outpointIndex\\n ) = parseWalletOutboundTxInput(walletOutboundTxInputVector);\\n require(\\n mainUtxo.txHash == outpointTxHash &&\\n mainUtxo.txOutputIndex == outpointIndex,\\n \\\"Outbound transaction input must point to the wallet's main UTXO\\\"\\n );\\n\\n // Main UTXO used as an input, mark it as spent.\\n self.spentMainUTXOs[\\n uint256(\\n keccak256(\\n abi.encodePacked(mainUtxo.txHash, mainUtxo.txOutputIndex)\\n )\\n )\\n ] = true;\\n }\\n\\n /// @notice Parses the input vector of an outbound Bitcoin transaction\\n /// performed from the given wallet. It extracts the single input\\n /// then the transaction hash and output index from its outpoint.\\n /// There are two outbound transactions from a wallet possible: a\\n /// redemption transaction or a moving funds to another wallet\\n /// transaction.\\n /// @param walletOutboundTxInputVector Bitcoin outbound transaction input\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVin` function\\n /// before it is passed here.\\n /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is\\n /// pointed in the input's outpoint.\\n /// @return outpointIndex 4-byte index of the Bitcoin transaction output\\n /// which is pointed in the input's outpoint.\\n function parseWalletOutboundTxInput(\\n bytes memory walletOutboundTxInputVector\\n ) internal pure returns (bytes32 outpointTxHash, uint32 outpointIndex) {\\n // To determine the total number of Bitcoin transaction inputs,\\n // we need to parse the compactSize uint (VarInt) the input vector is\\n // prepended by. That compactSize uint encodes the number of vector\\n // elements using the format presented in:\\n // https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers\\n // We don't need asserting the compactSize uint is parseable since it\\n // was already checked during `validateVin` validation.\\n // See `BitcoinTx.inputVector` docs for more details.\\n (, uint256 inputsCount) = walletOutboundTxInputVector.parseVarInt();\\n require(\\n inputsCount == 1,\\n \\\"Outbound transaction must have a single input\\\"\\n );\\n\\n bytes memory input = walletOutboundTxInputVector.extractInputAtIndex(0);\\n\\n outpointTxHash = input.extractInputTxIdLE();\\n\\n outpointIndex = BTCUtils.reverseUint32(\\n uint32(input.extractTxIndexLE())\\n );\\n\\n // There is only one input in the transaction. Input has an outpoint\\n // field that is a reference to the transaction being spent (see\\n // `BitcoinTx` docs). The outpoint contains the hash of the transaction\\n // to spend (`outpointTxHash`) and the index of the specific output\\n // from that transaction (`outpointIndex`).\\n return (outpointTxHash, outpointIndex);\\n }\\n}\\n\\n/// @title Bridge redemption\\n/// @notice The library handles the logic for redeeming Bitcoin balances from\\n/// the Bridge.\\n/// @dev To initiate a redemption, a user with a Bank balance supplies\\n/// a Bitcoin address. Then, the system calculates the redemption fee, and\\n/// releases balance to the provided Bitcoin address. Just like in case of\\n/// sweeps of revealed deposits, redemption requests are processed in\\n/// batches and require SPV proof to be submitted to the Bridge.\\nlibrary Redemption {\\n using BridgeState for BridgeState.Storage;\\n using Wallets for BridgeState.Storage;\\n using BitcoinTx for BridgeState.Storage;\\n\\n using BTCUtils for bytes;\\n using BytesLib for bytes;\\n\\n /// @notice Represents a redemption request.\\n struct RedemptionRequest {\\n // ETH address of the redeemer who created the request.\\n address redeemer;\\n // Requested TBTC amount in satoshi.\\n uint64 requestedAmount;\\n // Treasury TBTC fee in satoshi at the moment of request creation.\\n uint64 treasuryFee;\\n // Transaction maximum BTC fee in satoshi at the moment of request\\n // creation.\\n uint64 txMaxFee;\\n // UNIX timestamp the request was created at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 requestedAt;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n /// @notice Represents an outcome of the redemption Bitcoin transaction\\n /// outputs processing.\\n struct RedemptionTxOutputsInfo {\\n // Sum of all outputs values i.e. all redemptions and change value,\\n // if present.\\n uint256 outputsTotalValue;\\n // Total TBTC value in satoshi that should be burned by the Bridge.\\n // It includes the total amount of all BTC redeemed in the transaction\\n // and the fee paid to BTC miners for the redemption transaction.\\n uint64 totalBurnableValue;\\n // Total TBTC value in satoshi that should be transferred to\\n // the treasury. It is a sum of all treasury fees paid by all\\n // redeemers included in the redemption transaction.\\n uint64 totalTreasuryFee;\\n // Index of the change output. The change output becomes\\n // the new main wallet's UTXO.\\n uint32 changeIndex;\\n // Value in satoshi of the change output.\\n uint64 changeValue;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n /// @notice Represents temporary information needed during the processing of\\n /// the redemption Bitcoin transaction outputs. This structure is an\\n /// internal one and should not be exported outside of the redemption\\n /// transaction processing code.\\n /// @dev Allows to mitigate \\\"stack too deep\\\" errors on EVM.\\n struct RedemptionTxOutputsProcessingInfo {\\n // The first output starting index in the transaction.\\n uint256 outputStartingIndex;\\n // The number of outputs in the transaction.\\n uint256 outputsCount;\\n // P2PKH script for the wallet. Needed to determine the change output.\\n bytes32 walletP2PKHScriptKeccak;\\n // P2WPKH script for the wallet. Needed to determine the change output.\\n bytes32 walletP2WPKHScriptKeccak;\\n // This struct doesn't contain `__gap` property as the structure is not\\n // stored, it is used as a function's memory argument.\\n }\\n\\n event RedemptionRequested(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript,\\n address indexed redeemer,\\n uint64 requestedAmount,\\n uint64 treasuryFee,\\n uint64 txMaxFee\\n );\\n\\n event RedemptionsCompleted(\\n bytes20 indexed walletPubKeyHash,\\n bytes32 redemptionTxHash\\n );\\n\\n event RedemptionTimedOut(\\n bytes20 indexed walletPubKeyHash,\\n bytes redeemerOutputScript\\n );\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script.\\n /// This function handles the simplest case, where balance owner is\\n /// the redeemer.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed. Balance owner address is stored as\\n /// a redeemer address who will be able co claim back the Bank\\n /// balance if anything goes wrong during the redemption.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to proceed the request,\\n /// - Balance owner must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo,\\n address balanceOwner,\\n bytes calldata redeemerOutputScript,\\n uint64 amount\\n ) external {\\n requestRedemption(\\n self,\\n walletPubKeyHash,\\n mainUtxo,\\n balanceOwner,\\n balanceOwner,\\n redeemerOutputScript,\\n amount\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script. Used by\\n /// `Bridge.receiveBalanceApproval`. Can handle more complex cases\\n /// where balance owner may be someone else than the redeemer.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @param redemptionData ABI-encoded redemption data:\\n /// [\\n /// address redeemer,\\n /// bytes20 walletPubKeyHash,\\n /// bytes32 mainUtxoTxHash,\\n /// uint32 mainUtxoTxOutputIndex,\\n /// uint64 mainUtxoTxOutputValue,\\n /// bytes redeemerOutputScript\\n /// ]\\n ///\\n /// - redeemer: The Ethereum address of the redeemer who will be able\\n /// to claim Bank balance if anything goes wrong during the redemption.\\n /// In the most basic case, when someone redeems their Bitcoin\\n /// balance from the Bank, `balanceOwner` is the same as `redeemer`.\\n /// However, when a Vault is redeeming part of its balance for some\\n /// redeemer address (for example, someone who has earlier deposited\\n /// into that Vault), `balanceOwner` is the Vault, and `redeemer` is\\n /// the address for which the vault is redeeming its balance to,\\n /// - walletPubKeyHash: The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key),\\n /// - mainUtxoTxHash: Data of the wallet's main UTXO TX hash, as\\n /// currently known on the Ethereum chain,\\n /// - mainUtxoTxOutputIndex: Data of the wallet's main UTXO output\\n /// index, as currently known on Ethereum chain,\\n /// - mainUtxoTxOutputValue: Data of the wallet's main UTXO output\\n /// value, as currently known on Ethereum chain,\\n /// - redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo*` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to proceed the request,\\n /// - Balance owner must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n BridgeState.Storage storage self,\\n address balanceOwner,\\n uint64 amount,\\n bytes calldata redemptionData\\n ) external {\\n (\\n address redeemer,\\n bytes20 walletPubKeyHash,\\n bytes32 mainUtxoTxHash,\\n uint32 mainUtxoTxOutputIndex,\\n uint64 mainUtxoTxOutputValue,\\n bytes memory redeemerOutputScript\\n ) = abi.decode(\\n redemptionData,\\n (address, bytes20, bytes32, uint32, uint64, bytes)\\n );\\n\\n requestRedemption(\\n self,\\n walletPubKeyHash,\\n BitcoinTx.UTXO(\\n mainUtxoTxHash,\\n mainUtxoTxOutputIndex,\\n mainUtxoTxOutputValue\\n ),\\n balanceOwner,\\n redeemer,\\n redeemerOutputScript,\\n amount\\n );\\n }\\n\\n /// @notice Requests redemption of the given amount from the specified\\n /// wallet to the redeemer Bitcoin output script.\\n /// @param walletPubKeyHash The 20-byte wallet public key hash (computed\\n /// using Bitcoin HASH160 over the compressed ECDSA public key).\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param balanceOwner The address of the Bank balance owner whose balance\\n /// is getting redeemed.\\n /// @param redeemer The Ethereum address of the redeemer who will be able to\\n /// claim Bank balance if anything goes wrong during the redemption.\\n /// In the most basic case, when someone redeems their Bitcoin\\n /// balance from the Bank, `balanceOwner` is the same as `redeemer`.\\n /// However, when a Vault is redeeming part of its balance for some\\n /// redeemer address (for example, someone who has earlier deposited\\n /// into that Vault), `balanceOwner` is the Vault, and `redeemer` is\\n /// the address for which the vault is redeeming its balance to.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock\\n /// redeemed BTC.\\n /// @param amount Requested amount in satoshi. This is also the Bank balance\\n /// that is taken from the `balanceOwner` upon request.\\n /// Once the request is handled, the actual amount of BTC locked\\n /// on the redeemer output script will be always lower than this value\\n /// since the treasury and Bitcoin transaction fees must be incurred.\\n /// The minimal amount satisfying the request can be computed as:\\n /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.\\n /// Fees values are taken at the moment of request creation.\\n /// @dev Requirements:\\n /// - Wallet behind `walletPubKeyHash` must be live,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain,\\n /// - `redeemerOutputScript` must be a proper Bitcoin script,\\n /// - `redeemerOutputScript` cannot have wallet PKH as payload,\\n /// - `amount` must be above or equal the `redemptionDustThreshold`,\\n /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be\\n /// used for only one pending request at the same time,\\n /// - Wallet must have enough Bitcoin balance to proceed the request,\\n /// - Balance owner must make an allowance in the Bank that the Bridge\\n /// contract can spend the given `amount`.\\n function requestRedemption(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO memory mainUtxo,\\n address balanceOwner,\\n address redeemer,\\n bytes memory redeemerOutputScript,\\n uint64 amount\\n ) internal {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n require(\\n mainUtxoHash != bytes32(0),\\n \\\"No main UTXO for the given wallet\\\"\\n );\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n\\n // Validate if redeemer output script is a correct standard type\\n // (P2PKH, P2WPKH, P2SH or P2WSH). This is done by using\\n // `BTCUtils.extractHashAt` on it. Such a function extracts the payload\\n // properly only from standard outputs so if it succeeds, we have a\\n // guarantee the redeemer output script is proper. The underlying way\\n // of validation is the same as in tBTC v1.\\n bytes memory redeemerOutputScriptPayload = redeemerOutputScript\\n .extractHashAt(0, redeemerOutputScript.length);\\n\\n require(\\n redeemerOutputScriptPayload.length > 0,\\n \\\"Redeemer output script must be a standard type\\\"\\n );\\n // Check if the redeemer output script payload does not point to the\\n // wallet public key hash.\\n require(\\n redeemerOutputScriptPayload.length != 20 ||\\n walletPubKeyHash != redeemerOutputScriptPayload.slice20(0),\\n \\\"Redeemer output script must not point to the wallet PKH\\\"\\n );\\n\\n require(\\n amount >= self.redemptionDustThreshold,\\n \\\"Redemption amount too small\\\"\\n );\\n\\n // The redemption key is built on top of the wallet public key hash\\n // and redeemer output script pair. That means there can be only one\\n // request asking for redemption from the given wallet to the given\\n // BTC script at the same time.\\n uint256 redemptionKey = getRedemptionKey(\\n walletPubKeyHash,\\n redeemerOutputScript\\n );\\n\\n // Check if given redemption key is not used by a pending redemption.\\n // There is no need to check for existence in `timedOutRedemptions`\\n // since the wallet's state is changed to other than Live after\\n // first time out is reported so making new requests is not possible.\\n // slither-disable-next-line incorrect-equality\\n require(\\n self.pendingRedemptions[redemptionKey].requestedAt == 0,\\n \\\"There is a pending redemption request from this wallet to the same address\\\"\\n );\\n\\n // No need to check whether `amount - treasuryFee - txMaxFee > 0`\\n // since the `redemptionDustThreshold` should force that condition\\n // to be always true.\\n uint64 treasuryFee = self.redemptionTreasuryFeeDivisor > 0\\n ? amount / self.redemptionTreasuryFeeDivisor\\n : 0;\\n uint64 txMaxFee = self.redemptionTxMaxFee;\\n\\n // The main wallet UTXO's value doesn't include all pending redemptions.\\n // To determine if the requested redemption can be performed by the\\n // wallet we need to subtract the total value of all pending redemptions\\n // from that wallet's main UTXO value. Given that the treasury fee is\\n // not redeemed from the wallet, we are subtracting it.\\n wallet.pendingRedemptionsValue += amount - treasuryFee;\\n require(\\n mainUtxo.txOutputValue >= wallet.pendingRedemptionsValue,\\n \\\"Insufficient wallet funds\\\"\\n );\\n\\n self.pendingRedemptions[redemptionKey] = RedemptionRequest(\\n redeemer,\\n amount,\\n treasuryFee,\\n txMaxFee,\\n /* solhint-disable-next-line not-rely-on-time */\\n uint32(block.timestamp)\\n );\\n\\n // slither-disable-next-line reentrancy-events\\n emit RedemptionRequested(\\n walletPubKeyHash,\\n redeemerOutputScript,\\n redeemer,\\n amount,\\n treasuryFee,\\n txMaxFee\\n );\\n\\n self.bank.transferBalanceFrom(balanceOwner, address(this), amount);\\n }\\n\\n /// @notice Used by the wallet to prove the BTC redemption transaction\\n /// and to make the necessary bookkeeping. Redemption is only\\n /// accepted if it satisfies SPV proof.\\n ///\\n /// The function is performing Bank balance updates by burning\\n /// the total redeemed Bitcoin amount from Bridge balance and\\n /// transferring the treasury fee sum to the treasury address.\\n ///\\n /// It is possible to prove the given redemption only one time.\\n /// @param redemptionTx Bitcoin redemption transaction data.\\n /// @param redemptionProof Bitcoin redemption proof data.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @dev Requirements:\\n /// - `redemptionTx` components must match the expected structure. See\\n /// `BitcoinTx.Info` docs for reference. Their values must exactly\\n /// correspond to appropriate Bitcoin transaction fields to produce\\n /// a provable transaction hash,\\n /// - The `redemptionTx` should represent a Bitcoin transaction with\\n /// exactly 1 input that refers to the wallet's main UTXO. That\\n /// transaction should have 1..n outputs handling existing pending\\n /// redemption requests or pointing to reported timed out requests.\\n /// There can be also 1 optional output representing the\\n /// change and pointing back to the 20-byte wallet public key hash.\\n /// The change should be always present if the redeemed value sum\\n /// is lower than the total wallet's BTC balance,\\n /// - `redemptionProof` components must match the expected structure.\\n /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`\\n /// field must contain a valid number of block headers, not less\\n /// than the `txProofDifficultyFactor` contract constant,\\n /// - `mainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// Additionally, the recent main UTXO on Ethereum must be set,\\n /// - `walletPubKeyHash` must be connected with the main UTXO used\\n /// as transaction single input.\\n /// Other remarks:\\n /// - Putting the change output as the first transaction output can\\n /// save some gas because the output processing loop begins each\\n /// iteration by checking whether the given output is the change\\n /// thus uses some gas for making the comparison. Once the change\\n /// is identified, that check is omitted in further iterations.\\n function submitRedemptionProof(\\n BridgeState.Storage storage self,\\n BitcoinTx.Info calldata redemptionTx,\\n BitcoinTx.Proof calldata redemptionProof,\\n BitcoinTx.UTXO calldata mainUtxo,\\n bytes20 walletPubKeyHash\\n ) external {\\n // Wallet state validation is performed in the `resolveRedeemingWallet`\\n // function.\\n\\n // The actual transaction proof is performed here. After that point, we\\n // can assume the transaction happened on Bitcoin chain and has\\n // a sufficient number of confirmations as determined by\\n // `txProofDifficultyFactor` constant.\\n bytes32 redemptionTxHash = self.validateProof(\\n redemptionTx,\\n redemptionProof\\n );\\n\\n Wallets.Wallet storage wallet = resolveRedeemingWallet(\\n self,\\n walletPubKeyHash,\\n mainUtxo\\n );\\n\\n // Process the redemption transaction input. Specifically, check if it\\n // refers to the expected wallet's main UTXO.\\n OutboundTx.processWalletOutboundTxInput(\\n self,\\n redemptionTx.inputVector,\\n mainUtxo\\n );\\n\\n // Process redemption transaction outputs to extract some info required\\n // for further processing.\\n RedemptionTxOutputsInfo memory outputsInfo = processRedemptionTxOutputs(\\n self,\\n redemptionTx.outputVector,\\n walletPubKeyHash\\n );\\n\\n require(\\n mainUtxo.txOutputValue - outputsInfo.outputsTotalValue <=\\n self.redemptionTxMaxTotalFee,\\n \\\"Transaction fee is too high\\\"\\n );\\n\\n if (outputsInfo.changeValue > 0) {\\n // If the change value is grater than zero, it means the change\\n // output exists and can be used as new wallet's main UTXO.\\n wallet.mainUtxoHash = keccak256(\\n abi.encodePacked(\\n redemptionTxHash,\\n outputsInfo.changeIndex,\\n outputsInfo.changeValue\\n )\\n );\\n } else {\\n // If the change value is zero, it means the change output doesn't\\n // exists and no funds left on the wallet. Delete the main UTXO\\n // for that wallet to represent that state in a proper way.\\n delete wallet.mainUtxoHash;\\n }\\n\\n wallet.pendingRedemptionsValue -= outputsInfo.totalBurnableValue;\\n\\n emit RedemptionsCompleted(walletPubKeyHash, redemptionTxHash);\\n\\n self.bank.decreaseBalance(outputsInfo.totalBurnableValue);\\n\\n if (outputsInfo.totalTreasuryFee > 0) {\\n self.bank.transferBalance(\\n self.treasury,\\n outputsInfo.totalTreasuryFee\\n );\\n }\\n }\\n\\n /// @notice Resolves redeeming wallet based on the provided wallet public\\n /// key hash. Validates the wallet state and current main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @param walletPubKeyHash public key hash of the wallet proving the sweep\\n /// Bitcoin transaction.\\n /// @param mainUtxo Data of the wallet's main UTXO, as currently known on\\n /// the Ethereum chain.\\n /// @return wallet Data of the sweeping wallet.\\n /// @dev Requirements:\\n /// - Sweeping wallet must be either in Live or MovingFunds state,\\n /// - Main UTXO of the redeeming wallet must exists in the storage,\\n /// - The passed `mainUTXO` parameter must be equal to the stored one.\\n function resolveRedeemingWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata mainUtxo\\n ) internal view returns (Wallets.Wallet storage wallet) {\\n wallet = self.registeredWallets[walletPubKeyHash];\\n\\n // Assert that main UTXO for passed wallet exists in storage.\\n bytes32 mainUtxoHash = wallet.mainUtxoHash;\\n require(mainUtxoHash != bytes32(0), \\\"No main UTXO for given wallet\\\");\\n\\n // Assert that passed main UTXO parameter is the same as in storage and\\n // can be used for further processing.\\n require(\\n keccak256(\\n abi.encodePacked(\\n mainUtxo.txHash,\\n mainUtxo.txOutputIndex,\\n mainUtxo.txOutputValue\\n )\\n ) == mainUtxoHash,\\n \\\"Invalid main UTXO data\\\"\\n );\\n\\n Wallets.WalletState walletState = wallet.state;\\n require(\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in Live or MovingFunds state\\\"\\n );\\n }\\n\\n /// @notice Processes the Bitcoin redemption transaction output vector.\\n /// It extracts each output and tries to identify it as a pending\\n /// redemption request, reported timed out request, or change.\\n /// Reverts if one of the outputs cannot be recognized properly.\\n /// This function also marks each request as processed by removing\\n /// them from `pendingRedemptions` mapping.\\n /// @param redemptionTxOutputVector Bitcoin redemption transaction output\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVout` function\\n /// before it is passed here.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @return info Outcomes of the processing.\\n function processRedemptionTxOutputs(\\n BridgeState.Storage storage self,\\n bytes memory redemptionTxOutputVector,\\n bytes20 walletPubKeyHash\\n ) internal returns (RedemptionTxOutputsInfo memory info) {\\n // Determining the total number of redemption transaction outputs in\\n // the same way as for number of inputs. See `BitcoinTx.outputVector`\\n // docs for more details.\\n (\\n uint256 outputsCompactSizeUintLength,\\n uint256 outputsCount\\n ) = redemptionTxOutputVector.parseVarInt();\\n\\n // To determine the first output starting index, we must jump over\\n // the compactSize uint which prepends the output vector. One byte\\n // must be added because `BtcUtils.parseVarInt` does not include\\n // compactSize uint tag in the returned length.\\n //\\n // For >= 0 && <= 252, `BTCUtils.determineVarIntDataLengthAt`\\n // returns `0`, so we jump over one byte of compactSize uint.\\n //\\n // For >= 253 && <= 0xffff there is `0xfd` tag,\\n // `BTCUtils.determineVarIntDataLengthAt` returns `2` (no\\n // tag byte included) so we need to jump over 1+2 bytes of\\n // compactSize uint.\\n //\\n // Please refer `BTCUtils` library and compactSize uint\\n // docs in `BitcoinTx` library for more details.\\n uint256 outputStartingIndex = 1 + outputsCompactSizeUintLength;\\n\\n // Calculate the keccak256 for two possible wallet's P2PKH or P2WPKH\\n // scripts that can be used to lock the change. This is done upfront to\\n // save on gas. Both scripts have a strict format defined by Bitcoin.\\n //\\n // The P2PKH script has the byte format: <0x1976a914> <20-byte PKH> <0x88ac>.\\n // According to https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n // - 0x19: Byte length of the entire script\\n // - 0x76: OP_DUP\\n // - 0xa9: OP_HASH160\\n // - 0x14: Byte length of the public key hash\\n // - 0x88: OP_EQUALVERIFY\\n // - 0xac: OP_CHECKSIG\\n // which matches the P2PKH structure as per:\\n // https://en.bitcoin.it/wiki/Transaction#Pay-to-PubkeyHash\\n bytes32 walletP2PKHScriptKeccak = keccak256(\\n abi.encodePacked(BitcoinTx.makeP2PKHScript(walletPubKeyHash))\\n );\\n // The P2WPKH script has the byte format: <0x160014> <20-byte PKH>.\\n // According to https://en.bitcoin.it/wiki/Script#Opcodes this translates to:\\n // - 0x16: Byte length of the entire script\\n // - 0x00: OP_0\\n // - 0x14: Byte length of the public key hash\\n // which matches the P2WPKH structure as per:\\n // https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH\\n bytes32 walletP2WPKHScriptKeccak = keccak256(\\n abi.encodePacked(BitcoinTx.makeP2WPKHScript(walletPubKeyHash))\\n );\\n\\n return\\n processRedemptionTxOutputs(\\n self,\\n redemptionTxOutputVector,\\n walletPubKeyHash,\\n RedemptionTxOutputsProcessingInfo(\\n outputStartingIndex,\\n outputsCount,\\n walletP2PKHScriptKeccak,\\n walletP2WPKHScriptKeccak\\n )\\n );\\n }\\n\\n /// @notice Processes all outputs from the redemption transaction. Tries to\\n /// identify output as a change output, pending redemption request\\n /// or reported redemption. Reverts if one of the outputs cannot be\\n /// recognized properly. Marks each request as processed by removing\\n /// them from `pendingRedemptions` mapping.\\n /// @param redemptionTxOutputVector Bitcoin redemption transaction output\\n /// vector. This function assumes vector's structure is valid so it\\n /// must be validated using e.g. `BTCUtils.validateVout` function\\n /// before it is passed here.\\n /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin\\n /// HASH160 over the compressed ECDSA public key) of the wallet which\\n /// performed the redemption transaction.\\n /// @param processInfo RedemptionTxOutputsProcessingInfo identifying output\\n /// starting index, the number of outputs and possible wallet change\\n /// P2PKH and P2WPKH scripts.\\n function processRedemptionTxOutputs(\\n BridgeState.Storage storage self,\\n bytes memory redemptionTxOutputVector,\\n bytes20 walletPubKeyHash,\\n RedemptionTxOutputsProcessingInfo memory processInfo\\n ) internal returns (RedemptionTxOutputsInfo memory resultInfo) {\\n // Helper flag indicating whether there was at least one redemption\\n // output present (redemption must be either pending or reported as\\n // timed out).\\n bool redemptionPresent = false;\\n\\n // Outputs processing loop.\\n for (uint256 i = 0; i < processInfo.outputsCount; i++) {\\n uint256 outputLength = redemptionTxOutputVector\\n .determineOutputLengthAt(processInfo.outputStartingIndex);\\n\\n // Extract the value from given output.\\n uint64 outputValue = redemptionTxOutputVector.extractValueAt(\\n processInfo.outputStartingIndex\\n );\\n\\n // The output consists of an 8-byte value and a variable length\\n // script. To hash that script we slice the output starting from\\n // 9th byte until the end.\\n uint256 scriptLength = outputLength - 8;\\n uint256 outputScriptStart = processInfo.outputStartingIndex + 8;\\n\\n bytes32 outputScriptHash;\\n /* solhint-disable-next-line no-inline-assembly */\\n assembly {\\n // The first argument to assembly keccak256 is the pointer.\\n // We point to `redemptionTxOutputVector` but at the position\\n // indicated by `outputScriptStart`. To load that position, we\\n // need to call `add(outputScriptStart, 32)` because\\n // `outputScriptStart` has 32 bytes.\\n outputScriptHash := keccak256(\\n add(redemptionTxOutputVector, add(outputScriptStart, 32)),\\n scriptLength\\n )\\n }\\n\\n if (\\n resultInfo.changeValue == 0 &&\\n (outputScriptHash == processInfo.walletP2PKHScriptKeccak ||\\n outputScriptHash == processInfo.walletP2WPKHScriptKeccak) &&\\n outputValue > 0\\n ) {\\n // If we entered here, that means the change output with a\\n // proper non-zero value was found.\\n resultInfo.changeIndex = uint32(i);\\n resultInfo.changeValue = outputValue;\\n } else {\\n // If we entered here, that the means the given output is\\n // supposed to represent a redemption.\\n (\\n uint64 burnableValue,\\n uint64 treasuryFee\\n ) = processNonChangeRedemptionTxOutput(\\n self,\\n _getRedemptionKey(walletPubKeyHash, outputScriptHash),\\n outputValue\\n );\\n resultInfo.totalBurnableValue += burnableValue;\\n resultInfo.totalTreasuryFee += treasuryFee;\\n redemptionPresent = true;\\n }\\n\\n resultInfo.outputsTotalValue += outputValue;\\n\\n // Make the `outputStartingIndex` pointing to the next output by\\n // increasing it by current output's length.\\n processInfo.outputStartingIndex += outputLength;\\n }\\n\\n // Protect against the cases when there is only a single change output\\n // referring back to the wallet PKH and just burning main UTXO value\\n // for transaction fees.\\n require(\\n redemptionPresent,\\n \\\"Redemption transaction must process at least one redemption\\\"\\n );\\n }\\n\\n /// @notice Processes a single redemption transaction output. Tries to\\n /// identify output as a pending redemption request or reported\\n /// redemption timeout. Output script passed to this function must\\n /// not be the change output. Such output needs to be identified\\n /// separately before calling this function.\\n /// Reverts if output is neither requested pending redemption nor\\n /// requested and reported timed-out redemption.\\n /// This function also marks each pending request as processed by\\n /// removing them from `pendingRedemptions` mapping.\\n /// @param redemptionKey Redemption key of the output being processed.\\n /// @param outputValue Value of the output being processed.\\n /// @return burnableValue The value burnable as a result of processing this\\n /// single redemption output. This value needs to be summed up with\\n /// burnable values of all other outputs to evaluate total burnable\\n /// value for the entire redemption transaction. This value is 0\\n /// for a timed-out redemption request.\\n /// @return treasuryFee The treasury fee from this single redemption output.\\n /// This value needs to be summed up with treasury fees of all other\\n /// outputs to evaluate the total treasury fee for the entire\\n /// redemption transaction. This value is 0 for a timed-out\\n /// redemption request.\\n /// @dev Requirements:\\n /// - This function should be called only if the given output\\n /// represents redemption. It must not be the change output.\\n function processNonChangeRedemptionTxOutput(\\n BridgeState.Storage storage self,\\n uint256 redemptionKey,\\n uint64 outputValue\\n ) internal returns (uint64 burnableValue, uint64 treasuryFee) {\\n if (self.pendingRedemptions[redemptionKey].requestedAt != 0) {\\n // If we entered here, that means the output was identified\\n // as a pending redemption request.\\n RedemptionRequest storage request = self.pendingRedemptions[\\n redemptionKey\\n ];\\n // Compute the request's redeemable amount as the requested\\n // amount reduced by the treasury fee. The request's\\n // minimal amount is then the redeemable amount reduced by\\n // the maximum transaction fee.\\n uint64 redeemableAmount = request.requestedAmount -\\n request.treasuryFee;\\n // Output value must fit between the request's redeemable\\n // and minimal amounts to be deemed valid.\\n require(\\n redeemableAmount - request.txMaxFee <= outputValue &&\\n outputValue <= redeemableAmount,\\n \\\"Output value is not within the acceptable range of the pending request\\\"\\n );\\n // Add the redeemable amount to the total burnable value\\n // the Bridge will use to decrease its balance in the Bank.\\n burnableValue = redeemableAmount;\\n // Add the request's treasury fee to the total treasury fee\\n // value the Bridge will transfer to the treasury.\\n treasuryFee = request.treasuryFee;\\n // Request was properly handled so remove its redemption\\n // key from the mapping to make it reusable for further\\n // requests.\\n delete self.pendingRedemptions[redemptionKey];\\n } else {\\n // If we entered here, the output is not a redemption\\n // request but there is still a chance the given output is\\n // related to a reported timed out redemption request.\\n // If so, check if the output value matches the request\\n // amount to confirm this is an overdue request fulfillment\\n // then bypass this output and process the subsequent\\n // ones. That also means the wallet was already punished\\n // for the inactivity. Otherwise, just revert.\\n RedemptionRequest storage request = self.timedOutRedemptions[\\n redemptionKey\\n ];\\n\\n require(\\n request.requestedAt != 0,\\n \\\"Output is a non-requested redemption\\\"\\n );\\n\\n uint64 redeemableAmount = request.requestedAmount -\\n request.treasuryFee;\\n\\n require(\\n redeemableAmount - request.txMaxFee <= outputValue &&\\n outputValue <= redeemableAmount,\\n \\\"Output value is not within the acceptable range of the timed out request\\\"\\n );\\n\\n delete self.timedOutRedemptions[redemptionKey];\\n }\\n }\\n\\n /// @notice Notifies that there is a pending redemption request associated\\n /// with the given wallet, that has timed out. The redemption\\n /// request is identified by the key built as\\n /// `keccak256(keccak256(redeemerOutputScript) | walletPubKeyHash)`.\\n /// The results of calling this function:\\n /// - the pending redemptions value for the wallet will be decreased\\n /// by the requested amount (minus treasury fee),\\n /// - the tokens taken from the redeemer on redemption request will\\n /// be returned to the redeemer,\\n /// - the request will be moved from pending redemptions to\\n /// timed-out redemptions,\\n /// - if the state of the wallet is `Live` or `MovingFunds`, the\\n /// wallet operators will be slashed and the notifier will be\\n /// rewarded,\\n /// - if the state of wallet is `Live`, the wallet will be closed or\\n /// marked as `MovingFunds` (depending on the presence or absence\\n /// of the wallet's main UTXO) and the wallet will no longer be\\n /// marked as the active wallet (if it was marked as such).\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param redeemerOutputScript The redeemer's length-prefixed output\\n /// script (P2PKH, P2WPKH, P2SH or P2WSH).\\n /// @dev Requirements:\\n /// - The wallet must be in the Live or MovingFunds or Terminated state,\\n /// - The redemption request identified by `walletPubKeyHash` and\\n /// `redeemerOutputScript` must exist,\\n /// - The expression `keccak256(abi.encode(walletMembersIDs))` must\\n /// be exactly the same as the hash stored under `membersIdsHash`\\n /// for the given `walletID`. Those IDs are not directly stored\\n /// in the contract for gas efficiency purposes but they can be\\n /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`\\n /// events of the `WalletRegistry` contract,\\n /// - The amount of time defined by `redemptionTimeout` must have\\n /// passed since the redemption was requested (the request must be\\n /// timed-out).\\n function notifyRedemptionTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs,\\n bytes calldata redeemerOutputScript\\n ) external {\\n // Wallet state is validated in `notifyWalletRedemptionTimeout`.\\n uint256 redemptionKey = getRedemptionKey(\\n walletPubKeyHash,\\n redeemerOutputScript\\n );\\n Redemption.RedemptionRequest memory request = self.pendingRedemptions[\\n redemptionKey\\n ];\\n\\n require(request.requestedAt > 0, \\\"Redemption request does not exist\\\");\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n request.requestedAt + self.redemptionTimeout < block.timestamp,\\n \\\"Redemption request has not timed out\\\"\\n );\\n\\n // Update the wallet's pending redemptions value\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n wallet.pendingRedemptionsValue -=\\n request.requestedAmount -\\n request.treasuryFee;\\n\\n // It is worth noting that there is no need to check if\\n // `timedOutRedemption` mapping already contains the given redemption\\n // key. There is no possibility to re-use a key of a reported timed-out\\n // redemption because the wallet responsible for causing the timeout is\\n // moved to a state that prevents it to receive new redemption requests.\\n\\n // Propagate timeout consequences to the wallet\\n self.notifyWalletRedemptionTimeout(walletPubKeyHash, walletMembersIDs);\\n\\n // Move the redemption from pending redemptions to timed-out redemptions\\n self.timedOutRedemptions[redemptionKey] = request;\\n delete self.pendingRedemptions[redemptionKey];\\n\\n // slither-disable-next-line reentrancy-events\\n emit RedemptionTimedOut(walletPubKeyHash, redeemerOutputScript);\\n\\n // Return the requested amount of tokens to the redeemer\\n self.bank.transferBalance(request.redeemer, request.requestedAmount);\\n }\\n\\n /// @notice Calculate redemption key without allocations.\\n /// @param walletPubKeyHash the pubkey hash of the wallet.\\n /// @param script the output script of the redemption.\\n /// @return The key = keccak256(keccak256(script) | walletPubKeyHash).\\n function getRedemptionKey(bytes20 walletPubKeyHash, bytes memory script)\\n internal\\n pure\\n returns (uint256)\\n {\\n bytes32 scriptHash = keccak256(script);\\n uint256 key;\\n /* solhint-disable-next-line no-inline-assembly */\\n assembly {\\n mstore(0, scriptHash)\\n mstore(32, walletPubKeyHash)\\n key := keccak256(0, 52)\\n }\\n return key;\\n }\\n\\n /// @notice Finish calculating redemption key without allocations.\\n /// @param walletPubKeyHash the pubkey hash of the wallet.\\n /// @param scriptHash the output script hash of the redemption.\\n /// @return The key = keccak256(scriptHash | walletPubKeyHash).\\n function _getRedemptionKey(bytes20 walletPubKeyHash, bytes32 scriptHash)\\n internal\\n pure\\n returns (uint256)\\n {\\n uint256 key;\\n /* solhint-disable-next-line no-inline-assembly */\\n assembly {\\n mstore(0, scriptHash)\\n mstore(32, walletPubKeyHash)\\n key := keccak256(0, 52)\\n }\\n return key;\\n }\\n}\\n\",\"keccak256\":\"0x341e2636230764f1bcc75948adedd4c8b38e34a87bb9094b251f9b0870922e93\",\"license\":\"GPL-3.0-only\"},\"contracts/bridge/Wallets.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport {BTCUtils} from \\\"@keep-network/bitcoin-spv-sol/contracts/BTCUtils.sol\\\";\\nimport {EcdsaDkg} from \\\"@keep-network/ecdsa/contracts/libraries/EcdsaDkg.sol\\\";\\nimport {Math} from \\\"@openzeppelin/contracts/utils/math/Math.sol\\\";\\n\\nimport \\\"./BitcoinTx.sol\\\";\\nimport \\\"./EcdsaLib.sol\\\";\\nimport \\\"./BridgeState.sol\\\";\\n\\n/// @title Wallet library\\n/// @notice Library responsible for handling integration between Bridge\\n/// contract and ECDSA wallets.\\nlibrary Wallets {\\n using BTCUtils for bytes;\\n\\n /// @notice Represents wallet state:\\n enum WalletState {\\n /// @dev The wallet is unknown to the Bridge.\\n Unknown,\\n /// @dev The wallet can sweep deposits and accept redemption requests.\\n Live,\\n /// @dev The wallet was deemed unhealthy and is expected to move their\\n /// outstanding funds to another wallet. The wallet can still\\n /// fulfill their pending redemption requests although new\\n /// redemption requests and new deposit reveals are not accepted.\\n MovingFunds,\\n /// @dev The wallet moved or redeemed all their funds and is in the\\n /// closing period where it is still a subject of fraud challenges\\n /// and must defend against them. This state is needed to protect\\n /// against deposit frauds on deposits revealed but not swept.\\n /// The closing period must be greater that the deposit refund\\n /// time plus some time margin.\\n Closing,\\n /// @dev The wallet finalized the closing period successfully and\\n /// can no longer perform any action in the Bridge.\\n Closed,\\n /// @dev The wallet committed a fraud that was reported, did not move\\n /// funds to another wallet before a timeout, or did not sweep\\n /// funds moved to if from another wallet before a timeout. The\\n /// wallet is blocked and can not perform any actions in the Bridge.\\n /// Off-chain coordination with the wallet operators is needed to\\n /// recover funds.\\n Terminated\\n }\\n\\n /// @notice Holds information about a wallet.\\n struct Wallet {\\n // Identifier of a ECDSA Wallet registered in the ECDSA Wallet Registry.\\n bytes32 ecdsaWalletID;\\n // Latest wallet's main UTXO hash computed as\\n // keccak256(txHash | txOutputIndex | txOutputValue). The `tx` prefix\\n // refers to the transaction which created that main UTXO. The `txHash`\\n // is `bytes32` (ordered as in Bitcoin internally), `txOutputIndex`\\n // an `uint32`, and `txOutputValue` an `uint64` value.\\n bytes32 mainUtxoHash;\\n // The total redeemable value of pending redemption requests targeting\\n // that wallet.\\n uint64 pendingRedemptionsValue;\\n // UNIX timestamp the wallet was created at.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 createdAt;\\n // UNIX timestamp indicating the moment the wallet was requested to\\n // move their funds.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 movingFundsRequestedAt;\\n // UNIX timestamp indicating the moment the wallet's closing period\\n // started.\\n // XXX: Unsigned 32-bit int unix seconds, will break February 7th 2106.\\n uint32 closingStartedAt;\\n // Total count of pending moved funds sweep requests targeting this wallet.\\n uint32 pendingMovedFundsSweepRequestsCount;\\n // Current state of the wallet.\\n WalletState state;\\n // Moving funds target wallet commitment submitted by the wallet. It\\n // is built by applying the keccak256 hash over the list of 20-byte\\n // public key hashes of the target wallets.\\n bytes32 movingFundsTargetWalletsCommitmentHash;\\n // This struct doesn't contain `__gap` property as the structure is stored\\n // in a mapping, mappings store values in different slots and they are\\n // not contiguous with other values.\\n }\\n\\n event NewWalletRequested();\\n\\n event NewWalletRegistered(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletMovingFunds(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosing(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletClosed(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n event WalletTerminated(\\n bytes32 indexed ecdsaWalletID,\\n bytes20 indexed walletPubKeyHash\\n );\\n\\n /// @notice Requests creation of a new wallet. This function just\\n /// forms a request and the creation process is performed\\n /// asynchronously. Outcome of that process should be delivered\\n /// using `registerNewWallet` function.\\n /// @param activeWalletMainUtxo Data of the active wallet's main UTXO, as\\n /// currently known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - `activeWalletMainUtxo` components must point to the recent main\\n /// UTXO of the given active wallet, as currently known on the\\n /// Ethereum chain. If there is no active wallet at the moment, or\\n /// the active wallet has no main UTXO, this parameter can be\\n /// empty as it is ignored,\\n /// - Wallet creation must not be in progress,\\n /// - If the active wallet is set, one of the following\\n /// conditions must be true:\\n /// - The active wallet BTC balance is above the minimum threshold\\n /// and the active wallet is old enough, i.e. the creation period\\n /// was elapsed since its creation time,\\n /// - The active wallet BTC balance is above the maximum threshold.\\n function requestNewWallet(\\n BridgeState.Storage storage self,\\n BitcoinTx.UTXO calldata activeWalletMainUtxo\\n ) external {\\n require(\\n self.ecdsaWalletRegistry.getWalletCreationState() ==\\n EcdsaDkg.State.IDLE,\\n \\\"Wallet creation already in progress\\\"\\n );\\n\\n bytes20 activeWalletPubKeyHash = self.activeWalletPubKeyHash;\\n\\n // If the active wallet is set, fetch this wallet's details from\\n // storage to perform conditions check. The `registerNewWallet`\\n // function guarantees an active wallet is always one of the\\n // registered ones.\\n if (activeWalletPubKeyHash != bytes20(0)) {\\n uint64 activeWalletBtcBalance = getWalletBtcBalance(\\n self,\\n activeWalletPubKeyHash,\\n activeWalletMainUtxo\\n );\\n uint32 activeWalletCreatedAt = self\\n .registeredWallets[activeWalletPubKeyHash]\\n .createdAt;\\n /* solhint-disable-next-line not-rely-on-time */\\n bool activeWalletOldEnough = block.timestamp >=\\n activeWalletCreatedAt + self.walletCreationPeriod;\\n\\n require(\\n (activeWalletOldEnough &&\\n activeWalletBtcBalance >=\\n self.walletCreationMinBtcBalance) ||\\n activeWalletBtcBalance >= self.walletCreationMaxBtcBalance,\\n \\\"Wallet creation conditions are not met\\\"\\n );\\n }\\n\\n emit NewWalletRequested();\\n\\n self.ecdsaWalletRegistry.requestNewWallet();\\n }\\n\\n /// @notice Registers a new wallet. This function should be called\\n /// after the wallet creation process initiated using\\n /// `requestNewWallet` completes and brings the outcomes.\\n /// @param ecdsaWalletID Wallet's unique identifier.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Given wallet data must not belong to an already registered wallet.\\n function registerNewWallet(\\n BridgeState.Storage storage self,\\n bytes32 ecdsaWalletID,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external {\\n require(\\n msg.sender == address(self.ecdsaWalletRegistry),\\n \\\"Caller is not the ECDSA Wallet Registry\\\"\\n );\\n\\n // Compress wallet's public key and calculate Bitcoin's hash160 of it.\\n bytes20 walletPubKeyHash = bytes20(\\n EcdsaLib.compressPublicKey(publicKeyX, publicKeyY).hash160View()\\n );\\n\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n require(\\n wallet.state == WalletState.Unknown,\\n \\\"ECDSA wallet has been already registered\\\"\\n );\\n wallet.ecdsaWalletID = ecdsaWalletID;\\n wallet.state = WalletState.Live;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.createdAt = uint32(block.timestamp);\\n\\n // Set the freshly created wallet as the new active wallet.\\n self.activeWalletPubKeyHash = walletPubKeyHash;\\n\\n self.liveWalletsCount++;\\n\\n emit NewWalletRegistered(ecdsaWalletID, walletPubKeyHash);\\n }\\n\\n /// @notice Handles a notification about a wallet redemption timeout.\\n /// Triggers the wallet moving funds process only if the wallet is\\n /// still in the Live state. That means multiple action timeouts can\\n /// be reported for the same wallet but only the first report\\n /// requests the wallet to move their funds. Executes slashing if\\n /// the wallet is in Live or MovingFunds state. Allows to notify\\n /// redemption timeout also for a Terminated wallet in case the\\n /// redemption was requested before the wallet got terminated.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the `Live`, `MovingFunds`,\\n /// or `Terminated` state.\\n function notifyWalletRedemptionTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n WalletState walletState = wallet.state;\\n\\n require(\\n walletState == WalletState.Live ||\\n walletState == WalletState.MovingFunds ||\\n walletState == WalletState.Terminated,\\n \\\"Wallet must be in Live or MovingFunds or Terminated state\\\"\\n );\\n\\n if (\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds\\n ) {\\n // Slash the wallet operators and reward the notifier\\n self.ecdsaWalletRegistry.seize(\\n self.redemptionTimeoutSlashingAmount,\\n self.redemptionTimeoutNotifierRewardMultiplier,\\n msg.sender,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n }\\n\\n if (walletState == WalletState.Live) {\\n moveFunds(self, walletPubKeyHash);\\n }\\n }\\n\\n /// @notice Handles a notification about a wallet heartbeat failure and\\n /// triggers the wallet moving funds process.\\n /// @param publicKeyX Wallet's public key's X coordinate.\\n /// @param publicKeyY Wallet's public key's Y coordinate.\\n /// @dev Requirements:\\n /// - The only caller authorized to call this function is `registry`,\\n /// - Wallet must be in Live state.\\n function notifyWalletHeartbeatFailed(\\n BridgeState.Storage storage self,\\n bytes32 publicKeyX,\\n bytes32 publicKeyY\\n ) external {\\n require(\\n msg.sender == address(self.ecdsaWalletRegistry),\\n \\\"Caller is not the ECDSA Wallet Registry\\\"\\n );\\n\\n // Compress wallet's public key and calculate Bitcoin's hash160 of it.\\n bytes20 walletPubKeyHash = bytes20(\\n EcdsaLib.compressPublicKey(publicKeyX, publicKeyY).hash160View()\\n );\\n\\n require(\\n self.registeredWallets[walletPubKeyHash].state == WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n moveFunds(self, walletPubKeyHash);\\n }\\n\\n /// @notice Notifies that the wallet is either old enough or has too few\\n /// satoshis left and qualifies to be closed.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMainUtxo Data of the wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @dev Requirements:\\n /// - Wallet must not be set as the current active wallet,\\n /// - Wallet must exceed the wallet maximum age OR the wallet BTC\\n /// balance must be lesser than the minimum threshold. If the latter\\n /// case is true, the `walletMainUtxo` components must point to the\\n /// recent main UTXO of the given wallet, as currently known on the\\n /// Ethereum chain. If the wallet has no main UTXO, this parameter\\n /// can be empty as it is ignored since the wallet balance is\\n /// assumed to be zero,\\n /// - Wallet must be in Live state.\\n function notifyWalletCloseable(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) external {\\n require(\\n self.activeWalletPubKeyHash != walletPubKeyHash,\\n \\\"Active wallet cannot be considered closeable\\\"\\n );\\n\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n require(\\n wallet.state == WalletState.Live,\\n \\\"Wallet must be in Live state\\\"\\n );\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n bool walletOldEnough = block.timestamp >=\\n wallet.createdAt + self.walletMaxAge;\\n\\n require(\\n walletOldEnough ||\\n getWalletBtcBalance(self, walletPubKeyHash, walletMainUtxo) <\\n self.walletClosureMinBtcBalance,\\n \\\"Wallet needs to be old enough or have too few satoshis\\\"\\n );\\n\\n moveFunds(self, walletPubKeyHash);\\n }\\n\\n /// @notice Notifies about the end of the closing period for the given wallet.\\n /// Closes the wallet ultimately and notifies the ECDSA registry\\n /// about this fact.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the Closing state,\\n /// - The wallet closing period must have elapsed.\\n function notifyWalletClosingPeriodElapsed(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n require(\\n wallet.state == WalletState.Closing,\\n \\\"Wallet must be in Closing state\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp >\\n wallet.closingStartedAt + self.walletClosingPeriod,\\n \\\"Closing period has not elapsed yet\\\"\\n );\\n\\n finalizeWalletClosing(self, walletPubKeyHash);\\n }\\n\\n /// @notice Notifies that the wallet completed the moving funds process\\n /// successfully. Checks if the funds were moved to the expected\\n /// target wallets. Closes the source wallet if everything went\\n /// good and reverts otherwise.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param targetWalletsHash 32-byte keccak256 hash over the list of\\n /// 20-byte public key hashes of the target wallets actually used\\n /// within the moving funds transactions.\\n /// @dev Requirements:\\n /// - The caller must make sure the moving funds transaction actually\\n /// happened on Bitcoin chain and fits the protocol requirements,\\n /// - The source wallet must be in the MovingFunds state,\\n /// - The target wallets commitment must be submitted by the source\\n /// wallet,\\n /// - The actual target wallets used in the moving funds transaction\\n /// must be exactly the same as the target wallets commitment.\\n function notifyWalletFundsMoved(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n bytes32 targetWalletsHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n // Check that the wallet is in the MovingFunds state but don't check\\n // if the moving funds timeout is exceeded. That should give a\\n // possibility to move funds in case when timeout was hit but was\\n // not reported yet.\\n require(\\n wallet.state == WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n bytes32 targetWalletsCommitmentHash = wallet\\n .movingFundsTargetWalletsCommitmentHash;\\n\\n require(\\n targetWalletsCommitmentHash != bytes32(0),\\n \\\"Target wallets commitment not submitted yet\\\"\\n );\\n\\n // Make sure that the target wallets where funds were moved to are\\n // exactly the same as the ones the source wallet committed to.\\n require(\\n targetWalletsCommitmentHash == targetWalletsHash,\\n \\\"Target wallets don't correspond to the commitment\\\"\\n );\\n\\n // If funds were moved, the wallet has no longer a main UTXO.\\n delete wallet.mainUtxoHash;\\n\\n beginWalletClosing(self, walletPubKeyHash);\\n }\\n\\n /// @notice Called when a MovingFunds wallet has a balance below the dust\\n /// threshold. Begins the wallet closing.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state.\\n function notifyWalletMovingFundsBelowDust(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n WalletState walletState = self\\n .registeredWallets[walletPubKeyHash]\\n .state;\\n\\n require(\\n walletState == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n beginWalletClosing(self, walletPubKeyHash);\\n }\\n\\n /// @notice Called when the timeout for MovingFunds for the wallet elapsed.\\n /// Slashes wallet members and terminates the wallet.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the MovingFunds state.\\n function notifyWalletMovingFundsTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) internal {\\n Wallets.Wallet storage wallet = self.registeredWallets[\\n walletPubKeyHash\\n ];\\n\\n require(\\n wallet.state == Wallets.WalletState.MovingFunds,\\n \\\"Wallet must be in MovingFunds state\\\"\\n );\\n\\n self.ecdsaWalletRegistry.seize(\\n self.movingFundsTimeoutSlashingAmount,\\n self.movingFundsTimeoutNotifierRewardMultiplier,\\n msg.sender,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n\\n terminateWallet(self, walletPubKeyHash);\\n }\\n\\n /// @notice Called when a wallet which was asked to sweep funds moved from\\n /// another wallet did not provide a sweeping proof before a timeout.\\n /// Slashes and terminates the wallet who failed to provide a proof.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet which was\\n /// supposed to sweep funds.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @dev Requirements:\\n /// - The wallet must be in the `Live`, `MovingFunds`,\\n /// or `Terminated` state.\\n function notifyWalletMovedFundsSweepTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n WalletState walletState = wallet.state;\\n\\n require(\\n walletState == WalletState.Live ||\\n walletState == WalletState.MovingFunds ||\\n walletState == WalletState.Terminated,\\n \\\"Wallet must be in Live or MovingFunds or Terminated state\\\"\\n );\\n\\n if (\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds\\n ) {\\n self.ecdsaWalletRegistry.seize(\\n self.movedFundsSweepTimeoutSlashingAmount,\\n self.movedFundsSweepTimeoutNotifierRewardMultiplier,\\n msg.sender,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n\\n terminateWallet(self, walletPubKeyHash);\\n }\\n }\\n\\n /// @notice Called when a wallet which was challenged for a fraud did not\\n /// defeat the challenge before the timeout. Slashes and terminates\\n /// the wallet who failed to defeat the challenge. If the wallet is\\n /// already terminated, it does nothing.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet which was\\n /// supposed to sweep funds.\\n /// @param walletMembersIDs Identifiers of the wallet signing group members.\\n /// @param challenger Address of the party which submitted the fraud\\n /// challenge.\\n /// @dev Requirements:\\n /// - The wallet must be in the `Live`, `MovingFunds`, `Closing`\\n /// or `Terminated` state.\\n function notifyWalletFraudChallengeDefeatTimeout(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n uint32[] calldata walletMembersIDs,\\n address challenger\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n WalletState walletState = wallet.state;\\n\\n if (\\n walletState == Wallets.WalletState.Live ||\\n walletState == Wallets.WalletState.MovingFunds ||\\n walletState == Wallets.WalletState.Closing\\n ) {\\n self.ecdsaWalletRegistry.seize(\\n self.fraudSlashingAmount,\\n self.fraudNotifierRewardMultiplier,\\n challenger,\\n wallet.ecdsaWalletID,\\n walletMembersIDs\\n );\\n\\n terminateWallet(self, walletPubKeyHash);\\n } else if (walletState == Wallets.WalletState.Terminated) {\\n // This is a special case when the wallet was already terminated\\n // due to a previous deliberate protocol violation. In that\\n // case, this function should be still callable for other fraud\\n // challenges timeouts in order to let the challenger unlock its\\n // ETH deposit back. However, the wallet termination logic is\\n // not called and the challenger is not rewarded.\\n } else {\\n revert(\\n \\\"Wallet must be in Live or MovingFunds or Closing or Terminated state\\\"\\n );\\n }\\n }\\n\\n /// @notice Requests a wallet to move their funds. If the wallet balance\\n /// is zero, the wallet closing begins immediately. If the move\\n /// funds request refers to the current active wallet, such a wallet\\n /// is no longer considered active and the active wallet slot\\n /// is unset allowing to trigger a new wallet creation immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the Live state.\\n function moveFunds(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n if (wallet.mainUtxoHash == bytes32(0)) {\\n // If the wallet has no main UTXO, that means its BTC balance\\n // is zero and the wallet closing should begin immediately.\\n beginWalletClosing(self, walletPubKeyHash);\\n } else {\\n // Otherwise, initialize the moving funds process.\\n wallet.state = WalletState.MovingFunds;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.movingFundsRequestedAt = uint32(block.timestamp);\\n\\n // slither-disable-next-line reentrancy-events\\n emit WalletMovingFunds(wallet.ecdsaWalletID, walletPubKeyHash);\\n }\\n\\n if (self.activeWalletPubKeyHash == walletPubKeyHash) {\\n // If the move funds request refers to the current active wallet,\\n // unset the active wallet and make the wallet creation process\\n // possible in order to get a new healthy active wallet.\\n delete self.activeWalletPubKeyHash;\\n }\\n\\n self.liveWalletsCount--;\\n }\\n\\n /// @notice Begins the closing period of the given wallet.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the\\n /// MovingFunds state.\\n function beginWalletClosing(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n // Initialize the closing period.\\n wallet.state = WalletState.Closing;\\n /* solhint-disable-next-line not-rely-on-time */\\n wallet.closingStartedAt = uint32(block.timestamp);\\n\\n // slither-disable-next-line reentrancy-events\\n emit WalletClosing(wallet.ecdsaWalletID, walletPubKeyHash);\\n }\\n\\n /// @notice Finalizes the closing period of the given wallet and notifies\\n /// the ECDSA registry about this fact.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the Closing state.\\n function finalizeWalletClosing(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n wallet.state = WalletState.Closed;\\n\\n emit WalletClosed(wallet.ecdsaWalletID, walletPubKeyHash);\\n\\n self.ecdsaWalletRegistry.closeWallet(wallet.ecdsaWalletID);\\n }\\n\\n /// @notice Terminates the given wallet and notifies the ECDSA registry\\n /// about this fact. If the wallet termination refers to the current\\n /// active wallet, such a wallet is no longer considered active and\\n /// the active wallet slot is unset allowing to trigger a new wallet\\n /// creation immediately.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @dev Requirements:\\n /// - The caller must make sure that the wallet is in the\\n /// Live or MovingFunds or Closing state.\\n function terminateWallet(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash\\n ) internal {\\n Wallet storage wallet = self.registeredWallets[walletPubKeyHash];\\n\\n if (wallet.state == WalletState.Live) {\\n self.liveWalletsCount--;\\n }\\n\\n wallet.state = WalletState.Terminated;\\n\\n // slither-disable-next-line reentrancy-events\\n emit WalletTerminated(wallet.ecdsaWalletID, walletPubKeyHash);\\n\\n if (self.activeWalletPubKeyHash == walletPubKeyHash) {\\n // If termination refers to the current active wallet,\\n // unset the active wallet and make the wallet creation process\\n // possible in order to get a new healthy active wallet.\\n delete self.activeWalletPubKeyHash;\\n }\\n\\n self.ecdsaWalletRegistry.closeWallet(wallet.ecdsaWalletID);\\n }\\n\\n /// @notice Gets BTC balance for given the wallet.\\n /// @param walletPubKeyHash 20-byte public key hash of the wallet.\\n /// @param walletMainUtxo Data of the wallet's main UTXO, as currently\\n /// known on the Ethereum chain.\\n /// @return walletBtcBalance Current BTC balance for the given wallet.\\n /// @dev Requirements:\\n /// - `walletMainUtxo` components must point to the recent main UTXO\\n /// of the given wallet, as currently known on the Ethereum chain.\\n /// If the wallet has no main UTXO, this parameter can be empty as it\\n /// is ignored.\\n function getWalletBtcBalance(\\n BridgeState.Storage storage self,\\n bytes20 walletPubKeyHash,\\n BitcoinTx.UTXO calldata walletMainUtxo\\n ) internal view returns (uint64 walletBtcBalance) {\\n bytes32 walletMainUtxoHash = self\\n .registeredWallets[walletPubKeyHash]\\n .mainUtxoHash;\\n\\n // If the wallet has a main UTXO hash set, cross-check it with the\\n // provided plain-text parameter and get the transaction output value\\n // as BTC balance. Otherwise, the BTC balance is just zero.\\n if (walletMainUtxoHash != bytes32(0)) {\\n require(\\n keccak256(\\n abi.encodePacked(\\n walletMainUtxo.txHash,\\n walletMainUtxo.txOutputIndex,\\n walletMainUtxo.txOutputValue\\n )\\n ) == walletMainUtxoHash,\\n \\\"Invalid wallet main UTXO data\\\"\\n );\\n\\n walletBtcBalance = walletMainUtxo.txOutputValue;\\n }\\n\\n return walletBtcBalance;\\n }\\n}\\n\",\"keccak256\":\"0x7d0ddff8dc20c10b1e62c8dba304c928c8d8de1c8b6c4d3a1c557dae99743435\",\"license\":\"GPL-3.0-only\"},\"contracts/token/TBTC.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@thesis/solidity-contracts/contracts/token/ERC20WithPermit.sol\\\";\\nimport \\\"@thesis/solidity-contracts/contracts/token/MisfundRecovery.sol\\\";\\n\\ncontract TBTC is ERC20WithPermit, MisfundRecovery {\\n constructor() ERC20WithPermit(\\\"tBTC v2\\\", \\\"tBTC\\\") {}\\n}\\n\",\"keccak256\":\"0x4542aaa48f7682005b815253768b6433c811daff5d2727db256d5f1879f5ccbf\",\"license\":\"GPL-3.0-only\"},\"contracts/vault/IVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"../bank/IReceiveBalanceApproval.sol\\\";\\n\\n/// @title Bank Vault interface\\n/// @notice `IVault` is an interface for a smart contract consuming Bank\\n/// balances of other contracts or externally owned accounts (EOA).\\ninterface IVault is IReceiveBalanceApproval {\\n /// @notice Called by the Bank in `increaseBalanceAndCall` function after\\n /// increasing the balance in the Bank for the vault. It happens in\\n /// the same transaction in which deposits were swept by the Bridge.\\n /// This allows the depositor to route their deposit revealed to the\\n /// Bridge to the particular smart contract (vault) in the same\\n /// transaction in which the deposit is revealed. This way, the\\n /// depositor does not have to execute additional transaction after\\n /// the deposit gets swept by the Bridge to approve and transfer\\n /// their balance to the vault.\\n /// @param depositors Addresses of depositors whose deposits have been swept.\\n /// @param depositedAmounts Amounts deposited by individual depositors and\\n /// swept.\\n /// @dev The implementation must ensure this function can only be called\\n /// by the Bank. The Bank guarantees that the vault's balance was\\n /// increased by the sum of all deposited amounts before this function\\n /// is called, in the same transaction.\\n function receiveBalanceIncrease(\\n address[] calldata depositors,\\n uint256[] calldata depositedAmounts\\n ) external;\\n}\\n\",\"keccak256\":\"0x12866d625abab349324ee28c6f6ec0114eaa7069ea0c5f7c7b23f6a0f833ae60\",\"license\":\"GPL-3.0-only\"},\"contracts/vault/TBTCOptimisticMinting.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"../bridge/Bridge.sol\\\";\\nimport \\\"../bridge/Deposit.sol\\\";\\nimport \\\"../GovernanceUtils.sol\\\";\\n\\n/// @title TBTC Optimistic Minting\\n/// @notice The Optimistic Minting mechanism allows to mint TBTC before\\n/// `TBTCVault` receives the Bank balance. There are two permissioned\\n/// sets in the system: Minters and Guardians, both set up in 1-of-n\\n/// mode. Minters observe the revealed deposits and request minting TBTC.\\n/// Any single Minter can perform this action. There is an\\n/// `optimisticMintingDelay` between the time of the request from\\n/// a Minter to the time TBTC is minted. During the time of the delay,\\n/// any Guardian can cancel the minting.\\n/// @dev This functionality is a part of `TBTCVault`. It is implemented in\\n/// a separate abstract contract to achieve better separation of concerns\\n/// and easier-to-follow code.\\nabstract contract TBTCOptimisticMinting is Ownable {\\n // Represents optimistic minting request for the given deposit revealed\\n // to the Bridge.\\n struct OptimisticMintingRequest {\\n // UNIX timestamp at which the optimistic minting was requested.\\n uint64 requestedAt;\\n // UNIX timestamp at which the optimistic minting was finalized.\\n // 0 if not yet finalized.\\n uint64 finalizedAt;\\n }\\n\\n /// @notice The time delay that needs to pass between initializing and\\n /// finalizing the upgrade of governable parameters.\\n uint256 public constant GOVERNANCE_DELAY = 24 hours;\\n\\n /// @notice Multiplier to convert satoshi to TBTC token units.\\n uint256 public constant SATOSHI_MULTIPLIER = 10**10;\\n\\n Bridge public immutable bridge;\\n\\n /// @notice Indicates if the optimistic minting has been paused. Only the\\n /// Governance can pause optimistic minting. Note that the pause of\\n /// the optimistic minting does not stop the standard minting flow\\n /// where wallets sweep deposits.\\n bool public isOptimisticMintingPaused;\\n\\n /// @notice Divisor used to compute the treasury fee taken from each\\n /// optimistically minted deposit and transferred to the treasury\\n /// upon finalization of the optimistic mint. This fee is computed\\n /// as follows: `fee = amount / optimisticMintingFeeDivisor`.\\n /// For example, if the fee needs to be 2%, the\\n /// `optimisticMintingFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n /// The optimistic minting fee does not replace the deposit treasury\\n /// fee cut by the Bridge. The optimistic fee is a percentage AFTER\\n /// the treasury fee is cut:\\n /// `optimisticMintingFee = (depositAmount - treasuryFee) / optimisticMintingFeeDivisor`\\n uint32 public optimisticMintingFeeDivisor = 500; // 1/500 = 0.002 = 0.2%\\n\\n /// @notice The time that needs to pass between the moment the optimistic\\n /// minting is requested and the moment optimistic minting is\\n /// finalized with minting TBTC.\\n uint32 public optimisticMintingDelay = 3 hours;\\n\\n /// @notice Indicates if the given address is a Minter. Only Minters can\\n /// request optimistic minting.\\n mapping(address => bool) public isMinter;\\n\\n /// @notice List of all Minters.\\n /// @dev May be used to establish an order in which the Minters should\\n /// request for an optimistic minting.\\n address[] public minters;\\n\\n /// @notice Indicates if the given address is a Guardian. Only Guardians can\\n /// cancel requested optimistic minting.\\n mapping(address => bool) public isGuardian;\\n\\n /// @notice Collection of all revealed deposits for which the optimistic\\n /// minting was requested. Indexed by a deposit key computed as\\n /// `keccak256(fundingTxHash | fundingOutputIndex)`.\\n mapping(uint256 => OptimisticMintingRequest)\\n public optimisticMintingRequests;\\n\\n /// @notice Optimistic minting debt value per depositor's address. The debt\\n /// represents the total value of all depositor's deposits revealed\\n /// to the Bridge that has not been yet swept and led to the\\n /// optimistic minting of TBTC. When `TBTCVault` sweeps a deposit,\\n /// the debt is fully or partially paid off, no matter if that\\n /// particular swept deposit was used for the optimistic minting or\\n /// not. The values are in 1e18 Ethereum precision.\\n mapping(address => uint256) public optimisticMintingDebt;\\n\\n /// @notice New optimistic minting fee divisor value. Set only when the\\n /// parameter update process is pending. Once the update gets\\n // finalized, this will be the value of the divisor.\\n uint32 public newOptimisticMintingFeeDivisor;\\n /// @notice The timestamp at which the update of the optimistic minting fee\\n /// divisor started. Zero if update is not in progress.\\n uint256 public optimisticMintingFeeUpdateInitiatedTimestamp;\\n\\n /// @notice New optimistic minting delay value. Set only when the parameter\\n /// update process is pending. Once the update gets finalized, this\\n // will be the value of the delay.\\n uint32 public newOptimisticMintingDelay;\\n /// @notice The timestamp at which the update of the optimistic minting\\n /// delay started. Zero if update is not in progress.\\n uint256 public optimisticMintingDelayUpdateInitiatedTimestamp;\\n\\n event OptimisticMintingRequested(\\n address indexed minter,\\n uint256 indexed depositKey,\\n address indexed depositor,\\n uint256 amount, // amount in 1e18 Ethereum precision\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n );\\n event OptimisticMintingFinalized(\\n address indexed minter,\\n uint256 indexed depositKey,\\n address indexed depositor,\\n uint256 optimisticMintingDebt\\n );\\n event OptimisticMintingCancelled(\\n address indexed guardian,\\n uint256 indexed depositKey\\n );\\n event OptimisticMintingDebtRepaid(\\n address indexed depositor,\\n uint256 optimisticMintingDebt\\n );\\n event MinterAdded(address indexed minter);\\n event MinterRemoved(address indexed minter);\\n event GuardianAdded(address indexed guardian);\\n event GuardianRemoved(address indexed guardian);\\n event OptimisticMintingPaused();\\n event OptimisticMintingUnpaused();\\n\\n event OptimisticMintingFeeUpdateStarted(\\n uint32 newOptimisticMintingFeeDivisor\\n );\\n event OptimisticMintingFeeUpdated(uint32 newOptimisticMintingFeeDivisor);\\n\\n event OptimisticMintingDelayUpdateStarted(uint32 newOptimisticMintingDelay);\\n event OptimisticMintingDelayUpdated(uint32 newOptimisticMintingDelay);\\n\\n modifier onlyMinter() {\\n require(isMinter[msg.sender], \\\"Caller is not a minter\\\");\\n _;\\n }\\n\\n modifier onlyGuardian() {\\n require(isGuardian[msg.sender], \\\"Caller is not a guardian\\\");\\n _;\\n }\\n\\n modifier onlyOwnerOrGuardian() {\\n require(\\n owner() == msg.sender || isGuardian[msg.sender],\\n \\\"Caller is not the owner or guardian\\\"\\n );\\n _;\\n }\\n\\n modifier whenOptimisticMintingNotPaused() {\\n require(!isOptimisticMintingPaused, \\\"Optimistic minting paused\\\");\\n _;\\n }\\n\\n modifier onlyAfterGovernanceDelay(uint256 updateInitiatedTimestamp) {\\n GovernanceUtils.onlyAfterGovernanceDelay(\\n updateInitiatedTimestamp,\\n GOVERNANCE_DELAY\\n );\\n _;\\n }\\n\\n constructor(Bridge _bridge) {\\n require(\\n address(_bridge) != address(0),\\n \\\"Bridge can not be the zero address\\\"\\n );\\n\\n bridge = _bridge;\\n }\\n\\n /// @dev Mints the given amount of TBTC to the given depositor's address.\\n /// Implemented by TBTCVault.\\n function _mint(address minter, uint256 amount) internal virtual;\\n\\n /// @notice Allows to fetch a list of all Minters.\\n function getMinters() external view returns (address[] memory) {\\n return minters;\\n }\\n\\n /// @notice Allows a Minter to request for an optimistic minting of TBTC.\\n /// The following conditions must be met:\\n /// - There is no optimistic minting request for the deposit,\\n /// finalized or not.\\n /// - The deposit with the given Bitcoin funding transaction hash\\n /// and output index has been revealed to the Bridge.\\n /// - The deposit has not been swept yet.\\n /// - The deposit is targeted into the TBTCVault.\\n /// - The optimistic minting is not paused.\\n /// After calling this function, the Minter has to wait for\\n /// `optimisticMintingDelay` before finalizing the mint with a call\\n /// to finalizeOptimisticMint.\\n /// @dev The deposit done on the Bitcoin side must be revealed early enough\\n /// to the Bridge on Ethereum to pass the Bridge's validation. The\\n /// validation passes successfully only if the deposit reveal is done\\n /// respectively earlier than the moment when the deposit refund\\n /// locktime is reached, i.e. the deposit becomes refundable. It may\\n /// happen that the wallet does not sweep a revealed deposit and one of\\n /// the Minters requests an optimistic mint for that deposit just\\n /// before the locktime is reached. Guardians must cancel optimistic\\n /// minting for this deposit because the wallet will not be able to\\n /// sweep it. The on-chain optimistic minting code does not perform any\\n /// validation for gas efficiency: it would have to perform the same\\n /// validation as `validateDepositRefundLocktime` and expect the entire\\n /// `DepositRevealInfo` to be passed to assemble the expected script\\n /// hash on-chain. Guardians must validate if the deposit happened on\\n /// Bitcoin, that the script hash has the expected format, and that the\\n /// wallet is an active one so they can also validate the time left for\\n /// the refund.\\n function requestOptimisticMint(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external onlyMinter whenOptimisticMintingNotPaused {\\n uint256 depositKey = calculateDepositKey(\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n\\n OptimisticMintingRequest storage request = optimisticMintingRequests[\\n depositKey\\n ];\\n require(\\n request.requestedAt == 0,\\n \\\"Optimistic minting already requested for the deposit\\\"\\n );\\n\\n Deposit.DepositRequest memory deposit = bridge.deposits(depositKey);\\n\\n require(deposit.revealedAt != 0, \\\"The deposit has not been revealed\\\");\\n require(deposit.sweptAt == 0, \\\"The deposit is already swept\\\");\\n require(deposit.vault == address(this), \\\"Unexpected vault address\\\");\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n request.requestedAt = uint64(block.timestamp);\\n\\n emit OptimisticMintingRequested(\\n msg.sender,\\n depositKey,\\n deposit.depositor,\\n deposit.amount * SATOSHI_MULTIPLIER,\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n }\\n\\n /// @notice Allows a Minter to finalize previously requested optimistic\\n /// minting. The following conditions must be met:\\n /// - The optimistic minting has been requested for the given\\n /// deposit.\\n /// - The deposit has not been swept yet.\\n /// - At least `optimisticMintingDelay` passed since the optimistic\\n /// minting was requested for the given deposit.\\n /// - The optimistic minting has not been finalized earlier for the\\n /// given deposit.\\n /// - The optimistic minting request for the given deposit has not\\n /// been canceled by a Guardian.\\n /// - The optimistic minting is not paused.\\n /// This function mints TBTC and increases `optimisticMintingDebt`\\n /// for the given depositor. The optimistic minting request is\\n /// marked as finalized.\\n function finalizeOptimisticMint(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external onlyMinter whenOptimisticMintingNotPaused {\\n uint256 depositKey = calculateDepositKey(\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n\\n OptimisticMintingRequest storage request = optimisticMintingRequests[\\n depositKey\\n ];\\n require(\\n request.requestedAt != 0,\\n \\\"Optimistic minting not requested for the deposit\\\"\\n );\\n require(\\n request.finalizedAt == 0,\\n \\\"Optimistic minting already finalized for the deposit\\\"\\n );\\n\\n require(\\n /* solhint-disable-next-line not-rely-on-time */\\n block.timestamp > request.requestedAt + optimisticMintingDelay,\\n \\\"Optimistic minting delay has not passed yet\\\"\\n );\\n\\n Deposit.DepositRequest memory deposit = bridge.deposits(depositKey);\\n require(deposit.sweptAt == 0, \\\"The deposit is already swept\\\");\\n\\n // Bridge, when sweeping, cuts a deposit treasury fee and splits\\n // Bitcoin miner fee for the sweep transaction evenly between the\\n // depositors in the sweep.\\n //\\n // When tokens are optimistically minted, we do not know what the\\n // Bitcoin miner fee for the sweep transaction will look like.\\n // The Bitcoin miner fee is ignored. When sweeping, the miner fee is\\n // subtracted so the optimisticMintingDebt may stay non-zero after the\\n // deposit is swept.\\n //\\n // This imbalance is supposed to be solved by a donation to the Bridge.\\n uint256 amountToMint = (deposit.amount - deposit.treasuryFee) *\\n SATOSHI_MULTIPLIER;\\n\\n // The Optimistic Minting mechanism may additionally cut a fee from the\\n // amount that is left after deducting the Bridge deposit treasury fee.\\n // Think of this fee as an extra payment for faster processing of\\n // deposits. One does not need to use the Optimistic Minting mechanism\\n // and they may wait for the Bridge to sweep their deposit if they do\\n // not want to pay the Optimistic Minting fee.\\n uint256 optimisticMintFee = optimisticMintingFeeDivisor > 0\\n ? (amountToMint / optimisticMintingFeeDivisor)\\n : 0;\\n\\n // Both the optimistic minting fee and the share that goes to the\\n // depositor are optimistically minted. All TBTC that is optimistically\\n // minted should be added to the optimistic minting debt. When the\\n // deposit is swept, it is paying off both the depositor's share and the\\n // treasury's share (optimistic minting fee).\\n uint256 newDebt = optimisticMintingDebt[deposit.depositor] +\\n amountToMint;\\n optimisticMintingDebt[deposit.depositor] = newDebt;\\n\\n _mint(deposit.depositor, amountToMint - optimisticMintFee);\\n if (optimisticMintFee > 0) {\\n _mint(bridge.treasury(), optimisticMintFee);\\n }\\n\\n /* solhint-disable-next-line not-rely-on-time */\\n request.finalizedAt = uint64(block.timestamp);\\n\\n emit OptimisticMintingFinalized(\\n msg.sender,\\n depositKey,\\n deposit.depositor,\\n newDebt\\n );\\n }\\n\\n /// @notice Allows a Guardian to cancel optimistic minting request. The\\n /// following conditions must be met:\\n /// - The optimistic minting request for the given deposit exists.\\n /// - The optimistic minting request for the given deposit has not\\n /// been finalized yet.\\n /// Optimistic minting request is removed. It is possible to request\\n /// optimistic minting again for the same deposit later.\\n /// @dev Guardians must validate the following conditions for every deposit\\n /// for which the optimistic minting was requested:\\n /// - The deposit happened on Bitcoin side and it has enough\\n /// confirmations.\\n /// - The optimistic minting has been requested early enough so that\\n /// the wallet has enough time to sweep the deposit.\\n /// - The wallet is an active one and it does perform sweeps or it will\\n /// perform sweeps once the sweeps are activated.\\n function cancelOptimisticMint(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) external onlyGuardian {\\n uint256 depositKey = calculateDepositKey(\\n fundingTxHash,\\n fundingOutputIndex\\n );\\n\\n OptimisticMintingRequest storage request = optimisticMintingRequests[\\n depositKey\\n ];\\n require(\\n request.requestedAt != 0,\\n \\\"Optimistic minting not requested for the deposit\\\"\\n );\\n require(\\n request.finalizedAt == 0,\\n \\\"Optimistic minting already finalized for the deposit\\\"\\n );\\n\\n // Delete it. It allows to request optimistic minting for the given\\n // deposit again. Useful in case of an errant Guardian.\\n delete optimisticMintingRequests[depositKey];\\n\\n emit OptimisticMintingCancelled(msg.sender, depositKey);\\n }\\n\\n /// @notice Adds the address to the Minter list.\\n function addMinter(address minter) external onlyOwner {\\n require(!isMinter[minter], \\\"This address is already a minter\\\");\\n isMinter[minter] = true;\\n minters.push(minter);\\n emit MinterAdded(minter);\\n }\\n\\n /// @notice Removes the address from the Minter list.\\n function removeMinter(address minter) external onlyOwnerOrGuardian {\\n require(isMinter[minter], \\\"This address is not a minter\\\");\\n delete isMinter[minter];\\n\\n // We do not expect too many Minters so a simple loop is safe.\\n for (uint256 i = 0; i < minters.length; i++) {\\n if (minters[i] == minter) {\\n minters[i] = minters[minters.length - 1];\\n // slither-disable-next-line costly-loop\\n minters.pop();\\n break;\\n }\\n }\\n\\n emit MinterRemoved(minter);\\n }\\n\\n /// @notice Adds the address to the Guardian set.\\n function addGuardian(address guardian) external onlyOwner {\\n require(!isGuardian[guardian], \\\"This address is already a guardian\\\");\\n isGuardian[guardian] = true;\\n emit GuardianAdded(guardian);\\n }\\n\\n /// @notice Removes the address from the Guardian set.\\n function removeGuardian(address guardian) external onlyOwner {\\n require(isGuardian[guardian], \\\"This address is not a guardian\\\");\\n delete isGuardian[guardian];\\n emit GuardianRemoved(guardian);\\n }\\n\\n /// @notice Pauses the optimistic minting. Note that the pause of the\\n /// optimistic minting does not stop the standard minting flow\\n /// where wallets sweep deposits.\\n function pauseOptimisticMinting() external onlyOwner {\\n require(\\n !isOptimisticMintingPaused,\\n \\\"Optimistic minting already paused\\\"\\n );\\n isOptimisticMintingPaused = true;\\n emit OptimisticMintingPaused();\\n }\\n\\n /// @notice Unpauses the optimistic minting.\\n function unpauseOptimisticMinting() external onlyOwner {\\n require(isOptimisticMintingPaused, \\\"Optimistic minting is not paused\\\");\\n isOptimisticMintingPaused = false;\\n emit OptimisticMintingUnpaused();\\n }\\n\\n /// @notice Begins the process of updating optimistic minting fee.\\n /// The fee is computed as follows:\\n /// `fee = amount / optimisticMintingFeeDivisor`.\\n /// For example, if the fee needs to be 2% of each deposit,\\n /// the `optimisticMintingFeeDivisor` should be set to `50` because\\n /// `1/50 = 0.02 = 2%`.\\n /// @dev See the documentation for optimisticMintingFeeDivisor.\\n function beginOptimisticMintingFeeUpdate(\\n uint32 _newOptimisticMintingFeeDivisor\\n ) external onlyOwner {\\n /* solhint-disable-next-line not-rely-on-time */\\n optimisticMintingFeeUpdateInitiatedTimestamp = block.timestamp;\\n newOptimisticMintingFeeDivisor = _newOptimisticMintingFeeDivisor;\\n emit OptimisticMintingFeeUpdateStarted(_newOptimisticMintingFeeDivisor);\\n }\\n\\n /// @notice Finalizes the update process of the optimistic minting fee.\\n function finalizeOptimisticMintingFeeUpdate()\\n external\\n onlyOwner\\n onlyAfterGovernanceDelay(optimisticMintingFeeUpdateInitiatedTimestamp)\\n {\\n optimisticMintingFeeDivisor = newOptimisticMintingFeeDivisor;\\n emit OptimisticMintingFeeUpdated(newOptimisticMintingFeeDivisor);\\n\\n newOptimisticMintingFeeDivisor = 0;\\n optimisticMintingFeeUpdateInitiatedTimestamp = 0;\\n }\\n\\n /// @notice Begins the process of updating optimistic minting delay.\\n function beginOptimisticMintingDelayUpdate(\\n uint32 _newOptimisticMintingDelay\\n ) external onlyOwner {\\n /* solhint-disable-next-line not-rely-on-time */\\n optimisticMintingDelayUpdateInitiatedTimestamp = block.timestamp;\\n newOptimisticMintingDelay = _newOptimisticMintingDelay;\\n emit OptimisticMintingDelayUpdateStarted(_newOptimisticMintingDelay);\\n }\\n\\n /// @notice Finalizes the update process of the optimistic minting delay.\\n function finalizeOptimisticMintingDelayUpdate()\\n external\\n onlyOwner\\n onlyAfterGovernanceDelay(optimisticMintingDelayUpdateInitiatedTimestamp)\\n {\\n optimisticMintingDelay = newOptimisticMintingDelay;\\n emit OptimisticMintingDelayUpdated(newOptimisticMintingDelay);\\n\\n newOptimisticMintingDelay = 0;\\n optimisticMintingDelayUpdateInitiatedTimestamp = 0;\\n }\\n\\n /// @notice Calculates deposit key the same way as the Bridge contract.\\n /// The deposit key is computed as\\n /// `keccak256(fundingTxHash | fundingOutputIndex)`.\\n function calculateDepositKey(\\n bytes32 fundingTxHash,\\n uint32 fundingOutputIndex\\n ) public pure returns (uint256) {\\n return\\n uint256(\\n keccak256(abi.encodePacked(fundingTxHash, fundingOutputIndex))\\n );\\n }\\n\\n /// @notice Used by `TBTCVault.receiveBalanceIncrease` to repay the optimistic\\n /// minting debt before TBTC is minted. When optimistic minting is\\n /// finalized, debt equal to the value of the deposit being\\n /// a subject of the optimistic minting is incurred. When `TBTCVault`\\n /// sweeps a deposit, the debt is fully or partially paid off, no\\n /// matter if that particular deposit was used for the optimistic\\n /// minting or not.\\n /// @dev See `TBTCVault.receiveBalanceIncrease`\\n /// @param depositor The depositor whose balance increase is received.\\n /// @param amount The balance increase amount for the depositor received.\\n /// @return The TBTC amount that should be minted after paying off the\\n /// optimistic minting debt.\\n function repayOptimisticMintingDebt(address depositor, uint256 amount)\\n internal\\n returns (uint256)\\n {\\n uint256 debt = optimisticMintingDebt[depositor];\\n if (debt == 0) {\\n return amount;\\n }\\n\\n if (amount > debt) {\\n optimisticMintingDebt[depositor] = 0;\\n emit OptimisticMintingDebtRepaid(depositor, 0);\\n return amount - debt;\\n } else {\\n optimisticMintingDebt[depositor] = debt - amount;\\n emit OptimisticMintingDebtRepaid(depositor, debt - amount);\\n return 0;\\n }\\n }\\n}\\n\",\"keccak256\":\"0xa4bfc703dafeca2acb0e3c5c96d7f052692147b3812496f426f43e25ef4ba123\",\"license\":\"GPL-3.0-only\"},\"contracts/vault/TBTCVault.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\n\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588 \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\u2588\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n// \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c \\u2590\\u2588\\u2588\\u2588\\u2588\\u258c\\n\\npragma solidity 0.8.17;\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\n\\nimport \\\"./IVault.sol\\\";\\nimport \\\"./TBTCOptimisticMinting.sol\\\";\\nimport \\\"../bank/Bank.sol\\\";\\nimport \\\"../token/TBTC.sol\\\";\\n\\n/// @title TBTC application vault\\n/// @notice TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of\\n/// Bitcoin. It facilitates Bitcoin holders to act on the Ethereum\\n/// blockchain and access the decentralized finance (DeFi) ecosystem.\\n/// TBTC Vault mints and unmints TBTC based on Bitcoin balances in the\\n/// Bank.\\n/// @dev TBTC Vault is the owner of TBTC token contract and is the only contract\\n/// minting the token.\\ncontract TBTCVault is IVault, Ownable, TBTCOptimisticMinting {\\n using SafeERC20 for IERC20;\\n\\n Bank public immutable bank;\\n TBTC public immutable tbtcToken;\\n\\n /// @notice The address of a new TBTC vault. Set only when the upgrade\\n /// process is pending. Once the upgrade gets finalized, the new\\n /// TBTC vault will become an owner of TBTC token.\\n address public newVault;\\n /// @notice The timestamp at which an upgrade to a new TBTC vault was\\n /// initiated. Set only when the upgrade process is pending.\\n uint256 public upgradeInitiatedTimestamp;\\n\\n event Minted(address indexed to, uint256 amount);\\n event Unminted(address indexed from, uint256 amount);\\n\\n event UpgradeInitiated(address newVault, uint256 timestamp);\\n event UpgradeFinalized(address newVault);\\n\\n modifier onlyBank() {\\n require(msg.sender == address(bank), \\\"Caller is not the Bank\\\");\\n _;\\n }\\n\\n constructor(\\n Bank _bank,\\n TBTC _tbtcToken,\\n Bridge _bridge\\n ) TBTCOptimisticMinting(_bridge) {\\n require(\\n address(_bank) != address(0),\\n \\\"Bank can not be the zero address\\\"\\n );\\n\\n require(\\n address(_tbtcToken) != address(0),\\n \\\"TBTC token can not be the zero address\\\"\\n );\\n\\n bank = _bank;\\n tbtcToken = _tbtcToken;\\n }\\n\\n /// @notice Mints the given `amount` of TBTC to the caller previously\\n /// transferring `amount / SATOSHI_MULTIPLIER` of the Bank balance\\n /// from caller to TBTC Vault. If `amount` is not divisible by\\n /// SATOSHI_MULTIPLIER, the remainder is left on the caller's\\n /// Bank balance.\\n /// @dev TBTC Vault must have an allowance for caller's balance in the\\n /// Bank for at least `amount / SATOSHI_MULTIPLIER`.\\n /// @param amount Amount of TBTC to mint.\\n function mint(uint256 amount) external {\\n (uint256 convertibleAmount, , uint256 satoshis) = amountToSatoshis(\\n amount\\n );\\n\\n require(\\n bank.balanceOf(msg.sender) >= satoshis,\\n \\\"Amount exceeds balance in the bank\\\"\\n );\\n _mint(msg.sender, convertibleAmount);\\n bank.transferBalanceFrom(msg.sender, address(this), satoshis);\\n }\\n\\n /// @notice Transfers `satoshis` of the Bank balance from the caller\\n /// to TBTC Vault and mints `satoshis * SATOSHI_MULTIPLIER` of TBTC\\n /// to the caller.\\n /// @dev Can only be called by the Bank via `approveBalanceAndCall`.\\n /// @param owner The owner who approved their Bank balance.\\n /// @param satoshis Amount of satoshis used to mint TBTC.\\n function receiveBalanceApproval(\\n address owner,\\n uint256 satoshis,\\n bytes calldata\\n ) external override onlyBank {\\n require(\\n bank.balanceOf(owner) >= satoshis,\\n \\\"Amount exceeds balance in the bank\\\"\\n );\\n _mint(owner, satoshis * SATOSHI_MULTIPLIER);\\n bank.transferBalanceFrom(owner, address(this), satoshis);\\n }\\n\\n /// @notice Mints the same amount of TBTC as the deposited satoshis amount\\n /// multiplied by SATOSHI_MULTIPLIER for each depositor in the array.\\n /// Can only be called by the Bank after the Bridge swept deposits\\n /// and Bank increased balance for the vault.\\n /// @dev Fails if `depositors` array is empty. Expects the length of\\n /// `depositors` and `depositedSatoshiAmounts` is the same.\\n function receiveBalanceIncrease(\\n address[] calldata depositors,\\n uint256[] calldata depositedSatoshiAmounts\\n ) external override onlyBank {\\n require(depositors.length != 0, \\\"No depositors specified\\\");\\n for (uint256 i = 0; i < depositors.length; i++) {\\n address depositor = depositors[i];\\n uint256 satoshis = depositedSatoshiAmounts[i];\\n _mint(\\n depositor,\\n repayOptimisticMintingDebt(\\n depositor,\\n satoshis * SATOSHI_MULTIPLIER\\n )\\n );\\n }\\n }\\n\\n /// @notice Burns `amount` of TBTC from the caller's balance and transfers\\n /// `amount / SATOSHI_MULTIPLIER` back to the caller's balance in\\n /// the Bank. If `amount` is not divisible by SATOSHI_MULTIPLIER,\\n /// the remainder is left on the caller's account.\\n /// @dev Caller must have at least `amount` of TBTC approved to\\n /// TBTC Vault.\\n /// @param amount Amount of TBTC to unmint.\\n function unmint(uint256 amount) external {\\n (uint256 convertibleAmount, , ) = amountToSatoshis(amount);\\n\\n _unmint(msg.sender, convertibleAmount);\\n }\\n\\n /// @notice Burns `amount` of TBTC from the caller's balance and transfers\\n /// `amount / SATOSHI_MULTIPLIER` of Bank balance to the Bridge\\n /// requesting redemption based on the provided `redemptionData`.\\n /// If `amount` is not divisible by SATOSHI_MULTIPLIER, the\\n /// remainder is left on the caller's account.\\n /// @dev Caller must have at least `amount` of TBTC approved to\\n /// TBTC Vault.\\n /// @param amount Amount of TBTC to unmint and request to redeem in Bridge.\\n /// @param redemptionData Redemption data in a format expected from\\n /// `redemptionData` parameter of Bridge's `receiveBalanceApproval`\\n /// function.\\n function unmintAndRedeem(uint256 amount, bytes calldata redemptionData)\\n external\\n {\\n (uint256 convertibleAmount, , ) = amountToSatoshis(amount);\\n\\n _unmintAndRedeem(msg.sender, convertibleAmount, redemptionData);\\n }\\n\\n /// @notice Burns `amount` of TBTC from the caller's balance. If `extraData`\\n /// is empty, transfers `amount` back to the caller's balance in the\\n /// Bank. If `extraData` is not empty, requests redemption in the\\n /// Bridge using the `extraData` as a `redemptionData` parameter to\\n /// Bridge's `receiveBalanceApproval` function.\\n /// If `amount` is not divisible by SATOSHI_MULTIPLIER, the\\n /// remainder is left on the caller's account. Note that it may\\n /// left a token approval equal to the remainder.\\n /// @dev This function is doing the same as `unmint` or `unmintAndRedeem`\\n /// (depending on `extraData` parameter) but it allows to execute\\n /// unminting without a separate approval transaction. The function can\\n /// be called only via `approveAndCall` of TBTC token.\\n /// @param from TBTC token holder executing unminting.\\n /// @param amount Amount of TBTC to unmint.\\n /// @param token TBTC token address.\\n /// @param extraData Redemption data in a format expected from\\n /// `redemptionData` parameter of Bridge's `receiveBalanceApproval`\\n /// function. If empty, `receiveApproval` is not requesting a\\n /// redemption of Bank balance but is instead performing just TBTC\\n /// unminting to a Bank balance.\\n function receiveApproval(\\n address from,\\n uint256 amount,\\n address token,\\n bytes calldata extraData\\n ) external {\\n require(token == address(tbtcToken), \\\"Token is not TBTC\\\");\\n require(msg.sender == token, \\\"Only TBTC caller allowed\\\");\\n (uint256 convertibleAmount, , ) = amountToSatoshis(amount);\\n if (extraData.length == 0) {\\n _unmint(from, convertibleAmount);\\n } else {\\n _unmintAndRedeem(from, convertibleAmount, extraData);\\n }\\n }\\n\\n /// @notice Initiates vault upgrade process. The upgrade process needs to be\\n /// finalized with a call to `finalizeUpgrade` function after the\\n /// `UPGRADE_GOVERNANCE_DELAY` passes. Only the governance can\\n /// initiate the upgrade.\\n /// @param _newVault The new vault address.\\n function initiateUpgrade(address _newVault) external onlyOwner {\\n require(_newVault != address(0), \\\"New vault address cannot be zero\\\");\\n /* solhint-disable-next-line not-rely-on-time */\\n emit UpgradeInitiated(_newVault, block.timestamp);\\n /* solhint-disable-next-line not-rely-on-time */\\n upgradeInitiatedTimestamp = block.timestamp;\\n newVault = _newVault;\\n }\\n\\n /// @notice Allows the governance to finalize vault upgrade process. The\\n /// upgrade process needs to be first initiated with a call to\\n /// `initiateUpgrade` and the `GOVERNANCE_DELAY` needs to pass.\\n /// Once the upgrade is finalized, the new vault becomes the owner\\n /// of the TBTC token and receives the whole Bank balance of this\\n /// vault.\\n function finalizeUpgrade()\\n external\\n onlyOwner\\n onlyAfterGovernanceDelay(upgradeInitiatedTimestamp)\\n {\\n emit UpgradeFinalized(newVault);\\n // slither-disable-next-line reentrancy-no-eth\\n tbtcToken.transferOwnership(newVault);\\n bank.transferBalance(newVault, bank.balanceOf(address(this)));\\n newVault = address(0);\\n upgradeInitiatedTimestamp = 0;\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC20\\n /// token sent mistakenly to the TBTC token contract address.\\n /// @param token Address of the recovered ERC20 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param amount Recovered amount.\\n function recoverERC20FromToken(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n tbtcToken.recoverERC20(token, recipient, amount);\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC721\\n /// token sent mistakenly to the TBTC token contract address.\\n /// @param token Address of the recovered ERC721 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param tokenId Identifier of the recovered token.\\n /// @param data Additional data.\\n function recoverERC721FromToken(\\n IERC721 token,\\n address recipient,\\n uint256 tokenId,\\n bytes calldata data\\n ) external onlyOwner {\\n tbtcToken.recoverERC721(token, recipient, tokenId, data);\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC20\\n /// token sent - mistakenly or not - to the vault address. This\\n /// function should be used to withdraw TBTC v1 tokens transferred\\n /// to TBTCVault as a result of VendingMachine > TBTCVault upgrade.\\n /// @param token Address of the recovered ERC20 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param amount Recovered amount.\\n function recoverERC20(\\n IERC20 token,\\n address recipient,\\n uint256 amount\\n ) external onlyOwner {\\n token.safeTransfer(recipient, amount);\\n }\\n\\n /// @notice Allows the governance of the TBTCVault to recover any ERC721\\n /// token sent mistakenly to the vault address.\\n /// @param token Address of the recovered ERC721 token contract.\\n /// @param recipient Address the recovered token should be sent to.\\n /// @param tokenId Identifier of the recovered token.\\n /// @param data Additional data.\\n function recoverERC721(\\n IERC721 token,\\n address recipient,\\n uint256 tokenId,\\n bytes calldata data\\n ) external onlyOwner {\\n token.safeTransferFrom(address(this), recipient, tokenId, data);\\n }\\n\\n /// @notice Returns the amount of TBTC to be minted/unminted, the remainder,\\n /// and the Bank balance to be transferred for the given mint/unmint.\\n /// Note that if the `amount` is not divisible by SATOSHI_MULTIPLIER,\\n /// the remainder is left on the caller's account when minting or\\n /// unminting.\\n /// @return convertibleAmount Amount of TBTC to be minted/unminted.\\n /// @return remainder Not convertible remainder if amount is not divisible\\n /// by SATOSHI_MULTIPLIER.\\n /// @return satoshis Amount in satoshis - the Bank balance to be transferred\\n /// for the given mint/unmint\\n function amountToSatoshis(uint256 amount)\\n public\\n view\\n returns (\\n uint256 convertibleAmount,\\n uint256 remainder,\\n uint256 satoshis\\n )\\n {\\n remainder = amount % SATOSHI_MULTIPLIER;\\n convertibleAmount = amount - remainder;\\n satoshis = convertibleAmount / SATOSHI_MULTIPLIER;\\n }\\n\\n // slither-disable-next-line calls-loop\\n function _mint(address minter, uint256 amount) internal override {\\n emit Minted(minter, amount);\\n tbtcToken.mint(minter, amount);\\n }\\n\\n /// @dev `amount` MUST be divisible by SATOSHI_MULTIPLIER with no change.\\n function _unmint(address unminter, uint256 amount) internal {\\n emit Unminted(unminter, amount);\\n tbtcToken.burnFrom(unminter, amount);\\n bank.transferBalance(unminter, amount / SATOSHI_MULTIPLIER);\\n }\\n\\n /// @dev `amount` MUST be divisible by SATOSHI_MULTIPLIER with no change.\\n function _unmintAndRedeem(\\n address redeemer,\\n uint256 amount,\\n bytes calldata redemptionData\\n ) internal {\\n emit Unminted(redeemer, amount);\\n tbtcToken.burnFrom(redeemer, amount);\\n bank.approveBalanceAndCall(\\n address(bridge),\\n amount / SATOSHI_MULTIPLIER,\\n redemptionData\\n );\\n }\\n}\\n\",\"keccak256\":\"0x98f5c27ce01926f53eb30daa11bd9b2b0cf24274d81a99a04a74ed220f0a69cb\",\"license\":\"GPL-3.0-only\"}},\"version\":1}", + "bytecode": "0x60e060405260008054600160a81b600160e81b031916650a8c0000007d60aa1b1790553480156200002f57600080fd5b5060405162003e2f38038062003e2f83398101604081905262000052916200020c565b806200005e33620001a3565b6001600160a01b038116620000c55760405162461bcd60e51b815260206004820152602260248201527f4272696467652063616e206e6f7420626520746865207a65726f206164647265604482015261737360f01b60648201526084015b60405180910390fd5b6001600160a01b039081166080528316620001235760405162461bcd60e51b815260206004820181905260248201527f42616e6b2063616e206e6f7420626520746865207a65726f20616464726573736044820152606401620000bc565b6001600160a01b0382166200018a5760405162461bcd60e51b815260206004820152602660248201527f5442544320746f6b656e2063616e206e6f7420626520746865207a65726f206160448201526564647265737360d01b6064820152608401620000bc565b506001600160a01b0391821660a0521660c05262000260565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b03811681146200020957600080fd5b50565b6000806000606084860312156200022257600080fd5b83516200022f81620001f3565b60208501519093506200024281620001f3565b60408501519092506200025581620001f3565b809150509250925092565b60805160a05160c051613b136200031c600039600081816107330152818161098001528181610cf401528181611fb0015281816123b101528181612d6d01528181612ed8015261301f01526000818161057901528181610d6101528181610ebc01528181610f4a0152818161104f0152818161242d015281816125650152818161265601528181612f36015261307d01526000818161075a015281816115720152818161170e01528181611d620152612f650152613b136000f3fe608060405234801561001057600080fd5b50600436106103365760003560e01c80638532c511116101b2578063a410d29b116100f9578063c36b32b7116100a2578063e5d3d7141161007c578063e5d3d7141461072e578063e78cea9214610755578063f2fde38b1461077c578063fc4e51f61461078f57600080fd5b8063c36b32b7146106ff578063c7ba034714610712578063d0ff65b51461071e57600080fd5b8063b0b54895116100d3578063b0b54895146106cd578063b9f78798146106d7578063bc7b6b99146106f757600080fd5b8063a410d29b1461068f578063a526d83b14610697578063aa271e1a146106aa57600080fd5b8063951315261161015b5780639a508c8e116101355780639a508c8e1461066b578063a0712d6814610673578063a0cceb951461068657600080fd5b80639513152614610647578063983b2d56146106505780639a4e36d51461066357600080fd5b8063897f712c1161018c578063897f712c1461060f5780638da5cb5b146106235780638f4ffcb11461063457600080fd5b80638532c511146105d95780638623ec7b146105e957806388aaf0c8146105fc57600080fd5b806347c1ffdb116102815780636c626aa41161022a5780637445a5a0116102045780637445a5a01461054657806376cdb03b1461057457806380df5ed2146105b3578063820b5513146105c657600080fd5b80636c626aa4146104d0578063714041561461052b578063715018a61461053e57600080fd5b806364e779b11161025b57806364e779b1146104955780636abe3a6c146104a85780636b32810b146104bb57600080fd5b806347c1ffdb1461046357806353dce4df1461046b5780635ae2da461461047e57600080fd5b80633092afd5116102e3578063461c6373116102bd578063461c63731461042a578063475d05701461043d578063479aa9271461045057600080fd5b80633092afd5146103fb578063317dfa761461040e57806341906ab71461042157600080fd5b80631171bda9116103145780631171bda9146103b4578063124f65bd146103c75780632e73e398146103e857600080fd5b806309b53f511461033b5780630c68ba211461036c5780630f3425731461039f575b600080fd5b60005461035290600160a81b900463ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b61038f61037a3660046133e9565b60036020526000908152604090205460ff1681565b6040519015158152602001610363565b6103b26103ad366004613418565b6107a2565b005b6103b26103c2366004613435565b610842565b6103da6103d5366004613476565b6108a3565b604051908152602001610363565b6103b26103f63660046134ef565b610908565b6103b26104093660046133e9565b6109f6565b6103b261041c366004613435565b610c65565b6103da60095481565b6103b26104383660046135a7565b610d56565b6103b261044b366004613613565b610eb1565b6103b261045e3660046133e9565b6110b2565b6103b26111b7565b6103b2610479366004613663565b611295565b60005461035290600160c81b900463ffffffff1681565b6103b26104a33660046136af565b6112b6565b6103b26104b6366004613476565b6112d3565b6104c3611820565b60405161036391906136c8565b61050a6104de3660046136af565b60046020526000908152604090205467ffffffffffffffff808216916801000000000000000090041682565b6040805167ffffffffffffffff938416815292909116602083015201610363565b6103b26105393660046133e9565b611882565b6103b261197b565b6105596105543660046136af565b6119cf565b60408051938452602084019290925290820152606001610363565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610363565b6103b26105c1366004613476565b611a07565b6103b26105d4366004613476565b611bf3565b6006546103529063ffffffff1681565b61059b6105f73660046136af565b611f84565b600a5461059b906001600160a01b031681565b60005461038f90600160a01b900460ff1681565b6000546001600160a01b031661059b565b6103b2610642366004613715565b611fae565b6103da600b5481565b6103b261065e3660046133e9565b6120c3565b6103b2612200565b6103b26122de565b6103b26106813660046136af565b612535565b6103da60075481565b6103b261268d565b6103b26106a53660046133e9565b612775565b61038f6106b83660046133e9565b60016020526000908152604090205460ff1681565b6103da6201518081565b6103da6106e53660046133e9565b60056020526000908152604090205481565b6103b2612898565b6103b261070d366004613418565b61296f565b6103da6402540be40081565b6008546103529063ffffffff1681565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6103b261078a3660046133e9565b612a03565b6103b261079d3660046134ef565b612ad3565b6000546001600160a01b031633146107ef5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064015b60405180910390fd5b426009556008805463ffffffff191663ffffffff83169081179091556040519081527f682bc0fb7e0d6bcb974cf556b95f68533cafc411d83d9f33ac192ccf45dda605906020015b60405180910390a150565b6000546001600160a01b0316331461088a5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b61089e6001600160a01b0384168383612b68565b505050565b600082826040516020016108e692919091825260e01b7fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6040516020818303038152906040528051906020012060001c90505b92915050565b6000546001600160a01b031633146109505760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fc4e51f6906109bd9088908890889088908890600401613794565b600060405180830381600087803b1580156109d757600080fd5b505af11580156109eb573d6000803e3d6000fd5b505050505050505050565b33610a096000546001600160a01b031690565b6001600160a01b03161480610a2d57503360009081526003602052604090205460ff165b610a9f5760405162461bcd60e51b815260206004820152602360248201527f43616c6c6572206973206e6f7420746865206f776e6572206f7220677561726460448201527f69616e000000000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b03811660009081526001602052604090205460ff16610b075760405162461bcd60e51b815260206004820152601c60248201527f546869732061646472657373206973206e6f742061206d696e7465720000000060448201526064016107e6565b6001600160a01b0381166000908152600160205260408120805460ff191690555b600254811015610c2d57816001600160a01b031660028281548110610b4f57610b4f6137c7565b6000918252602090912001546001600160a01b031603610c1b5760028054610b79906001906137f3565b81548110610b8957610b896137c7565b600091825260209091200154600280546001600160a01b039092169183908110610bb557610bb56137c7565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506002805480610bf457610bf4613806565b600082815260209020810160001990810180546001600160a01b0319169055019055610c2d565b80610c258161381c565b915050610b28565b506040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b6000546001600160a01b03163314610cad5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301528381166024830152604482018390527f00000000000000000000000000000000000000000000000000000000000000001690631171bda9906064015b600060405180830381600087803b158015610d3957600080fd5b505af1158015610d4d573d6000803e3d6000fd5b50505050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610dce5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016107e6565b6000839003610e1f5760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f72732073706563696669656400000000000000000060448201526064016107e6565b60005b83811015610eaa576000858583818110610e3e57610e3e6137c7565b9050602002016020810190610e5391906133e9565b90506000848484818110610e6957610e696137c7565b905060200201359050610e9582610e90846402540be40085610e8b9190613835565b612be8565b612ceb565b50508080610ea29061381c565b915050610e22565b5050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610f295760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016107e6565b6040516370a0823160e01b81526001600160a01b03858116600483015284917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa158015610f93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb7919061384c565b10156110105760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016107e6565b61102384610e906402540be40086613835565b604051631f1b6d2760e21b81526001600160a01b038581166004830152306024830152604482018590527f00000000000000000000000000000000000000000000000000000000000000001690637c6db49c906064015b600060405180830381600087803b15801561109457600080fd5b505af11580156110a8573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146110fa5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b0381166111505760405162461bcd60e51b815260206004820181905260248201527f4e6577207661756c7420616464726573732063616e6e6f74206265207a65726f60448201526064016107e6565b604080516001600160a01b03831681524260208201527f5cc842cab066489e13292128663547c68705dbf476f0131e0107f155719c6124910160405180910390a142600b55600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146111ff5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b60075461120f8162015180612dc6565b600654600080547fffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160a81b81029290921790556040519081527fa7f4ce7c3586e2000cdec6b25c5e7d0b20f9b4f435aa22d9c1feb32dbb506f779060200160405180910390a1506006805463ffffffff191690556000600755565b60006112a0846119cf565b505090506112b033828585612e6f565b50505050565b60006112c1826119cf565b505090506112cf3382612fb6565b5050565b3360009081526001602052604090205460ff166113325760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016107e6565b600054600160a01b900460ff161561138c5760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016107e6565b600061139883836108a3565b600081815260046020526040812080549293509167ffffffffffffffff16900361142a5760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016107e6565b805468010000000000000000900467ffffffffffffffff16156114b55760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b60005481546114db91600160c81b900463ffffffff169067ffffffffffffffff16613865565b67ffffffffffffffff1642116115595760405162461bcd60e51b815260206004820152602b60248201527f4f7074696d6973746963206d696e74696e672064656c617920686173206e6f7460448201527f207061737365642079657400000000000000000000000000000000000000000060648201526084016107e6565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa1580156115c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e591906138b9565b90508060a0015163ffffffff166000146116415760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016107e6565b60006402540be4008260800151836020015161165d9190613966565b67ffffffffffffffff166116719190613835565b6000805491925090600160a81b900463ffffffff166116915760006116ab565b6000546116ab90600160a81b900463ffffffff168361399d565b83516001600160a01b0316600090815260056020526040812054919250906116d49084906139b1565b84516001600160a01b03166000908152600560205260409020819055845190915061170390610e9084866137f3565b8115611794576117947f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561176a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178e91906139c4565b83612ceb565b84547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff16680100000000000000004267ffffffffffffffff160217855583516040518281526001600160a01b0390911690879033907f2cffebf26d639426e79514d100febae8b2c63e700e5dc0fa6c88a129633506369060200160405180910390a45050505050505050565b6060600280548060200260200160405190810160405280929190818152602001828054801561187857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161185a575b5050505050905090565b6000546001600160a01b031633146118ca5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526003602052604090205460ff166119325760405162461bcd60e51b815260206004820152601e60248201527f546869732061646472657373206973206e6f74206120677561726469616e000060448201526064016107e6565b6001600160a01b038116600081815260036020526040808220805460ff19169055517fb8107d0c6b40be480ce3172ee66ba6d64b71f6b1685a851340036e6e2e3e3c529190a250565b6000546001600160a01b031633146119c35760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6119cd6000613105565b565b600080806119e26402540be400856139e1565b91506119ee82856137f3565b92506119ff6402540be4008461399d565b929491935050565b3360009081526003602052604090205460ff16611a665760405162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f74206120677561726469616e000000000000000060448201526064016107e6565b6000611a7283836108a3565b600081815260046020526040812080549293509167ffffffffffffffff169003611b045760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016107e6565b805468010000000000000000900467ffffffffffffffff1615611b8f5760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b60008281526004602052604080822080547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016905551839133917f1256b41d4b18d922811c358ab80cb0375aae28f45373de35cfda580662193fcd9190a350505050565b3360009081526001602052604090205460ff16611c525760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016107e6565b600054600160a01b900460ff1615611cac5760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016107e6565b6000611cb883836108a3565b600081815260046020526040902080549192509067ffffffffffffffff1615611d495760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c726561647920726571756560448201527f7374656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa158015611db1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd591906138b9565b9050806040015163ffffffff16600003611e3b5760405162461bcd60e51b815260206004820152602160248201527f546865206465706f73697420686173206e6f74206265656e2072657665616c656044820152601960fa1b60648201526084016107e6565b60a081015163ffffffff1615611e935760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016107e6565b60608101516001600160a01b03163014611eef5760405162461bcd60e51b815260206004820152601860248201527f556e6578706563746564207661756c742061646472657373000000000000000060448201526064016107e6565b815467ffffffffffffffff19164267ffffffffffffffff908116919091178355815160208301516001600160a01b0390911691859133917f36f39c606d55d7dd2a05b8c4e41e9a6ca8c501cea10009c1762f6826a146e05591611f59916402540be4009116613835565b60408051918252602082018b905263ffffffff8a169082015260600160405180910390a45050505050565b60028181548110611f9457600080fd5b6000918252602090912001546001600160a01b0316905081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461202f5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f74205442544300000000000000000000000000000060448201526064016107e6565b336001600160a01b038416146120875760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f776564000000000000000060448201526064016107e6565b6000612092856119cf565b509091505060008290036120af576120aa8682612fb6565b6120bb565b6120bb86828585612e6f565b505050505050565b6000546001600160a01b0316331461210b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526001602052604090205460ff16156121745760405162461bcd60e51b815260206004820181905260248201527f54686973206164647265737320697320616c72656164792061206d696e74657260448201526064016107e6565b6001600160a01b0381166000818152600160208190526040808320805460ff19168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180546001600160a01b03191684179055517f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f69190a250565b6000546001600160a01b031633146122485760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6009546122588162015180612dc6565b600854600080547fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160c81b81029290921790556040519081527ff52de3377e3ae270d1e38f99b9b8d587814643811516ea55ba4d597f9950d4ec9060200160405180910390a1506008805463ffffffff191690556000600955565b6000546001600160a01b031633146123265760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600b546123368162015180612dc6565b600a546040516001600160a01b0390911681527f81a9bb8030ed4116b405800280e065110a37afb57b69948e714c97fab23475ec9060200160405180910390a1600a546040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063f2fde38b90602401600060405180830381600087803b1580156123f757600080fd5b505af115801561240b573d6000803e3d6000fd5b5050600a546040516370a0823160e01b81523060048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811694506356a6d9ef93509091169083906370a0823190602401602060405180830381865afa158015612483573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a7919061384c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561250557600080fd5b505af1158015612519573d6000803e3d6000fd5b5050600a80546001600160a01b031916905550506000600b5550565b600080612541836119cf565b6040516370a0823160e01b8152336004820152929450925082916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691506370a0823190602401602060405180830381865afa1580156125ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125d1919061384c565b101561262a5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016107e6565b6126343383612ceb565b604051631f1b6d2760e21b8152336004820152306024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637c6db49c90606401610d1f565b6000546001600160a01b031633146126d55760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600054600160a01b900460ff16156127395760405162461bcd60e51b815260206004820152602160248201527f4f7074696d6973746963206d696e74696e6720616c72656164792070617573656044820152601960fa1b60648201526084016107e6565b6000805460ff60a01b1916600160a01b1781556040517f23a83c8aeda8c831401c17b5bfb8b2ead79fcfe9c027fe34a4f8576e2c7c74cc9190a1565b6000546001600160a01b031633146127bd5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526003602052604090205460ff161561284c5760405162461bcd60e51b815260206004820152602260248201527f54686973206164647265737320697320616c726561647920612067756172646960448201527f616e00000000000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b038116600081815260036020526040808220805460ff19166001179055517f038596bb31e2e7d3d9f184d4c98b310103f6d7f5830e5eec32bffe6f1728f9699190a250565b6000546001600160a01b031633146128e05760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600054600160a01b900460ff166129395760405162461bcd60e51b815260206004820181905260248201527f4f7074696d6973746963206d696e74696e67206973206e6f742070617573656460448201526064016107e6565b6000805460ff60a01b191681556040517fcb27470ed9568d9eeb8939707bafc19404d908a26ce5f468a6aa781024fd6a839190a1565b6000546001600160a01b031633146129b75760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b426007556006805463ffffffff191663ffffffff83169081179091556040519081527f0dbfec7f12acffbb5cec595ac4370907eaf84caa7025dd71f4021433be79eba990602001610837565b6000546001600160a01b03163314612a4b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b038116612ac75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107e6565b612ad081613105565b50565b6000546001600160a01b03163314612b1b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde906109bd9030908890889088908890600401613794565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261089e908490613155565b6001600160a01b038216600090815260056020526040812054808203612c115782915050610902565b80831115612c78576001600160a01b0384166000818152600560209081526040808320839055519182527fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8910160405180910390a2612c7081846137f3565b915050610902565b612c8283826137f3565b6001600160a01b0385166000818152600560205260409020919091557fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8612cc985846137f3565b60405190815260200160405180910390a26000915050610902565b5092915050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe82604051612d2691815260200190565b60405180910390a26040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906340c10f19906044015b600060405180830381600087803b158015612db257600080fd5b505af11580156120bb573d6000803e3d6000fd5b60008211612e165760405162461bcd60e51b815260206004820152601460248201527f4368616e6765206e6f7420696e6974696174656400000000000000000000000060448201526064016107e6565b80612e2183426137f3565b10156112cf5760405162461bcd60e51b815260206004820181905260248201527f476f7665726e616e63652064656c617920686173206e6f7420656c617073656460448201526064016107e6565b836001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b884604051612eaa91815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038581166004830152602482018590527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b158015612f1c57600080fd5b505af1158015612f30573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a38757e7f00000000000000000000000000000000000000000000000000000000000000006402540be40086612f95919061399d565b85856040518563ffffffff1660e01b815260040161107a94939291906139f5565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b882604051612ff191815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b15801561306357600080fd5b505af1158015613077573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166356a6d9ef836402540be400846130bc919061399d565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401612d98565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006131aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661323a9092919063ffffffff16565b80519091501561089e57808060200190518101906131c89190613a28565b61089e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107e6565b60606132498484600085613253565b90505b9392505050565b6060824710156132cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b0385163b6133225760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107e6565b600080866001600160a01b0316858760405161333e9190613a6e565b60006040518083038185875af1925050503d806000811461337b576040519150601f19603f3d011682016040523d82523d6000602084013e613380565b606091505b509150915061339082828661339b565b979650505050505050565b606083156133aa57508161324c565b8251156133ba5782518084602001fd5b8160405162461bcd60e51b81526004016107e69190613a8a565b6001600160a01b0381168114612ad057600080fd5b6000602082840312156133fb57600080fd5b813561324c816133d4565b63ffffffff81168114612ad057600080fd5b60006020828403121561342a57600080fd5b813561324c81613406565b60008060006060848603121561344a57600080fd5b8335613455816133d4565b92506020840135613465816133d4565b929592945050506040919091013590565b6000806040838503121561348957600080fd5b82359150602083013561349b81613406565b809150509250929050565b60008083601f8401126134b857600080fd5b50813567ffffffffffffffff8111156134d057600080fd5b6020830191508360208285010111156134e857600080fd5b9250929050565b60008060008060006080868803121561350757600080fd5b8535613512816133d4565b94506020860135613522816133d4565b935060408601359250606086013567ffffffffffffffff81111561354557600080fd5b613551888289016134a6565b969995985093965092949392505050565b60008083601f84011261357457600080fd5b50813567ffffffffffffffff81111561358c57600080fd5b6020830191508360208260051b85010111156134e857600080fd5b600080600080604085870312156135bd57600080fd5b843567ffffffffffffffff808211156135d557600080fd5b6135e188838901613562565b909650945060208701359150808211156135fa57600080fd5b5061360787828801613562565b95989497509550505050565b6000806000806060858703121561362957600080fd5b8435613634816133d4565b935060208501359250604085013567ffffffffffffffff81111561365757600080fd5b613607878288016134a6565b60008060006040848603121561367857600080fd5b83359250602084013567ffffffffffffffff81111561369657600080fd5b6136a2868287016134a6565b9497909650939450505050565b6000602082840312156136c157600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156137095783516001600160a01b0316835292840192918401916001016136e4565b50909695505050505050565b60008060008060006080868803121561372d57600080fd5b8535613738816133d4565b945060208601359350604086013561374f816133d4565b9250606086013567ffffffffffffffff81111561354557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b0380881683528087166020840152508460408301526080606083015261339060808301848661376b565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610902576109026137dd565b634e487b7160e01b600052603160045260246000fd5b60006001820161382e5761382e6137dd565b5060010190565b8082028115828204841417610902576109026137dd565b60006020828403121561385e57600080fd5b5051919050565b67ffffffffffffffff818116838216019080821115612ce457612ce46137dd565b8051613891816133d4565b919050565b805167ffffffffffffffff8116811461389157600080fd5b805161389181613406565b600060c082840312156138cb57600080fd5b60405160c0810181811067ffffffffffffffff821117156138fc57634e487b7160e01b600052604160045260246000fd5b60405261390883613886565b815261391660208401613896565b6020820152613927604084016138ae565b604082015261393860608401613886565b606082015261394960808401613896565b608082015261395a60a084016138ae565b60a08201529392505050565b67ffffffffffffffff828116828216039080821115612ce457612ce46137dd565b634e487b7160e01b600052601260045260246000fd5b6000826139ac576139ac613987565b500490565b80820180821115610902576109026137dd565b6000602082840312156139d657600080fd5b815161324c816133d4565b6000826139f0576139f0613987565b500690565b6001600160a01b0385168152836020820152606060408201526000613a1e60608301848661376b565b9695505050505050565b600060208284031215613a3a57600080fd5b8151801515811461324c57600080fd5b60005b83811015613a65578181015183820152602001613a4d565b50506000910152565b60008251613a80818460208701613a4a565b9190910192915050565b6020815260008251806020840152613aa9816040850160208701613a4a565b601f01601f1916919091016040019291505056fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212209a07381069555c36987780153c945020363fa37b34dc75e1273fdc2b8ab2e0d464736f6c63430008110033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106103365760003560e01c80638532c511116101b2578063a410d29b116100f9578063c36b32b7116100a2578063e5d3d7141161007c578063e5d3d7141461072e578063e78cea9214610755578063f2fde38b1461077c578063fc4e51f61461078f57600080fd5b8063c36b32b7146106ff578063c7ba034714610712578063d0ff65b51461071e57600080fd5b8063b0b54895116100d3578063b0b54895146106cd578063b9f78798146106d7578063bc7b6b99146106f757600080fd5b8063a410d29b1461068f578063a526d83b14610697578063aa271e1a146106aa57600080fd5b8063951315261161015b5780639a508c8e116101355780639a508c8e1461066b578063a0712d6814610673578063a0cceb951461068657600080fd5b80639513152614610647578063983b2d56146106505780639a4e36d51461066357600080fd5b8063897f712c1161018c578063897f712c1461060f5780638da5cb5b146106235780638f4ffcb11461063457600080fd5b80638532c511146105d95780638623ec7b146105e957806388aaf0c8146105fc57600080fd5b806347c1ffdb116102815780636c626aa41161022a5780637445a5a0116102045780637445a5a01461054657806376cdb03b1461057457806380df5ed2146105b3578063820b5513146105c657600080fd5b80636c626aa4146104d0578063714041561461052b578063715018a61461053e57600080fd5b806364e779b11161025b57806364e779b1146104955780636abe3a6c146104a85780636b32810b146104bb57600080fd5b806347c1ffdb1461046357806353dce4df1461046b5780635ae2da461461047e57600080fd5b80633092afd5116102e3578063461c6373116102bd578063461c63731461042a578063475d05701461043d578063479aa9271461045057600080fd5b80633092afd5146103fb578063317dfa761461040e57806341906ab71461042157600080fd5b80631171bda9116103145780631171bda9146103b4578063124f65bd146103c75780632e73e398146103e857600080fd5b806309b53f511461033b5780630c68ba211461036c5780630f3425731461039f575b600080fd5b60005461035290600160a81b900463ffffffff1681565b60405163ffffffff90911681526020015b60405180910390f35b61038f61037a3660046133e9565b60036020526000908152604090205460ff1681565b6040519015158152602001610363565b6103b26103ad366004613418565b6107a2565b005b6103b26103c2366004613435565b610842565b6103da6103d5366004613476565b6108a3565b604051908152602001610363565b6103b26103f63660046134ef565b610908565b6103b26104093660046133e9565b6109f6565b6103b261041c366004613435565b610c65565b6103da60095481565b6103b26104383660046135a7565b610d56565b6103b261044b366004613613565b610eb1565b6103b261045e3660046133e9565b6110b2565b6103b26111b7565b6103b2610479366004613663565b611295565b60005461035290600160c81b900463ffffffff1681565b6103b26104a33660046136af565b6112b6565b6103b26104b6366004613476565b6112d3565b6104c3611820565b60405161036391906136c8565b61050a6104de3660046136af565b60046020526000908152604090205467ffffffffffffffff808216916801000000000000000090041682565b6040805167ffffffffffffffff938416815292909116602083015201610363565b6103b26105393660046133e9565b611882565b6103b261197b565b6105596105543660046136af565b6119cf565b60408051938452602084019290925290820152606001610363565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610363565b6103b26105c1366004613476565b611a07565b6103b26105d4366004613476565b611bf3565b6006546103529063ffffffff1681565b61059b6105f73660046136af565b611f84565b600a5461059b906001600160a01b031681565b60005461038f90600160a01b900460ff1681565b6000546001600160a01b031661059b565b6103b2610642366004613715565b611fae565b6103da600b5481565b6103b261065e3660046133e9565b6120c3565b6103b2612200565b6103b26122de565b6103b26106813660046136af565b612535565b6103da60075481565b6103b261268d565b6103b26106a53660046133e9565b612775565b61038f6106b83660046133e9565b60016020526000908152604090205460ff1681565b6103da6201518081565b6103da6106e53660046133e9565b60056020526000908152604090205481565b6103b2612898565b6103b261070d366004613418565b61296f565b6103da6402540be40081565b6008546103529063ffffffff1681565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b61059b7f000000000000000000000000000000000000000000000000000000000000000081565b6103b261078a3660046133e9565b612a03565b6103b261079d3660046134ef565b612ad3565b6000546001600160a01b031633146107ef5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064015b60405180910390fd5b426009556008805463ffffffff191663ffffffff83169081179091556040519081527f682bc0fb7e0d6bcb974cf556b95f68533cafc411d83d9f33ac192ccf45dda605906020015b60405180910390a150565b6000546001600160a01b0316331461088a5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b61089e6001600160a01b0384168383612b68565b505050565b600082826040516020016108e692919091825260e01b7fffffffff0000000000000000000000000000000000000000000000000000000016602082015260240190565b6040516020818303038152906040528051906020012060001c90505b92915050565b6000546001600160a01b031633146109505760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fc4e51f6906109bd9088908890889088908890600401613794565b600060405180830381600087803b1580156109d757600080fd5b505af11580156109eb573d6000803e3d6000fd5b505050505050505050565b33610a096000546001600160a01b031690565b6001600160a01b03161480610a2d57503360009081526003602052604090205460ff165b610a9f5760405162461bcd60e51b815260206004820152602360248201527f43616c6c6572206973206e6f7420746865206f776e6572206f7220677561726460448201527f69616e000000000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b03811660009081526001602052604090205460ff16610b075760405162461bcd60e51b815260206004820152601c60248201527f546869732061646472657373206973206e6f742061206d696e7465720000000060448201526064016107e6565b6001600160a01b0381166000908152600160205260408120805460ff191690555b600254811015610c2d57816001600160a01b031660028281548110610b4f57610b4f6137c7565b6000918252602090912001546001600160a01b031603610c1b5760028054610b79906001906137f3565b81548110610b8957610b896137c7565b600091825260209091200154600280546001600160a01b039092169183908110610bb557610bb56137c7565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506002805480610bf457610bf4613806565b600082815260209020810160001990810180546001600160a01b0319169055019055610c2d565b80610c258161381c565b915050610b28565b506040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b6000546001600160a01b03163314610cad5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301528381166024830152604482018390527f00000000000000000000000000000000000000000000000000000000000000001690631171bda9906064015b600060405180830381600087803b158015610d3957600080fd5b505af1158015610d4d573d6000803e3d6000fd5b50505050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610dce5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016107e6565b6000839003610e1f5760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f72732073706563696669656400000000000000000060448201526064016107e6565b60005b83811015610eaa576000858583818110610e3e57610e3e6137c7565b9050602002016020810190610e5391906133e9565b90506000848484818110610e6957610e696137c7565b905060200201359050610e9582610e90846402540be40085610e8b9190613835565b612be8565b612ceb565b50508080610ea29061381c565b915050610e22565b5050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610f295760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064016107e6565b6040516370a0823160e01b81526001600160a01b03858116600483015284917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa158015610f93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb7919061384c565b10156110105760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016107e6565b61102384610e906402540be40086613835565b604051631f1b6d2760e21b81526001600160a01b038581166004830152306024830152604482018590527f00000000000000000000000000000000000000000000000000000000000000001690637c6db49c906064015b600060405180830381600087803b15801561109457600080fd5b505af11580156110a8573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146110fa5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b0381166111505760405162461bcd60e51b815260206004820181905260248201527f4e6577207661756c7420616464726573732063616e6e6f74206265207a65726f60448201526064016107e6565b604080516001600160a01b03831681524260208201527f5cc842cab066489e13292128663547c68705dbf476f0131e0107f155719c6124910160405180910390a142600b55600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b031633146111ff5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b60075461120f8162015180612dc6565b600654600080547fffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160a81b81029290921790556040519081527fa7f4ce7c3586e2000cdec6b25c5e7d0b20f9b4f435aa22d9c1feb32dbb506f779060200160405180910390a1506006805463ffffffff191690556000600755565b60006112a0846119cf565b505090506112b033828585612e6f565b50505050565b60006112c1826119cf565b505090506112cf3382612fb6565b5050565b3360009081526001602052604090205460ff166113325760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016107e6565b600054600160a01b900460ff161561138c5760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016107e6565b600061139883836108a3565b600081815260046020526040812080549293509167ffffffffffffffff16900361142a5760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016107e6565b805468010000000000000000900467ffffffffffffffff16156114b55760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b60005481546114db91600160c81b900463ffffffff169067ffffffffffffffff16613865565b67ffffffffffffffff1642116115595760405162461bcd60e51b815260206004820152602b60248201527f4f7074696d6973746963206d696e74696e672064656c617920686173206e6f7460448201527f207061737365642079657400000000000000000000000000000000000000000060648201526084016107e6565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa1580156115c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e591906138b9565b90508060a0015163ffffffff166000146116415760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016107e6565b60006402540be4008260800151836020015161165d9190613966565b67ffffffffffffffff166116719190613835565b6000805491925090600160a81b900463ffffffff166116915760006116ab565b6000546116ab90600160a81b900463ffffffff168361399d565b83516001600160a01b0316600090815260056020526040812054919250906116d49084906139b1565b84516001600160a01b03166000908152600560205260409020819055845190915061170390610e9084866137f3565b8115611794576117947f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166361d027b36040518163ffffffff1660e01b8152600401602060405180830381865afa15801561176a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178e91906139c4565b83612ceb565b84547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff16680100000000000000004267ffffffffffffffff160217855583516040518281526001600160a01b0390911690879033907f2cffebf26d639426e79514d100febae8b2c63e700e5dc0fa6c88a129633506369060200160405180910390a45050505050505050565b6060600280548060200260200160405190810160405280929190818152602001828054801561187857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161185a575b5050505050905090565b6000546001600160a01b031633146118ca5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526003602052604090205460ff166119325760405162461bcd60e51b815260206004820152601e60248201527f546869732061646472657373206973206e6f74206120677561726469616e000060448201526064016107e6565b6001600160a01b038116600081815260036020526040808220805460ff19169055517fb8107d0c6b40be480ce3172ee66ba6d64b71f6b1685a851340036e6e2e3e3c529190a250565b6000546001600160a01b031633146119c35760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6119cd6000613105565b565b600080806119e26402540be400856139e1565b91506119ee82856137f3565b92506119ff6402540be4008461399d565b929491935050565b3360009081526003602052604090205460ff16611a665760405162461bcd60e51b815260206004820152601860248201527f43616c6c6572206973206e6f74206120677561726469616e000000000000000060448201526064016107e6565b6000611a7283836108a3565b600081815260046020526040812080549293509167ffffffffffffffff169003611b045760405162461bcd60e51b815260206004820152603060248201527f4f7074696d6973746963206d696e74696e67206e6f742072657175657374656460448201527f20666f7220746865206465706f7369740000000000000000000000000000000060648201526084016107e6565b805468010000000000000000900467ffffffffffffffff1615611b8f5760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c72656164792066696e616c60448201527f697a656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b60008281526004602052604080822080547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016905551839133917f1256b41d4b18d922811c358ab80cb0375aae28f45373de35cfda580662193fcd9190a350505050565b3360009081526001602052604090205460ff16611c525760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f742061206d696e7465720000000000000000000060448201526064016107e6565b600054600160a01b900460ff1615611cac5760405162461bcd60e51b815260206004820152601960248201527f4f7074696d6973746963206d696e74696e67207061757365640000000000000060448201526064016107e6565b6000611cb883836108a3565b600081815260046020526040902080549192509067ffffffffffffffff1615611d495760405162461bcd60e51b815260206004820152603460248201527f4f7074696d6973746963206d696e74696e6720616c726561647920726571756560448201527f7374656420666f7220746865206465706f73697400000000000000000000000060648201526084016107e6565b604051630b02c43d60e41b8152600481018390526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b02c43d09060240160c060405180830381865afa158015611db1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd591906138b9565b9050806040015163ffffffff16600003611e3b5760405162461bcd60e51b815260206004820152602160248201527f546865206465706f73697420686173206e6f74206265656e2072657665616c656044820152601960fa1b60648201526084016107e6565b60a081015163ffffffff1615611e935760405162461bcd60e51b815260206004820152601c60248201527f546865206465706f73697420697320616c72656164792073776570740000000060448201526064016107e6565b60608101516001600160a01b03163014611eef5760405162461bcd60e51b815260206004820152601860248201527f556e6578706563746564207661756c742061646472657373000000000000000060448201526064016107e6565b815467ffffffffffffffff19164267ffffffffffffffff908116919091178355815160208301516001600160a01b0390911691859133917f36f39c606d55d7dd2a05b8c4e41e9a6ca8c501cea10009c1762f6826a146e05591611f59916402540be4009116613835565b60408051918252602082018b905263ffffffff8a169082015260600160405180910390a45050505050565b60028181548110611f9457600080fd5b6000918252602090912001546001600160a01b0316905081565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b03161461202f5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f74205442544300000000000000000000000000000060448201526064016107e6565b336001600160a01b038416146120875760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f776564000000000000000060448201526064016107e6565b6000612092856119cf565b509091505060008290036120af576120aa8682612fb6565b6120bb565b6120bb86828585612e6f565b505050505050565b6000546001600160a01b0316331461210b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526001602052604090205460ff16156121745760405162461bcd60e51b815260206004820181905260248201527f54686973206164647265737320697320616c72656164792061206d696e74657260448201526064016107e6565b6001600160a01b0381166000818152600160208190526040808320805460ff19168317905560028054928301815583527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace90910180546001600160a01b03191684179055517f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f69190a250565b6000546001600160a01b031633146122485760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6009546122588162015180612dc6565b600854600080547fffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffffff1663ffffffff909216600160c81b81029290921790556040519081527ff52de3377e3ae270d1e38f99b9b8d587814643811516ea55ba4d597f9950d4ec9060200160405180910390a1506008805463ffffffff191690556000600955565b6000546001600160a01b031633146123265760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600b546123368162015180612dc6565b600a546040516001600160a01b0390911681527f81a9bb8030ed4116b405800280e065110a37afb57b69948e714c97fab23475ec9060200160405180910390a1600a546040517ff2fde38b0000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063f2fde38b90602401600060405180830381600087803b1580156123f757600080fd5b505af115801561240b573d6000803e3d6000fd5b5050600a546040516370a0823160e01b81523060048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811694506356a6d9ef93509091169083906370a0823190602401602060405180830381865afa158015612483573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a7919061384c565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561250557600080fd5b505af1158015612519573d6000803e3d6000fd5b5050600a80546001600160a01b031916905550506000600b5550565b600080612541836119cf565b6040516370a0823160e01b8152336004820152929450925082916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691506370a0823190602401602060405180830381865afa1580156125ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125d1919061384c565b101561262a5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b60648201526084016107e6565b6126343383612ceb565b604051631f1b6d2760e21b8152336004820152306024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637c6db49c90606401610d1f565b6000546001600160a01b031633146126d55760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600054600160a01b900460ff16156127395760405162461bcd60e51b815260206004820152602160248201527f4f7074696d6973746963206d696e74696e6720616c72656164792070617573656044820152601960fa1b60648201526084016107e6565b6000805460ff60a01b1916600160a01b1781556040517f23a83c8aeda8c831401c17b5bfb8b2ead79fcfe9c027fe34a4f8576e2c7c74cc9190a1565b6000546001600160a01b031633146127bd5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b03811660009081526003602052604090205460ff161561284c5760405162461bcd60e51b815260206004820152602260248201527f54686973206164647265737320697320616c726561647920612067756172646960448201527f616e00000000000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b038116600081815260036020526040808220805460ff19166001179055517f038596bb31e2e7d3d9f184d4c98b310103f6d7f5830e5eec32bffe6f1728f9699190a250565b6000546001600160a01b031633146128e05760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b600054600160a01b900460ff166129395760405162461bcd60e51b815260206004820181905260248201527f4f7074696d6973746963206d696e74696e67206973206e6f742070617573656460448201526064016107e6565b6000805460ff60a01b191681556040517fcb27470ed9568d9eeb8939707bafc19404d908a26ce5f468a6aa781024fd6a839190a1565b6000546001600160a01b031633146129b75760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b426007556006805463ffffffff191663ffffffff83169081179091556040519081527f0dbfec7f12acffbb5cec595ac4370907eaf84caa7025dd71f4021433be79eba990602001610837565b6000546001600160a01b03163314612a4b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6001600160a01b038116612ac75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107e6565b612ad081613105565b50565b6000546001600160a01b03163314612b1b5760405162461bcd60e51b81526020600482018190526024820152600080516020613abe83398151915260448201526064016107e6565b6040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b0386169063b88d4fde906109bd9030908890889088908890600401613794565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261089e908490613155565b6001600160a01b038216600090815260056020526040812054808203612c115782915050610902565b80831115612c78576001600160a01b0384166000818152600560209081526040808320839055519182527fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8910160405180910390a2612c7081846137f3565b915050610902565b612c8283826137f3565b6001600160a01b0385166000818152600560205260409020919091557fb30abd1b9e3d58cd8525b3d5c5aa002db1e43a150af5b172a8d16efcc7a141f8612cc985846137f3565b60405190815260200160405180910390a26000915050610902565b5092915050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe82604051612d2691815260200190565b60405180910390a26040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906340c10f19906044015b600060405180830381600087803b158015612db257600080fd5b505af11580156120bb573d6000803e3d6000fd5b60008211612e165760405162461bcd60e51b815260206004820152601460248201527f4368616e6765206e6f7420696e6974696174656400000000000000000000000060448201526064016107e6565b80612e2183426137f3565b10156112cf5760405162461bcd60e51b815260206004820181905260248201527f476f7665726e616e63652064656c617920686173206e6f7420656c617073656460448201526064016107e6565b836001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b884604051612eaa91815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038581166004830152602482018590527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b158015612f1c57600080fd5b505af1158015612f30573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634a38757e7f00000000000000000000000000000000000000000000000000000000000000006402540be40086612f95919061399d565b85856040518563ffffffff1660e01b815260040161107a94939291906139f5565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b882604051612ff191815260200190565b60405180910390a260405163079cc67960e41b81526001600160a01b038381166004830152602482018390527f000000000000000000000000000000000000000000000000000000000000000016906379cc679090604401600060405180830381600087803b15801561306357600080fd5b505af1158015613077573d6000803e3d6000fd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166356a6d9ef836402540be400846130bc919061399d565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526024820152604401612d98565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006131aa826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661323a9092919063ffffffff16565b80519091501561089e57808060200190518101906131c89190613a28565b61089e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107e6565b60606132498484600085613253565b90505b9392505050565b6060824710156132cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016107e6565b6001600160a01b0385163b6133225760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107e6565b600080866001600160a01b0316858760405161333e9190613a6e565b60006040518083038185875af1925050503d806000811461337b576040519150601f19603f3d011682016040523d82523d6000602084013e613380565b606091505b509150915061339082828661339b565b979650505050505050565b606083156133aa57508161324c565b8251156133ba5782518084602001fd5b8160405162461bcd60e51b81526004016107e69190613a8a565b6001600160a01b0381168114612ad057600080fd5b6000602082840312156133fb57600080fd5b813561324c816133d4565b63ffffffff81168114612ad057600080fd5b60006020828403121561342a57600080fd5b813561324c81613406565b60008060006060848603121561344a57600080fd5b8335613455816133d4565b92506020840135613465816133d4565b929592945050506040919091013590565b6000806040838503121561348957600080fd5b82359150602083013561349b81613406565b809150509250929050565b60008083601f8401126134b857600080fd5b50813567ffffffffffffffff8111156134d057600080fd5b6020830191508360208285010111156134e857600080fd5b9250929050565b60008060008060006080868803121561350757600080fd5b8535613512816133d4565b94506020860135613522816133d4565b935060408601359250606086013567ffffffffffffffff81111561354557600080fd5b613551888289016134a6565b969995985093965092949392505050565b60008083601f84011261357457600080fd5b50813567ffffffffffffffff81111561358c57600080fd5b6020830191508360208260051b85010111156134e857600080fd5b600080600080604085870312156135bd57600080fd5b843567ffffffffffffffff808211156135d557600080fd5b6135e188838901613562565b909650945060208701359150808211156135fa57600080fd5b5061360787828801613562565b95989497509550505050565b6000806000806060858703121561362957600080fd5b8435613634816133d4565b935060208501359250604085013567ffffffffffffffff81111561365757600080fd5b613607878288016134a6565b60008060006040848603121561367857600080fd5b83359250602084013567ffffffffffffffff81111561369657600080fd5b6136a2868287016134a6565b9497909650939450505050565b6000602082840312156136c157600080fd5b5035919050565b6020808252825182820181905260009190848201906040850190845b818110156137095783516001600160a01b0316835292840192918401916001016136e4565b50909695505050505050565b60008060008060006080868803121561372d57600080fd5b8535613738816133d4565b945060208601359350604086013561374f816133d4565b9250606086013567ffffffffffffffff81111561354557600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b0380881683528087166020840152508460408301526080606083015261339060808301848661376b565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610902576109026137dd565b634e487b7160e01b600052603160045260246000fd5b60006001820161382e5761382e6137dd565b5060010190565b8082028115828204841417610902576109026137dd565b60006020828403121561385e57600080fd5b5051919050565b67ffffffffffffffff818116838216019080821115612ce457612ce46137dd565b8051613891816133d4565b919050565b805167ffffffffffffffff8116811461389157600080fd5b805161389181613406565b600060c082840312156138cb57600080fd5b60405160c0810181811067ffffffffffffffff821117156138fc57634e487b7160e01b600052604160045260246000fd5b60405261390883613886565b815261391660208401613896565b6020820152613927604084016138ae565b604082015261393860608401613886565b606082015261394960808401613896565b608082015261395a60a084016138ae565b60a08201529392505050565b67ffffffffffffffff828116828216039080821115612ce457612ce46137dd565b634e487b7160e01b600052601260045260246000fd5b6000826139ac576139ac613987565b500490565b80820180821115610902576109026137dd565b6000602082840312156139d657600080fd5b815161324c816133d4565b6000826139f0576139f0613987565b500690565b6001600160a01b0385168152836020820152606060408201526000613a1e60608301848661376b565b9695505050505050565b600060208284031215613a3a57600080fd5b8151801515811461324c57600080fd5b60005b83811015613a65578181015183820152602001613a4d565b50506000910152565b60008251613a80818460208701613a4a565b9190910192915050565b6020815260008251806020840152613aa9816040850160208701613a4a565b601f01601f1916919091016040019291505056fe4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212209a07381069555c36987780153c945020363fa37b34dc75e1273fdc2b8ab2e0d464736f6c63430008110033", + "devdoc": { + "details": "TBTC Vault is the owner of TBTC token contract and is the only contract minting the token.", + "kind": "dev", + "methods": { + "amountToSatoshis(uint256)": { + "returns": { + "convertibleAmount": "Amount of TBTC to be minted/unminted.", + "remainder": "Not convertible remainder if amount is not divisible by SATOSHI_MULTIPLIER.", + "satoshis": "Amount in satoshis - the Bank balance to be transferred for the given mint/unmint" + } + }, + "beginOptimisticMintingFeeUpdate(uint32)": { + "details": "See the documentation for optimisticMintingFeeDivisor." + }, + "cancelOptimisticMint(bytes32,uint32)": { + "details": "Guardians must validate the following conditions for every deposit for which the optimistic minting was requested: - The deposit happened on Bitcoin side and it has enough confirmations. - The optimistic minting has been requested early enough so that the wallet has enough time to sweep the deposit. - The wallet is an active one and it does perform sweeps or it will perform sweeps once the sweeps are activated." + }, + "initiateUpgrade(address)": { + "params": { + "_newVault": "The new vault address." + } + }, + "mint(uint256)": { + "details": "TBTC Vault must have an allowance for caller's balance in the Bank for at least `amount / SATOSHI_MULTIPLIER`.", + "params": { + "amount": "Amount of TBTC to mint." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "receiveApproval(address,uint256,address,bytes)": { + "details": "This function is doing the same as `unmint` or `unmintAndRedeem` (depending on `extraData` parameter) but it allows to execute unminting without a separate approval transaction. The function can be called only via `approveAndCall` of TBTC token.", + "params": { + "amount": "Amount of TBTC to unmint.", + "extraData": "Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function. If empty, `receiveApproval` is not requesting a redemption of Bank balance but is instead performing just TBTC unminting to a Bank balance.", + "from": "TBTC token holder executing unminting.", + "token": "TBTC token address." + } + }, + "receiveBalanceApproval(address,uint256,bytes)": { + "details": "Can only be called by the Bank via `approveBalanceAndCall`.", + "params": { + "owner": "The owner who approved their Bank balance.", + "satoshis": "Amount of satoshis used to mint TBTC." + } + }, + "receiveBalanceIncrease(address[],uint256[])": { + "details": "Fails if `depositors` array is empty. Expects the length of `depositors` and `depositedSatoshiAmounts` is the same." + }, + "recoverERC20(address,address,uint256)": { + "params": { + "amount": "Recovered amount.", + "recipient": "Address the recovered token should be sent to.", + "token": "Address of the recovered ERC20 token contract." + } + }, + "recoverERC20FromToken(address,address,uint256)": { + "params": { + "amount": "Recovered amount.", + "recipient": "Address the recovered token should be sent to.", + "token": "Address of the recovered ERC20 token contract." + } + }, + "recoverERC721(address,address,uint256,bytes)": { + "params": { + "data": "Additional data.", + "recipient": "Address the recovered token should be sent to.", + "token": "Address of the recovered ERC721 token contract.", + "tokenId": "Identifier of the recovered token." + } + }, + "recoverERC721FromToken(address,address,uint256,bytes)": { + "params": { + "data": "Additional data.", + "recipient": "Address the recovered token should be sent to.", + "token": "Address of the recovered ERC721 token contract.", + "tokenId": "Identifier of the recovered token." + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner." + }, + "requestOptimisticMint(bytes32,uint32)": { + "details": "The deposit done on the Bitcoin side must be revealed early enough to the Bridge on Ethereum to pass the Bridge's validation. The validation passes successfully only if the deposit reveal is done respectively earlier than the moment when the deposit refund locktime is reached, i.e. the deposit becomes refundable. It may happen that the wallet does not sweep a revealed deposit and one of the Minters requests an optimistic mint for that deposit just before the locktime is reached. Guardians must cancel optimistic minting for this deposit because the wallet will not be able to sweep it. The on-chain optimistic minting code does not perform any validation for gas efficiency: it would have to perform the same validation as `validateDepositRefundLocktime` and expect the entire `DepositRevealInfo` to be passed to assemble the expected script hash on-chain. Guardians must validate if the deposit happened on Bitcoin, that the script hash has the expected format, and that the wallet is an active one so they can also validate the time left for the refund." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "unmint(uint256)": { + "details": "Caller must have at least `amount` of TBTC approved to TBTC Vault.", + "params": { + "amount": "Amount of TBTC to unmint." + } + }, + "unmintAndRedeem(uint256,bytes)": { + "details": "Caller must have at least `amount` of TBTC approved to TBTC Vault.", + "params": { + "amount": "Amount of TBTC to unmint and request to redeem in Bridge.", + "redemptionData": "Redemption data in a format expected from `redemptionData` parameter of Bridge's `receiveBalanceApproval` function." + } + } + }, + "title": "TBTC application vault", + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "GOVERNANCE_DELAY()": { + "notice": "The time delay that needs to pass between initializing and finalizing the upgrade of governable parameters." + }, + "SATOSHI_MULTIPLIER()": { + "notice": "Multiplier to convert satoshi to TBTC token units." + }, + "addGuardian(address)": { + "notice": "Adds the address to the Guardian set." + }, + "addMinter(address)": { + "notice": "Adds the address to the Minter list." + }, + "amountToSatoshis(uint256)": { + "notice": "Returns the amount of TBTC to be minted/unminted, the remainder, and the Bank balance to be transferred for the given mint/unmint. Note that if the `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account when minting or unminting." + }, + "beginOptimisticMintingDelayUpdate(uint32)": { + "notice": "Begins the process of updating optimistic minting delay." + }, + "beginOptimisticMintingFeeUpdate(uint32)": { + "notice": "Begins the process of updating optimistic minting fee. The fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2% of each deposit, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`." + }, + "calculateDepositKey(bytes32,uint32)": { + "notice": "Calculates deposit key the same way as the Bridge contract. The deposit key is computed as `keccak256(fundingTxHash | fundingOutputIndex)`." + }, + "cancelOptimisticMint(bytes32,uint32)": { + "notice": "Allows a Guardian to cancel optimistic minting request. The following conditions must be met: - The optimistic minting request for the given deposit exists. - The optimistic minting request for the given deposit has not been finalized yet. Optimistic minting request is removed. It is possible to request optimistic minting again for the same deposit later." + }, + "finalizeOptimisticMint(bytes32,uint32)": { + "notice": "Allows a Minter to finalize previously requested optimistic minting. The following conditions must be met: - The optimistic minting has been requested for the given deposit. - The deposit has not been swept yet. - At least `optimisticMintingDelay` passed since the optimistic minting was requested for the given deposit. - The optimistic minting has not been finalized earlier for the given deposit. - The optimistic minting request for the given deposit has not been canceled by a Guardian. - The optimistic minting is not paused. This function mints TBTC and increases `optimisticMintingDebt` for the given depositor. The optimistic minting request is marked as finalized." + }, + "finalizeOptimisticMintingDelayUpdate()": { + "notice": "Finalizes the update process of the optimistic minting delay." + }, + "finalizeOptimisticMintingFeeUpdate()": { + "notice": "Finalizes the update process of the optimistic minting fee." + }, + "finalizeUpgrade()": { + "notice": "Allows the governance to finalize vault upgrade process. The upgrade process needs to be first initiated with a call to `initiateUpgrade` and the `GOVERNANCE_DELAY` needs to pass. Once the upgrade is finalized, the new vault becomes the owner of the TBTC token and receives the whole Bank balance of this vault." + }, + "getMinters()": { + "notice": "Allows to fetch a list of all Minters." + }, + "initiateUpgrade(address)": { + "notice": "Initiates vault upgrade process. The upgrade process needs to be finalized with a call to `finalizeUpgrade` function after the `UPGRADE_GOVERNANCE_DELAY` passes. Only the governance can initiate the upgrade." + }, + "isGuardian(address)": { + "notice": "Indicates if the given address is a Guardian. Only Guardians can cancel requested optimistic minting." + }, + "isMinter(address)": { + "notice": "Indicates if the given address is a Minter. Only Minters can request optimistic minting." + }, + "isOptimisticMintingPaused()": { + "notice": "Indicates if the optimistic minting has been paused. Only the Governance can pause optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits." + }, + "mint(uint256)": { + "notice": "Mints the given `amount` of TBTC to the caller previously transferring `amount / SATOSHI_MULTIPLIER` of the Bank balance from caller to TBTC Vault. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's Bank balance." + }, + "minters(uint256)": { + "notice": "List of all Minters." + }, + "newOptimisticMintingDelay()": { + "notice": "New optimistic minting delay value. Set only when the parameter update process is pending. Once the update gets finalized, this" + }, + "newOptimisticMintingFeeDivisor()": { + "notice": "New optimistic minting fee divisor value. Set only when the parameter update process is pending. Once the update gets" + }, + "newVault()": { + "notice": "The address of a new TBTC vault. Set only when the upgrade process is pending. Once the upgrade gets finalized, the new TBTC vault will become an owner of TBTC token." + }, + "optimisticMintingDebt(address)": { + "notice": "Optimistic minting debt value per depositor's address. The debt represents the total value of all depositor's deposits revealed to the Bridge that has not been yet swept and led to the optimistic minting of TBTC. When `TBTCVault` sweeps a deposit, the debt is fully or partially paid off, no matter if that particular swept deposit was used for the optimistic minting or not. The values are in 1e18 Ethereum precision." + }, + "optimisticMintingDelay()": { + "notice": "The time that needs to pass between the moment the optimistic minting is requested and the moment optimistic minting is finalized with minting TBTC." + }, + "optimisticMintingDelayUpdateInitiatedTimestamp()": { + "notice": "The timestamp at which the update of the optimistic minting delay started. Zero if update is not in progress." + }, + "optimisticMintingFeeDivisor()": { + "notice": "Divisor used to compute the treasury fee taken from each optimistically minted deposit and transferred to the treasury upon finalization of the optimistic mint. This fee is computed as follows: `fee = amount / optimisticMintingFeeDivisor`. For example, if the fee needs to be 2%, the `optimisticMintingFeeDivisor` should be set to `50` because `1/50 = 0.02 = 2%`. The optimistic minting fee does not replace the deposit treasury fee cut by the Bridge. The optimistic fee is a percentage AFTER the treasury fee is cut: `optimisticMintingFee = (depositAmount - treasuryFee) / optimisticMintingFeeDivisor`" + }, + "optimisticMintingFeeUpdateInitiatedTimestamp()": { + "notice": "The timestamp at which the update of the optimistic minting fee divisor started. Zero if update is not in progress." + }, + "optimisticMintingRequests(uint256)": { + "notice": "Collection of all revealed deposits for which the optimistic minting was requested. Indexed by a deposit key computed as `keccak256(fundingTxHash | fundingOutputIndex)`." + }, + "pauseOptimisticMinting()": { + "notice": "Pauses the optimistic minting. Note that the pause of the optimistic minting does not stop the standard minting flow where wallets sweep deposits." + }, + "receiveApproval(address,uint256,address,bytes)": { + "notice": "Burns `amount` of TBTC from the caller's balance. If `extraData` is empty, transfers `amount` back to the caller's balance in the Bank. If `extraData` is not empty, requests redemption in the Bridge using the `extraData` as a `redemptionData` parameter to Bridge's `receiveBalanceApproval` function. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account. Note that it may left a token approval equal to the remainder." + }, + "receiveBalanceApproval(address,uint256,bytes)": { + "notice": "Transfers `satoshis` of the Bank balance from the caller to TBTC Vault and mints `satoshis * SATOSHI_MULTIPLIER` of TBTC to the caller." + }, + "receiveBalanceIncrease(address[],uint256[])": { + "notice": "Mints the same amount of TBTC as the deposited satoshis amount multiplied by SATOSHI_MULTIPLIER for each depositor in the array. Can only be called by the Bank after the Bridge swept deposits and Bank increased balance for the vault." + }, + "recoverERC20(address,address,uint256)": { + "notice": "Allows the governance of the TBTCVault to recover any ERC20 token sent - mistakenly or not - to the vault address. This function should be used to withdraw TBTC v1 tokens transferred to TBTCVault as a result of VendingMachine > TBTCVault upgrade." + }, + "recoverERC20FromToken(address,address,uint256)": { + "notice": "Allows the governance of the TBTCVault to recover any ERC20 token sent mistakenly to the TBTC token contract address." + }, + "recoverERC721(address,address,uint256,bytes)": { + "notice": "Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the vault address." + }, + "recoverERC721FromToken(address,address,uint256,bytes)": { + "notice": "Allows the governance of the TBTCVault to recover any ERC721 token sent mistakenly to the TBTC token contract address." + }, + "removeGuardian(address)": { + "notice": "Removes the address from the Guardian set." + }, + "removeMinter(address)": { + "notice": "Removes the address from the Minter list." + }, + "requestOptimisticMint(bytes32,uint32)": { + "notice": "Allows a Minter to request for an optimistic minting of TBTC. The following conditions must be met: - There is no optimistic minting request for the deposit, finalized or not. - The deposit with the given Bitcoin funding transaction hash and output index has been revealed to the Bridge. - The deposit has not been swept yet. - The deposit is targeted into the TBTCVault. - The optimistic minting is not paused. After calling this function, the Minter has to wait for `optimisticMintingDelay` before finalizing the mint with a call to finalizeOptimisticMint." + }, + "unmint(uint256)": { + "notice": "Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` back to the caller's balance in the Bank. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account." + }, + "unmintAndRedeem(uint256,bytes)": { + "notice": "Burns `amount` of TBTC from the caller's balance and transfers `amount / SATOSHI_MULTIPLIER` of Bank balance to the Bridge requesting redemption based on the provided `redemptionData`. If `amount` is not divisible by SATOSHI_MULTIPLIER, the remainder is left on the caller's account." + }, + "unpauseOptimisticMinting()": { + "notice": "Unpauses the optimistic minting." + }, + "upgradeInitiatedTimestamp()": { + "notice": "The timestamp at which an upgrade to a new TBTC vault was initiated. Set only when the upgrade process is pending." + } + }, + "notice": "TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of Bitcoin. It facilitates Bitcoin holders to act on the Ethereum blockchain and access the decentralized finance (DeFi) ecosystem. TBTC Vault mints and unmints TBTC based on Bitcoin balances in the Bank.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 9835, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 21717, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "isOptimisticMintingPaused", + "offset": 20, + "slot": "0", + "type": "t_bool" + }, + { + "astId": 21721, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingFeeDivisor", + "offset": 21, + "slot": "0", + "type": "t_uint32" + }, + { + "astId": 21725, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingDelay", + "offset": 25, + "slot": "0", + "type": "t_uint32" + }, + { + "astId": 21730, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "isMinter", + "offset": 0, + "slot": "1", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 21734, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "minters", + "offset": 0, + "slot": "2", + "type": "t_array(t_address)dyn_storage" + }, + { + "astId": 21739, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "isGuardian", + "offset": 0, + "slot": "3", + "type": "t_mapping(t_address,t_bool)" + }, + { + "astId": 21745, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingRequests", + "offset": 0, + "slot": "4", + "type": "t_mapping(t_uint256,t_struct(OptimisticMintingRequest)21701_storage)" + }, + { + "astId": 21750, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingDebt", + "offset": 0, + "slot": "5", + "type": "t_mapping(t_address,t_uint256)" + }, + { + "astId": 21753, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "newOptimisticMintingFeeDivisor", + "offset": 0, + "slot": "6", + "type": "t_uint32" + }, + { + "astId": 21756, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingFeeUpdateInitiatedTimestamp", + "offset": 0, + "slot": "7", + "type": "t_uint256" + }, + { + "astId": 21759, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "newOptimisticMintingDelay", + "offset": 0, + "slot": "8", + "type": "t_uint32" + }, + { + "astId": 21762, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "optimisticMintingDelayUpdateInitiatedTimestamp", + "offset": 0, + "slot": "9", + "type": "t_uint256" + }, + { + "astId": 22633, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "newVault", + "offset": 0, + "slot": "10", + "type": "t_address" + }, + { + "astId": 22636, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "upgradeInitiatedTimestamp", + "offset": 0, + "slot": "11", + "type": "t_uint256" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_address)dyn_storage": { + "base": "t_address", + "encoding": "dynamic_array", + "label": "address[]", + "numberOfBytes": "32" + }, + "t_bool": { + "encoding": "inplace", + "label": "bool", + "numberOfBytes": "1" + }, + "t_mapping(t_address,t_bool)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => bool)", + "numberOfBytes": "32", + "value": "t_bool" + }, + "t_mapping(t_address,t_uint256)": { + "encoding": "mapping", + "key": "t_address", + "label": "mapping(address => uint256)", + "numberOfBytes": "32", + "value": "t_uint256" + }, + "t_mapping(t_uint256,t_struct(OptimisticMintingRequest)21701_storage)": { + "encoding": "mapping", + "key": "t_uint256", + "label": "mapping(uint256 => struct TBTCOptimisticMinting.OptimisticMintingRequest)", + "numberOfBytes": "32", + "value": "t_struct(OptimisticMintingRequest)21701_storage" + }, + "t_struct(OptimisticMintingRequest)21701_storage": { + "encoding": "inplace", + "label": "struct TBTCOptimisticMinting.OptimisticMintingRequest", + "members": [ + { + "astId": 21698, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "requestedAt", + "offset": 0, + "slot": "0", + "type": "t_uint64" + }, + { + "astId": 21700, + "contract": "contracts/vault/TBTCVault.sol:TBTCVault", + "label": "finalizedAt", + "offset": 8, + "slot": "0", + "type": "t_uint64" + } + ], + "numberOfBytes": "32" + }, + "t_uint256": { + "encoding": "inplace", + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint32": { + "encoding": "inplace", + "label": "uint32", + "numberOfBytes": "4" + }, + "t_uint64": { + "encoding": "inplace", + "label": "uint64", + "numberOfBytes": "8" + } + } + } +} diff --git a/typescript/src/lib/ethereum/artifacts/mainnet/WalletRegistry.json b/typescript/src/lib/ethereum/artifacts/mainnet/WalletRegistry.json new file mode 100644 index 000000000..380a69761 --- /dev/null +++ b/typescript/src/lib/ethereum/artifacts/mainnet/WalletRegistry.json @@ -0,0 +1,1962 @@ +{ + "address": "0x46d52E41C2F300BC82217Ce22b920c34995204eb", + "abi": [ + { + "inputs": [ + { + "internalType": "contract SortitionPool", + "name": "_sortitionPool", + "type": "address" + }, + { + "internalType": "contract IStaking", + "name": "_staking", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "AuthorizationDecreaseApproved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "decreasingAt", + "type": "uint64" + } + ], + "name": "AuthorizationDecreaseRequested", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "AuthorizationIncreased", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint96", + "name": "minimumAuthorization", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "authorizationDecreaseDelay", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "authorizationDecreaseChangePeriod", + "type": "uint64" + } + ], + "name": "AuthorizationParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "slashingAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "maliciousSubmitter", + "type": "address" + } + ], + "name": "DkgMaliciousResultSlashed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "slashingAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "maliciousSubmitter", + "type": "address" + } + ], + "name": "DkgMaliciousResultSlashingFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "seedTimeout", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "resultChallengePeriodLength", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "resultChallengeExtraGas", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "resultSubmissionTimeout", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "resultSubmitterPrecedencePeriodLength", + "type": "uint256" + } + ], + "name": "DkgParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "DkgResultApproved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "challenger", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "reason", + "type": "string" + } + ], + "name": "DkgResultChallenged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "resultHash", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "seed", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "indexed": false, + "internalType": "struct EcdsaDkg.Result", + "name": "result", + "type": "tuple" + } + ], + "name": "DkgResultSubmitted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "DkgSeedTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "seed", + "type": "uint256" + } + ], + "name": "DkgStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "DkgStateLocked", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "DkgTimedOut", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "dkgResultSubmissionGas", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "dkgResultApprovalGasOffset", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "notifyOperatorInactivityGasOffset", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "notifySeedTimeoutGasOffset", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "notifyDkgTimeoutNegativeGasOffset", + "type": "uint256" + } + ], + "name": "GasParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldGovernance", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "GovernanceTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "notifier", + "type": "address" + } + ], + "name": "InactivityClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "InvoluntaryAuthorizationDecreaseFailed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "OperatorJoinedSortitionPool", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "OperatorRegistered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "OperatorStatusUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "randomBeacon", + "type": "address" + } + ], + "name": "RandomBeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newReimbursementPool", + "type": "address" + } + ], + "name": "ReimbursementPoolUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "maliciousDkgResultNotificationRewardMultiplier", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sortitionPoolRewardsBanDuration", + "type": "uint256" + } + ], + "name": "RewardParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint96", + "name": "amount", + "type": "uint96" + } + ], + "name": "RewardsWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "maliciousDkgResultSlashingAmount", + "type": "uint256" + } + ], + "name": "SlashingParametersUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "WalletClosed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "dkgResultHash", + "type": "bytes32" + } + ], + "name": "WalletCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "walletOwner", + "type": "address" + } + ], + "name": "WalletOwnerUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "relayEntry", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "__beaconCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "approveAuthorizationDecrease", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "internalType": "struct EcdsaDkg.Result", + "name": "dkgResult", + "type": "tuple" + } + ], + "name": "approveDkgResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "authorizationDecreaseRequested", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "authorizationIncreased", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "authorizationParameters", + "outputs": [ + { + "internalType": "uint96", + "name": "minimumAuthorization", + "type": "uint96" + }, + { + "internalType": "uint64", + "name": "authorizationDecreaseDelay", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "authorizationDecreaseChangePeriod", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "availableRewards", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "internalType": "struct EcdsaDkg.Result", + "name": "dkgResult", + "type": "tuple" + } + ], + "name": "challengeDkgResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "closeWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "dkgParameters", + "outputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "seedTimeout", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resultChallengePeriodLength", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resultChallengeExtraGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "resultSubmissionTimeout", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "submitterPrecedencePeriodLength", + "type": "uint256" + } + ], + "internalType": "struct EcdsaDkg.Parameters", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "eligibleStake", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gasParameters", + "outputs": [ + { + "internalType": "uint256", + "name": "dkgResultSubmissionGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dkgResultApprovalGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifyOperatorInactivityGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifySeedTimeoutGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifyDkgTimeoutNegativeGasOffset", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "getWallet", + "outputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "membersIdsHash", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyX", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "publicKeyY", + "type": "bytes32" + } + ], + "internalType": "struct Wallets.Wallet", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWalletCreationState", + "outputs": [ + { + "internalType": "enum EcdsaDkg.State", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "getWalletPublicKey", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governance", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hasDkgTimedOut", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hasSeedTimedOut", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "inactivityClaimNonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract EcdsaDkgValidator", + "name": "_ecdsaDkgValidator", + "type": "address" + }, + { + "internalType": "contract IRandomBeacon", + "name": "_randomBeacon", + "type": "address" + }, + { + "internalType": "contract ReimbursementPool", + "name": "_reimbursementPool", + "type": "address" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + }, + { + "internalType": "uint96", + "name": "fromAmount", + "type": "uint96" + }, + { + "internalType": "uint96", + "name": "toAmount", + "type": "uint96" + } + ], + "name": "involuntaryAuthorizationDecrease", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "internalType": "struct EcdsaDkg.Result", + "name": "result", + "type": "tuple" + } + ], + "name": "isDkgResultValid", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + }, + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isOperatorInPool", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "isOperatorUpToDate", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + }, + { + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "internalType": "uint256", + "name": "walletMemberIndex", + "type": "uint256" + } + ], + "name": "isWalletMember", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + } + ], + "name": "isWalletRegistered", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "joinSortitionPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "minimumAuthorization", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "notifyDkgTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "internalType": "uint256[]", + "name": "inactiveMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "bool", + "name": "heartbeatFailed", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + } + ], + "internalType": "struct EcdsaInactivity.Claim", + "name": "claim", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint32[]", + "name": "groupMembers", + "type": "uint32[]" + } + ], + "name": "notifyOperatorInactivity", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "notifySeedTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "operatorToStakingProvider", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "pendingAuthorizationDecrease", + "outputs": [ + { + "internalType": "uint96", + "name": "", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "randomBeacon", + "outputs": [ + { + "internalType": "contract IRandomBeacon", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "registerOperator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "reimbursementPool", + "outputs": [ + { + "internalType": "contract ReimbursementPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "remainingAuthorizationDecreaseDelay", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "requestNewWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rewardParameters", + "outputs": [ + { + "internalType": "uint256", + "name": "maliciousDkgResultNotificationRewardMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sortitionPoolRewardsBanDuration", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint96", + "name": "amount", + "type": "uint96" + }, + { + "internalType": "uint256", + "name": "rewardMultiplier", + "type": "uint256" + }, + { + "internalType": "address", + "name": "notifier", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "walletID", + "type": "bytes32" + }, + { + "internalType": "uint32[]", + "name": "walletMembersIDs", + "type": "uint32[]" + } + ], + "name": "seize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "selectGroup", + "outputs": [ + { + "internalType": "uint32[]", + "name": "", + "type": "uint32[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "slashingParameters", + "outputs": [ + { + "internalType": "uint96", + "name": "maliciousDkgResultSlashingAmount", + "type": "uint96" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "sortitionPool", + "outputs": [ + { + "internalType": "contract SortitionPool", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "staking", + "outputs": [ + { + "internalType": "contract IStaking", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "stakingProviderToOperator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "submitterMemberIndex", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "groupPubKey", + "type": "bytes" + }, + { + "internalType": "uint8[]", + "name": "misbehavedMembersIndices", + "type": "uint8[]" + }, + { + "internalType": "bytes", + "name": "signatures", + "type": "bytes" + }, + { + "internalType": "uint256[]", + "name": "signingMembersIndices", + "type": "uint256[]" + }, + { + "internalType": "uint32[]", + "name": "members", + "type": "uint32[]" + }, + { + "internalType": "bytes32", + "name": "membersHash", + "type": "bytes32" + } + ], + "internalType": "struct EcdsaDkg.Result", + "name": "dkgResult", + "type": "tuple" + } + ], + "name": "submitDkgResult", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint96", + "name": "_minimumAuthorization", + "type": "uint96" + }, + { + "internalType": "uint64", + "name": "_authorizationDecreaseDelay", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "_authorizationDecreaseChangePeriod", + "type": "uint64" + } + ], + "name": "updateAuthorizationParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_seedTimeout", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_resultChallengePeriodLength", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_resultChallengeExtraGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_resultSubmissionTimeout", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_submitterPrecedencePeriodLength", + "type": "uint256" + } + ], + "name": "updateDkgParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "dkgResultSubmissionGas", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "dkgResultApprovalGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifyOperatorInactivityGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifySeedTimeoutGasOffset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "notifyDkgTimeoutNegativeGasOffset", + "type": "uint256" + } + ], + "name": "updateGasParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "operator", + "type": "address" + } + ], + "name": "updateOperatorStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ReimbursementPool", + "name": "_reimbursementPool", + "type": "address" + } + ], + "name": "updateReimbursementPool", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "maliciousDkgResultNotificationRewardMultiplier", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sortitionPoolRewardsBanDuration", + "type": "uint256" + } + ], + "name": "updateRewardParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint96", + "name": "maliciousDkgResultSlashingAmount", + "type": "uint96" + } + ], + "name": "updateSlashingParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IWalletOwner", + "name": "_walletOwner", + "type": "address" + } + ], + "name": "updateWalletOwner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IRandomBeacon", + "name": "_randomBeacon", + "type": "address" + } + ], + "name": "upgradeRandomBeacon", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "walletOwner", + "outputs": [ + { + "internalType": "contract IWalletOwner", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + } + ], + "name": "withdrawIneligibleRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "stakingProvider", + "type": "address" + } + ], + "name": "withdrawRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xe1e6a55e3026832dd8c68138e13a8ebc2be5a7350035cfdf7bf94ae55d3f5e8d", + "receipt": { + "to": null, + "from": "0x123694886DBf5Ac94DDA07135349534536D14cAf", + "contractAddress": "0x46d52E41C2F300BC82217Ce22b920c34995204eb", + "transactionIndex": 153, + "gasUsed": "1053765", + "logsBloom": "0x00000000000000000000000000000000400000004000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000002000000000000000800000000000000000000000000000000000000000000000000000000800000000000000000000000000002000000200000000000000000000000000002000080000000000000800000000000000000000000000000000400000000000000000000000000000000000000000020000000000000800000040000000000000400000000000000000000000000000000000000200800000000000000000000000000000000000000000000", + "blockHash": "0x3732970bbd880c54173c7ce85b492b3590b39e450f34676090c21425058cc49b", + "transactionHash": "0xe1e6a55e3026832dd8c68138e13a8ebc2be5a7350035cfdf7bf94ae55d3f5e8d", + "logs": [ + { + "transactionIndex": 153, + "blockNumber": 15639521, + "transactionHash": "0xe1e6a55e3026832dd8c68138e13a8ebc2be5a7350035cfdf7bf94ae55d3f5e8d", + "address": "0x46d52E41C2F300BC82217Ce22b920c34995204eb", + "topics": [ + "0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", + "0x000000000000000000000000fbae130e06bbc8ca198861beecae6e2b830398fb" + ], + "data": "0x", + "logIndex": 147, + "blockHash": "0x3732970bbd880c54173c7ce85b492b3590b39e450f34676090c21425058cc49b" + }, + { + "transactionIndex": 153, + "blockNumber": 15639521, + "transactionHash": "0xe1e6a55e3026832dd8c68138e13a8ebc2be5a7350035cfdf7bf94ae55d3f5e8d", + "address": "0x46d52E41C2F300BC82217Ce22b920c34995204eb", + "topics": [ + "0x5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000123694886dbf5ac94dda07135349534536d14caf", + "logIndex": 148, + "blockHash": "0x3732970bbd880c54173c7ce85b492b3590b39e450f34676090c21425058cc49b" + }, + { + "transactionIndex": 153, + "blockNumber": 15639521, + "transactionHash": "0xe1e6a55e3026832dd8c68138e13a8ebc2be5a7350035cfdf7bf94ae55d3f5e8d", + "address": "0x46d52E41C2F300BC82217Ce22b920c34995204eb", + "topics": [ + "0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498" + ], + "data": "0x0000000000000000000000000000000000000000000000000000000000000001", + "logIndex": 149, + "blockHash": "0x3732970bbd880c54173c7ce85b492b3590b39e450f34676090c21425058cc49b" + }, + { + "transactionIndex": 153, + "blockNumber": 15639521, + "transactionHash": "0xe1e6a55e3026832dd8c68138e13a8ebc2be5a7350035cfdf7bf94ae55d3f5e8d", + "address": "0x46d52E41C2F300BC82217Ce22b920c34995204eb", + "topics": [ + "0x7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f" + ], + "data": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000007affa05f726d293eb1193807a91617318292008e", + "logIndex": 150, + "blockHash": "0x3732970bbd880c54173c7ce85b492b3590b39e450f34676090c21425058cc49b" + } + ], + "blockNumber": 15639521, + "cumulativeGasUsed": "8679696", + "status": 1, + "byzantium": true + }, + "args": [ + "0xc2731fb2823af3Efc2694c9bC86F444d5c5bb4Dc", + "0x01B67b1194C75264d06F808A921228a95C765dd7" + ], + "numDeployments": 1, + "libraries": { + "EcdsaInactivity": "0x8263eFCb8F28246697585c89Fed0501Cd946F764" + }, + "implementation": "0xFbaE130e06Bbc8CA198861BEeCae6e2B830398fb", + "devdoc": "Contract deployed as upgradable proxy" +} diff --git a/typescript/src/lib/ethereum/bridge.ts b/typescript/src/lib/ethereum/bridge.ts index fda724628..fecf0fe25 100644 --- a/typescript/src/lib/ethereum/bridge.ts +++ b/typescript/src/lib/ethereum/bridge.ts @@ -32,13 +32,17 @@ import { } from "../bitcoin" import { EthersContractConfig, + EthersContractDeployment, EthersContractHandle, EthersTransactionUtils, } from "./adapter" -import BridgeDeployment from "@keep-network/tbtc-v2/artifacts/Bridge.json" import { EthereumAddress } from "./address" import { EthereumWalletRegistry } from "./wallet-registry" +import MainnetBridgeDeployment from "./artifacts/mainnet/Bridge.json" +import GoerliBridgeDeployment from "./artifacts/goerli/Bridge.json" +import LocalBridgeDeployment from "@keep-network/tbtc-v2/artifacts/Bridge.json" + type DepositRequestTypechain = DepositTypechain.DepositRequestStructOutput type RedemptionRequestTypechain = @@ -52,8 +56,35 @@ export class EthereumBridge extends EthersContractHandle implements Bridge { - constructor(config: EthersContractConfig) { - super(config, BridgeDeployment) + constructor( + config: EthersContractConfig, + deploymentType: "local" | "goerli" | "mainnet" = "local" + ) { + let deployment: EthersContractDeployment + + switch (deploymentType) { + case "local": + deployment = LocalBridgeDeployment + break + case "goerli": + deployment = GoerliBridgeDeployment + break + case "mainnet": + deployment = MainnetBridgeDeployment + break + default: + throw new Error("Unsupported deployment type") + } + + super(config, deployment) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {Bridge#getChainIdentifier} + */ + getChainIdentifier(): ChainIdentifier { + return EthereumAddress.from(this._instance.address) } // eslint-disable-next-line valid-jsdoc diff --git a/typescript/src/lib/ethereum/index.ts b/typescript/src/lib/ethereum/index.ts index 5e822f8f1..4f038294d 100644 --- a/typescript/src/lib/ethereum/index.ts +++ b/typescript/src/lib/ethereum/index.ts @@ -1,3 +1,10 @@ +import { TBTCContracts } from "../contracts" +import { providers, Signer } from "ethers" +import { EthereumBridge } from "./bridge" +import { EthereumWalletRegistry } from "./wallet-registry" +import { EthereumTBTCToken } from "./tbtc-token" +import { EthereumTBTCVault } from "./tbtc-vault" + export * from "./address" export * from "./bridge" export * from "./tbtc-token" @@ -8,3 +15,86 @@ export * from "./wallet-registry" // contains low-level contract integration code. Re-export only components // that are relevant for `lib/ethereum` clients. export { EthersContractConfig as EthereumContractConfig } from "./adapter" + +/** + * Represents an Ethereum signer. This type is a wrapper for Ethers-specific + * types and can be either a Signer that can make write transactions + * or a Provider that works only in the read-only mode. + */ +export type EthereumSigner = Signer | providers.Provider + +/** + * Resolves the Ethereum network the given Signer is tied to. + * @param signer The signer whose network should be resolved. + * @returns Ethereum network. + */ +export async function ethereumNetworkFromSigner( + signer: EthereumSigner +): Promise { + let chainId: number + if (signer instanceof Signer) { + chainId = await signer.getChainId() + } else { + const network = await signer.getNetwork() + chainId = network.chainId + } + + switch (chainId) { + case 1: + return "mainnet" + case 5: + return "goerli" + default: + return "local" + } +} + +/** + * Supported Ethereum networks. + */ +export type EthereumNetwork = "local" | "goerli" | "mainnet" + +/** + * Loads Ethereum implementation of tBTC contracts for the given Ethereum + * network and attaches the given signer there. + * @param signer Signer that should be attached to tBTC contracts. + * @param network Ethereum network. + * @returns Handle to tBTC contracts. + * @throws Throws an error if the signer's Ethereum network is other than + * the one used to load tBTC contracts. + */ +export async function loadEthereumContracts( + signer: EthereumSigner, + network: EthereumNetwork +): Promise { + const signerNetwork = await ethereumNetworkFromSigner(signer) + if (signerNetwork !== network) { + throw new Error("Signer uses different network than tBTC contracts") + } + + const bridge = new EthereumBridge({ signerOrProvider: signer }, network) + const tbtcToken = new EthereumTBTCToken({ signerOrProvider: signer }, network) + const tbtcVault = new EthereumTBTCVault({ signerOrProvider: signer }, network) + const walletRegistry = new EthereumWalletRegistry( + { signerOrProvider: signer }, + "mainnet" + ) + + const bridgeWalletRegistry = await bridge.walletRegistry() + if ( + !bridgeWalletRegistry + .getChainIdentifier() + .equals(walletRegistry.getChainIdentifier()) + ) { + throw new Error( + "Wallet registry used by Bridge is different than the one resolved from artifacts" + ) + } + + return { + bridge, + tbtcToken, + tbtcVault, + walletRegistry, + } +} diff --git a/typescript/src/lib/ethereum/tbtc-token.ts b/typescript/src/lib/ethereum/tbtc-token.ts index cb174a045..c100473cb 100644 --- a/typescript/src/lib/ethereum/tbtc-token.ts +++ b/typescript/src/lib/ethereum/tbtc-token.ts @@ -1,16 +1,20 @@ import { TBTC as TBTCTypechain } from "../../../typechain/TBTC" -import { TBTCToken } from "../contracts" +import { ChainIdentifier, TBTCToken } from "../contracts" import { BigNumber, ContractTransaction, utils } from "ethers" import { BitcoinHashUtils, BitcoinUtxo } from "../bitcoin" import { Hex } from "../utils" import { EthersContractConfig, + EthersContractDeployment, EthersContractHandle, EthersTransactionUtils, } from "./adapter" -import TBTCDeployment from "@keep-network/tbtc-v2/artifacts/TBTC.json" import { EthereumAddress } from "./address" +import MainnetTBTCTokenDeployment from "./artifacts/mainnet/TBTCToken.json" +import GoerliTBTCTokenDeployment from "./artifacts/goerli/TBTCToken.json" +import LocalTBTCTokenDeployment from "@keep-network/tbtc-v2/artifacts/TBTCToken.json" + /** * Implementation of the Ethereum TBTC v2 token handle. * @see {TBTCToken} for reference. @@ -19,8 +23,35 @@ export class EthereumTBTCToken extends EthersContractHandle implements TBTCToken { - constructor(config: EthersContractConfig) { - super(config, TBTCDeployment) + constructor( + config: EthersContractConfig, + deploymentType: "local" | "goerli" | "mainnet" = "local" + ) { + let deployment: EthersContractDeployment + + switch (deploymentType) { + case "local": + deployment = LocalTBTCTokenDeployment + break + case "goerli": + deployment = GoerliTBTCTokenDeployment + break + case "mainnet": + deployment = MainnetTBTCTokenDeployment + break + default: + throw new Error("Unsupported deployment type") + } + + super(config, deployment) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {TBTCToken#getChainIdentifier} + */ + getChainIdentifier(): ChainIdentifier { + return EthereumAddress.from(this._instance.address) } // eslint-disable-next-line valid-jsdoc diff --git a/typescript/src/lib/ethereum/tbtc-vault.ts b/typescript/src/lib/ethereum/tbtc-vault.ts index 7a49d3b65..1bf66b002 100644 --- a/typescript/src/lib/ethereum/tbtc-vault.ts +++ b/typescript/src/lib/ethereum/tbtc-vault.ts @@ -11,15 +11,19 @@ import { import { BigNumber, ContractTransaction } from "ethers" import { BitcoinTxHash } from "../bitcoin" import { backoffRetrier, Hex } from "../utils" -import TBTCVaultDeployment from "@keep-network/tbtc-v2/artifacts/TBTCVault.json" import { EthersContractConfig, + EthersContractDeployment, EthersContractHandle, EthersTransactionUtils, } from "./adapter" import { EthereumAddress } from "./address" import { EthereumBridge } from "./bridge" +import MainnetTBTCVaultDeployment from "./artifacts/mainnet/TBTCVault.json" +import GoerliTBTCVaultDeployment from "./artifacts/goerli/TBTCVault.json" +import LocalTBTCVaultDeployment from "@keep-network/tbtc-v2/artifacts/TBTCVault.json" + type ContractOptimisticMintingRequest = { requestedAt: BigNumber finalizedAt: BigNumber @@ -33,8 +37,27 @@ export class EthereumTBTCVault extends EthersContractHandle implements TBTCVault { - constructor(config: EthersContractConfig) { - super(config, TBTCVaultDeployment) + constructor( + config: EthersContractConfig, + deploymentType: "local" | "goerli" | "mainnet" = "local" + ) { + let deployment: EthersContractDeployment + + switch (deploymentType) { + case "local": + deployment = LocalTBTCVaultDeployment + break + case "goerli": + deployment = GoerliTBTCVaultDeployment + break + case "mainnet": + deployment = MainnetTBTCVaultDeployment + break + default: + throw new Error("Unsupported deployment type") + } + + super(config, deployment) } // eslint-disable-next-line valid-jsdoc diff --git a/typescript/src/lib/ethereum/wallet-registry.ts b/typescript/src/lib/ethereum/wallet-registry.ts index a71940e78..c71621cc0 100644 --- a/typescript/src/lib/ethereum/wallet-registry.ts +++ b/typescript/src/lib/ethereum/wallet-registry.ts @@ -5,14 +5,22 @@ import { DkgResultApprovedEvent, DkgResultChallengedEvent, DkgResultSubmittedEvent, + ChainIdentifier, } from "../contracts" import { backoffRetrier, Hex } from "../utils" import { Event as EthersEvent } from "@ethersproject/contracts" import { BigNumber } from "ethers" -import WalletRegistryDeployment from "@keep-network/ecdsa/artifacts/WalletRegistry.json" -import { EthersContractConfig, EthersContractHandle } from "./adapter" +import { + EthersContractConfig, + EthersContractDeployment, + EthersContractHandle, +} from "./adapter" import { EthereumAddress } from "./address" +import MainnetWalletRegistryDeployment from "./artifacts/mainnet/WalletRegistry.json" +import GoerliWalletRegistryDeployment from "./artifacts/goerli/WalletRegistry.json" +import LocalWalletRegistryDeployment from "@keep-network/ecdsa/artifacts/WalletRegistry.json" + /** * Implementation of the Ethereum WalletRegistry handle. * @see {WalletRegistry} for reference. @@ -21,8 +29,35 @@ export class EthereumWalletRegistry extends EthersContractHandle implements WalletRegistry { - constructor(config: EthersContractConfig) { - super(config, WalletRegistryDeployment) + constructor( + config: EthersContractConfig, + deploymentType: "local" | "goerli" | "mainnet" = "local" + ) { + let deployment: EthersContractDeployment + + switch (deploymentType) { + case "local": + deployment = LocalWalletRegistryDeployment + break + case "goerli": + deployment = GoerliWalletRegistryDeployment + break + case "mainnet": + deployment = MainnetWalletRegistryDeployment + break + default: + throw new Error("Unsupported deployment type") + } + + super(config, deployment) + } + + // eslint-disable-next-line valid-jsdoc + /** + * @see {WalletRegistry#getChainIdentifier} + */ + getChainIdentifier(): ChainIdentifier { + return EthereumAddress.from(this._instance.address) } // eslint-disable-next-line valid-jsdoc diff --git a/typescript/src/services/maintenance/maintenance-service.ts b/typescript/src/services/maintenance/maintenance-service.ts index 01c55637e..913fd9225 100644 --- a/typescript/src/services/maintenance/maintenance-service.ts +++ b/typescript/src/services/maintenance/maintenance-service.ts @@ -2,7 +2,6 @@ import { TBTCContracts } from "../../lib/contracts" import { BitcoinClient } from "../../lib/bitcoin" import { OptimisticMinting } from "./optimistic-minting" import { Spv } from "./spv" -import {WalletTx} from "./wallet-tx"; /** * Service exposing features relevant to authorized maintainers and diff --git a/typescript/src/services/tbtc.ts b/typescript/src/services/tbtc.ts new file mode 100644 index 000000000..f3ca647d4 --- /dev/null +++ b/typescript/src/services/tbtc.ts @@ -0,0 +1,96 @@ +import { DepositsService } from "./deposits" +import { MaintenanceService } from "./maintenance" +import { RedemptionsService } from "./redemptions" +import { TBTCContracts } from "../lib/contracts" +import { BitcoinClient, BitcoinNetwork } from "../lib/bitcoin" +import { EthereumSigner, loadEthereumContracts } from "../lib/ethereum" +import { ElectrumClient } from "../lib/electrum" + +/** + * Entrypoint component of the tBTC v2 SDK. + */ +export class TBTC { + /** + * Service supporting the tBTC v2 deposit flow. + */ + public readonly deposits: DepositsService + /** + * Service supporting authorized operations of tBTC v2 system maintainers + * and operators. + */ + public readonly maintenance: MaintenanceService + /** + * Service supporting the tBTC v2 redemption flow. + */ + public readonly redemptions: RedemptionsService + /** + * Handle to tBTC contracts for low-level access. + */ + public readonly tbtcContracts: TBTCContracts + /** + * Bitcoin client handle for low-level access. + */ + public readonly bitcoinClient: BitcoinClient + + private constructor( + tbtcContracts: TBTCContracts, + bitcoinClient: BitcoinClient + ) { + this.deposits = new DepositsService(tbtcContracts, bitcoinClient) + this.maintenance = new MaintenanceService(tbtcContracts, bitcoinClient) + this.redemptions = new RedemptionsService(tbtcContracts, bitcoinClient) + this.tbtcContracts = tbtcContracts + this.bitcoinClient = bitcoinClient + } + + /** + * Initializes the tBTC v2 SDK entrypoint for Ethereum and Bitcoin mainnets. + * The initialized instance uses default Electrum servers to interact + * with Bitcoin mainnet + * @param signer Ethereum signer. + * @returns Initialized tBTC v2 SDK entrypoint. + * @throws Throws an error if the signer's Ethereum network is other than + * Ethereum mainnet. + */ + static async initializeMainnet(signer: EthereumSigner): Promise { + const tbtcContracts = await loadEthereumContracts(signer, "mainnet") + const bitcoinClient = ElectrumClient.fromDefaultConfig( + BitcoinNetwork.Mainnet + ) + return new TBTC(tbtcContracts, bitcoinClient) + } + + /** + * Initializes the tBTC v2 SDK entrypoint for Ethereum goerli and Bitcoin testnet. + * The initialized instance uses default Electrum servers to interact + * with Bitcoin testnet + * @param signer Ethereum signer. + * @returns Initialized tBTC v2 SDK entrypoint. + * @throws Throws an error if the signer's Ethereum network is other than + * Ethereum mainnet. + */ + static async initializeGoerli(signer: EthereumSigner): Promise { + const tbtcContracts = await loadEthereumContracts(signer, "goerli") + const bitcoinClient = ElectrumClient.fromDefaultConfig( + BitcoinNetwork.Testnet + ) + return new TBTC(tbtcContracts, bitcoinClient) + } + + /** + * Initializes the tBTC v2 SDK entrypoint with custom tBTC contracts and + * Bitcoin client. + * @param tbtcContracts Custom tBTC contracts handle. + * @param bitcoinClient Custom Bitcoin client implementation. + * @returns Initialized tBTC v2 SDK entrypoint. + * @dev This function is especially useful for local development as it gives + * flexibility to combine different implementations of tBTC v2 contracts + * with different Bitcoin networks. + */ + static async initializeCustom( + tbtcContracts: TBTCContracts, + bitcoinClient: BitcoinClient + ): Promise { + return new TBTC(tbtcContracts, bitcoinClient) + } +} diff --git a/typescript/test/utils/mock-bridge.ts b/typescript/test/utils/mock-bridge.ts index 8e7ecc118..f6fbd0757 100644 --- a/typescript/test/utils/mock-bridge.ts +++ b/typescript/test/utils/mock-bridge.ts @@ -378,4 +378,8 @@ export class MockBridge implements Bridge { ): Promise { throw new Error("not implemented") } + + getChainIdentifier(): ChainIdentifier { + return EthereumAddress.from("0x894cfd89700040163727828AE20B52099C58F02C") + } } diff --git a/typescript/test/utils/mock-tbtc-token.ts b/typescript/test/utils/mock-tbtc-token.ts index 29ba32497..b2238f550 100644 --- a/typescript/test/utils/mock-tbtc-token.ts +++ b/typescript/test/utils/mock-tbtc-token.ts @@ -1,7 +1,8 @@ -import { TBTCToken } from "../../src/lib/contracts" +import { ChainIdentifier, TBTCToken } from "../../src/lib/contracts" import { Hex } from "../../src/lib/utils" import { BigNumber } from "ethers" import { BitcoinUtxo } from "../../src/lib/bitcoin" +import { EthereumAddress } from "../../src" interface RequestRedemptionLog { walletPublicKey: string @@ -38,4 +39,8 @@ export class MockTBTCToken implements TBTCToken { "0xf7d0c92c8de4d117d915c2a8a54ee550047f926bc00b91b651c40628751cfe29" ) } + + getChainIdentifier(): ChainIdentifier { + return EthereumAddress.from("0x694cfd89700040163727828AE20B52099C58F02C") + } } diff --git a/typescript/test/utils/mock-wallet-registry.ts b/typescript/test/utils/mock-wallet-registry.ts index 708c6fb00..2acc1c464 100644 --- a/typescript/test/utils/mock-wallet-registry.ts +++ b/typescript/test/utils/mock-wallet-registry.ts @@ -4,8 +4,10 @@ import { DkgResultApprovedEvent, DkgResultChallengedEvent, DkgResultSubmittedEvent, + ChainIdentifier, } from "../../src/lib/contracts" import { Hex } from "../../src/lib/utils" +import { EthereumAddress } from "../../src" export class MockWalletRegistry implements WalletRegistry { getDkgResultApprovedEvents( @@ -32,4 +34,8 @@ export class MockWalletRegistry implements WalletRegistry { getWalletPublicKey(walletID: Hex): Promise { throw new Error("not implemented") } + + getChainIdentifier(): ChainIdentifier { + return EthereumAddress.from("0x794cfd89700040163727828AE20B52099C58F02C") + } } From 5c74ca679515d836d9ad6d46847db578d350ecd6 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 4 Oct 2023 14:33:15 +0200 Subject: [PATCH 178/205] Facilitate deposit initiation Here we get rid of the `depositor` parameter that must be passed by the caller in favor of a default depositor set upon deposit service creation. This should facilitate the public API of the deposit service and make it more friendly for 3rd party integrators. --- typescript/src/lib/ethereum/index.ts | 21 +++++++- .../src/services/deposits/deposits-service.ts | 51 ++++++++++++------- typescript/src/services/tbtc.ts | 49 ++++++++++++++---- 3 files changed, 91 insertions(+), 30 deletions(-) diff --git a/typescript/src/lib/ethereum/index.ts b/typescript/src/lib/ethereum/index.ts index 4f038294d..d61c7eaad 100644 --- a/typescript/src/lib/ethereum/index.ts +++ b/typescript/src/lib/ethereum/index.ts @@ -4,6 +4,7 @@ import { EthereumBridge } from "./bridge" import { EthereumWalletRegistry } from "./wallet-registry" import { EthereumTBTCToken } from "./tbtc-token" import { EthereumTBTCVault } from "./tbtc-vault" +import { EthereumAddress } from "./address" export * from "./address" export * from "./bridge" @@ -24,7 +25,7 @@ export { EthersContractConfig as EthereumContractConfig } from "./adapter" export type EthereumSigner = Signer | providers.Provider /** - * Resolves the Ethereum network the given Signer is tied to. + * Resolves the Ethereum network the given signer is tied to. * @param signer The signer whose network should be resolved. * @returns Ethereum network. */ @@ -49,6 +50,24 @@ export async function ethereumNetworkFromSigner( } } +/** + * Resolves the Ethereum address tied to the given signer. The address + * cannot be resolved for signers that works in the read-only mode + * @param signer The signer whose address should be resolved. + * @returns Ethereum address or undefined for read-only signers. + * @throws Throws an error if the address of the signer is not a proper + * Ethereum address. + */ +export async function ethereumAddressFromSigner( + signer: EthereumSigner +): Promise { + if (signer instanceof Signer) { + return EthereumAddress.from(await signer.getAddress()) + } else { + return undefined + } +} + /** * Supported Ethereum networks. */ diff --git a/typescript/src/services/deposits/deposits-service.ts b/typescript/src/services/deposits/deposits-service.ts index d7c5c73b5..9c8ef01d5 100644 --- a/typescript/src/services/deposits/deposits-service.ts +++ b/typescript/src/services/deposits/deposits-service.ts @@ -29,6 +29,11 @@ export class DepositsService { * Bitcoin client handle. */ private readonly bitcoinClient: BitcoinClient + /** + * Chain-specific identifier of the default depositor used for deposits + * initiated by this service. + */ + private defaultDepositor: ChainIdentifier | undefined constructor(tbtcContracts: TBTCContracts, bitcoinClient: BitcoinClient) { this.tbtcContracts = tbtcContracts @@ -36,34 +41,31 @@ export class DepositsService { } /** - * Initiates a new deposit for the given depositor and Bitcoin recovery address. - * @param depositor Identifier of the depositor specific for the target chain - * deposited BTC are bridged to. For example, this is a - * 20-byte address on Ethereum. + * Initiates the tBTC v2 deposit process. * @param bitcoinRecoveryAddress P2PKH or P2WPKH Bitcoin address that can * be used for emergency recovery of the * deposited funds. - * @returns Handle to the initiated deposit. + * @returns Handle to the initiated deposit process. + * @throws Throws an error if one of the following occurs: + * - The default depositor is not set + * - There are no active wallet in the Bridge contract + * - The Bitcoin recovery address is not a valid P2(W)PKH */ - // TODO: Accept depositor as string and automatically validate & convert OR - // explore the possibility of fetching this from the account instance. // TODO: Cover with unit tests. - async initiateDeposit( - depositor: ChainIdentifier, - bitcoinRecoveryAddress: string - ): Promise { - const receipt = await this.generateDepositReceipt( - depositor, - bitcoinRecoveryAddress - ) - + async initiateDeposit(bitcoinRecoveryAddress: string): Promise { + const receipt = await this.generateDepositReceipt(bitcoinRecoveryAddress) return Deposit.fromReceipt(receipt, this.tbtcContracts, this.bitcoinClient) } private async generateDepositReceipt( - depositor: ChainIdentifier, bitcoinRecoveryAddress: string ): Promise { + if (this.defaultDepositor === undefined) { + throw new Error( + "Default depositor is not set; use setDefaultDepositor first" + ) + } + const blindingFactor = crypto.randomBytes(8).toString("hex") const walletPublicKey = @@ -90,11 +92,24 @@ export class DepositsService { ) return { - depositor, + depositor: this.defaultDepositor, blindingFactor, walletPublicKeyHash, refundPublicKeyHash, refundLocktime, } } + + // eslint-disable-next-line valid-jsdoc + /** + * Sets the default depositor used for deposits initiated by this service. + * @param defaultDepositor Chain-specific identifier of the default depositor. + * @dev Typically, there is no need to use this method when DepositsService + * is orchestrated automatically. However, there are some use cases + * where setting the default depositor explicitly may be useful. + * Make sure you know what you are doing while using this method. + */ + setDefaultDepositor(defaultDepositor: ChainIdentifier) { + this.defaultDepositor = defaultDepositor + } } diff --git a/typescript/src/services/tbtc.ts b/typescript/src/services/tbtc.ts index f3ca647d4..abb7bd9de 100644 --- a/typescript/src/services/tbtc.ts +++ b/typescript/src/services/tbtc.ts @@ -3,7 +3,12 @@ import { MaintenanceService } from "./maintenance" import { RedemptionsService } from "./redemptions" import { TBTCContracts } from "../lib/contracts" import { BitcoinClient, BitcoinNetwork } from "../lib/bitcoin" -import { EthereumSigner, loadEthereumContracts } from "../lib/ethereum" +import { + ethereumAddressFromSigner, + EthereumNetwork, + EthereumSigner, + loadEthereumContracts, +} from "../lib/ethereum" import { ElectrumClient } from "../lib/electrum" /** @@ -53,11 +58,7 @@ export class TBTC { * Ethereum mainnet. */ static async initializeMainnet(signer: EthereumSigner): Promise { - const tbtcContracts = await loadEthereumContracts(signer, "mainnet") - const bitcoinClient = ElectrumClient.fromDefaultConfig( - BitcoinNetwork.Mainnet - ) - return new TBTC(tbtcContracts, bitcoinClient) + return TBTC.initializeEthereum(signer, "mainnet", BitcoinNetwork.Mainnet) } /** @@ -70,11 +71,37 @@ export class TBTC { * Ethereum mainnet. */ static async initializeGoerli(signer: EthereumSigner): Promise { - const tbtcContracts = await loadEthereumContracts(signer, "goerli") - const bitcoinClient = ElectrumClient.fromDefaultConfig( - BitcoinNetwork.Testnet - ) - return new TBTC(tbtcContracts, bitcoinClient) + return TBTC.initializeEthereum(signer, "goerli", BitcoinNetwork.Testnet) + } + + /** + * Initializes the tBTC v2 SDK entrypoint for the given Ethereum network and Bitcoin network. + * The initialized instance uses default Electrum servers to interact + * with Bitcoin network. + * @param signer Ethereum signer. + * @param ethereumNetwork Ethereum network. + * @param bitcoinNetwork Bitcoin network. + * @returns Initialized tBTC v2 SDK entrypoint. + * @throws Throws an error if the underlying signer's Ethereum network is + * other than the given Ethereum network. + */ + private static async initializeEthereum( + signer: EthereumSigner, + ethereumNetwork: EthereumNetwork, + bitcoinNetwork: BitcoinNetwork + ): Promise { + const signerAddress = await ethereumAddressFromSigner(signer) + const tbtcContracts = await loadEthereumContracts(signer, ethereumNetwork) + const bitcoinClient = ElectrumClient.fromDefaultConfig(bitcoinNetwork) + + const tbtc = new TBTC(tbtcContracts, bitcoinClient) + + // If signer address can be resolved, set it as default depositor. + if (signerAddress !== undefined) { + tbtc.deposits.setDefaultDepositor(signerAddress) + } + + return tbtc } /** From 64ea5390c1344a896ba204028668a979e9cef237 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 5 Oct 2023 13:40:32 +0200 Subject: [PATCH 179/205] Remove `src` and `typechain` from result package Those directories are not needed as everything is included in `dist` --- typescript/package.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index 0f803bdc4..27e8a36a4 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -15,11 +15,7 @@ "build": "npm run typechain && tsc --project tsconfig.build.json", "dev": "tsc --project tsconfig.build.json --watch" }, - "files": [ - "dist/", - "src/", - "typechain/" - ], + "files": ["dist"], "config": { "contracts": "./node_modules/@keep-network/ecdsa/artifacts/WalletRegistry.json ./node_modules/@keep-network/tbtc-v2/artifacts/{Bridge,TBTCVault,TBTC}.json" }, From cc3d85a5370723aff82fa079a94e6135c968313b Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 5 Oct 2023 14:07:19 +0200 Subject: [PATCH 180/205] Sort out and update TODOs Remove the ones that are no longer relevant and make the existing ones reflect real work that needs to be done. --- typescript/src/index.ts | 3 +++ typescript/src/lib/contracts/bridge.ts | 5 +---- typescript/src/lib/contracts/tbtc-token.ts | 2 -- typescript/src/lib/contracts/tbtc-vault.ts | 4 ---- typescript/src/lib/ethereum/adapter.ts | 2 -- typescript/src/lib/ethereum/address.ts | 4 ++-- typescript/src/services/deposits/deposit.ts | 1 - typescript/src/services/deposits/deposits-service.ts | 2 +- typescript/src/services/maintenance/spv.ts | 6 ------ typescript/src/services/maintenance/wallet-tx.ts | 5 ----- typescript/test/deposit.test.ts | 4 +++- typescript/test/electrum.test.ts | 5 +++-- 12 files changed, 13 insertions(+), 30 deletions(-) diff --git a/typescript/src/index.ts b/typescript/src/index.ts index 2ee4bcafd..628275200 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -12,3 +12,6 @@ export * from "./services/redemptions" // Export the entrypoint module. export * from "./services/tbtc" + +// TODO: Replace all properties that are expected to be un-prefixed hexadecimal +// strings with a Hex type to increase API consistency. diff --git a/typescript/src/lib/contracts/bridge.ts b/typescript/src/lib/contracts/bridge.ts index d78499c55..0e26c1587 100644 --- a/typescript/src/lib/contracts/bridge.ts +++ b/typescript/src/lib/contracts/bridge.ts @@ -55,7 +55,7 @@ export interface Bridge { depositOutputIndex: number, deposit: DepositReceipt, vault?: ChainIdentifier - ): Promise // TODO: Update to Hex + ): Promise /** * Gets a revealed deposit from the on-chain contract. @@ -181,9 +181,6 @@ export interface Bridge { getRedemptionRequestedEvents: GetChainEvents.Function } -// TODO: Replace all properties that are expected to be un-prefixed hexadecimal -// strings with a Hex type. - /** * Represents a deposit receipt. The receipt holds all information required * to build a unique deposit address on Bitcoin chain. diff --git a/typescript/src/lib/contracts/tbtc-token.ts b/typescript/src/lib/contracts/tbtc-token.ts index b78ef1823..596c88ddb 100644 --- a/typescript/src/lib/contracts/tbtc-token.ts +++ b/typescript/src/lib/contracts/tbtc-token.ts @@ -20,8 +20,6 @@ export interface TBTCToken { * supply should be fetched for. If this parameter is not set, the * total supply is taken for the latest block. */ - // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 - // precision to Bitcoin in 1e8 precision (satoshi). totalSupply(blockNumber?: number): Promise /** diff --git a/typescript/src/lib/contracts/tbtc-vault.ts b/typescript/src/lib/contracts/tbtc-vault.ts index 277e445ff..1ddb131d0 100644 --- a/typescript/src/lib/contracts/tbtc-vault.ts +++ b/typescript/src/lib/contracts/tbtc-vault.ts @@ -152,8 +152,6 @@ export type OptimisticMintingRequestedEvent = { * This value is in ERC 1e18 precision, it has to be converted before using * as Bitcoin value with 1e8 precision in satoshi. */ - // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 - // precision to Bitcoin in 1e8 precision (satoshi). amount: BigNumber /** * Hash of a Bitcoin transaction made to fund the deposit. @@ -204,7 +202,5 @@ export type OptimisticMintingFinalizedEvent = { * This value is in ERC 1e18 precision, it has to be converted before using * as Bitcoin value with 1e8 precision in satoshi. */ - // TODO: Consider adding a custom type to handle conversion from ERC with 1e18 - // precision to Bitcoin in 1e8 precision (satoshi). optimisticMintingDebt: BigNumber } & ChainEvent diff --git a/typescript/src/lib/ethereum/adapter.ts b/typescript/src/lib/ethereum/adapter.ts index 8a678acc3..0f678c26e 100644 --- a/typescript/src/lib/ethereum/adapter.ts +++ b/typescript/src/lib/ethereum/adapter.ts @@ -129,8 +129,6 @@ export class EthersContractHandle { options?: GetChainEvents.Options, ...filterArgs: Array ): Promise { - // TODO: Test if we need a workaround for querying events from big range in chunks, - // see: https://github.com/keep-network/tbtc-monitoring/blob/e169357d7b8c638d4eaf73d52aa8f53ee4aebc1d/src/lib/ethereum-helper.js#L44-L73 return backoffRetrier( options?.retries ?? this._totalRetryAttempts )(async () => { diff --git a/typescript/src/lib/ethereum/address.ts b/typescript/src/lib/ethereum/address.ts index 9135dddd0..a5bbb30a7 100644 --- a/typescript/src/lib/ethereum/address.ts +++ b/typescript/src/lib/ethereum/address.ts @@ -4,7 +4,8 @@ import { utils } from "ethers" /** * Represents an Ethereum address. */ -// TODO: Make Address extends Hex +// TODO: Make EthereumAddress extends Hex. Remember about keeping the address +// validation while creating EthereumAddress instance. export class EthereumAddress implements ChainIdentifier { readonly identifierHex: string @@ -24,7 +25,6 @@ export class EthereumAddress implements ChainIdentifier { return new EthereumAddress(address) } - // TODO: Remove once extends Hex equals(otherValue: EthereumAddress): boolean { return this.identifierHex === otherValue.identifierHex } diff --git a/typescript/src/services/deposits/deposit.ts b/typescript/src/services/deposits/deposit.ts index e455724ad..4ce3099a3 100644 --- a/typescript/src/services/deposits/deposit.ts +++ b/typescript/src/services/deposits/deposit.ts @@ -111,7 +111,6 @@ export class Deposit { * initiate minting (both modes). */ // TODO: Cover auto funding outpoint detection with unit tests. - // TODO: Return Hex. async initiateMinting(fundingOutpoint?: BitcoinTxOutpoint): Promise { let resolvedFundingOutpoint: BitcoinTxOutpoint diff --git a/typescript/src/services/deposits/deposits-service.ts b/typescript/src/services/deposits/deposits-service.ts index 9c8ef01d5..eb985d7c1 100644 --- a/typescript/src/services/deposits/deposits-service.ts +++ b/typescript/src/services/deposits/deposits-service.ts @@ -78,7 +78,7 @@ export class DepositsService { const walletPublicKeyHash = BitcoinHashUtils.computeHash160(walletPublicKey) // TODO: Only P2(W)PKH addresses can be used for recovery. The below conversion - // function ensures that but it would be good to check it here as well + // function ensures that but, it would be good to check it here as well // in case the converter implementation changes. const refundPublicKeyHash = BitcoinAddressConverter.addressToPublicKeyHash( bitcoinRecoveryAddress diff --git a/typescript/src/services/maintenance/spv.ts b/typescript/src/services/maintenance/spv.ts index d64fef5b9..c00d690db 100644 --- a/typescript/src/services/maintenance/spv.ts +++ b/typescript/src/services/maintenance/spv.ts @@ -42,9 +42,6 @@ export class Spv { confirmations, this.bitcoinClient ) - // TODO: Write a converter and use it to convert the transaction part of the - // proof to the decomposed transaction data (version, inputs, outputs, locktime). - // Use raw transaction data for now. const rawTransaction = await this.bitcoinClient.getRawTransaction( transactionHash ) @@ -78,9 +75,6 @@ export class Spv { confirmations, this.bitcoinClient ) - // TODO: Write a converter and use it to convert the transaction part of the - // proof to the decomposed transaction data (version, inputs, outputs, locktime). - // Use raw transaction data for now. const rawTransaction = await this.bitcoinClient.getRawTransaction( transactionHash ) diff --git a/typescript/src/services/maintenance/wallet-tx.ts b/typescript/src/services/maintenance/wallet-tx.ts index 4c2522e98..970f50574 100644 --- a/typescript/src/services/maintenance/wallet-tx.ts +++ b/typescript/src/services/maintenance/wallet-tx.ts @@ -603,11 +603,6 @@ class Redemption { totalOutputsValue = totalOutputsValue.add(outputValue) // Add the fee for this particular request to the overall transaction fee - // TODO: Using the maximum allowed transaction fee for the request (`txMaxFee`) - // as the transaction fee for now. In the future allow the caller to - // propose the value of the transaction fee. If the proposed transaction - // fee is smaller than the sum of fee shares from all the outputs then - // use the proposed fee and add the difference to outputs proportionally. txTotalFee = txTotalFee.add(request.txMaxFee) transaction.addOutput({ diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index 45887102d..d534d37e7 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -650,7 +650,9 @@ describe("Deposit", () => { }) describe("Deposit", () => { - describe("", () => { + // TODO: Implement unit tests for other functions. + + describe("initiateMinting", () => { describe("auto funding outpoint detection mode", () => { // TODO: Unit test for this case. }) diff --git a/typescript/test/electrum.test.ts b/typescript/test/electrum.test.ts index eccfe1056..6d8ff8730 100644 --- a/typescript/test/electrum.test.ts +++ b/typescript/test/electrum.test.ts @@ -18,7 +18,7 @@ import https from "https" const BLOCKSTREAM_TESTNET_API_URL = "https://blockstream.info/testnet/api" const testnetCredentials: ElectrumCredentials[] = [ - // TODO: Enable all protocols test for test.tbtc.network servers once they are + // FIXME: Enable all protocols test for test.tbtc.network servers once they are // publicly exposed. // // electrumx tcp // { @@ -138,7 +138,8 @@ describe.skip("Electrum", () => { ) expect(result).to.be.eql(testnetTransaction) }) - // TODO: Add case when transaction doesn't exist + + // TODO: Add case when transaction doesn't exist. }) describe("getRawTransaction", () => { From 66cbee185df5fbbe912a7e2b52fa2edcfec2868c Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 9 Oct 2023 11:39:21 +0200 Subject: [PATCH 181/205] Add `bitcoinjs-lib` and friends --- typescript/package.json | 11 +- typescript/yarn.lock | 238 ++++++++++++++++++++++++++++++++++------ 2 files changed, 212 insertions(+), 37 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index 27e8a36a4..fb929012a 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -13,7 +13,8 @@ "test": "mocha --exit --recursive 'test/**/*.test.ts'", "typechain": "rm -rf ./typechain && for i in $npm_package_config_contracts; do typechain --target ethers-v5 --out-dir ./typechain $i; done && rm ./typechain/index.ts", "build": "npm run typechain && tsc --project tsconfig.build.json", - "dev": "tsc --project tsconfig.build.json --watch" + "dev": "tsc --project tsconfig.build.json --watch", + "postinstall": "npm rebuild bcrypto" }, "files": ["dist"], "config": { @@ -22,7 +23,8 @@ "dependencies": { "@keep-network/ecdsa": "development", "@keep-network/tbtc-v2": "development", - "bitcoinjs-lib": "^6.1.5", + "bcoin": "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8", + "bitcoinjs-lib": "6.0.2", "bufio": "^1.0.6", "ecpair": "^2.1.0", "electrum-client-js": "git+https://github.com/keep-network/electrum-client-js.git#v0.1.1", @@ -54,6 +56,9 @@ "typescript": "^4.3.5" }, "engines": { - "node": ">=16" + "node": ">=14 <15" + }, + "browser": { + "bcoin": "bcoin/lib/bcoin-browser" } } diff --git a/typescript/yarn.lock b/typescript/yarn.lock index 08928f090..05897068f 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -1643,11 +1643,6 @@ resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-5.50.0.tgz#29c6419e8379d496ab6d0426eadf3c4d100cd186" integrity sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA== -"@noble/hashes@^1.2.0": - version "1.3.2" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" - integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== - "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -2496,16 +2491,50 @@ base-x@^3.0.2, base-x@^3.0.8: dependencies: safe-buffer "^5.0.1" -base-x@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.0.tgz#d0e3b7753450c73f8ad2389b5c018a4af7b2224a" - integrity sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw== - base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== +"bcfg@git+https://github.com/bcoin-org/bcfg.git#semver:~0.1.7": + version "0.1.7" + resolved "git+https://github.com/bcoin-org/bcfg.git#05122154b35baa82cd01dc9478ebee7346386ba1" + dependencies: + bsert "~0.0.10" + +"bcoin@git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8": + version "2.2.0" + resolved "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8" + dependencies: + bcfg "git+https://github.com/bcoin-org/bcfg.git#semver:~0.1.7" + bcrypto "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0" + bcurl "git+https://github.com/bcoin-org/bcurl.git#semver:^0.1.6" + bdb "git+https://github.com/bcoin-org/bdb.git#semver:~1.2.1" + bdns "git+https://github.com/bcoin-org/bdns.git#semver:~0.1.5" + bevent "git+https://github.com/bcoin-org/bevent.git#semver:~0.1.5" + bfile "git+https://github.com/bcoin-org/bfile.git#semver:~0.2.1" + bfilter "git+https://github.com/bcoin-org/bfilter.git#semver:~2.3.0" + bheep "git+https://github.com/bcoin-org/bheep.git#semver:~0.1.5" + binet "git+https://github.com/bcoin-org/binet.git#semver:~0.3.5" + blgr "git+https://github.com/bcoin-org/blgr.git#semver:~0.2.0" + blru "git+https://github.com/bcoin-org/blru.git#semver:~0.1.6" + blst "git+https://github.com/bcoin-org/blst.git#semver:~0.1.5" + bmutex "git+https://github.com/bcoin-org/bmutex.git#semver:~0.1.6" + brq "git+https://github.com/bcoin-org/brq.git#semver:~0.1.7" + bs32 "git+https://github.com/bcoin-org/bs32.git#semver:=0.1.6" + bsert "git+https://github.com/chjj/bsert.git#semver:~0.0.10" + bsock "git+https://github.com/bcoin-org/bsock.git#semver:~0.1.9" + bsocks "git+https://github.com/bcoin-org/bsocks.git#semver:~0.2.6" + btcp "git+https://github.com/bcoin-org/btcp.git#semver:~0.1.5" + buffer-map "git+https://github.com/chjj/buffer-map.git#semver:~0.0.7" + bufio "git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6" + bupnp "git+https://github.com/bcoin-org/bupnp.git#semver:~0.2.6" + bval "git+https://github.com/bcoin-org/bval.git#semver:~0.1.6" + bweb "git+https://github.com/bcoin-org/bweb.git#semver:=0.1.9" + loady "git+https://github.com/chjj/loady.git#semver:~0.0.1" + n64 "git+https://github.com/chjj/n64.git#semver:~0.2.10" + nan "git+https://github.com/braydonf/nan.git#semver:=2.14.0" + bcrypt-pbkdf@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" @@ -2513,6 +2542,34 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +"bcrypto@git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0": + version "5.5.0" + resolved "git+https://github.com/bcoin-org/bcrypto.git#34738cf15033e3bce91a4f6f41ec1ebee3c2fdc8" + dependencies: + bufio "~1.0.7" + loady "~0.0.5" + +"bcurl@git+https://github.com/bcoin-org/bcurl.git#semver:^0.1.6": + version "0.1.10" + resolved "git+https://github.com/bcoin-org/bcurl.git#d7e088fad4c284fb5d6fd7205c6b903bd3e6bf83" + dependencies: + brq "~0.1.8" + bsert "~0.0.10" + bsock "~0.1.9" + +"bdb@git+https://github.com/bcoin-org/bdb.git#semver:~1.2.1": + version "1.2.2" + resolved "git+https://github.com/bcoin-org/bdb.git#2c8d48c8adca4b11260263472766cd4b7ae74ef7" + dependencies: + bsert "~0.0.10" + loady "~0.0.1" + +"bdns@git+https://github.com/bcoin-org/bdns.git#semver:~0.1.5": + version "0.1.5" + resolved "git+https://github.com/bcoin-org/bdns.git#cb0b62a0075f7e1259fc50fa723ba644e9a07d14" + dependencies: + bsert "~0.0.10" + bech32@1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" @@ -2523,6 +2580,31 @@ bech32@^2.0.0: resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355" integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg== +"bevent@git+https://github.com/bcoin-org/bevent.git#semver:~0.1.5": + version "0.1.5" + resolved "git+https://github.com/bcoin-org/bevent.git#60fb503de3ea1292d29ce438bfba80f0bc5ccb60" + dependencies: + bsert "~0.0.10" + +"bfile@git+https://github.com/bcoin-org/bfile.git#semver:~0.2.1": + version "0.2.2" + resolved "git+https://github.com/bcoin-org/bfile.git#c3075133a02830dc384f8353d8275d4499b8bff9" + +"bfilter@git+https://github.com/bcoin-org/bfilter.git#semver:~2.3.0": + version "2.3.0" + resolved "git+https://github.com/bcoin-org/bfilter.git#70e42125f877191d340e8838a1a90fabb750e680" + dependencies: + bcrypto "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0" + bsert "git+https://github.com/chjj/bsert.git#semver:~0.0.10" + bufio "git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6" + loady "git+https://github.com/chjj/loady.git#semver:~0.0.1" + +"bheep@git+https://github.com/bcoin-org/bheep.git#semver:~0.1.5": + version "0.1.5" + resolved "git+https://github.com/bcoin-org/bheep.git#e59329d0a776ae71b2fb7a2876ee5b9fd3030fa2" + dependencies: + bsert "~0.0.10" + big-integer@^1.6.44: version "1.6.51" resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" @@ -2555,7 +2637,14 @@ bindings@^1.3.0: dependencies: file-uri-to-path "1.0.0" -bip174@^2.1.1: +"binet@git+https://github.com/bcoin-org/binet.git#semver:~0.3.5", binet@~0.3.5: + version "0.3.6" + resolved "git+https://github.com/bcoin-org/binet.git#d3decfb7a7257abdfb03c3a9c091499b2ebff0e1" + dependencies: + bs32 "~0.1.5" + bsert "~0.0.10" + +bip174@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/bip174/-/bip174-2.1.1.tgz#ef3e968cf76de234a546962bcf572cc150982f9f" integrity sha512-mdFV5+/v0XyNYXjBS6CQPLo9ekCx4gtKZFnJm5PMto7Fs9hTTDpkkzOB7/FtluRI6JbUUAu+snTYfJRgHLZbZQ== @@ -2602,17 +2691,19 @@ bip39@3.0.4: pbkdf2 "^3.0.9" randombytes "^2.0.1" -bitcoinjs-lib@^6.1.5: - version "6.1.5" - resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.1.5.tgz#3b03509ae7ddd80a440f10fc38c4a97f0a028d8c" - integrity sha512-yuf6xs9QX/E8LWE2aMJPNd0IxGofwfuVOiYdNUESkc+2bHHVKjhJd8qewqapeoolh9fihzHGoDCB5Vkr57RZCQ== +bitcoinjs-lib@6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.0.2.tgz#0fdf6c41978d93641b936d66f4afce44bb9b7f35" + integrity sha512-I994pGt9cL5s5OA6mkv1e8IuYcsKN2ORXnWbkqAXLNGvEnOHBhKBSvCjFl7YC2uVoJnfr/iwq7JMrq575SYO5w== dependencies: - "@noble/hashes" "^1.2.0" bech32 "^2.0.0" - bip174 "^2.1.1" - bs58check "^3.0.1" + bip174 "^2.0.1" + bs58check "^2.1.2" + create-hash "^1.1.0" + ripemd160 "^2.0.2" typeforce "^1.11.3" varuint-bitcoin "^1.1.2" + wif "^2.0.1" bl@^1.0.0: version "1.2.3" @@ -2627,6 +2718,18 @@ blakejs@^1.1.0: resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.2.1.tgz#5057e4206eadb4a97f7c0b6e197a505042fc3814" integrity sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ== +"blgr@git+https://github.com/bcoin-org/blgr.git#semver:~0.2.0": + version "0.2.0" + resolved "git+https://github.com/bcoin-org/blgr.git#050cbb587a1654a078468dbb92606330fdc4d120" + dependencies: + bsert "~0.0.10" + +"blru@git+https://github.com/bcoin-org/blru.git#semver:~0.1.6": + version "0.1.6" + resolved "git+https://github.com/bcoin-org/blru.git#c2c093e9475439333dfb87bfb2fdc3be6c98b080" + dependencies: + bsert "~0.0.10" + "bls12377js@https://github.com/celo-org/bls12377js#400bcaeec9e7620b040bfad833268f5289699cac": version "0.1.0" resolved "https://github.com/celo-org/bls12377js#400bcaeec9e7620b040bfad833268f5289699cac" @@ -2651,11 +2754,23 @@ blakejs@^1.1.0: ts-node "^8.4.1" typescript "^3.6.4" +"blst@git+https://github.com/bcoin-org/blst.git#semver:~0.1.5": + version "0.1.5" + resolved "git+https://github.com/bcoin-org/blst.git#d588403edb18e628899e05aeba8c3a98a5cdedff" + dependencies: + bsert "~0.0.10" + bluebird@^3.5.0, bluebird@^3.5.2: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== +"bmutex@git+https://github.com/bcoin-org/bmutex.git#semver:~0.1.6": + version "0.1.6" + resolved "git+https://github.com/bcoin-org/bmutex.git#e50782323932a4946ecc05a74c6d45861adc2c25" + dependencies: + bsert "~0.0.10" + bn.js@4.11.6: version "4.11.6" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" @@ -2778,6 +2893,18 @@ browserify-sign@^4.0.0: readable-stream "^3.6.0" safe-buffer "^5.2.0" +"brq@git+https://github.com/bcoin-org/brq.git#semver:~0.1.7", brq@~0.1.7, brq@~0.1.8: + version "0.1.8" + resolved "git+https://github.com/bcoin-org/brq.git#534bb2c83fb366ba40ad80bc3de796a174503294" + dependencies: + bsert "~0.0.10" + +"bs32@git+https://github.com/bcoin-org/bs32.git#semver:=0.1.6", bs32@~0.1.5: + version "0.1.6" + resolved "git+https://github.com/bcoin-org/bs32.git#21cf9c724659dc15df722d2410548828c142f265" + dependencies: + bsert "~0.0.10" + bs58@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" @@ -2785,13 +2912,6 @@ bs58@^4.0.0: dependencies: base-x "^3.0.2" -bs58@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279" - integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ== - dependencies: - base-x "^4.0.0" - bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" @@ -2801,13 +2921,26 @@ bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: create-hash "^1.1.0" safe-buffer "^5.1.2" -bs58check@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-3.0.1.tgz#2094d13720a28593de1cba1d8c4e48602fdd841c" - integrity sha512-hjuuJvoWEybo7Hn/0xOrczQKKEKD63WguEjlhLExYs2wUBcebDC1jDNK17eEAD2lYfw82d5ASC1d7K3SWszjaQ== +"bsert@git+https://github.com/chjj/bsert.git#semver:~0.0.10", bsert@~0.0.10: + version "0.0.10" + resolved "git+https://github.com/chjj/bsert.git#bd09d49eab8644bca08ae8259a3d8756e7d453fc" + +"bsock@git+https://github.com/bcoin-org/bsock.git#semver:~0.1.9", bsock@~0.1.8, bsock@~0.1.9: + version "0.1.9" + resolved "git+https://github.com/bcoin-org/bsock.git#7cf76b3021ae7929c023d1170f789811e91ae528" dependencies: - "@noble/hashes" "^1.2.0" - bs58 "^5.0.0" + bsert "~0.0.10" + +"bsocks@git+https://github.com/bcoin-org/bsocks.git#semver:~0.2.6": + version "0.2.6" + resolved "git+https://github.com/bcoin-org/bsocks.git#6a8eb764dc4408e7f47da4f84e1afb1b393117e8" + dependencies: + binet "~0.3.5" + bsert "~0.0.10" + +"btcp@git+https://github.com/bcoin-org/btcp.git#semver:~0.1.5": + version "0.1.5" + resolved "git+https://github.com/bcoin-org/btcp.git#4ea7e1ce5a43cd5348152c007aff76a419190a3a" buffer-alloc-unsafe@^1.1.0: version "1.1.0" @@ -2837,6 +2970,10 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== +"buffer-map@git+https://github.com/chjj/buffer-map.git#semver:~0.0.7": + version "0.0.7" + resolved "git+https://github.com/chjj/buffer-map.git#bad5863af9a520701937a17fc8fa2bd8ca8e73f3" + buffer-reverse@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-reverse/-/buffer-reverse-1.0.1.tgz#49283c8efa6f901bc01fa3304d06027971ae2f60" @@ -2889,10 +3026,31 @@ bufferutil@^4.0.1: dependencies: node-gyp-build "^4.3.0" -bufio@^1.0.6: +bufio@^1.0.6, "bufio@git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6", bufio@~1.0.7: version "1.0.7" resolved "git+https://github.com/bcoin-org/bufio.git#91ae6c93899ff9fad7d7cee9afd2a1c4933ca984" +"bupnp@git+https://github.com/bcoin-org/bupnp.git#semver:~0.2.6": + version "0.2.6" + resolved "git+https://github.com/bcoin-org/bupnp.git#c44fa7356aa297c9de96e8ad094a6816939cd688" + dependencies: + binet "~0.3.5" + brq "~0.1.7" + bsert "~0.0.10" + +"bval@git+https://github.com/bcoin-org/bval.git#semver:~0.1.6": + version "0.1.6" + resolved "git+https://github.com/bcoin-org/bval.git#c8cd14419ca46f63610dc48b797b076835e86f48" + dependencies: + bsert "~0.0.10" + +"bweb@git+https://github.com/bcoin-org/bweb.git#semver:=0.1.9": + version "0.1.9" + resolved "git+https://github.com/bcoin-org/bweb.git#31ae94ec9e97079610394e91928fe070d312c39d" + dependencies: + bsert "~0.0.10" + bsock "~0.1.8" + bytes@3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" @@ -5568,6 +5726,10 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" +"loady@git+https://github.com/chjj/loady.git#semver:~0.0.1", loady@~0.0.1, loady@~0.0.5: + version "0.0.5" + resolved "git+https://github.com/chjj/loady.git#b94958b7ee061518f4b85ea6da380e7ee93222d5" + locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -5986,11 +6148,19 @@ multihashes@^0.4.15, multihashes@~0.4.15: multibase "^0.7.0" varint "^5.0.0" +"n64@git+https://github.com/chjj/n64.git#semver:~0.2.10": + version "0.2.10" + resolved "git+https://github.com/chjj/n64.git#34f981f1441f569821d97a31f8cf21a3fc11b8f6" + nan@^2.13.2, nan@^2.14.0: version "2.15.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== +"nan@git+https://github.com/braydonf/nan.git#semver:=2.14.0": + version "2.14.0" + resolved "git+https://github.com/braydonf/nan.git#1dcc61bd06d84e389bfd5311b2b1492a14c74201" + nano-json-stream-parser@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz#0cc8f6d0e2b622b479c40d499c46d64b755c6f5f" @@ -6765,7 +6935,7 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -ripemd160@^2.0.0, ripemd160@^2.0.1: +ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== @@ -8652,7 +8822,7 @@ wide-align@1.1.3: dependencies: string-width "^1.0.2 || 2" -wif@2.0.6, wif@^2.0.6: +wif@2.0.6, wif@^2.0.1, wif@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/wif/-/wif-2.0.6.tgz#08d3f52056c66679299726fade0d432ae74b4704" integrity sha1-CNP1IFbGZnkplyb63g1DKudLRwQ= From 1b21713545df8ed7cacebbcb7cafb25b4d1f7ff3 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 9 Oct 2023 11:41:44 +0200 Subject: [PATCH 182/205] Integrate `bitcoinjs-lib` changes around deposit sweeps Here we pull changes from https://github.com/keep-network/tbtc-v2/pull/700 --- typescript/src/lib/bitcoin/address.ts | 33 +- typescript/src/lib/bitcoin/index.ts | 1 + typescript/src/lib/bitcoin/network.ts | 24 + typescript/src/lib/bitcoin/script.ts | 67 +++ typescript/src/services/deposits/deposit.ts | 55 ++- .../src/services/maintenance/wallet-tx.ts | 412 ++++++++++-------- typescript/test/bitcoin-network.test.ts | 35 +- typescript/test/bitcoin.test.ts | 86 +++- typescript/test/data/deposit-sweep.ts | 29 +- typescript/test/deposit-sweep.test.ts | 52 ++- 10 files changed, 551 insertions(+), 243 deletions(-) create mode 100644 typescript/src/lib/bitcoin/script.ts diff --git a/typescript/src/lib/bitcoin/address.ts b/typescript/src/lib/bitcoin/address.ts index 874d995ab..cc10aebda 100644 --- a/typescript/src/lib/bitcoin/address.ts +++ b/typescript/src/lib/bitcoin/address.ts @@ -1,6 +1,36 @@ import bcoin, { Script } from "bcoin" import { Hex } from "../utils" -import { BitcoinNetwork, toBcoinNetwork } from "./network" +import { + BitcoinNetwork, + toBcoinNetwork, + toBitcoinJsLibNetwork, +} from "./network" +import { payments } from "bitcoinjs-lib" + +/** + * Creates the Bitcoin address from the public key. Supports SegWit (P2WPKH) and + * Legacy (P2PKH) formats. + * @param publicKey - Public key used to derive the Bitcoin address. + * @param bitcoinNetwork - Target Bitcoin network. + * @param witness - Flag to determine address format: true for SegWit (P2WPKH) + * and false for Legacy (P2PKH). Default is true. + * @returns The derived Bitcoin address. + */ +export function publicKeyToAddress( + publicKey: Hex, + bitcoinNetwork: BitcoinNetwork, + witness: boolean = true +): string { + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + + if (witness) { + // P2WPKH (SegWit) + return payments.p2wpkh({ pubkey: publicKey.toBuffer(), network }).address! + } else { + // P2PKH (Legacy) + return payments.p2pkh({ pubkey: publicKey.toBuffer(), network }).address! + } +} /** * Converts a public key hash into a P2PKH/P2WPKH address. @@ -71,6 +101,7 @@ function outputScriptToAddress( * Utility functions allowing to perform Bitcoin address conversions. */ export const BitcoinAddressConverter = { + publicKeyToAddress, publicKeyHashToAddress, addressToPublicKeyHash, addressToOutputScript, diff --git a/typescript/src/lib/bitcoin/index.ts b/typescript/src/lib/bitcoin/index.ts index 52028bc46..5b9529bb9 100644 --- a/typescript/src/lib/bitcoin/index.ts +++ b/typescript/src/lib/bitcoin/index.ts @@ -5,5 +5,6 @@ export * from "./ecdsa-key" export * from "./hash" export * from "./header" export * from "./network" +export * from "./script" export * from "./spv" export * from "./tx" diff --git a/typescript/src/lib/bitcoin/network.ts b/typescript/src/lib/bitcoin/network.ts index bdb810e44..c40afb3bf 100644 --- a/typescript/src/lib/bitcoin/network.ts +++ b/typescript/src/lib/bitcoin/network.ts @@ -1,4 +1,5 @@ import { Hex } from "../utils" +import { networks } from "bitcoinjs-lib" /** * Bitcoin networks. @@ -64,3 +65,26 @@ export function toBcoinNetwork(bitcoinNetwork: BitcoinNetwork): string { } } } + +/** + * Converts the provided {@link BitcoinNetwork} enumeration to a format expected + * by the `bitcoinjs-lib` library. + * @param bitcoinNetwork - Specified Bitcoin network. + * @returns Network representation compatible with the `bitcoinjs-lib` library. + * @throws An error if the network is not supported by `bitcoinjs-lib`. + */ +export function toBitcoinJsLibNetwork( + bitcoinNetwork: BitcoinNetwork +): networks.Network { + switch (bitcoinNetwork) { + case BitcoinNetwork.Mainnet: { + return networks.bitcoin + } + case BitcoinNetwork.Testnet: { + return networks.testnet + } + default: { + throw new Error(`network not supported`) + } + } +} diff --git a/typescript/src/lib/bitcoin/script.ts b/typescript/src/lib/bitcoin/script.ts new file mode 100644 index 000000000..a66c39305 --- /dev/null +++ b/typescript/src/lib/bitcoin/script.ts @@ -0,0 +1,67 @@ +import { payments } from "bitcoinjs-lib" + +/** + * Checks if the provided script comes from a P2PKH input. + * @param script The script to be checked. + * @returns True if the script is P2PKH, false otherwise. + */ +function isP2PKHScript(script: Buffer): boolean { + try { + payments.p2pkh({ output: script }) + return true + } catch (err) { + return false + } +} + +/** + * Checks if the provided script comes from a P2WPKH input. + * @param script The script to be checked. + * @returns True if the script is P2WPKH, false otherwise. + */ +function isP2WPKHScript(script: Buffer): boolean { + try { + payments.p2wpkh({ output: script }) + return true + } catch (err) { + return false + } +} + +/** + * Checks if the provided script comes from a P2SH input. + * @param script The script to be checked. + * @returns True if the script is P2SH, false otherwise. + */ +function isP2SHScript(script: Buffer): boolean { + try { + payments.p2sh({ output: script }) + return true + } catch (err) { + return false + } +} + +/** + * Checks if the provided script comes from a P2PKH input. + * @param script The script to be checked. + * @returns True if the script is P2WSH, false otherwise. + */ +function isP2WSHScript(script: Buffer): boolean { + try { + payments.p2wsh({ output: script }) + return true + } catch (err) { + return false + } +} + +/** + * Utility functions allowing to deal with Bitcoin scripts. + */ +export const BitcoinScriptUtils = { + isP2PKHScript, + isP2WPKHScript, + isP2SHScript, + isP2WSHScript, +} diff --git a/typescript/src/services/deposits/deposit.ts b/typescript/src/services/deposits/deposit.ts index 4ce3099a3..19e36e9e0 100644 --- a/typescript/src/services/deposits/deposit.ts +++ b/typescript/src/services/deposits/deposit.ts @@ -12,8 +12,7 @@ import { extractBitcoinRawTxVectors, toBcoinNetwork, } from "../../lib/bitcoin" - -const { opcodes } = bcoin.script.common +import { Stack, script, opcodes } from "bitcoinjs-lib" /** * Component representing an instance of the tBTC v2 deposit process. @@ -193,33 +192,31 @@ export class DepositScript { * @returns Plain-text deposit script as an un-prefixed hex string. */ async getPlainText(): Promise { - // All HEXes pushed to the script must be un-prefixed. - const script = new bcoin.Script() - script.clear() - script.pushData(Buffer.from(this.receipt.depositor.identifierHex, "hex")) - script.pushOp(opcodes.OP_DROP) - script.pushData(Buffer.from(this.receipt.blindingFactor, "hex")) - script.pushOp(opcodes.OP_DROP) - script.pushOp(opcodes.OP_DUP) - script.pushOp(opcodes.OP_HASH160) - script.pushData(Buffer.from(this.receipt.walletPublicKeyHash, "hex")) - script.pushOp(opcodes.OP_EQUAL) - script.pushOp(opcodes.OP_IF) - script.pushOp(opcodes.OP_CHECKSIG) - script.pushOp(opcodes.OP_ELSE) - script.pushOp(opcodes.OP_DUP) - script.pushOp(opcodes.OP_HASH160) - script.pushData(Buffer.from(this.receipt.refundPublicKeyHash, "hex")) - script.pushOp(opcodes.OP_EQUALVERIFY) - script.pushData(Buffer.from(this.receipt.refundLocktime, "hex")) - script.pushOp(opcodes.OP_CHECKLOCKTIMEVERIFY) - script.pushOp(opcodes.OP_DROP) - script.pushOp(opcodes.OP_CHECKSIG) - script.pushOp(opcodes.OP_ENDIF) - script.compile() - - // Return script as HEX string. - return script.toRaw().toString("hex") + const chunks: Stack = [] + + // All HEXes pushed to the script must be un-prefixed + chunks.push(Buffer.from(this.receipt.depositor.identifierHex, "hex")) + chunks.push(opcodes.OP_DROP) + chunks.push(Buffer.from(this.receipt.blindingFactor, "hex")) + chunks.push(opcodes.OP_DROP) + chunks.push(opcodes.OP_DUP) + chunks.push(opcodes.OP_HASH160) + chunks.push(Buffer.from(this.receipt.walletPublicKeyHash, "hex")) + chunks.push(opcodes.OP_EQUAL) + chunks.push(opcodes.OP_IF) + chunks.push(opcodes.OP_CHECKSIG) + chunks.push(opcodes.OP_ELSE) + chunks.push(opcodes.OP_DUP) + chunks.push(opcodes.OP_HASH160) + chunks.push(Buffer.from(this.receipt.refundPublicKeyHash, "hex")) + chunks.push(opcodes.OP_EQUALVERIFY) + chunks.push(Buffer.from(this.receipt.refundLocktime, "hex")) + chunks.push(opcodes.OP_CHECKLOCKTIMEVERIFY) + chunks.push(opcodes.OP_DROP) + chunks.push(opcodes.OP_CHECKSIG) + chunks.push(opcodes.OP_ENDIF) + + return script.compile(chunks).toString("hex") } /** diff --git a/typescript/src/services/maintenance/wallet-tx.ts b/typescript/src/services/maintenance/wallet-tx.ts index 970f50574..4c017bebb 100644 --- a/typescript/src/services/maintenance/wallet-tx.ts +++ b/typescript/src/services/maintenance/wallet-tx.ts @@ -1,11 +1,15 @@ import { + BitcoinAddressConverter, BitcoinClient, BitcoinHashUtils, + BitcoinNetwork, BitcoinPrivateKeyUtils, BitcoinPublicKeyUtils, BitcoinRawTx, + BitcoinScriptUtils, BitcoinTxHash, BitcoinUtxo, + toBitcoinJsLibNetwork, } from "../../lib/bitcoin" import { BigNumber } from "ethers" import { @@ -15,6 +19,17 @@ import { } from "../../lib/contracts" import bcoin from "bcoin" import { DepositScript } from "../deposits" +import { ECPairFactory } from "ecpair" +import * as tinysecp from "tiny-secp256k1" +import { Hex } from "../../lib/utils" +import { + payments, + script, + Signer, + Stack, + Transaction, + TxOutput, +} from "bitcoinjs-lib" /** * Wallet transactions builder. This feature set is supposed to be used only @@ -111,8 +126,11 @@ class DepositSweep { } } + const bitcoinNetwork = await this.bitcoinClient.getNetwork() + const { transactionHash, newMainUtxo, rawTransaction } = await this.assembleTransaction( + bitcoinNetwork, fee, walletPrivateKey, utxosWithRaw, @@ -132,7 +150,8 @@ class DepositSweep { * Assembles a Bitcoin P2WPKH deposit sweep transaction. * @dev The caller is responsible for ensuring the provided UTXOs are correctly * formed, can be spent by the wallet and their combined value is greater - * then the fee. + * than the fee. + * @param bitcoinNetwork - The target Bitcoin network. * @param fee - the value that should be subtracted from the sum of the UTXOs * values and used as the transaction fee. * @param walletPrivateKey - Bitcoin private key of the wallet in WIF format. @@ -145,8 +164,11 @@ class DepositSweep { * - the sweep transaction hash, * - the new wallet's main UTXO produced by this transaction. * - the sweep transaction in the raw format + * @throws Error if the provided UTXOs and deposits mismatch or if an unsupported + * UTXO script type is encountered. */ async assembleTransaction( + bitcoinNetwork: BitcoinNetwork, fee: BigNumber, walletPrivateKey: string, utxos: (BitcoinUtxo & BitcoinRawTx)[], @@ -167,252 +189,289 @@ class DepositSweep { ) } - const walletKeyRing = BitcoinPrivateKeyUtils.createKeyRing( + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + // eslint-disable-next-line new-cap + const walletKeyPair = ECPairFactory(tinysecp).fromWIF( walletPrivateKey, + network + ) + const walletAddress = BitcoinAddressConverter.publicKeyToAddress( + Hex.from(walletKeyPair.publicKey), + bitcoinNetwork, this.witness ) - const walletAddress = walletKeyRing.getAddress("string") - const inputCoins = [] - let totalInputValue = BigNumber.from(0) + const transaction = new Transaction() + let outputValue = BigNumber.from(0) if (mainUtxo) { - inputCoins.push( - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), - mainUtxo.outputIndex, - -1 - ) + transaction.addInput( + mainUtxo.transactionHash.reverse().toBuffer(), + mainUtxo.outputIndex ) - totalInputValue = totalInputValue.add(mainUtxo.value) + outputValue = outputValue.add(mainUtxo.value) } - for (const utxo of utxos) { - inputCoins.push( - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), - utxo.outputIndex, - -1 - ) + transaction.addInput( + utxo.transactionHash.reverse().toBuffer(), + utxo.outputIndex ) - totalInputValue = totalInputValue.add(utxo.value) + outputValue = outputValue.add(utxo.value) } + outputValue = outputValue.sub(fee) - const transaction = new bcoin.MTX() + const outputScript = + BitcoinAddressConverter.addressToOutputScript(walletAddress) - transaction.addOutput({ - script: bcoin.Script.fromAddress(walletAddress), - value: totalInputValue.toNumber(), - }) + transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) - await transaction.fund(inputCoins, { - changeAddress: walletAddress, - hardFee: fee.toNumber(), - subtractFee: true, - }) + // Sign the main UTXO input if there is main UTXO. + if (mainUtxo) { + const inputIndex = 0 // Main UTXO is the first input. + const previousOutput = Transaction.fromHex(mainUtxo.transactionHex).outs[ + mainUtxo.outputIndex + ] - if (transaction.outputs.length != 1) { - throw new Error("Deposit sweep transaction must have only one output") + await this.signMainUtxoInput( + transaction, + inputIndex, + previousOutput, + walletKeyPair + ) } - // UTXOs must be mapped to deposits, as `fund` may arrange inputs in any - // order - const utxosWithDeposits: (BitcoinUtxo & BitcoinRawTx & DepositReceipt)[] = - utxos.map((utxo, index) => ({ - ...utxo, - ...deposits[index], - })) - - for (let i = 0; i < transaction.inputs.length; i++) { - const previousOutpoint = transaction.inputs[i].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - const previousScript = previousOutput.script - - // P2(W)PKH (main UTXO) - if ( - previousScript.isPubkeyhash() || - previousScript.isWitnessPubkeyhash() - ) { - await this.signMainUtxoInput(transaction, i, walletKeyRing) - continue - } + // Sign the deposit inputs. + for (let depositIndex = 0; depositIndex < deposits.length; depositIndex++) { + // If there is a main UTXO index, we must adjust input index as the first + // input is the main UTXO input. + const inputIndex = mainUtxo ? depositIndex + 1 : depositIndex - const utxoWithDeposit = utxosWithDeposits.find( - (u) => - u.transactionHash.toString() === previousOutpoint.txid() && - u.outputIndex == previousOutpoint.index - ) - if (!utxoWithDeposit) { - throw new Error("Unknown input") - } + const utxo = utxos[depositIndex] + const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ + utxo.outputIndex + ] + const previousOutputValue = previousOutput.value + const previousOutputScript = previousOutput.script - if (previousScript.isScripthash()) { + const deposit = deposits[depositIndex] + + if (BitcoinScriptUtils.isP2SHScript(previousOutputScript)) { // P2SH (deposit UTXO) await this.signP2SHDepositInput( transaction, - i, - utxoWithDeposit, - walletKeyRing + inputIndex, + deposit, + previousOutputValue, + walletKeyPair ) - } else if (previousScript.isWitnessScripthash()) { + } else if (BitcoinScriptUtils.isP2WSHScript(previousOutputScript)) { // P2WSH (deposit UTXO) await this.signP2WSHDepositInput( transaction, - i, - utxoWithDeposit, - walletKeyRing + inputIndex, + deposit, + previousOutputValue, + walletKeyPair ) } else { throw new Error("Unsupported UTXO script type") } } - const transactionHash = BitcoinTxHash.from(transaction.txid()) + const transactionHash = BitcoinTxHash.from(transaction.getId()) return { transactionHash, newMainUtxo: { transactionHash, outputIndex: 0, // There is only one output. - value: BigNumber.from(transaction.outputs[0].value), + value: BigNumber.from(transaction.outs[0].value), }, rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), + transactionHex: transaction.toHex(), }, } } /** - * Creates script for the transaction input at the given index and signs the - * input. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Empty promise. + * Signs the main UTXO transaction input and sets the appropriate script or + * witness data. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param previousOutput - The previous output for the main UTXO input. + * @param walletKeyPair - A Signer object with the wallet's public and private + * key pair. + * @returns An empty promise upon successful signing. + * @throws Error if the UTXO doesn't belong to the wallet, or if the script + * format is invalid or unknown. */ private async signMainUtxoInput( - transaction: any, + transaction: Transaction, inputIndex: number, - walletKeyRing: any + previousOutput: TxOutput, + walletKeyPair: Signer ) { - const previousOutpoint = transaction.inputs[inputIndex].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - if (!walletKeyRing.ownOutput(previousOutput)) { + if ( + !this.canSpendOutput( + Hex.from(walletKeyPair.publicKey), + previousOutput.script + ) + ) { throw new Error("UTXO does not belong to the wallet") } - // Build script and set it as input's witness - transaction.scriptInput(inputIndex, previousOutput, walletKeyRing) - // Build signature and add it in front of script in input's witness - transaction.signInput(inputIndex, previousOutput, walletKeyRing) + + const sigHashType = Transaction.SIGHASH_ALL + + if (BitcoinScriptUtils.isP2PKHScript(previousOutput.script)) { + // P2PKH + const sigHash = transaction.hashForSignature( + inputIndex, + previousOutput.script, + sigHashType + ) + + const signature = script.signature.encode( + walletKeyPair.sign(sigHash), + sigHashType + ) + + const scriptSig = payments.p2pkh({ + signature: signature, + pubkey: walletKeyPair.publicKey, + }).input! + + transaction.ins[inputIndex].script = scriptSig + } else if (BitcoinScriptUtils.isP2WPKHScript(previousOutput.script)) { + // P2WPKH + const publicKeyHash = payments.p2wpkh({ output: previousOutput.script }) + .hash! + const p2pkhScript = payments.p2pkh({ hash: publicKeyHash }).output! + + const sigHash = transaction.hashForWitnessV0( + inputIndex, + p2pkhScript, + previousOutput.value, + sigHashType + ) + + const signature = script.signature.encode( + walletKeyPair.sign(sigHash), + sigHashType + ) + + transaction.ins[inputIndex].witness = [signature, walletKeyPair.publicKey] + } else { + throw new Error("Unknown type of main UTXO") + } } /** - * Creates and sets `scriptSig` for the transaction input at the given index by - * combining signature, wallet public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Empty promise. + * Signs a P2SH deposit transaction input and sets the `scriptSig`. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param deposit - Details of the deposit transaction. + * @param previousOutputValue - The value from the previous transaction output. + * @param walletKeyPair - A Signer object with the wallet's public and private + * key pair. + * @returns An empty promise upon successful signing. */ private async signP2SHDepositInput( - transaction: any, + transaction: Transaction, inputIndex: number, deposit: DepositReceipt, - walletKeyRing: any + previousOutputValue: number, + walletKeyPair: Signer ): Promise { - const { walletPublicKey, depositScript, previousOutputValue } = - await this.prepareInputSignData( - transaction, - inputIndex, - deposit, - walletKeyRing - ) + const depositScript = await this.prepareDepositScript( + deposit, + previousOutputValue, + walletKeyPair + ) + + const sigHashType = Transaction.SIGHASH_ALL - const signature: Buffer = transaction.signature( + const sigHash = transaction.hashForSignature( inputIndex, depositScript, - previousOutputValue, - walletKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 0 // legacy sighash version + sigHashType ) - const scriptSig = new bcoin.Script() - scriptSig.clear() - scriptSig.pushData(signature) - scriptSig.pushData(Buffer.from(walletPublicKey, "hex")) - scriptSig.pushData(depositScript.toRaw()) - scriptSig.compile() - - transaction.inputs[inputIndex].script = scriptSig + + const signature = script.signature.encode( + walletKeyPair.sign(sigHash), + sigHashType + ) + + const scriptSig: Stack = [] + scriptSig.push(signature) + scriptSig.push(walletKeyPair.publicKey) + scriptSig.push(depositScript) + + transaction.ins[inputIndex].script = script.compile(scriptSig) } /** - * Creates and sets witness script for the transaction input at the given index - * by combining signature, wallet public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param deposit - Data of the deposit. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Empty promise. + * Signs a P2WSH deposit transaction input and sets the witness script. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param deposit - Details of the deposit transaction. + * @param previousOutputValue - The value from the previous transaction output. + * @param walletKeyPair - A Signer object with the wallet's public and private + * key pair. + * @returns An empty promise upon successful signing. */ private async signP2WSHDepositInput( - transaction: any, + transaction: Transaction, inputIndex: number, deposit: DepositReceipt, - walletKeyRing: any + previousOutputValue: number, + walletKeyPair: Signer ): Promise { - const { walletPublicKey, depositScript, previousOutputValue } = - await this.prepareInputSignData( - transaction, - inputIndex, - deposit, - walletKeyRing - ) + const depositScript = await this.prepareDepositScript( + deposit, + previousOutputValue, + walletKeyPair + ) + + const sigHashType = Transaction.SIGHASH_ALL - const signature: Buffer = transaction.signature( + const sigHash = transaction.hashForWitnessV0( inputIndex, depositScript, previousOutputValue, - walletKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 1 // segwit sighash version + sigHashType ) - const witness = new bcoin.Witness() - witness.clear() - witness.pushData(signature) - witness.pushData(Buffer.from(walletPublicKey, "hex")) - witness.pushData(depositScript.toRaw()) - witness.compile() + const signature = script.signature.encode( + walletKeyPair.sign(sigHash), + sigHashType + ) + + const witness: Buffer[] = [] + witness.push(signature) + witness.push(walletKeyPair.publicKey) + witness.push(depositScript) - transaction.inputs[inputIndex].witness = witness + transaction.ins[inputIndex].witness = witness } /** - * Creates data needed to sign a deposit input. - * @param transaction - Mutable transaction containing the input. - * @param inputIndex - Index that points to the input. - * @param deposit - Data of the deposit. - * @param walletKeyRing - Key ring created using the wallet's private key. - * @returns Data needed to sign the input. + * Assembles the deposit script based on the given deposit details. Performs + * validations on values and key formats. + * @param deposit - The deposit details. + * @param previousOutputValue - Value from the previous transaction output. + * @param walletKeyPair - Signer object containing the wallet's key pair. + * @returns A Promise resolving to the assembled deposit script as a Buffer. + * @throws Error if there are discrepancies in values or key formats. */ - private async prepareInputSignData( - transaction: any, - inputIndex: number, + private async prepareDepositScript( deposit: DepositReceipt, - walletKeyRing: any - ): Promise<{ - walletPublicKey: string - depositScript: any - previousOutputValue: number - }> { - const previousOutpoint = transaction.inputs[inputIndex].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) + previousOutputValue: number, + walletKeyPair: Signer + ): Promise { + const walletPublicKey = walletKeyPair.publicKey.toString("hex") - const walletPublicKey = walletKeyRing.getPublicKey("hex") if ( - BitcoinHashUtils.computeHash160(walletKeyRing.getPublicKey("hex")) != + BitcoinHashUtils.computeHash160(walletPublicKey) != deposit.walletPublicKeyHash ) { throw new Error( @@ -424,18 +483,27 @@ class DepositSweep { throw new Error("Wallet public key must be compressed") } - const depositScript = bcoin.Script.fromRaw( - Buffer.from( - await DepositScript.fromReceipt(deposit).getPlainText(), - "hex" - ) + return Buffer.from( + await DepositScript.fromReceipt(deposit).getPlainText(), + "hex" ) + } - return { - walletPublicKey, - depositScript: depositScript, - previousOutputValue: previousOutput.value, - } + /** + * Determines if a UTXO's output script can be spent using the provided public + * key. + * @param publicKey - Public key used to derive the corresponding P2PKH and + * P2WPKH output scripts. + * @param outputScript - The output script of the UTXO in question. + * @returns True if the provided output script matches the P2PKH or P2WPKH + * output scripts derived from the given public key. False otherwise. + */ + private canSpendOutput(publicKey: Hex, outputScript: Buffer): boolean { + const pubkeyBuffer = publicKey.toBuffer() + const p2pkhOutput = payments.p2pkh({ pubkey: pubkeyBuffer }).output! + const p2wpkhOutput = payments.p2wpkh({ pubkey: pubkeyBuffer }).output! + + return outputScript.equals(p2pkhOutput) || outputScript.equals(p2wpkhOutput) } } diff --git a/typescript/test/bitcoin-network.test.ts b/typescript/test/bitcoin-network.test.ts index db4555b74..32102f996 100644 --- a/typescript/test/bitcoin-network.test.ts +++ b/typescript/test/bitcoin-network.test.ts @@ -1,5 +1,11 @@ import { expect } from "chai" -import { BitcoinTxHash, BitcoinNetwork, toBcoinNetwork } from "../src" +import { + BitcoinTxHash, + BitcoinNetwork, + toBcoinNetwork, + toBitcoinJsLibNetwork, +} from "../src" +import { networks } from "bitcoinjs-lib" describe("BitcoinNetwork", () => { const testData = [ @@ -9,6 +15,7 @@ describe("BitcoinNetwork", () => { // any value that doesn't match other supported networks genesisHash: BitcoinTxHash.from("0x00010203"), expectedToBcoinResult: new Error("network not supported"), + expectedToBitcoinJsLibResult: new Error("network not supported"), }, { enumKey: BitcoinNetwork.Testnet, @@ -17,6 +24,7 @@ describe("BitcoinNetwork", () => { "0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" ), expectedToBcoinResult: "testnet", + expectedToBitcoinJsLibResult: networks.testnet, }, { enumKey: BitcoinNetwork.Mainnet, @@ -25,11 +33,18 @@ describe("BitcoinNetwork", () => { "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" ), expectedToBcoinResult: "main", + expectedToBitcoinJsLibResult: networks.bitcoin, }, ] testData.forEach( - ({ enumKey, enumValue, genesisHash, expectedToBcoinResult }) => { + ({ + enumKey, + enumValue, + genesisHash, + expectedToBcoinResult, + expectedToBitcoinJsLibResult, + }) => { context(enumKey, async () => { describe(`toString`, async () => { it(`should return correct value`, async () => { @@ -58,6 +73,22 @@ describe("BitcoinNetwork", () => { }) } }) + + describe(`toBitcoinJsLibNetwork`, async () => { + if (expectedToBitcoinJsLibResult instanceof Error) { + it(`should throw an error`, async () => { + expect(() => toBitcoinJsLibNetwork(enumKey)).to.throw( + expectedToBitcoinJsLibResult.message + ) + }) + } else { + it(`should return ${expectedToBitcoinJsLibResult}`, async () => { + expect(toBitcoinJsLibNetwork(enumKey)).to.be.equal( + expectedToBitcoinJsLibResult + ) + }) + } + }) }) } ) diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index 785875480..c695fbee4 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -10,9 +10,10 @@ import { BitcoinCompactSizeUint, BitcoinAddressConverter, Hex, + BitcoinScriptUtils, } from "../src" import { BigNumber } from "ethers" -import { btcAddresses } from "./data/bitcoin" +import { btcAddresses, btcAddressFromPublicKey } from "./data/bitcoin" describe("Bitcoin", () => { describe("BitcoinPublicKeyUtils", () => { @@ -113,12 +114,37 @@ describe("Bitcoin", () => { const P2PKHAddressTestnet = "mkpoZkRvtd3SDGWgUDuXK1aEXZfHRM2gKw" const { + publicKeyToAddress, publicKeyHashToAddress, addressToPublicKeyHash, addressToOutputScript, outputScriptToAddress, } = BitcoinAddressConverter + describe("publicKeyToAddress", () => { + Object.entries(btcAddressFromPublicKey).forEach( + ([bitcoinNetwork, addressData]) => { + context(`with ${bitcoinNetwork} addresses`, () => { + Object.entries(addressData).forEach( + ([addressType, { publicKey, address }]) => { + it(`should return correct ${addressType} address for ${bitcoinNetwork}`, () => { + const witness = addressType === "P2WPKH" + const result = publicKeyToAddress( + publicKey, + bitcoinNetwork === "mainnet" + ? BitcoinNetwork.Mainnet + : BitcoinNetwork.Testnet, + witness + ) + expect(result).to.eq(address) + }) + } + ) + }) + } + ) + }) + describe("publicKeyHashToAddress", () => { context("when network is mainnet", () => { context("when witness option is true", () => { @@ -612,4 +638,62 @@ describe("Bitcoin", () => { }) }) }) + + describe("BitcoinScriptUtils", () => { + const { isP2PKHScript, isP2WPKHScript, isP2SHScript, isP2WSHScript } = + BitcoinScriptUtils + + describe("isScript", () => { + const testData = [ + { + testFunction: isP2PKHScript, + validScript: Buffer.from( + "76a9148db50eb52063ea9d98b3eac91489a90f738986f688ac", + "hex" + ), + name: "P2PKH", + }, + { + testFunction: isP2WPKHScript, + validScript: Buffer.from( + "00148db50eb52063ea9d98b3eac91489a90f738986f6", + "hex" + ), + name: "P2WPKH", + }, + { + testFunction: isP2SHScript, + validScript: Buffer.from( + "a914a9a5f97d5d3c4687a52e90718168270005b369c487", + "hex" + ), + name: "P2SH", + }, + { + testFunction: isP2WSHScript, + validScript: Buffer.from( + "0020b1f83e226979dc9fe74e87f6d303dbb08a27a1c7ce91664033f34c7f2d214cd7", + "hex" + ), + name: "P2WSH", + }, + ] + + testData.forEach(({ testFunction, validScript, name }) => { + describe(`is${name}Script`, () => { + it(`should return true for a valid ${name} script`, () => { + expect(testFunction(validScript)).to.be.true + }) + + it("should return false for other scripts", () => { + testData.forEach((data) => { + if (data.name !== name) { + expect(testFunction(data.validScript)).to.be.false + } + }) + }) + }) + }) + }) + }) }) diff --git a/typescript/test/data/deposit-sweep.ts b/typescript/test/data/deposit-sweep.ts index 0c962b841..0ba6ffee6 100644 --- a/typescript/test/data/deposit-sweep.ts +++ b/typescript/test/data/deposit-sweep.ts @@ -374,24 +374,23 @@ export const depositSweepWithNonWitnessMainUtxoAndWitnessOutput: DepositSweepTes witness: true, expectedSweep: { transactionHash: BitcoinTxHash.from( - "7831d0dfde7e160f3b9bb66c433710f0d3110d73ea78b9db65e81c091a6718a0" + "1933781f01f27f086c3a31c4a53035ebc7c4688e1f4b316babefa8f6dab77dc2" ), transaction: { transactionHex: - "01000000000102173a201f597a2c8ccd7842303a6653bb87437fb08dae671731a0" + - "75403b32a2fd0000000000ffffffffe19612be756bf7e740b47bec0e24845089ac" + - "e48c78d473cb34949b3007c4a2c8000000006a47304402204382deb051f9f3e2b5" + - "39e4bac2d1a50faf8d66bc7a3a3f3d286dabd96d92b58b02207c74c6aaf48e25d0" + - "7e02bb4039606d77ecfd80c492c050ab2486af6027fc2d5a012103989d253b17a6" + - "a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581d9ffffffff010884" + - "0000000000001600148db50eb52063ea9d98b3eac91489a90f738986f603483045" + - "022100c52bc876cdee80a3061ace3ffbce5e860942d444cd38e00e5f63fd8e818d" + - "7e7c022040a7017bb8213991697705e7092c481526c788a4731d06e582dc1c57be" + - "d7243b012103989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc2" + - "9dcf8581d95c14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508f9f0c90d" + - "000395237576a9148db50eb52063ea9d98b3eac91489a90f738986f68763ac6776" + - "a914e257eccafbc07c381642ce6e7e55120fb077fbed880448f2b262b175ac6800" + - "00000000", + "01000000000102e19612be756bf7e740b47bec0e24845089ace48c78d473cb34949" + + "b3007c4a2c8000000006a473044022013787be70eda0620002fa55c92abfcd32257" + + "d64fa652dd32bac65d705162a95902203407fea1abc99a9273ead3179ce60f60a34" + + "33fb2e93f58569e4bee9f63c0d679012103989d253b17a6a0f41838b84ff0d20e88" + + "98f9d7b1a98f2564da4cc29dcf8581d9ffffffff173a201f597a2c8ccd7842303a6" + + "653bb87437fb08dae671731a075403b32a2fd0000000000ffffffff010884000000" + + "0000001600148db50eb52063ea9d98b3eac91489a90f738986f6000348304502210" + + "0804f0fa989d632cda99a24159e28b8d31d4033c2d5de47d8207ea2767273d10a02" + + "20278e82d0714867b31eb013762306e2b97c2c1cc74b8135bee78d565e72ee630e0" + + "12103989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f2564da4cc29dcf8581" + + "d95c14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508f9f0c90d000395237" + + "576a9148db50eb52063ea9d98b3eac91489a90f738986f68763ac6776a914e257ec" + + "cafbc07c381642ce6e7e55120fb077fbed880448f2b262b175ac6800000000", }, }, } diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index 403d56020..10aa2b640 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -1,5 +1,6 @@ import { BigNumber } from "ethers" import { + BitcoinNetwork, BitcoinRawTx, BitcoinTxHash, BitcoinUtxo, @@ -39,8 +40,6 @@ describe("Sweep", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { - bcoin.set("testnet") - tbtcContracts = new MockTBTCContracts() bitcoinClient = new MockBitcoinClient() }) @@ -430,6 +429,7 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, utxosWithRaw, @@ -570,6 +570,7 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, utxosWithRaw, @@ -726,6 +727,7 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, utxosWithRaw, @@ -753,25 +755,7 @@ describe("Sweep", () => { // Validate inputs. expect(txJSON.inputs.length).to.be.equal(2) - const p2wshInput = txJSON.inputs[0] - expect(p2wshInput.prevout.hash).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() - ) - expect(p2wshInput.prevout.index).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .deposits[0].utxo.outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wshInput.witness.length).to.be.greaterThan(0) - expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2wshInput.address).to.be.equal( - "tb1qk8urugnf08wfle6wslmdxq7mkz9z0gw8e6gkvspn7dx87tfpfntshdm7qr" - ) - - const p2pkhInput = txJSON.inputs[1] // main UTXO + const p2pkhInput = txJSON.inputs[0] // main UTXO expect(p2pkhInput.prevout.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() ) @@ -789,6 +773,24 @@ describe("Sweep", () => { "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" ) + const p2wshInput = txJSON.inputs[1] + expect(p2wshInput.prevout.hash).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() + ) + expect(p2wshInput.prevout.index).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .deposits[0].utxo.outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wshInput.witness.length).to.be.greaterThan(0) + expect(p2wshInput.script.length).to.be.equal(0) + // Input's address should be set to the address generated from deposit + // script hash + expect(p2wshInput.address).to.be.equal( + "tb1qk8urugnf08wfle6wslmdxq7mkz9z0gw8e6gkvspn7dx87tfpfntshdm7qr" + ) + // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -860,6 +862,7 @@ describe("Sweep", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, utxosWithRaw, @@ -948,6 +951,7 @@ describe("Sweep", () => { await expect( walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, [], @@ -985,6 +989,7 @@ describe("Sweep", () => { await expect( walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, utxosWithRaw, @@ -1025,6 +1030,7 @@ describe("Sweep", () => { await expect( walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, [utxoWithRaw], @@ -1050,6 +1056,7 @@ describe("Sweep", () => { await expect( walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, fee, anotherPrivateKey, [utxoWithRaw], @@ -1084,6 +1091,7 @@ describe("Sweep", () => { await expect( walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, fee, testnetWalletPrivateKey, [utxoWithRaw], @@ -1103,8 +1111,6 @@ describe("Sweep", () => { let maintenanceService: MaintenanceService beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() tbtcContracts = new MockTBTCContracts() From 6647d69fc42a897f0aaffc3cadf56c0ba4ead576 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 10 Oct 2023 11:00:23 +0200 Subject: [PATCH 183/205] Integrate `bitcoinjs-lib` changes around deposits Here we pull changes from https://github.com/keep-network/tbtc-v2/pull/702 --- typescript/src/lib/bitcoin/hash.ts | 13 ++ typescript/src/services/deposits/deposit.ts | 42 ++++-- typescript/src/services/deposits/funding.ts | 144 +++++++++++++++----- typescript/test/bitcoin.test.ts | 17 ++- typescript/test/deposit.test.ts | 38 ++++-- 5 files changed, 193 insertions(+), 61 deletions(-) diff --git a/typescript/src/lib/bitcoin/hash.ts b/typescript/src/lib/bitcoin/hash.ts index 31426edf9..018771f19 100644 --- a/typescript/src/lib/bitcoin/hash.ts +++ b/typescript/src/lib/bitcoin/hash.ts @@ -19,6 +19,7 @@ function computeHash160(text: string): string { * Computes the double SHA256 for the given text. * @param text - Text the double SHA256 is computed for. * @returns Hash as a 32-byte un-prefixed hex string. + * @dev Do not confuse it with computeSha256 which computes single SHA256. */ function computeHash256(text: Hex): Hex { const firstHash = utils.sha256(text.toPrefixedString()) @@ -36,6 +37,17 @@ function hashLEToBigNumber(hash: Hex): BigNumber { return BigNumber.from(hash.reverse().toPrefixedString()) } +/** + * Computes the single SHA256 for the given text. + * @param text - Text the single SHA256 is computed for. + * @returns Hash as a 32-byte un-prefixed hex string. + * @dev Do not confuse it with computeHash256 which computes double SHA256. + */ +function computeSha256(text: Hex): Hex { + const hash = utils.sha256(text.toPrefixedString()) + return Hex.from(hash) +} + /** * Utility functions allowing to deal with Bitcoin hashes. */ @@ -43,4 +55,5 @@ export const BitcoinHashUtils = { computeHash160, computeHash256, hashLEToBigNumber, + computeSha256, } diff --git a/typescript/src/services/deposits/deposit.ts b/typescript/src/services/deposits/deposit.ts index 19e36e9e0..ed93eff73 100644 --- a/typescript/src/services/deposits/deposit.ts +++ b/typescript/src/services/deposits/deposit.ts @@ -3,16 +3,17 @@ import { TBTCContracts, validateDepositReceipt, } from "../../lib/contracts" -import bcoin from "bcoin" import { BitcoinClient, + BitcoinHashUtils, BitcoinNetwork, BitcoinTxOutpoint, BitcoinUtxo, extractBitcoinRawTxVectors, - toBcoinNetwork, + toBitcoinJsLibNetwork, } from "../../lib/bitcoin" -import { Stack, script, opcodes } from "bitcoinjs-lib" +import { payments, Stack, script, opcodes } from "bitcoinjs-lib" +import { Hex } from "../../lib/utils" /** * Component representing an instance of the tBTC v2 deposit process. @@ -181,11 +182,11 @@ export class DepositScript { */ async getHash(): Promise { const script = await this.getPlainText() - // Parse the script from HEX string. - const parsedScript = bcoin.Script.fromRaw(Buffer.from(script, "hex")) // If witness script hash should be produced, SHA256 should be used. // Legacy script hash needs HASH160. - return this.witness ? parsedScript.sha256() : parsedScript.hash160() + return this.witness + ? BitcoinHashUtils.computeSha256(Hex.from(script)).toBuffer() + : Buffer.from(BitcoinHashUtils.computeHash160(script), "hex") } /** @@ -226,9 +227,30 @@ export class DepositScript { */ async deriveAddress(bitcoinNetwork: BitcoinNetwork): Promise { const scriptHash = await this.getHash() - const address = this.witness - ? bcoin.Address.fromWitnessScripthash(scriptHash) - : bcoin.Address.fromScripthash(scriptHash) - return address.toString(toBcoinNetwork(bitcoinNetwork)) + + const bitcoinJsLibNetwork = toBitcoinJsLibNetwork(bitcoinNetwork) + + if (this.witness) { + // OP_0 + const p2wshOutput = Buffer.concat([ + Buffer.from([opcodes.OP_0, 0x20]), + scriptHash, + ]) + + return payments.p2wsh({ + output: p2wshOutput, + network: bitcoinJsLibNetwork, + }).address! + } else { + // OP_HASH160 OP_EQUAL + const p2shOutput = Buffer.concat([ + Buffer.from([opcodes.OP_HASH160, 0x14]), + scriptHash, + Buffer.from([opcodes.OP_EQUAL]), + ]) + + return payments.p2sh({ output: p2shOutput, network: bitcoinJsLibNetwork }) + .address! + } } } diff --git a/typescript/src/services/deposits/funding.ts b/typescript/src/services/deposits/funding.ts index a13cc86f5..ff250d096 100644 --- a/typescript/src/services/deposits/funding.ts +++ b/typescript/src/services/deposits/funding.ts @@ -1,13 +1,19 @@ import { DepositScript } from "./deposit" import { + BitcoinAddressConverter, BitcoinClient, - BitcoinPrivateKeyUtils, + BitcoinNetwork, BitcoinRawTx, + BitcoinScriptUtils, BitcoinTxHash, BitcoinUtxo, + toBitcoinJsLibNetwork, } from "../../lib/bitcoin" import { BigNumber } from "ethers" -import bcoin from "bcoin" +import { Psbt, Transaction } from "bitcoinjs-lib" +import { ECPairFactory } from "ecpair" +import * as tinysecp from "tiny-secp256k1" +import { Hex } from "../../lib/utils" /** * Component allowing to craft and submit the Bitcoin funding transaction using @@ -37,56 +43,104 @@ export class DepositFunding { * can be unlocked using the depositor's private key. It is also * caller's responsibility to ensure the given deposit is funded exactly * once. + * @param bitcoinNetwork The target Bitcoin network. * @param amount Deposit amount in satoshis. - * @param inputUtxos UTXOs that should be used as transaction inputs. + * @param inputUtxos UTXOs to be used for funding the deposit transaction. + * So far only P2WPKH UTXO inputs are supported. + * @param fee Transaction fee to be subtracted from the sum of the UTXOs' values. * @param depositorPrivateKey Bitcoin private key of the depositor. Must * be able to unlock input UTXOs. * @returns The outcome consisting of: * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. * - the deposit transaction in the raw format + * @dev UTXOs are selected for transaction funding based on their types. UTXOs + * with unsupported types are skipped. The selection process stops once + * the sum of the chosen UTXOs meets the required funding amount. + * @throws {Error} When the sum of the selected UTXOs is insufficient to cover + * the deposit amount and transaction fee. */ async assembleTransaction( + bitcoinNetwork: BitcoinNetwork, amount: BigNumber, inputUtxos: (BitcoinUtxo & BitcoinRawTx)[], + fee: BigNumber, depositorPrivateKey: string ): Promise<{ transactionHash: BitcoinTxHash depositUtxo: BitcoinUtxo rawTransaction: BitcoinRawTx }> { - const depositorKeyRing = - BitcoinPrivateKeyUtils.createKeyRing(depositorPrivateKey) - const depositorAddress = depositorKeyRing.getAddress("string") - - const inputCoins = inputUtxos.map((utxo) => - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), - utxo.outputIndex, - -1 - ) + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + // eslint-disable-next-line new-cap + const depositorKeyPair = ECPairFactory(tinysecp).fromWIF( + depositorPrivateKey, + network ) - const transaction = new bcoin.MTX() + const psbt = new Psbt({ network }) + psbt.setVersion(1) + + const totalExpenses = amount.add(fee) + let totalInputValue = BigNumber.from(0) + + for (const utxo of inputUtxos) { + const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ + utxo.outputIndex + ] + const previousOutputValue = previousOutput.value + const previousOutputScript = previousOutput.script + + // TODO: Add support for other utxo types along with unit tests for the + // given type. + if (BitcoinScriptUtils.isP2WPKHScript(previousOutputScript)) { + psbt.addInput({ + hash: utxo.transactionHash.reverse().toBuffer(), + index: utxo.outputIndex, + witnessUtxo: { + script: previousOutputScript, + value: previousOutputValue, + }, + }) + + totalInputValue = totalInputValue.add(utxo.value) + if (totalInputValue.gte(totalExpenses)) { + break + } + } + // Skip UTXO if the type is unsupported. + } - const scriptHash = await this.script.getHash() + // Sum of the selected UTXOs must be equal to or greater than the deposit + // amount plus fee. + if (totalInputValue.lt(totalExpenses)) { + throw new Error("Not enough funds in selected UTXOs to fund transaction") + } - transaction.addOutput({ - script: this.script.witness - ? bcoin.Script.fromProgram(0, scriptHash) - : bcoin.Script.fromScripthash(scriptHash), + // Add deposit output. + psbt.addOutput({ + address: await this.script.deriveAddress(bitcoinNetwork), value: amount.toNumber(), }) - await transaction.fund(inputCoins, { - rate: null, // set null explicitly to always use the default value - changeAddress: depositorAddress, - subtractFee: false, // do not subtract the fee from outputs - }) + // Add change output if needed. + const changeValue = totalInputValue.sub(totalExpenses) + if (changeValue.gt(0)) { + const depositorAddress = BitcoinAddressConverter.publicKeyToAddress( + Hex.from(depositorKeyPair.publicKey), + bitcoinNetwork + ) + psbt.addOutput({ + address: depositorAddress, + value: changeValue.toNumber(), + }) + } - transaction.sign(depositorKeyRing) + psbt.signAllInputs(depositorKeyPair) + psbt.finalizeAllInputs() - const transactionHash = BitcoinTxHash.from(transaction.txid()) + const transaction = psbt.extractTransaction() + const transactionHash = BitcoinTxHash.from(transaction.getId()) return { transactionHash, @@ -96,7 +150,7 @@ export class DepositFunding { value: amount, }, rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), + transactionHex: transaction.toHex(), }, } } @@ -108,30 +162,35 @@ export class DepositFunding { * some UTXOs that can be used as input. It is also caller's responsibility * to ensure the given deposit is funded exactly once. * @param amount Deposit amount in satoshis. + * @param inputUtxos UTXOs to be used for funding the deposit transaction. So + * far only P2WPKH UTXO inputs are supported. + * @param fee The value that should be subtracted from the sum of the UTXOs + * values and used as the transaction fee. * @param depositorPrivateKey Bitcoin private key of the depositor. * @param bitcoinClient Bitcoin client used to interact with the network. * @returns The outcome consisting of: * - the deposit transaction hash, * - the deposit UTXO produced by this transaction. + * @dev UTXOs are selected for transaction funding based on their types. UTXOs + * with unsupported types are skipped. The selection process stops once + * the sum of the chosen UTXOs meets the required funding amount. + * Be aware that the function will attempt to broadcast the transaction, + * although successful broadcast is not guaranteed. + * @throws {Error} When the sum of the selected UTXOs is insufficient to cover + * the deposit amount and transaction fee. */ async submitTransaction( amount: BigNumber, + inputUtxos: BitcoinUtxo[], + fee: BigNumber, depositorPrivateKey: string, bitcoinClient: BitcoinClient ): Promise<{ transactionHash: BitcoinTxHash depositUtxo: BitcoinUtxo }> { - const depositorKeyRing = - BitcoinPrivateKeyUtils.createKeyRing(depositorPrivateKey) - const depositorAddress = depositorKeyRing.getAddress("string") - - const utxos = await bitcoinClient.findAllUnspentTransactionOutputs( - depositorAddress - ) - const utxosWithRaw: (BitcoinUtxo & BitcoinRawTx)[] = [] - for (const utxo of utxos) { + for (const utxo of inputUtxos) { const utxoRawTransaction = await bitcoinClient.getRawTransaction( utxo.transactionHash ) @@ -142,9 +201,20 @@ export class DepositFunding { }) } + const bitcoinNetwork = await bitcoinClient.getNetwork() + const { transactionHash, depositUtxo, rawTransaction } = - await this.assembleTransaction(amount, utxosWithRaw, depositorPrivateKey) + await this.assembleTransaction( + bitcoinNetwork, + amount, + utxosWithRaw, + fee, + depositorPrivateKey + ) + // Note that `broadcast` may fail silently (i.e. no error will be returned, + // even if the transaction is rejected by other nodes and does not enter the + // mempool, for example due to an UTXO being already spent). await bitcoinClient.broadcast(rawTransaction) return { diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index c695fbee4..c2d1bb007 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -65,7 +65,7 @@ describe("Bitcoin", () => { }) describe("BitcoinHashUtils", () => { - const { computeHash160, computeHash256, hashLEToBigNumber } = + const { computeHash160, computeHash256, hashLEToBigNumber, computeSha256 } = BitcoinHashUtils describe("computeHash160", () => { @@ -104,6 +104,21 @@ describe("Bitcoin", () => { expect(hashLEToBigNumber(hash)).to.equal(expectedBigNumber) }) }) + + describe("computeSha256", () => { + it("should compute hash256 correctly", () => { + const hexValue = Hex.from( + "03474444cca71c678f5019d16782b6522735717a94602085b4adf707b465c36ca8" + ) + const expectedSha256 = Hex.from( + "c62e5cb26c97cb52fea7f9965e9ea1f8d41c97773688aa88674e64629fc02901" + ) + + expect(computeSha256(hexValue).toString()).to.be.equal( + expectedSha256.toString() + ) + }) + }) }) describe("BitcoinAddressConverter", () => { diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index d534d37e7..ec135e568 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -9,16 +9,16 @@ import { } from "./data/deposit" import { BitcoinLocktimeUtils, + BitcoinNetwork, BitcoinRawTx, BitcoinTxHash, BitcoinUtxo, - extractBitcoinRawTxVectors, - DepositReceipt, - EthereumAddress, - BitcoinNetwork, + Deposit, DepositFunding, + DepositReceipt, DepositScript, - Deposit, + EthereumAddress, + extractBitcoinRawTxVectors, } from "../src" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import bcoin from "bcoin" @@ -209,16 +209,8 @@ describe("Deposit", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() - // Tie used testnetAddress with testnetUTXO to use it during deposit - // creation. - const utxos = new Map() - utxos.set(testnetAddress, [testnetUTXO]) - bitcoinClient.unspentTransactionOutputs = utxos - // Tie testnetTransaction to testnetUTXO. This is needed since // submitDepositTransaction attach transaction data to each UTXO. const rawTransactions = new Map() @@ -234,6 +226,8 @@ describe("Deposit", () => { let depositUtxo: BitcoinUtxo beforeEach(async () => { + const fee = BigNumber.from(1520) + const depositFunding = DepositFunding.fromScript( DepositScript.fromReceipt(deposit, true) ) @@ -241,6 +235,8 @@ describe("Deposit", () => { ;({ transactionHash, depositUtxo } = await depositFunding.submitTransaction( depositAmount, + [testnetUTXO], + fee, testnetPrivateKey, bitcoinClient )) @@ -275,6 +271,8 @@ describe("Deposit", () => { let depositUtxo: BitcoinUtxo beforeEach(async () => { + const fee = BigNumber.from(1410) + const depositFunding = DepositFunding.fromScript( DepositScript.fromReceipt(deposit, false) ) @@ -282,6 +280,8 @@ describe("Deposit", () => { ;({ transactionHash, depositUtxo } = await depositFunding.submitTransaction( depositAmount, + [testnetUTXO], + fee, testnetPrivateKey, bitcoinClient )) @@ -319,6 +319,8 @@ describe("Deposit", () => { let transaction: BitcoinRawTx beforeEach(async () => { + const fee = BigNumber.from(1520) + const depositFunding = DepositFunding.fromScript( DepositScript.fromReceipt(deposit, true) ) @@ -328,8 +330,10 @@ describe("Deposit", () => { depositUtxo, rawTransaction: transaction, } = await depositFunding.assembleTransaction( + BitcoinNetwork.Testnet, depositAmount, [testnetUTXO], + fee, testnetPrivateKey )) }) @@ -419,6 +423,8 @@ describe("Deposit", () => { let transaction: BitcoinRawTx beforeEach(async () => { + const fee = BigNumber.from(1410) + const depositFunding = DepositFunding.fromScript( DepositScript.fromReceipt(deposit, false) ) @@ -428,8 +434,10 @@ describe("Deposit", () => { depositUtxo, rawTransaction: transaction, } = await depositFunding.assembleTransaction( + BitcoinNetwork.Testnet, depositAmount, [testnetUTXO], + fee, testnetPrivateKey )) }) @@ -664,14 +672,18 @@ describe("Deposit", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { + const fee = BigNumber.from(1520) + const depositFunding = DepositFunding.fromScript( DepositScript.fromReceipt(deposit) ) // Create a deposit transaction. const result = await depositFunding.assembleTransaction( + BitcoinNetwork.Testnet, depositAmount, [testnetUTXO], + fee, testnetPrivateKey ) From 3dfad7aec1bb07d506c0413bd64b7daeb7710c61 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 10 Oct 2023 11:42:33 +0200 Subject: [PATCH 184/205] Integrate `bitcoinjs-lib` changes around redemptions Here we pull changes from https://github.com/keep-network/tbtc-v2/pull/703 --- typescript/src/lib/bitcoin/ecdsa-key.ts | 31 +++--- typescript/src/services/deposits/funding.ts | 9 +- typescript/src/services/deposits/refund.ts | 11 +- .../src/services/maintenance/wallet-tx.ts | 103 ++++++++++-------- typescript/test/redemption.test.ts | 14 ++- 5 files changed, 95 insertions(+), 73 deletions(-) diff --git a/typescript/src/lib/bitcoin/ecdsa-key.ts b/typescript/src/lib/bitcoin/ecdsa-key.ts index 16a6b1ec7..f7b845840 100644 --- a/typescript/src/lib/bitcoin/ecdsa-key.ts +++ b/typescript/src/lib/bitcoin/ecdsa-key.ts @@ -1,7 +1,8 @@ -import bcoin from "bcoin" -import wif from "wif" import { BigNumber } from "ethers" import { Hex } from "../utils" +import { ECPairFactory, ECPairInterface } from "ecpair" +import * as tinysecp from "tiny-secp256k1" +import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./network" /** * Checks whether given public key is a compressed Bitcoin public key. @@ -59,25 +60,25 @@ export const BitcoinPublicKeyUtils = { } /** - * Creates a Bitcoin key ring based on the given private key. - * @param privateKey Private key that should be used to create the key ring - * @param witness Flag indicating whether the key ring will create witness - * or non-witness addresses + * Creates a Bitcoin key pair based on the given private key. + * @param privateKey Private key that should be used to create the key pair. + * @param bitcoinNetwork Bitcoin network the given key pair is relevant for. * @returns Bitcoin key ring. */ -function createKeyRing(privateKey: string, witness: boolean = true): any { - const decodedPrivateKey = wif.decode(privateKey) - - return new bcoin.KeyRing({ - witness: witness, - privateKey: decodedPrivateKey.privateKey, - compressed: decodedPrivateKey.compressed, - }) +function createKeyPair( + privateKey: string, + bitcoinNetwork: BitcoinNetwork +): ECPairInterface { + // eslint-disable-next-line new-cap + return ECPairFactory(tinysecp).fromWIF( + privateKey, + toBitcoinJsLibNetwork(bitcoinNetwork) + ) } /** * Utility functions allowing to perform Bitcoin ECDSA public keys. */ export const BitcoinPrivateKeyUtils = { - createKeyRing, + createKeyPair, } diff --git a/typescript/src/services/deposits/funding.ts b/typescript/src/services/deposits/funding.ts index ff250d096..c520f5e83 100644 --- a/typescript/src/services/deposits/funding.ts +++ b/typescript/src/services/deposits/funding.ts @@ -3,6 +3,7 @@ import { BitcoinAddressConverter, BitcoinClient, BitcoinNetwork, + BitcoinPrivateKeyUtils, BitcoinRawTx, BitcoinScriptUtils, BitcoinTxHash, @@ -11,8 +12,6 @@ import { } from "../../lib/bitcoin" import { BigNumber } from "ethers" import { Psbt, Transaction } from "bitcoinjs-lib" -import { ECPairFactory } from "ecpair" -import * as tinysecp from "tiny-secp256k1" import { Hex } from "../../lib/utils" /** @@ -72,10 +71,10 @@ export class DepositFunding { rawTransaction: BitcoinRawTx }> { const network = toBitcoinJsLibNetwork(bitcoinNetwork) - // eslint-disable-next-line new-cap - const depositorKeyPair = ECPairFactory(tinysecp).fromWIF( + + const depositorKeyPair = BitcoinPrivateKeyUtils.createKeyPair( depositorPrivateKey, - network + bitcoinNetwork ) const psbt = new Psbt({ network }) diff --git a/typescript/src/services/deposits/refund.ts b/typescript/src/services/deposits/refund.ts index 4582c7f1c..6b896e0e9 100644 --- a/typescript/src/services/deposits/refund.ts +++ b/typescript/src/services/deposits/refund.ts @@ -1,7 +1,6 @@ import bcoin from "bcoin" import { BigNumber } from "ethers" import { - BitcoinPrivateKeyUtils, BitcoinRawTx, BitcoinClient, BitcoinTxHash, @@ -11,6 +10,7 @@ import { } from "../../lib/bitcoin" import { validateDepositReceipt } from "../../lib/contracts" import { DepositScript } from "./" +import wif from "wif" /** * Component allowing to craft and submit the Bitcoin refund transaction using @@ -106,8 +106,13 @@ export class DepositRefund { }> { validateDepositReceipt(this.script.receipt) - const refunderKeyRing = - BitcoinPrivateKeyUtils.createKeyRing(refunderPrivateKey) + const decodedPrivateKey = wif.decode(refunderPrivateKey) + + const refunderKeyRing = new bcoin.KeyRing({ + witness: true, + privateKey: decodedPrivateKey.privateKey, + compressed: decodedPrivateKey.compressed, + }) const transaction = new bcoin.MTX() diff --git a/typescript/src/services/maintenance/wallet-tx.ts b/typescript/src/services/maintenance/wallet-tx.ts index 4c017bebb..552929510 100644 --- a/typescript/src/services/maintenance/wallet-tx.ts +++ b/typescript/src/services/maintenance/wallet-tx.ts @@ -17,10 +17,7 @@ import { RedemptionRequest, TBTCContracts, } from "../../lib/contracts" -import bcoin from "bcoin" import { DepositScript } from "../deposits" -import { ECPairFactory } from "ecpair" -import * as tinysecp from "tiny-secp256k1" import { Hex } from "../../lib/utils" import { payments, @@ -29,6 +26,7 @@ import { Stack, Transaction, TxOutput, + Psbt, } from "bitcoinjs-lib" /** @@ -189,11 +187,9 @@ class DepositSweep { ) } - const network = toBitcoinJsLibNetwork(bitcoinNetwork) - // eslint-disable-next-line new-cap - const walletKeyPair = ECPairFactory(tinysecp).fromWIF( + const walletKeyPair = BitcoinPrivateKeyUtils.createKeyPair( walletPrivateKey, - network + bitcoinNetwork ) const walletAddress = BitcoinAddressConverter.publicKeyToAddress( Hex.from(walletKeyPair.publicKey), @@ -566,11 +562,14 @@ class Redemption { transactionHex: mainUtxoRawTransaction.transactionHex, } - const walletPublicKey = BitcoinPrivateKeyUtils.createKeyRing( - walletPrivateKey + const bitcoinNetwork = await this.bitcoinClient.getNetwork() + + const walletKeyPair = BitcoinPrivateKeyUtils.createKeyPair( + walletPrivateKey, + bitcoinNetwork ) - .getPublicKey() - .toString("hex") + + const walletPublicKey = walletKeyPair.publicKey.toString("hex") const redemptionRequests: RedemptionRequest[] = [] @@ -593,6 +592,7 @@ class Redemption { const { transactionHash, newMainUtxo, rawTransaction } = await this.assembleTransaction( + bitcoinNetwork, walletPrivateKey, mainUtxoWithRaw, redemptionRequests @@ -617,6 +617,7 @@ class Redemption { * - there is at least one redemption * - the `requestedAmount` in each redemption request is greater than * the sum of its `txFee` and `treasuryFee` + * @param bitcoinNetwork The target Bitcoin network. * @param walletPrivateKey - The private key of the wallet in the WIF format * @param mainUtxo - The main UTXO of the wallet. Must match the main UTXO held * by the on-chain Bridge contract @@ -627,6 +628,7 @@ class Redemption { * - the redemption transaction in the raw format */ async assembleTransaction( + bitcoinNetwork: BitcoinNetwork, walletPrivateKey: string, mainUtxo: BitcoinUtxo & BitcoinRawTx, redemptionRequests: RedemptionRequest[] @@ -639,22 +641,45 @@ class Redemption { throw new Error("There must be at least one request to redeem") } - const walletKeyRing = BitcoinPrivateKeyUtils.createKeyRing( + const walletKeyPair = BitcoinPrivateKeyUtils.createKeyPair( walletPrivateKey, + bitcoinNetwork + ) + const walletAddress = BitcoinAddressConverter.publicKeyToAddress( + Hex.from(walletKeyPair.publicKey), + bitcoinNetwork, this.witness ) - const walletAddress = walletKeyRing.getAddress("string") - - // Use the main UTXO as the single transaction input - const inputCoins = [ - bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(mainUtxo.transactionHex, "hex"), - mainUtxo.outputIndex, - -1 - ), - ] - const transaction = new bcoin.MTX() + const network = toBitcoinJsLibNetwork(bitcoinNetwork) + const psbt = new Psbt({ network }) + psbt.setVersion(1) + + // Add input (current main UTXO). + const previousOutput = Transaction.fromHex(mainUtxo.transactionHex).outs[ + mainUtxo.outputIndex + ] + const previousOutputScript = previousOutput.script + const previousOutputValue = previousOutput.value + + if (BitcoinScriptUtils.isP2PKHScript(previousOutputScript)) { + psbt.addInput({ + hash: mainUtxo.transactionHash.reverse().toBuffer(), + index: mainUtxo.outputIndex, + nonWitnessUtxo: Buffer.from(mainUtxo.transactionHex, "hex"), + }) + } else if (BitcoinScriptUtils.isP2WPKHScript(previousOutputScript)) { + psbt.addInput({ + hash: mainUtxo.transactionHash.reverse().toBuffer(), + index: mainUtxo.outputIndex, + witnessUtxo: { + script: previousOutputScript, + value: previousOutputValue, + }, + }) + } else { + throw new Error("Unexpected main UTXO type") + } let txTotalFee = BigNumber.from(0) let totalOutputsValue = BigNumber.from(0) @@ -673,44 +698,34 @@ class Redemption { // Add the fee for this particular request to the overall transaction fee txTotalFee = txTotalFee.add(request.txMaxFee) - transaction.addOutput({ - script: bcoin.Script.fromRaw( - Buffer.from(request.redeemerOutputScript, "hex") - ), + psbt.addOutput({ + script: Buffer.from(request.redeemerOutputScript, "hex"), value: outputValue.toNumber(), }) } - // If there is a change output, add it explicitly to the transaction. - // If we did not add this output explicitly, the bcoin library would add it - // anyway during funding, but if the value of the change output was very low, - // the library would consider it "dust" and add it to the fee rather than - // create a new output. + // If there is a change output, add it to the transaction. const changeOutputValue = mainUtxo.value .sub(totalOutputsValue) .sub(txTotalFee) if (changeOutputValue.gt(0)) { - transaction.addOutput({ - script: bcoin.Script.fromAddress(walletAddress), + psbt.addOutput({ + address: walletAddress, value: changeOutputValue.toNumber(), }) } - await transaction.fund(inputCoins, { - changeAddress: walletAddress, - hardFee: txTotalFee.toNumber(), - subtractFee: false, - }) - - transaction.sign(walletKeyRing) + psbt.signAllInputs(walletKeyPair) + psbt.finalizeAllInputs() - const transactionHash = BitcoinTxHash.from(transaction.txid()) + const transaction = psbt.extractTransaction() + const transactionHash = BitcoinTxHash.from(transaction.getId()) // If there is a change output, it will be the new wallet's main UTXO. const newMainUtxo = changeOutputValue.gt(0) ? { transactionHash, // It was the last output added to the transaction. - outputIndex: transaction.outputs.length - 1, + outputIndex: transaction.outs.length - 1, value: changeOutputValue, } : undefined @@ -719,7 +734,7 @@ class Redemption { transactionHash, newMainUtxo, rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), + transactionHex: transaction.toHex(), }, } } diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index 468360684..371662f2c 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -61,8 +61,6 @@ describe("Redemption", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { - bcoin.set("testnet") - tbtcContracts = new MockTBTCContracts() bitcoinClient = new MockBitcoinClient() @@ -818,8 +816,6 @@ describe("Redemption", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { - bcoin.set("testnet") - tbtcContracts = new MockTBTCContracts() bitcoinClient = new MockBitcoinClient() }) @@ -1272,6 +1268,7 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.redemption.assembleTransaction( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests @@ -1396,6 +1393,7 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.redemption.assembleTransaction( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests @@ -1519,6 +1517,7 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.redemption.assembleTransaction( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests @@ -1642,6 +1641,7 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.redemption.assembleTransaction( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests @@ -1764,6 +1764,7 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.redemption.assembleTransaction( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests @@ -1930,6 +1931,7 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.redemption.assembleTransaction( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests @@ -2045,6 +2047,7 @@ describe("Redemption", () => { newMainUtxo, rawTransaction: transaction, } = await walletTx.redemption.assembleTransaction( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, redemptionRequests @@ -2140,6 +2143,7 @@ describe("Redemption", () => { await expect( walletTx.redemption.assembleTransaction( + BitcoinNetwork.Testnet, walletPrivateKey, data.mainUtxo, [] // empty list of redemption requests @@ -2166,8 +2170,6 @@ describe("Redemption", () => { let maintenanceService: MaintenanceService beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() tbtcContracts = new MockTBTCContracts() From 162ce256b4478cb3aabe5baa3fcdab691a95b74c Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 10 Oct 2023 12:13:38 +0200 Subject: [PATCH 185/205] Integrate `bitcoinjs-lib` changes around deposit refund Here we pull changes from https://github.com/keep-network/tbtc-v2/pull/706 --- typescript/src/services/deposits/refund.ts | 231 ++++++++++----------- typescript/test/deposit-refund.test.ts | 3 - 2 files changed, 110 insertions(+), 124 deletions(-) diff --git a/typescript/src/services/deposits/refund.ts b/typescript/src/services/deposits/refund.ts index 6b896e0e9..5c4f0dcb4 100644 --- a/typescript/src/services/deposits/refund.ts +++ b/typescript/src/services/deposits/refund.ts @@ -1,16 +1,24 @@ -import bcoin from "bcoin" import { BigNumber } from "ethers" import { - BitcoinRawTx, + BitcoinAddressConverter, BitcoinClient, - BitcoinTxHash, - BitcoinUtxo, BitcoinHashUtils, + BitcoinNetwork, + BitcoinPrivateKeyUtils, BitcoinPublicKeyUtils, + BitcoinRawTx, + BitcoinScriptUtils, + BitcoinTxHash, + BitcoinUtxo, } from "../../lib/bitcoin" import { validateDepositReceipt } from "../../lib/contracts" import { DepositScript } from "./" -import wif from "wif" +import { + Signer, + Transaction, + script as btcjsscript, + Stack, +} from "bitcoinjs-lib" /** * Component allowing to craft and submit the Bitcoin refund transaction using @@ -67,7 +75,10 @@ export class DepositRefund { transactionHex: utxoRawTransaction.transactionHex, } + const bitcoinNetwork = await bitcoinClient.getNetwork() + const { transactionHash, rawTransaction } = await this.assembleTransaction( + bitcoinNetwork, fee, utxoWithRaw, refunderAddress, @@ -84,6 +95,7 @@ export class DepositRefund { /** * Assembles a Bitcoin P2(W)PKH deposit refund transaction. + * @param bitcoinNetwork - The target Bitcoin network. * @param fee - the value that will be subtracted from the deposit UTXO being * refunded and used as the transaction fee. * @param utxo - UTXO that was created during depositing that needs be refunded. @@ -96,6 +108,7 @@ export class DepositRefund { * - the refund transaction in the raw format. */ async assembleTransaction( + bitcoinNetwork: BitcoinNetwork, fee: BigNumber, utxo: BitcoinUtxo & BitcoinRawTx, refunderAddress: string, @@ -106,36 +119,23 @@ export class DepositRefund { }> { validateDepositReceipt(this.script.receipt) - const decodedPrivateKey = wif.decode(refunderPrivateKey) - - const refunderKeyRing = new bcoin.KeyRing({ - witness: true, - privateKey: decodedPrivateKey.privateKey, - compressed: decodedPrivateKey.compressed, - }) + const refunderKeyPair = BitcoinPrivateKeyUtils.createKeyPair( + refunderPrivateKey, + bitcoinNetwork + ) - const transaction = new bcoin.MTX() + const outputValue = utxo.value.sub(fee) - transaction.addOutput({ - script: bcoin.Script.fromAddress(refunderAddress), - value: utxo.value.toNumber(), - }) + const transaction = new Transaction() - const inputCoin = bcoin.Coin.fromTX( - bcoin.MTX.fromRaw(utxo.transactionHex, "hex"), - utxo.outputIndex, - -1 + transaction.addInput( + utxo.transactionHash.reverse().toBuffer(), + utxo.outputIndex ) - await transaction.fund([inputCoin], { - changeAddress: refunderAddress, - hardFee: fee.toNumber(), - subtractFee: true, - }) - - if (transaction.outputs.length != 1) { - throw new Error("Deposit refund transaction must have only one output") - } + const outputScript = + BitcoinAddressConverter.addressToOutputScript(refunderAddress) + transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) // In order to be able to spend the UTXO being refunded the transaction's // locktime must be set to a value equal to or higher than the refund locktime. @@ -144,65 +144,56 @@ export class DepositRefund { transaction.locktime = locktimeToUnixTimestamp( this.script.receipt.refundLocktime ) - transaction.inputs[0].sequence = 0xfffffffe + transaction.ins[0].sequence = 0xfffffffe // Sign the input - const previousOutpoint = transaction.inputs[0].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) - const previousScript = previousOutput.script - - if (previousScript.isScripthash()) { - // P2SH UTXO deposit input - await this.signP2SHDepositInput(transaction, 0, refunderKeyRing) - } else if (previousScript.isWitnessScripthash()) { - // P2WSH UTXO deposit input - await this.signP2WSHDepositInput(transaction, 0, refunderKeyRing) + const previousOutput = Transaction.fromHex(utxo.transactionHex).outs[ + utxo.outputIndex + ] + const previousOutputValue = previousOutput.value + const previousOutputScript = previousOutput.script + + if (BitcoinScriptUtils.isP2SHScript(previousOutputScript)) { + // P2SH deposit UTXO + await this.signP2SHDepositInput(transaction, 0, refunderKeyPair) + } else if (BitcoinScriptUtils.isP2WSHScript(previousOutputScript)) { + // P2WSH deposit UTXO + await this.signP2WSHDepositInput( + transaction, + 0, + previousOutputValue, + refunderKeyPair + ) } else { throw new Error("Unsupported UTXO script type") } - // Verify the transaction by executing its input scripts. - const tx = transaction.toTX() - if (!tx.verify(transaction.view)) { - throw new Error("Transaction verification failure") - } - - const transactionHash = BitcoinTxHash.from(transaction.txid()) + const transactionHash = BitcoinTxHash.from(transaction.getId()) return { transactionHash, rawTransaction: { - transactionHex: transaction.toRaw().toString("hex"), + transactionHex: transaction.toHex(), }, } } /** - * Creates data needed to sign a deposit input to be refunded. - * @param transaction - Mutable transaction containing the input to be refunded. - * @param inputIndex - Index that points to the input. - * @param refunderKeyRing - Key ring created using the refunder's private key. - * @returns Data needed to sign the input. + * Assembles the deposit script based on the given deposit details. Performs + * validations on values and key formats. + * @param refunderKeyPair - Signer object containing the refunder's key pair. + * @returns A Promise resolving to the assembled deposit script as a Buffer. + * @throws Error if there are discrepancies in values or key formats. */ - private async prepareInputSignData( - transaction: any, - inputIndex: number, - refunderKeyRing: any - ): Promise<{ - refunderPublicKey: string - depositScript: any - previousOutputValue: number - }> { - const previousOutpoint = transaction.inputs[inputIndex].prevout - const previousOutput = transaction.view.getOutput(previousOutpoint) + private async prepareDepositScript(refunderKeyPair: Signer): Promise { + const refunderPublicKey = refunderKeyPair.publicKey.toString("hex") - const refunderPublicKey = refunderKeyRing.getPublicKey("hex") if ( - BitcoinHashUtils.computeHash160(refunderKeyRing.getPublicKey("hex")) != + BitcoinHashUtils.computeHash160(refunderPublicKey) != this.script.receipt.refundPublicKeyHash ) { throw new Error( - "Refund public key does not correspond to the refunder private key" + "Refund public key does not correspond to wallet private key" ) } @@ -210,84 +201,82 @@ export class DepositRefund { throw new Error("Refunder public key must be compressed") } - const depositScript = bcoin.Script.fromRaw( - Buffer.from(await this.script.getPlainText(), "hex") - ) - - return { - refunderPublicKey: refunderPublicKey, - depositScript: depositScript, - previousOutputValue: previousOutput.value, - } + return Buffer.from(await this.script.getPlainText(), "hex") } /** - * Creates and sets `scriptSig` for the transaction input at the given index by - * combining signature, refunder's public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param refunderKeyRing - Key ring created using the refunder's private key. - * @returns Empty return. + * Signs a P2SH deposit transaction input and sets the `scriptSig`. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param refunderKeyPair - A Signer object with the refunder's public and private + * key pair. + * @returns An empty promise upon successful signing. */ private async signP2SHDepositInput( - transaction: any, + transaction: Transaction, inputIndex: number, - refunderKeyRing: any + refunderKeyPair: Signer ) { - const { refunderPublicKey, depositScript, previousOutputValue } = - await this.prepareInputSignData(transaction, inputIndex, refunderKeyRing) + const depositScript = await this.prepareDepositScript(refunderKeyPair) - const signature: Buffer = transaction.signature( + const sigHashType = Transaction.SIGHASH_ALL + + const sigHash = transaction.hashForSignature( inputIndex, depositScript, - previousOutputValue, - refunderKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 0 // legacy sighash version + sigHashType ) - const scriptSig = new bcoin.Script() - scriptSig.clear() - scriptSig.pushData(signature) - scriptSig.pushData(Buffer.from(refunderPublicKey, "hex")) - scriptSig.pushData(depositScript.toRaw()) - scriptSig.compile() - - transaction.inputs[inputIndex].script = scriptSig + + const signature = btcjsscript.signature.encode( + refunderKeyPair.sign(sigHash), + sigHashType + ) + + const scriptSig: Stack = [] + scriptSig.push(signature) + scriptSig.push(refunderKeyPair.publicKey) + scriptSig.push(depositScript) + + transaction.ins[inputIndex].script = btcjsscript.compile(scriptSig) } /** - * Creates and sets witness script for the transaction input at the given index - * by combining signature, refunder public key and deposit script. - * @param transaction - Mutable transaction containing the input to be signed. - * @param inputIndex - Index that points to the input to be signed. - * @param refunderKeyRing - Key ring created using the refunder's private key. - * @returns Empty return. + * Signs a P2WSH deposit transaction input and sets the witness script. + * @param transaction - The transaction containing the input to be signed. + * @param inputIndex - Index pointing to the input within the transaction. + * @param previousOutputValue - The value from the previous transaction output. + * @param refunderKeyPair - A Signer object with the refunder's public and private + * key pair. + * @returns An empty promise upon successful signing. */ private async signP2WSHDepositInput( - transaction: any, + transaction: Transaction, inputIndex: number, - refunderKeyRing: any + previousOutputValue: number, + refunderKeyPair: Signer ) { - const { refunderPublicKey, depositScript, previousOutputValue } = - await this.prepareInputSignData(transaction, inputIndex, refunderKeyRing) + const depositScript = await this.prepareDepositScript(refunderKeyPair) - const signature: Buffer = transaction.signature( + const sigHashType = Transaction.SIGHASH_ALL + + const sigHash = transaction.hashForWitnessV0( inputIndex, depositScript, previousOutputValue, - refunderKeyRing.privateKey, - bcoin.Script.hashType.ALL, - 1 // segwit sighash version + sigHashType + ) + + const signature = btcjsscript.signature.encode( + refunderKeyPair.sign(sigHash), + sigHashType ) - const witness = new bcoin.Witness() - witness.clear() - witness.pushData(signature) - witness.pushData(Buffer.from(refunderPublicKey, "hex")) - witness.pushData(depositScript.toRaw()) - witness.compile() + const witness: Buffer[] = [] + witness.push(signature) + witness.push(refunderKeyPair.publicKey) + witness.push(depositScript) - transaction.inputs[inputIndex].witness = witness + transaction.ins[inputIndex].witness = witness } } diff --git a/typescript/test/deposit-refund.test.ts b/typescript/test/deposit-refund.test.ts index 6825e6fa8..722d74566 100644 --- a/typescript/test/deposit-refund.test.ts +++ b/typescript/test/deposit-refund.test.ts @@ -1,6 +1,5 @@ import { BigNumber } from "ethers" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import bcoin from "bcoin" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) @@ -23,8 +22,6 @@ describe("Refund", () => { let bitcoinClient: MockBitcoinClient beforeEach(async () => { - bcoin.set("testnet") - bitcoinClient = new MockBitcoinClient() }) From 398788767dbe0ee2e5a22c2d0351cdd8729aa7d6 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 10 Oct 2023 13:44:17 +0200 Subject: [PATCH 186/205] Remove `bcoin` completely Here we pull changes from https://github.com/keep-network/tbtc-v2/pull/707 --- typescript/package.json | 7 +- typescript/src/lib/bitcoin/address.ts | 74 ++++--- typescript/src/lib/bitcoin/network.ts | 21 -- typescript/src/lib/bitcoin/tx.ts | 47 +++-- typescript/src/lib/electrum/client.ts | 47 +++-- .../src/services/deposits/deposits-service.ts | 5 +- typescript/src/services/deposits/refund.ts | 6 +- .../src/services/maintenance/wallet-tx.ts | 6 +- .../redemptions/redemptions-service.ts | 16 +- typescript/test/bitcoin-network.test.ts | 32 +-- typescript/test/bitcoin.test.ts | 164 +++++++++++---- typescript/test/data/redemption.ts | 19 +- typescript/test/deposit-sweep.test.ts | 111 ++++------ typescript/test/deposit.test.ts | 28 ++- typescript/test/redemption.test.ts | 99 ++++----- typescript/test/utils/helpers.ts | 6 +- typescript/yarn.lock | 195 +----------------- 17 files changed, 360 insertions(+), 523 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index fb929012a..a518d97fe 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -13,8 +13,7 @@ "test": "mocha --exit --recursive 'test/**/*.test.ts'", "typechain": "rm -rf ./typechain && for i in $npm_package_config_contracts; do typechain --target ethers-v5 --out-dir ./typechain $i; done && rm ./typechain/index.ts", "build": "npm run typechain && tsc --project tsconfig.build.json", - "dev": "tsc --project tsconfig.build.json --watch", - "postinstall": "npm rebuild bcrypto" + "dev": "tsc --project tsconfig.build.json --watch" }, "files": ["dist"], "config": { @@ -23,7 +22,6 @@ "dependencies": { "@keep-network/ecdsa": "development", "@keep-network/tbtc-v2": "development", - "bcoin": "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8", "bitcoinjs-lib": "6.0.2", "bufio": "^1.0.6", "ecpair": "^2.1.0", @@ -57,8 +55,5 @@ }, "engines": { "node": ">=14 <15" - }, - "browser": { - "bcoin": "bcoin/lib/bcoin-browser" } } diff --git a/typescript/src/lib/bitcoin/address.ts b/typescript/src/lib/bitcoin/address.ts index cc10aebda..3d5dd2594 100644 --- a/typescript/src/lib/bitcoin/address.ts +++ b/typescript/src/lib/bitcoin/address.ts @@ -1,11 +1,6 @@ -import bcoin, { Script } from "bcoin" +import { address as btcjsaddress, payments } from "bitcoinjs-lib" import { Hex } from "../utils" -import { - BitcoinNetwork, - toBcoinNetwork, - toBitcoinJsLibNetwork, -} from "./network" -import { payments } from "bitcoinjs-lib" +import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./network" /** * Creates the Bitcoin address from the public key. Supports SegWit (P2WPKH) and @@ -34,67 +29,84 @@ export function publicKeyToAddress( /** * Converts a public key hash into a P2PKH/P2WPKH address. - * @param publicKeyHash - public key hash that will be encoded. Must be an + * @param publicKeyHash Public key hash that will be encoded. Must be an * unprefixed hex string (without 0x prefix). - * @param witness - If true, a witness public key hash will be encoded and + * @param witness If true, a witness public key hash will be encoded and * P2WPKH address will be returned. Returns P2PKH address otherwise - * @param network - Network the address should be encoded for. + * @param bitcoinNetwork Network the address should be encoded for. * @returns P2PKH or P2WPKH address encoded from the given public key hash * @throws Throws an error if network is not supported. */ function publicKeyHashToAddress( publicKeyHash: string, witness: boolean, - network: BitcoinNetwork + bitcoinNetwork: BitcoinNetwork ): string { - const buffer = Buffer.from(publicKeyHash, "hex") - const bcoinNetwork = toBcoinNetwork(network) + const hash = Buffer.from(publicKeyHash, "hex") + const network = toBitcoinJsLibNetwork(bitcoinNetwork) return witness - ? bcoin.Address.fromWitnessPubkeyhash(buffer).toString(bcoinNetwork) - : bcoin.Address.fromPubkeyhash(buffer).toString(bcoinNetwork) + ? payments.p2wpkh({ hash, network }).address! + : payments.p2pkh({ hash, network }).address! } /** * Converts a P2PKH or P2WPKH address into a public key hash. Throws if the * provided address is not PKH-based. - * @param address - P2PKH or P2WPKH address that will be decoded. + * @param address P2PKH or P2WPKH address that will be decoded. + * @param bitcoinNetwork Network the address should be decoded for. * @returns Public key hash decoded from the address. This will be an unprefixed * hex string (without 0x prefix). */ -function addressToPublicKeyHash(address: string): string { - const addressObject = new bcoin.Address(address) +function addressToPublicKeyHash( + address: string, + bitcoinNetwork: BitcoinNetwork +): string { + const network = toBitcoinJsLibNetwork(bitcoinNetwork) - const isPKH = - addressObject.isPubkeyhash() || addressObject.isWitnessPubkeyhash() - if (!isPKH) { - throw new Error("Address must be P2PKH or P2WPKH") - } + try { + // Try extracting hash from P2PKH address. + const hash = payments.p2pkh({ address: address, network }).hash! + return hash.toString("hex") + } catch (err) {} + + try { + // Try extracting hash from P2WPKH address. + const hash = payments.p2wpkh({ address: address, network }).hash! + return hash.toString("hex") + } catch (err) {} - return addressObject.getHash("hex") + throw new Error("Address must be P2PKH or P2WPKH valid for given network") } /** * Converts an address to the respective output script. * @param address BTC address. + * @param bitcoinNetwork Bitcoin network corresponding to the address. * @returns The un-prefixed and not prepended with length output script. */ -function addressToOutputScript(address: string): Hex { - return Hex.from(Script.fromAddress(address).toRaw().toString("hex")) +function addressToOutputScript( + address: string, + bitcoinNetwork: BitcoinNetwork +): Hex { + return Hex.from( + btcjsaddress.toOutputScript(address, toBitcoinJsLibNetwork(bitcoinNetwork)) + ) } /** * Converts an output script to the respective network-specific address. * @param script The unprefixed and not prepended with length output script. - * @param network Bitcoin network. + * @param bitcoinNetwork Bitcoin network the address should be produced for. * @returns The Bitcoin address. */ function outputScriptToAddress( script: Hex, - network: BitcoinNetwork = BitcoinNetwork.Mainnet + bitcoinNetwork: BitcoinNetwork = BitcoinNetwork.Mainnet ): string { - return Script.fromRaw(script.toString(), "hex") - .getAddress() - ?.toString(toBcoinNetwork(network)) + return btcjsaddress.fromOutputScript( + script.toBuffer(), + toBitcoinJsLibNetwork(bitcoinNetwork) + ) } /** diff --git a/typescript/src/lib/bitcoin/network.ts b/typescript/src/lib/bitcoin/network.ts index c40afb3bf..bf2376674 100644 --- a/typescript/src/lib/bitcoin/network.ts +++ b/typescript/src/lib/bitcoin/network.ts @@ -45,27 +45,6 @@ export namespace BitcoinNetwork { } } -/** - * Converts enumerated {@link BitcoinNetwork} to a string expected by the - * {@link https://github.com/keep-network/bcoin/blob/aba6841e43546e8a485e96dc0019d1e788eab2ee/lib/protocol/networks.js#L33| `bcoin` library} - * @param bitcoinNetwork Bitcoin network. - * @returns String representing the given network in bcoin library. - * @throws An error if the network is not supported by bcoin. - */ -export function toBcoinNetwork(bitcoinNetwork: BitcoinNetwork): string { - switch (bitcoinNetwork) { - case BitcoinNetwork.Mainnet: { - return "main" - } - case BitcoinNetwork.Testnet: { - return "testnet" - } - default: { - throw new Error(`network not supported`) - } - } -} - /** * Converts the provided {@link BitcoinNetwork} enumeration to a format expected * by the `bitcoinjs-lib` library. diff --git a/typescript/src/lib/bitcoin/tx.ts b/typescript/src/lib/bitcoin/tx.ts index 6841f4225..f068500b1 100644 --- a/typescript/src/lib/bitcoin/tx.ts +++ b/typescript/src/lib/bitcoin/tx.ts @@ -1,4 +1,4 @@ -import { TX } from "bcoin" +import { Transaction as Tx } from "bitcoinjs-lib" import bufio from "bufio" import { BigNumber } from "ethers" import { Hex } from "../utils" @@ -133,46 +133,53 @@ export interface BitcoinRawTxVectors { export function extractBitcoinRawTxVectors( rawTransaction: BitcoinRawTx ): BitcoinRawTxVectors { - const toHex = (bufferWriter: any) => { + const toHex = (bufferWriter: any): string => { return bufferWriter.render().toString("hex") } - const vectorToRaw = (elements: any[]) => { + const getTxInputVector = (tx: Tx): string => { const buffer = bufio.write() - buffer.writeVarint(elements.length) - for (const element of elements) { - element.toWriter(buffer) - } + buffer.writeVarint(tx.ins.length) + tx.ins.forEach((input) => { + buffer.writeHash(input.hash) + buffer.writeU32(input.index) + buffer.writeVarBytes(input.script) + buffer.writeU32(input.sequence) + }) return toHex(buffer) } - const getTxInputVector = (tx: any) => { - return vectorToRaw(tx.inputs) - } - - const getTxOutputVector = (tx: any) => { - return vectorToRaw(tx.outputs) + const getTxOutputVector = (tx: Tx): string => { + const buffer = bufio.write() + buffer.writeVarint(tx.outs.length) + tx.outs.forEach((output) => { + buffer.writeI64(output.value) + buffer.writeVarBytes(output.script) + }) + return toHex(buffer) } - const getTxVersion = (tx: any) => { + const getTxVersion = (tx: Tx): string => { const buffer = bufio.write() buffer.writeU32(tx.version) return toHex(buffer) } - const getTxLocktime = (tx: any) => { + const getTxLocktime = (tx: Tx): string => { const buffer = bufio.write() buffer.writeU32(tx.locktime) return toHex(buffer) } - const tx = TX.fromRaw(Buffer.from(rawTransaction.transactionHex, "hex"), null) + const transaction = Tx.fromBuffer( + Buffer.from(rawTransaction.transactionHex, "hex") + ) return { - version: getTxVersion(tx), - inputs: getTxInputVector(tx), - outputs: getTxOutputVector(tx), - locktime: getTxLocktime(tx), + version: getTxVersion(transaction), + inputs: getTxInputVector(transaction), + outputs: getTxOutputVector(transaction), + locktime: getTxLocktime(transaction), } } diff --git a/typescript/src/lib/electrum/client.ts b/typescript/src/lib/electrum/client.ts index dd0b10aab..d4dbb57c8 100644 --- a/typescript/src/lib/electrum/client.ts +++ b/typescript/src/lib/electrum/client.ts @@ -1,4 +1,4 @@ -import bcoin from "bcoin" +import { Transaction as Tx, TxInput, TxOutput } from "bitcoinjs-lib" import pTimeout from "p-timeout" import { BitcoinClient, @@ -11,6 +11,7 @@ import { BitcoinTxMerkleBranch, BitcoinTxOutput, BitcoinUtxo, + BitcoinHashUtils, } from "../bitcoin" import Electrum from "electrum-client-js" import { BigNumber, utils } from "ethers" @@ -255,8 +256,12 @@ export class ElectrumClient implements BitcoinClient { */ findAllUnspentTransactionOutputs(address: string): Promise { return this.withElectrum(async (electrum: Electrum) => { - const script = - BitcoinAddressConverter.addressToOutputScript(address).toString() + const bitcoinNetwork = await this.getNetwork() + + const script = BitcoinAddressConverter.addressToOutputScript( + address, + bitcoinNetwork + ).toString() // eslint-disable-next-line camelcase type UnspentOutput = { tx_pos: number; value: number; tx_hash: string } @@ -282,8 +287,12 @@ export class ElectrumClient implements BitcoinClient { */ getTransactionHistory(address: string, limit?: number): Promise { return this.withElectrum(async (electrum: Electrum) => { - const script = - BitcoinAddressConverter.addressToOutputScript(address).toString() + const bitcoinNetwork = await this.getNetwork() + + const script = BitcoinAddressConverter.addressToOutputScript( + address, + bitcoinNetwork + ).toString() // eslint-disable-next-line camelcase type HistoryItem = { height: number; tx_hash: string } @@ -350,26 +359,26 @@ export class ElectrumClient implements BitcoinClient { } // Decode the raw transaction. - const transaction = bcoin.TX.fromRaw(rawTransaction, "hex") + const transaction = Tx.fromHex(rawTransaction) - const inputs = transaction.inputs.map( - (input: any): BitcoinTxInput => ({ - transactionHash: BitcoinTxHash.from(input.prevout.hash).reverse(), - outputIndex: input.prevout.index, - scriptSig: Hex.from(input.script.toRaw()), + const inputs = transaction.ins.map( + (input: TxInput): BitcoinTxInput => ({ + transactionHash: BitcoinTxHash.from(input.hash).reverse(), + outputIndex: input.index, + scriptSig: Hex.from(input.script), }) ) - const outputs = transaction.outputs.map( - (output: any, i: number): BitcoinTxOutput => ({ + const outputs = transaction.outs.map( + (output: TxOutput, i: number): BitcoinTxOutput => ({ outputIndex: i, value: BigNumber.from(output.value), - scriptPubKey: Hex.from(output.script.toRaw()), + scriptPubKey: Hex.from(output.script), }) ) return { - transactionHash: BitcoinTxHash.from(transaction.hash()).reverse(), + transactionHash: BitcoinTxHash.from(transaction.getId()), inputs: inputs, outputs: outputs, } @@ -418,7 +427,7 @@ export class ElectrumClient implements BitcoinClient { ) // Decode the raw transaction. - const transaction = bcoin.TX.fromRaw(rawTransaction, "hex") + const transaction = Tx.fromHex(rawTransaction) // As a workaround for the problem described in https://github.com/Blockstream/electrs/pull/36 // we need to calculate the number of confirmations based on the latest @@ -436,8 +445,10 @@ export class ElectrumClient implements BitcoinClient { // If a transaction is unconfirmed (is still in the mempool) the height will // have a value of `0` or `-1`. let txBlockHeight: number = Math.min() - for (const output of transaction.outputs) { - const scriptHash: Buffer = output.script.sha256() + for (const output of transaction.outs) { + const scriptHash: Buffer = BitcoinHashUtils.computeSha256( + Hex.from(output.script) + ).toBuffer() type HistoryEntry = { // eslint-disable-next-line camelcase diff --git a/typescript/src/services/deposits/deposits-service.ts b/typescript/src/services/deposits/deposits-service.ts index eb985d7c1..e04048d29 100644 --- a/typescript/src/services/deposits/deposits-service.ts +++ b/typescript/src/services/deposits/deposits-service.ts @@ -77,11 +77,14 @@ export class DepositsService { const walletPublicKeyHash = BitcoinHashUtils.computeHash160(walletPublicKey) + const bitcoinNetwork = await this.bitcoinClient.getNetwork() + // TODO: Only P2(W)PKH addresses can be used for recovery. The below conversion // function ensures that but, it would be good to check it here as well // in case the converter implementation changes. const refundPublicKeyHash = BitcoinAddressConverter.addressToPublicKeyHash( - bitcoinRecoveryAddress + bitcoinRecoveryAddress, + bitcoinNetwork ) const currentTimestamp = Math.floor(new Date().getTime() / 1000) diff --git a/typescript/src/services/deposits/refund.ts b/typescript/src/services/deposits/refund.ts index 5c4f0dcb4..d4ad401fb 100644 --- a/typescript/src/services/deposits/refund.ts +++ b/typescript/src/services/deposits/refund.ts @@ -133,8 +133,10 @@ export class DepositRefund { utxo.outputIndex ) - const outputScript = - BitcoinAddressConverter.addressToOutputScript(refunderAddress) + const outputScript = BitcoinAddressConverter.addressToOutputScript( + refunderAddress, + bitcoinNetwork + ) transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) // In order to be able to spend the UTXO being refunded the transaction's diff --git a/typescript/src/services/maintenance/wallet-tx.ts b/typescript/src/services/maintenance/wallet-tx.ts index 552929510..dda223671 100644 --- a/typescript/src/services/maintenance/wallet-tx.ts +++ b/typescript/src/services/maintenance/wallet-tx.ts @@ -216,8 +216,10 @@ class DepositSweep { } outputValue = outputValue.sub(fee) - const outputScript = - BitcoinAddressConverter.addressToOutputScript(walletAddress) + const outputScript = BitcoinAddressConverter.addressToOutputScript( + walletAddress, + bitcoinNetwork + ) transaction.addOutput(outputScript.toBuffer(), outputValue.toNumber()) diff --git a/typescript/src/services/redemptions/redemptions-service.ts b/typescript/src/services/redemptions/redemptions-service.ts index 2b99e7fbd..f3fd5f49c 100644 --- a/typescript/src/services/redemptions/redemptions-service.ts +++ b/typescript/src/services/redemptions/redemptions-service.ts @@ -51,8 +51,11 @@ export class RedemptionsService { targetChainTxHash: Hex walletPublicKey: string }> { + const bitcoinNetwork = await this.bitcoinClient.getNetwork() + const redeemerOutputScript = BitcoinAddressConverter.addressToOutputScript( - bitcoinRedeemerAddress + bitcoinRedeemerAddress, + bitcoinNetwork ).toString() // TODO: Validate the given script is supported for redemption. @@ -258,8 +261,10 @@ export class RedemptionsService { // Get the wallet script based on the wallet address. This is required // to find transaction outputs that lock funds on the wallet. - const walletScript = - BitcoinAddressConverter.addressToOutputScript(walletAddress) + const walletScript = BitcoinAddressConverter.addressToOutputScript( + walletAddress, + bitcoinNetwork + ) const isWalletOutput = (output: BitcoinTxOutput) => walletScript.equals(output.scriptPubKey) @@ -328,8 +333,11 @@ export class RedemptionsService { walletPublicKey: string, type: "pending" | "timedOut" = "pending" ): Promise { + const bitcoinNetwork = await this.bitcoinClient.getNetwork() + const redeemerOutputScript = BitcoinAddressConverter.addressToOutputScript( - bitcoinRedeemerAddress + bitcoinRedeemerAddress, + bitcoinNetwork ).toString() let redemptionRequest: RedemptionRequest | undefined = undefined diff --git a/typescript/test/bitcoin-network.test.ts b/typescript/test/bitcoin-network.test.ts index 32102f996..b8457f52a 100644 --- a/typescript/test/bitcoin-network.test.ts +++ b/typescript/test/bitcoin-network.test.ts @@ -1,10 +1,5 @@ import { expect } from "chai" -import { - BitcoinTxHash, - BitcoinNetwork, - toBcoinNetwork, - toBitcoinJsLibNetwork, -} from "../src" +import { BitcoinTxHash, BitcoinNetwork, toBitcoinJsLibNetwork } from "../src" import { networks } from "bitcoinjs-lib" describe("BitcoinNetwork", () => { @@ -14,7 +9,6 @@ describe("BitcoinNetwork", () => { enumValue: "unknown", // any value that doesn't match other supported networks genesisHash: BitcoinTxHash.from("0x00010203"), - expectedToBcoinResult: new Error("network not supported"), expectedToBitcoinJsLibResult: new Error("network not supported"), }, { @@ -23,7 +17,6 @@ describe("BitcoinNetwork", () => { genesisHash: BitcoinTxHash.from( "0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" ), - expectedToBcoinResult: "testnet", expectedToBitcoinJsLibResult: networks.testnet, }, { @@ -32,19 +25,12 @@ describe("BitcoinNetwork", () => { genesisHash: BitcoinTxHash.from( "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" ), - expectedToBcoinResult: "main", expectedToBitcoinJsLibResult: networks.bitcoin, }, ] testData.forEach( - ({ - enumKey, - enumValue, - genesisHash, - expectedToBcoinResult, - expectedToBitcoinJsLibResult, - }) => { + ({ enumKey, enumValue, genesisHash, expectedToBitcoinJsLibResult }) => { context(enumKey, async () => { describe(`toString`, async () => { it(`should return correct value`, async () => { @@ -60,20 +46,6 @@ describe("BitcoinNetwork", () => { }) }) - describe(`toBcoinNetwork`, async () => { - if (expectedToBcoinResult instanceof Error) { - it(`should throw an error`, async () => { - expect(() => toBcoinNetwork(enumKey)).to.throw( - expectedToBcoinResult.message - ) - }) - } else { - it(`should return ${expectedToBcoinResult}`, async () => { - expect(toBcoinNetwork(enumKey)).to.be.equal(expectedToBcoinResult) - }) - } - }) - describe(`toBitcoinJsLibNetwork`, async () => { if (expectedToBitcoinJsLibResult instanceof Error) { it(`should throw an error`, async () => { diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/bitcoin.test.ts index c2d1bb007..6b5b2f206 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/bitcoin.test.ts @@ -1,19 +1,21 @@ import { expect } from "chai" import { - BitcoinNetwork, - BitcoinPublicKeyUtils, - BitcoinLocktimeUtils, + BitcoinAddressConverter, + BitcoinCompactSizeUint, + BitcoinHashUtils, BitcoinHeader, BitcoinHeaderSerializer, - BitcoinHashUtils, + BitcoinLocktimeUtils, + BitcoinNetwork, + BitcoinPublicKeyUtils, + BitcoinScriptUtils, BitcoinTargetConverter, - BitcoinCompactSizeUint, - BitcoinAddressConverter, + extractBitcoinRawTxVectors, Hex, - BitcoinScriptUtils, } from "../src" import { BigNumber } from "ethers" import { btcAddresses, btcAddressFromPublicKey } from "./data/bitcoin" +import { depositSweepWithNoMainUtxoAndWitnessOutput } from "./data/deposit-sweep" describe("Bitcoin", () => { describe("BitcoinPublicKeyUtils", () => { @@ -185,7 +187,9 @@ describe("Bitcoin", () => { true, BitcoinNetwork.Mainnet ) - ).to.throw("P2WPKH must be 20 bytes") + ).to.throw( + `Expected property "hash" of type Buffer(Length: 20), got Buffer(Length: 21)` + ) }) }) }) @@ -213,7 +217,9 @@ describe("Bitcoin", () => { false, BitcoinNetwork.Mainnet ) - ).to.throw("P2PKH must be 20 bytes") + ).to.throw( + `Expected property "hash" of type Buffer(Length: 20), got Buffer(Length: 21)` + ) }) }) }) @@ -243,7 +249,9 @@ describe("Bitcoin", () => { true, BitcoinNetwork.Testnet ) - ).to.throw("P2WPKH must be 20 bytes") + ).to.throw( + `Expected property "hash" of type Buffer(Length: 20), got Buffer(Length: 21)` + ) }) }) }) @@ -271,7 +279,9 @@ describe("Bitcoin", () => { false, BitcoinNetwork.Testnet ) - ).to.throw("P2PKH must be 20 bytes") + ).to.throw( + `Expected property "hash" of type Buffer(Length: 20), got Buffer(Length: 21)` + ) }) }) }) @@ -290,17 +300,17 @@ describe("Bitcoin", () => { context("when network is mainnet", () => { context("when proper P2WPKH address is provided", () => { it("should decode P2WPKH adress correctly", () => { - expect(addressToPublicKeyHash(P2WPKHAddress)).to.be.equal( - publicKeyHash - ) + expect( + addressToPublicKeyHash(P2WPKHAddress, BitcoinNetwork.Mainnet) + ).to.be.equal(publicKeyHash) }) }) context("when proper P2PKH address is provided", () => { it("should decode P2PKH address correctly", () => { - expect(addressToPublicKeyHash(P2PKHAddress)).to.be.equal( - publicKeyHash - ) + expect( + addressToPublicKeyHash(P2PKHAddress, BitcoinNetwork.Mainnet) + ).to.be.equal(publicKeyHash) }) }) @@ -308,8 +318,10 @@ describe("Bitcoin", () => { it("should throw", () => { const bitcoinAddress = "123" + P2PKHAddress - expect(() => addressToPublicKeyHash(bitcoinAddress)).to.throw( - "Address is too long" + expect(() => + addressToPublicKeyHash(bitcoinAddress, BitcoinNetwork.Mainnet) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" ) }) }) @@ -317,8 +329,13 @@ describe("Bitcoin", () => { context("when unsupported P2SH address is provided", () => { it("should throw", () => { expect(() => - addressToPublicKeyHash("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX") - ).to.throw("Address must be P2PKH or P2WPKH") + addressToPublicKeyHash( + "3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX", + BitcoinNetwork.Mainnet + ) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) }) }) @@ -326,9 +343,25 @@ describe("Bitcoin", () => { it("should throw", () => { expect(() => addressToPublicKeyHash( - "bc1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhsdxuv4m" + "bc1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhsdxuv4m", + BitcoinNetwork.Mainnet + ) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) + }) + }) + + context("when address from testnet network is provided", () => { + it("should throw", () => { + expect(() => + addressToPublicKeyHash( + "mkpoZkRvtd3SDGWgUDuXK1aEXZfHRM2gKw", + BitcoinNetwork.Mainnet ) - ).to.throw("Address must be P2PKH or P2WPKH") + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) }) }) }) @@ -336,17 +369,23 @@ describe("Bitcoin", () => { context("when network is testnet", () => { context("when proper P2WPKH address is provided", () => { it("should decode P2WPKH adress correctly", () => { - expect(addressToPublicKeyHash(P2WPKHAddressTestnet)).to.be.equal( - publicKeyHash - ) + expect( + addressToPublicKeyHash( + P2WPKHAddressTestnet, + BitcoinNetwork.Testnet + ) + ).to.be.equal(publicKeyHash) }) }) context("when proper P2PKH address is provided", () => { it("should decode P2PKH address correctly", () => { - expect(addressToPublicKeyHash(P2PKHAddressTestnet)).to.be.equal( - publicKeyHash - ) + expect( + addressToPublicKeyHash( + P2PKHAddressTestnet, + BitcoinNetwork.Testnet + ) + ).to.be.equal(publicKeyHash) }) }) @@ -354,8 +393,10 @@ describe("Bitcoin", () => { it("should throw", () => { const bitcoinAddress = "123" + P2PKHAddressTestnet - expect(() => addressToPublicKeyHash(bitcoinAddress)).to.throw( - "Address is too long" + expect(() => + addressToPublicKeyHash(bitcoinAddress, BitcoinNetwork.Testnet) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" ) }) }) @@ -363,8 +404,13 @@ describe("Bitcoin", () => { context("when unsupported P2SH address is provided", () => { it("should throw", () => { expect(() => - addressToPublicKeyHash("2MyxShnGQ5NifGb8CHYrtmzosRySxZ9pZo5") - ).to.throw("Address must be P2PKH or P2WPKH") + addressToPublicKeyHash( + "2MyxShnGQ5NifGb8CHYrtmzosRySxZ9pZo5", + BitcoinNetwork.Testnet + ) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) }) }) @@ -372,9 +418,25 @@ describe("Bitcoin", () => { it("should throw", () => { expect(() => addressToPublicKeyHash( - "tb1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhs6w2r05" + "tb1qma629cu92skg0t86lftyaf9uflzwhp7jk63h6mpmv3ezh6puvdhs6w2r05", + BitcoinNetwork.Testnet ) - ).to.throw("Address must be P2PKH or P2WPKH") + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) + }) + }) + + context("when address from mainnet network is provided", () => { + it("should throw", () => { + expect(() => + addressToPublicKeyHash( + "bc1q8gudgnt2pjxshwzwqgevccet0eyvwtswt03nuy", + BitcoinNetwork.Testnet + ) + ).to.throw( + "Address must be P2PKH or P2WPKH valid for given network" + ) }) }) }) @@ -391,7 +453,12 @@ describe("Bitcoin", () => { { address, scriptPubKey: expectedOutputScript }, ]) => { it(`should create correct output script for ${addressType} address type`, () => { - const result = addressToOutputScript(address) + const network = + bitcoinNetwork === "mainnet" + ? BitcoinNetwork.Mainnet + : BitcoinNetwork.Testnet + + const result = addressToOutputScript(address, network) expect(result.toString()).to.eq(expectedOutputScript.toString()) }) @@ -711,4 +778,29 @@ describe("Bitcoin", () => { }) }) }) + + describe("extractBitcoinRawTxVectors", () => { + it("should return correct transaction vectors", () => { + const rawTransaction = + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transaction + const decomposedTransaction = extractBitcoinRawTxVectors(rawTransaction) + + expect(decomposedTransaction.version).to.be.equal("01000000") + expect(decomposedTransaction.inputs).to.be.equal( + "02bc187be612bc3db8cfcdec56b75e9bc0262ab6eacfe27cc1a699bacd53e3d07400" + + "000000c948304502210089a89aaf3fec97ac9ffa91cdff59829f0cb3ef852a468153" + + "e2c0e2b473466d2e022072902bb923ef016ac52e941ced78f816bf27991c2b73211e" + + "227db27ec200bc0a012103989d253b17a6a0f41838b84ff0d20e8898f9d7b1a98f25" + + "64da4cc29dcf8581d94c5c14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508" + + "f9f0c90d000395237576a9148db50eb52063ea9d98b3eac91489a90f738986f68763" + + "ac6776a914e257eccafbc07c381642ce6e7e55120fb077fbed8804e0250162b175ac" + + "68ffffffffdc557e737b6688c5712649b86f7757a722dc3d42786f23b2fa826394df" + + "ec545c0000000000ffffffff" + ) + expect(decomposedTransaction.outputs).to.be.equal( + "01488a0000000000001600148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + expect(decomposedTransaction.locktime).to.be.equal("00000000") + }) + }) }) diff --git a/typescript/test/data/redemption.ts b/typescript/test/data/redemption.ts index 9ff50845d..f840e2b6a 100644 --- a/typescript/test/data/redemption.ts +++ b/typescript/test/data/redemption.ts @@ -1,17 +1,18 @@ import { BigNumber, BytesLike } from "ethers" import { + BitcoinAddressConverter, + BitcoinNetwork, + BitcoinRawTx, BitcoinRawTxVectors, BitcoinSpvProof, BitcoinTx, - BitcoinRawTx, - BitcoinUtxo, - BitcoinTxMerkleBranch, BitcoinTxHash, - BitcoinAddressConverter, - RedemptionRequest, - WalletState, + BitcoinTxMerkleBranch, + BitcoinUtxo, EthereumAddress, Hex, + RedemptionRequest, + WalletState, } from "../../src" /** @@ -745,7 +746,8 @@ export const findWalletForRedemptionData: { outputIndex: 0, value: BigNumber.from("791613461"), scriptPubKey: BitcoinAddressConverter.addressToOutputScript( - "tb1qqwm566yn44rdlhgph8sw8vecta8uutg79afuja" + "tb1qqwm566yn44rdlhgph8sw8vecta8uutg79afuja", + BitcoinNetwork.Testnet ), }, ], @@ -870,7 +872,8 @@ export const findWalletForRedemptionData: { outputIndex: 0, value: BigNumber.from("3370000"), // 0.0337 BTC scriptPubKey: BitcoinAddressConverter.addressToOutputScript( - "tb1qx2xejtjltdcau5dpks8ucszkhxdg3fj88404lh" + "tb1qx2xejtjltdcau5dpks8ucszkhxdg3fj88404lh", + BitcoinNetwork.Testnet ), }, ], diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts index 10aa2b640..54965e208 100644 --- a/typescript/test/deposit-sweep.test.ts +++ b/typescript/test/deposit-sweep.test.ts @@ -8,12 +8,7 @@ import { MaintenanceService, WalletTx, } from "../src" -import { - testnetDepositScripthashAddress, - testnetDepositWitnessScripthashAddress, - testnetWalletAddress, - testnetWalletPrivateKey, -} from "./data/deposit" +import { testnetWalletAddress, testnetWalletPrivateKey } from "./data/deposit" import { depositSweepWithWitnessMainUtxoAndWitnessOutput, depositSweepWithNoMainUtxoAndWitnessOutput, @@ -23,12 +18,12 @@ import { NO_MAIN_UTXO, } from "./data/deposit-sweep" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import bcoin from "bcoin" import * as chai from "chai" import chaiAsPromised from "chai-as-promised" chai.use(chaiAsPromised) import { expect } from "chai" import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" +import { txToJSON } from "./utils/helpers" describe("Sweep", () => { const fee = BigNumber.from(1600) @@ -445,8 +440,10 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() @@ -457,28 +454,23 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(2) const p2shInput = txJSON.inputs[0] - expect(p2shInput.prevout.hash).to.be.equal( + expect(p2shInput.hash).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2shInput.prevout.index).to.be.equal( + expect(p2shInput.index).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.equal("00") + expect(p2shInput.witness).to.be.empty expect(p2shInput.script.length).to.be.greaterThan(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2shInput.address).to.be.equal( - testnetDepositScripthashAddress - ) const p2wshInput = txJSON.inputs[1] - expect(p2wshInput.prevout.hash).to.be.equal( + expect(p2wshInput.hash).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() ) - expect(p2wshInput.prevout.index).to.be.equal( + expect(p2wshInput.index).to.be.equal( depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo .outputIndex ) @@ -486,11 +478,6 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wshInput.witness.length).to.be.greaterThan(0) expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // witness script hash - expect(p2wshInput.address).to.be.equal( - testnetDepositWitnessScripthashAddress - ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -587,8 +574,10 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() @@ -599,10 +588,10 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(3) const p2wkhInput = txJSON.inputs[0] - expect(p2wkhInput.prevout.hash).to.be.equal( + expect(p2wkhInput.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() ) - expect(p2wkhInput.prevout.index).to.be.equal( + expect(p2wkhInput.index).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo .outputIndex ) @@ -610,33 +599,25 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wkhInput.witness.length).to.be.greaterThan(0) expect(p2wkhInput.script.length).to.be.equal(0) - // The input comes from the main UTXO so the input should be the - // wallet's address - expect(p2wkhInput.address).to.be.equal(testnetWalletAddress) const p2shInput = txJSON.inputs[1] - expect(p2shInput.prevout.hash).to.be.equal( + expect(p2shInput.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2shInput.prevout.index).to.be.equal( + expect(p2shInput.index).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0] .utxo.outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.equal("00") + expect(p2shInput.witness).to.be.empty expect(p2shInput.script.length).to.be.greaterThan(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2shInput.address).to.be.equal( - testnetDepositScripthashAddress - ) const p2wshInput = txJSON.inputs[2] - expect(p2wshInput.prevout.hash).to.be.equal( + expect(p2wshInput.hash).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() ) - expect(p2wshInput.prevout.index).to.be.equal( + expect(p2wshInput.index).to.be.equal( depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1] .utxo.outputIndex ) @@ -644,11 +625,6 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wshInput.witness.length).to.be.greaterThan(0) expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // witness script hash - expect(p2wshInput.address).to.be.equal( - testnetDepositWitnessScripthashAddress - ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -744,8 +720,10 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() @@ -756,28 +734,23 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(2) const p2pkhInput = txJSON.inputs[0] // main UTXO - expect(p2pkhInput.prevout.hash).to.be.equal( + expect(p2pkhInput.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() ) - expect(p2pkhInput.prevout.index).to.be.equal( + expect(p2pkhInput.index).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2pkhInput.witness).to.be.equal("00") + expect(p2pkhInput.witness).to.be.empty expect(p2pkhInput.script.length).to.be.greaterThan(0) - // The input comes from the main UTXO so the input should be the - // wallet's address - expect(p2pkhInput.address).to.be.equal( - "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" - ) const p2wshInput = txJSON.inputs[1] - expect(p2wshInput.prevout.hash).to.be.equal( + expect(p2wshInput.hash).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2wshInput.prevout.index).to.be.equal( + expect(p2wshInput.index).to.be.equal( depositSweepWithNonWitnessMainUtxoAndWitnessOutput .deposits[0].utxo.outputIndex ) @@ -785,11 +758,6 @@ describe("Sweep", () => { // field should be filled, while the `script` field should be empty. expect(p2wshInput.witness.length).to.be.greaterThan(0) expect(p2wshInput.script.length).to.be.equal(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2wshInput.address).to.be.equal( - "tb1qk8urugnf08wfle6wslmdxq7mkz9z0gw8e6gkvspn7dx87tfpfntshdm7qr" - ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) @@ -878,8 +846,10 @@ describe("Sweep", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep.transactionHash.toString() @@ -890,22 +860,17 @@ describe("Sweep", () => { expect(txJSON.inputs.length).to.be.equal(1) const p2shInput = txJSON.inputs[0] - expect(p2shInput.prevout.hash).to.be.equal( + expect(p2shInput.hash).to.be.equal( depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo.transactionHash.toString() ) - expect(p2shInput.prevout.index).to.be.equal( + expect(p2shInput.index).to.be.equal( depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo .outputIndex ) // Transaction should be signed. As it's not SegWit input, the `witness` // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.equal("00") + expect(p2shInput.witness).to.be.empty expect(p2shInput.script.length).to.be.greaterThan(0) - // Input's address should be set to the address generated from deposit - // script hash - expect(p2shInput.address).to.be.equal( - "2N8iF1pRndihBzgLDna9MfRhmqktwTdHejA" - ) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(1) diff --git a/typescript/test/deposit.test.ts b/typescript/test/deposit.test.ts index ec135e568..73f33e320 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/deposit.test.ts @@ -21,8 +21,8 @@ import { extractBitcoinRawTxVectors, } from "../src" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import bcoin from "bcoin" import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" +import { txToJSON } from "./utils/helpers" describe("Deposit", () => { const depositCreatedAt: number = 1640181600 @@ -343,8 +343,10 @@ describe("Deposit", () => { expect(transaction).to.be.eql(expectedP2WSHDeposit.transaction) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( expectedP2WSHDeposit.transactionHash.toString() @@ -356,15 +358,12 @@ describe("Deposit", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( - testnetUTXO.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) + expect(input.hash).to.be.equal(testnetUTXO.transactionHash.toString()) + expect(input.index).to.be.equal(testnetUTXO.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(testnetAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -447,8 +446,10 @@ describe("Deposit", () => { expect(transaction).to.be.eql(expectedP2SHDeposit.transaction) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( expectedP2SHDeposit.transactionHash.toString() @@ -460,15 +461,12 @@ describe("Deposit", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( - testnetUTXO.transactionHash.toString() - ) - expect(input.prevout.index).to.be.equal(testnetUTXO.outputIndex) + expect(input.hash).to.be.equal(testnetUTXO.transactionHash.toString()) + expect(input.index).to.be.equal(testnetUTXO.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(testnetAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) diff --git a/typescript/test/redemption.test.ts b/typescript/test/redemption.test.ts index 371662f2c..4fbd9f5fe 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/redemption.test.ts @@ -6,15 +6,15 @@ import { BitcoinTx, BitcoinTxHash, BitcoinUtxo, + Hex, + MaintenanceService, NewWalletRegisteredEvent, RedemptionRequest, + RedemptionsService, Wallet, WalletState, - RedemptionsService, WalletTx, - MaintenanceService, } from "../src" -import bcoin from "bcoin" import { MockBitcoinClient } from "./utils/mock-bitcoin-client" import { findWalletForRedemptionData, @@ -38,7 +38,7 @@ import { expect } from "chai" import chaiAsPromised from "chai-as-promised" import { BigNumber, BigNumberish } from "ethers" import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" -import { Hex } from "../src" +import { txToJSON } from "./utils/helpers" chai.use(chaiAsPromised) @@ -99,8 +99,10 @@ describe("Redemption", () => { { outputIndex: mainUtxo.outputIndex, value: mainUtxo.value, - scriptPubKey: - BitcoinAddressConverter.addressToOutputScript(walletAddress), + scriptPubKey: BitcoinAddressConverter.addressToOutputScript( + walletAddress, + BitcoinNetwork.Testnet + ), }, ], } as BitcoinTx, @@ -1282,11 +1284,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from( + const txJSON = txToJSON( transaction.transactionHex, - "hex" + BitcoinNetwork.Testnet ) - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -1298,17 +1299,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -1407,11 +1405,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from( + const txJSON = txToJSON( transaction.transactionHex, - "hex" + BitcoinNetwork.Testnet ) - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -1423,17 +1420,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -1531,11 +1525,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from( + const txJSON = txToJSON( transaction.transactionHex, - "hex" + BitcoinNetwork.Testnet ) - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -1547,17 +1540,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -1655,11 +1645,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from( + const txJSON = txToJSON( transaction.transactionHex, - "hex" + BitcoinNetwork.Testnet ) - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -1671,17 +1660,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -1778,8 +1764,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -1791,17 +1779,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(5) @@ -1945,8 +1930,10 @@ describe("Redemption", () => { ) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -1958,17 +1945,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal( - data.mainUtxo.outputIndex - ) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) @@ -2059,8 +2043,10 @@ describe("Redemption", () => { expect(transaction).to.be.eql(data.expectedRedemption.transaction) // Convert raw transaction to JSON to make detailed comparison. - const buffer = Buffer.from(transaction.transactionHex, "hex") - const txJSON = bcoin.TX.fromRaw(buffer).getJSON("testnet") + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) expect(txJSON.hash).to.be.equal( data.expectedRedemption.transactionHash.toString() @@ -2072,15 +2058,14 @@ describe("Redemption", () => { const input = txJSON.inputs[0] - expect(input.prevout.hash).to.be.equal( + expect(input.hash).to.be.equal( data.mainUtxo.transactionHash.toString() ) - expect(input.prevout.index).to.be.equal(data.mainUtxo.outputIndex) + expect(input.index).to.be.equal(data.mainUtxo.outputIndex) // Transaction should be signed but this is SegWit input so the `script` // field should be empty and the `witness` field should be filled instead. expect(input.script.length).to.be.equal(0) expect(input.witness.length).to.be.greaterThan(0) - expect(input.address).to.be.equal(p2wpkhWalletAddress) // Validate outputs. expect(txJSON.outputs.length).to.be.equal(2) diff --git a/typescript/test/utils/helpers.ts b/typescript/test/utils/helpers.ts index 59634d35b..8378ea344 100644 --- a/typescript/test/utils/helpers.ts +++ b/typescript/test/utils/helpers.ts @@ -1,8 +1,4 @@ -import { Hex } from "../../src/hex" -import { - BitcoinNetwork, - toBitcoinJsLibNetwork, -} from "../../src/bitcoin-network" +import { BitcoinNetwork, toBitcoinJsLibNetwork, Hex } from "../../src" import { Transaction, address } from "bitcoinjs-lib" /** diff --git a/typescript/yarn.lock b/typescript/yarn.lock index 05897068f..ba01c6262 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -2496,45 +2496,6 @@ base64-js@^1.3.1: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== -"bcfg@git+https://github.com/bcoin-org/bcfg.git#semver:~0.1.7": - version "0.1.7" - resolved "git+https://github.com/bcoin-org/bcfg.git#05122154b35baa82cd01dc9478ebee7346386ba1" - dependencies: - bsert "~0.0.10" - -"bcoin@git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8": - version "2.2.0" - resolved "git+https://github.com/keep-network/bcoin.git#5accd32c63e6025a0d35d67739c4a6e84095a1f8" - dependencies: - bcfg "git+https://github.com/bcoin-org/bcfg.git#semver:~0.1.7" - bcrypto "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0" - bcurl "git+https://github.com/bcoin-org/bcurl.git#semver:^0.1.6" - bdb "git+https://github.com/bcoin-org/bdb.git#semver:~1.2.1" - bdns "git+https://github.com/bcoin-org/bdns.git#semver:~0.1.5" - bevent "git+https://github.com/bcoin-org/bevent.git#semver:~0.1.5" - bfile "git+https://github.com/bcoin-org/bfile.git#semver:~0.2.1" - bfilter "git+https://github.com/bcoin-org/bfilter.git#semver:~2.3.0" - bheep "git+https://github.com/bcoin-org/bheep.git#semver:~0.1.5" - binet "git+https://github.com/bcoin-org/binet.git#semver:~0.3.5" - blgr "git+https://github.com/bcoin-org/blgr.git#semver:~0.2.0" - blru "git+https://github.com/bcoin-org/blru.git#semver:~0.1.6" - blst "git+https://github.com/bcoin-org/blst.git#semver:~0.1.5" - bmutex "git+https://github.com/bcoin-org/bmutex.git#semver:~0.1.6" - brq "git+https://github.com/bcoin-org/brq.git#semver:~0.1.7" - bs32 "git+https://github.com/bcoin-org/bs32.git#semver:=0.1.6" - bsert "git+https://github.com/chjj/bsert.git#semver:~0.0.10" - bsock "git+https://github.com/bcoin-org/bsock.git#semver:~0.1.9" - bsocks "git+https://github.com/bcoin-org/bsocks.git#semver:~0.2.6" - btcp "git+https://github.com/bcoin-org/btcp.git#semver:~0.1.5" - buffer-map "git+https://github.com/chjj/buffer-map.git#semver:~0.0.7" - bufio "git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6" - bupnp "git+https://github.com/bcoin-org/bupnp.git#semver:~0.2.6" - bval "git+https://github.com/bcoin-org/bval.git#semver:~0.1.6" - bweb "git+https://github.com/bcoin-org/bweb.git#semver:=0.1.9" - loady "git+https://github.com/chjj/loady.git#semver:~0.0.1" - n64 "git+https://github.com/chjj/n64.git#semver:~0.2.10" - nan "git+https://github.com/braydonf/nan.git#semver:=2.14.0" - bcrypt-pbkdf@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" @@ -2542,34 +2503,6 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" -"bcrypto@git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0": - version "5.5.0" - resolved "git+https://github.com/bcoin-org/bcrypto.git#34738cf15033e3bce91a4f6f41ec1ebee3c2fdc8" - dependencies: - bufio "~1.0.7" - loady "~0.0.5" - -"bcurl@git+https://github.com/bcoin-org/bcurl.git#semver:^0.1.6": - version "0.1.10" - resolved "git+https://github.com/bcoin-org/bcurl.git#d7e088fad4c284fb5d6fd7205c6b903bd3e6bf83" - dependencies: - brq "~0.1.8" - bsert "~0.0.10" - bsock "~0.1.9" - -"bdb@git+https://github.com/bcoin-org/bdb.git#semver:~1.2.1": - version "1.2.2" - resolved "git+https://github.com/bcoin-org/bdb.git#2c8d48c8adca4b11260263472766cd4b7ae74ef7" - dependencies: - bsert "~0.0.10" - loady "~0.0.1" - -"bdns@git+https://github.com/bcoin-org/bdns.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/bdns.git#cb0b62a0075f7e1259fc50fa723ba644e9a07d14" - dependencies: - bsert "~0.0.10" - bech32@1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" @@ -2580,31 +2513,6 @@ bech32@^2.0.0: resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355" integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg== -"bevent@git+https://github.com/bcoin-org/bevent.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/bevent.git#60fb503de3ea1292d29ce438bfba80f0bc5ccb60" - dependencies: - bsert "~0.0.10" - -"bfile@git+https://github.com/bcoin-org/bfile.git#semver:~0.2.1": - version "0.2.2" - resolved "git+https://github.com/bcoin-org/bfile.git#c3075133a02830dc384f8353d8275d4499b8bff9" - -"bfilter@git+https://github.com/bcoin-org/bfilter.git#semver:~2.3.0": - version "2.3.0" - resolved "git+https://github.com/bcoin-org/bfilter.git#70e42125f877191d340e8838a1a90fabb750e680" - dependencies: - bcrypto "git+https://github.com/bcoin-org/bcrypto.git#semver:~5.5.0" - bsert "git+https://github.com/chjj/bsert.git#semver:~0.0.10" - bufio "git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6" - loady "git+https://github.com/chjj/loady.git#semver:~0.0.1" - -"bheep@git+https://github.com/bcoin-org/bheep.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/bheep.git#e59329d0a776ae71b2fb7a2876ee5b9fd3030fa2" - dependencies: - bsert "~0.0.10" - big-integer@^1.6.44: version "1.6.51" resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" @@ -2637,13 +2545,6 @@ bindings@^1.3.0: dependencies: file-uri-to-path "1.0.0" -"binet@git+https://github.com/bcoin-org/binet.git#semver:~0.3.5", binet@~0.3.5: - version "0.3.6" - resolved "git+https://github.com/bcoin-org/binet.git#d3decfb7a7257abdfb03c3a9c091499b2ebff0e1" - dependencies: - bs32 "~0.1.5" - bsert "~0.0.10" - bip174@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/bip174/-/bip174-2.1.1.tgz#ef3e968cf76de234a546962bcf572cc150982f9f" @@ -2718,18 +2619,6 @@ blakejs@^1.1.0: resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.2.1.tgz#5057e4206eadb4a97f7c0b6e197a505042fc3814" integrity sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ== -"blgr@git+https://github.com/bcoin-org/blgr.git#semver:~0.2.0": - version "0.2.0" - resolved "git+https://github.com/bcoin-org/blgr.git#050cbb587a1654a078468dbb92606330fdc4d120" - dependencies: - bsert "~0.0.10" - -"blru@git+https://github.com/bcoin-org/blru.git#semver:~0.1.6": - version "0.1.6" - resolved "git+https://github.com/bcoin-org/blru.git#c2c093e9475439333dfb87bfb2fdc3be6c98b080" - dependencies: - bsert "~0.0.10" - "bls12377js@https://github.com/celo-org/bls12377js#400bcaeec9e7620b040bfad833268f5289699cac": version "0.1.0" resolved "https://github.com/celo-org/bls12377js#400bcaeec9e7620b040bfad833268f5289699cac" @@ -2754,23 +2643,11 @@ blakejs@^1.1.0: ts-node "^8.4.1" typescript "^3.6.4" -"blst@git+https://github.com/bcoin-org/blst.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/blst.git#d588403edb18e628899e05aeba8c3a98a5cdedff" - dependencies: - bsert "~0.0.10" - bluebird@^3.5.0, bluebird@^3.5.2: version "3.7.2" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== -"bmutex@git+https://github.com/bcoin-org/bmutex.git#semver:~0.1.6": - version "0.1.6" - resolved "git+https://github.com/bcoin-org/bmutex.git#e50782323932a4946ecc05a74c6d45861adc2c25" - dependencies: - bsert "~0.0.10" - bn.js@4.11.6: version "4.11.6" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" @@ -2893,18 +2770,6 @@ browserify-sign@^4.0.0: readable-stream "^3.6.0" safe-buffer "^5.2.0" -"brq@git+https://github.com/bcoin-org/brq.git#semver:~0.1.7", brq@~0.1.7, brq@~0.1.8: - version "0.1.8" - resolved "git+https://github.com/bcoin-org/brq.git#534bb2c83fb366ba40ad80bc3de796a174503294" - dependencies: - bsert "~0.0.10" - -"bs32@git+https://github.com/bcoin-org/bs32.git#semver:=0.1.6", bs32@~0.1.5: - version "0.1.6" - resolved "git+https://github.com/bcoin-org/bs32.git#21cf9c724659dc15df722d2410548828c142f265" - dependencies: - bsert "~0.0.10" - bs58@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a" @@ -2921,27 +2786,6 @@ bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: create-hash "^1.1.0" safe-buffer "^5.1.2" -"bsert@git+https://github.com/chjj/bsert.git#semver:~0.0.10", bsert@~0.0.10: - version "0.0.10" - resolved "git+https://github.com/chjj/bsert.git#bd09d49eab8644bca08ae8259a3d8756e7d453fc" - -"bsock@git+https://github.com/bcoin-org/bsock.git#semver:~0.1.9", bsock@~0.1.8, bsock@~0.1.9: - version "0.1.9" - resolved "git+https://github.com/bcoin-org/bsock.git#7cf76b3021ae7929c023d1170f789811e91ae528" - dependencies: - bsert "~0.0.10" - -"bsocks@git+https://github.com/bcoin-org/bsocks.git#semver:~0.2.6": - version "0.2.6" - resolved "git+https://github.com/bcoin-org/bsocks.git#6a8eb764dc4408e7f47da4f84e1afb1b393117e8" - dependencies: - binet "~0.3.5" - bsert "~0.0.10" - -"btcp@git+https://github.com/bcoin-org/btcp.git#semver:~0.1.5": - version "0.1.5" - resolved "git+https://github.com/bcoin-org/btcp.git#4ea7e1ce5a43cd5348152c007aff76a419190a3a" - buffer-alloc-unsafe@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" @@ -2970,10 +2814,6 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== -"buffer-map@git+https://github.com/chjj/buffer-map.git#semver:~0.0.7": - version "0.0.7" - resolved "git+https://github.com/chjj/buffer-map.git#bad5863af9a520701937a17fc8fa2bd8ca8e73f3" - buffer-reverse@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-reverse/-/buffer-reverse-1.0.1.tgz#49283c8efa6f901bc01fa3304d06027971ae2f60" @@ -3026,31 +2866,10 @@ bufferutil@^4.0.1: dependencies: node-gyp-build "^4.3.0" -bufio@^1.0.6, "bufio@git+https://github.com/bcoin-org/bufio.git#semver:~1.0.6", bufio@~1.0.7: +bufio@^1.0.6: version "1.0.7" resolved "git+https://github.com/bcoin-org/bufio.git#91ae6c93899ff9fad7d7cee9afd2a1c4933ca984" -"bupnp@git+https://github.com/bcoin-org/bupnp.git#semver:~0.2.6": - version "0.2.6" - resolved "git+https://github.com/bcoin-org/bupnp.git#c44fa7356aa297c9de96e8ad094a6816939cd688" - dependencies: - binet "~0.3.5" - brq "~0.1.7" - bsert "~0.0.10" - -"bval@git+https://github.com/bcoin-org/bval.git#semver:~0.1.6": - version "0.1.6" - resolved "git+https://github.com/bcoin-org/bval.git#c8cd14419ca46f63610dc48b797b076835e86f48" - dependencies: - bsert "~0.0.10" - -"bweb@git+https://github.com/bcoin-org/bweb.git#semver:=0.1.9": - version "0.1.9" - resolved "git+https://github.com/bcoin-org/bweb.git#31ae94ec9e97079610394e91928fe070d312c39d" - dependencies: - bsert "~0.0.10" - bsock "~0.1.8" - bytes@3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" @@ -5726,10 +5545,6 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" -"loady@git+https://github.com/chjj/loady.git#semver:~0.0.1", loady@~0.0.1, loady@~0.0.5: - version "0.0.5" - resolved "git+https://github.com/chjj/loady.git#b94958b7ee061518f4b85ea6da380e7ee93222d5" - locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -6148,19 +5963,11 @@ multihashes@^0.4.15, multihashes@~0.4.15: multibase "^0.7.0" varint "^5.0.0" -"n64@git+https://github.com/chjj/n64.git#semver:~0.2.10": - version "0.2.10" - resolved "git+https://github.com/chjj/n64.git#34f981f1441f569821d97a31f8cf21a3fc11b8f6" - nan@^2.13.2, nan@^2.14.0: version "2.15.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== -"nan@git+https://github.com/braydonf/nan.git#semver:=2.14.0": - version "2.14.0" - resolved "git+https://github.com/braydonf/nan.git#1dcc61bd06d84e389bfd5311b2b1492a14c74201" - nano-json-stream-parser@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz#0cc8f6d0e2b622b479c40d499c46d64b755c6f5f" From b3628409fd5201f564b0c7c36df4f03df1277eb5 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 10 Oct 2023 13:47:00 +0200 Subject: [PATCH 187/205] Update `bitcoinjs-lib` and supported `node` version Here we pull changes from https://github.com/keep-network/tbtc-v2/pull/708 --- typescript/package.json | 4 ++-- typescript/yarn.lock | 47 ++++++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/typescript/package.json b/typescript/package.json index a518d97fe..27e8a36a4 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -22,7 +22,7 @@ "dependencies": { "@keep-network/ecdsa": "development", "@keep-network/tbtc-v2": "development", - "bitcoinjs-lib": "6.0.2", + "bitcoinjs-lib": "^6.1.5", "bufio": "^1.0.6", "ecpair": "^2.1.0", "electrum-client-js": "git+https://github.com/keep-network/electrum-client-js.git#v0.1.1", @@ -54,6 +54,6 @@ "typescript": "^4.3.5" }, "engines": { - "node": ">=14 <15" + "node": ">=16" } } diff --git a/typescript/yarn.lock b/typescript/yarn.lock index ba01c6262..08928f090 100644 --- a/typescript/yarn.lock +++ b/typescript/yarn.lock @@ -1643,6 +1643,11 @@ resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-5.50.0.tgz#29c6419e8379d496ab6d0426eadf3c4d100cd186" integrity sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA== +"@noble/hashes@^1.2.0": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" + integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -2491,6 +2496,11 @@ base-x@^3.0.2, base-x@^3.0.8: dependencies: safe-buffer "^5.0.1" +base-x@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.0.tgz#d0e3b7753450c73f8ad2389b5c018a4af7b2224a" + integrity sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw== + base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" @@ -2545,7 +2555,7 @@ bindings@^1.3.0: dependencies: file-uri-to-path "1.0.0" -bip174@^2.0.1: +bip174@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/bip174/-/bip174-2.1.1.tgz#ef3e968cf76de234a546962bcf572cc150982f9f" integrity sha512-mdFV5+/v0XyNYXjBS6CQPLo9ekCx4gtKZFnJm5PMto7Fs9hTTDpkkzOB7/FtluRI6JbUUAu+snTYfJRgHLZbZQ== @@ -2592,19 +2602,17 @@ bip39@3.0.4: pbkdf2 "^3.0.9" randombytes "^2.0.1" -bitcoinjs-lib@6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.0.2.tgz#0fdf6c41978d93641b936d66f4afce44bb9b7f35" - integrity sha512-I994pGt9cL5s5OA6mkv1e8IuYcsKN2ORXnWbkqAXLNGvEnOHBhKBSvCjFl7YC2uVoJnfr/iwq7JMrq575SYO5w== +bitcoinjs-lib@^6.1.5: + version "6.1.5" + resolved "https://registry.yarnpkg.com/bitcoinjs-lib/-/bitcoinjs-lib-6.1.5.tgz#3b03509ae7ddd80a440f10fc38c4a97f0a028d8c" + integrity sha512-yuf6xs9QX/E8LWE2aMJPNd0IxGofwfuVOiYdNUESkc+2bHHVKjhJd8qewqapeoolh9fihzHGoDCB5Vkr57RZCQ== dependencies: + "@noble/hashes" "^1.2.0" bech32 "^2.0.0" - bip174 "^2.0.1" - bs58check "^2.1.2" - create-hash "^1.1.0" - ripemd160 "^2.0.2" + bip174 "^2.1.1" + bs58check "^3.0.1" typeforce "^1.11.3" varuint-bitcoin "^1.1.2" - wif "^2.0.1" bl@^1.0.0: version "1.2.3" @@ -2777,6 +2785,13 @@ bs58@^4.0.0: dependencies: base-x "^3.0.2" +bs58@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279" + integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ== + dependencies: + base-x "^4.0.0" + bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-2.1.2.tgz#53b018291228d82a5aa08e7d796fdafda54aebfc" @@ -2786,6 +2801,14 @@ bs58check@<3.0.0, bs58check@^2.1.1, bs58check@^2.1.2: create-hash "^1.1.0" safe-buffer "^5.1.2" +bs58check@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/bs58check/-/bs58check-3.0.1.tgz#2094d13720a28593de1cba1d8c4e48602fdd841c" + integrity sha512-hjuuJvoWEybo7Hn/0xOrczQKKEKD63WguEjlhLExYs2wUBcebDC1jDNK17eEAD2lYfw82d5ASC1d7K3SWszjaQ== + dependencies: + "@noble/hashes" "^1.2.0" + bs58 "^5.0.0" + buffer-alloc-unsafe@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" @@ -6742,7 +6765,7 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.2: +ripemd160@^2.0.0, ripemd160@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== @@ -8629,7 +8652,7 @@ wide-align@1.1.3: dependencies: string-width "^1.0.2 || 2" -wif@2.0.6, wif@^2.0.1, wif@^2.0.6: +wif@2.0.6, wif@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/wif/-/wif-2.0.6.tgz#08d3f52056c66679299726fade0d432ae74b4704" integrity sha1-CNP1IFbGZnkplyb63g1DKudLRwQ= From 747c1d15e987d2bb660e1db1adf0aaefb033d95b Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Tue, 10 Oct 2023 13:58:51 +0200 Subject: [PATCH 188/205] Re-format `package.json` file --- typescript/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/typescript/package.json b/typescript/package.json index 27e8a36a4..bc3627f9d 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -15,7 +15,9 @@ "build": "npm run typechain && tsc --project tsconfig.build.json", "dev": "tsc --project tsconfig.build.json --watch" }, - "files": ["dist"], + "files": [ + "dist" + ], "config": { "contracts": "./node_modules/@keep-network/ecdsa/artifacts/WalletRegistry.json ./node_modules/@keep-network/tbtc-v2/artifacts/{Bridge,TBTCVault,TBTC}.json" }, From 876af0cfc4a33abca405b82623adbaa3bfa9845f Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 11 Oct 2023 10:58:38 +0200 Subject: [PATCH 189/205] Rework unit tests structure Here we adjust the unit tests to the recent changes. --- typescript/test/bitcoin-network.test.ts | 67 - typescript/test/deposit-refund.test.ts | 180 -- typescript/test/deposit-sweep.test.ts | 1140 ----------- typescript/test/electrum.test.ts | 290 --- typescript/test/hex.test.ts | 179 -- typescript/test/{ => lib}/bitcoin.test.ts | 456 ++++- typescript/test/lib/electrum.test.ts | 293 +++ typescript/test/{ => lib}/ethereum.test.ts | 6 +- typescript/test/lib/utils.test.ts | 181 ++ typescript/test/proof.test.ts | 394 ---- .../deposits.test.ts} | 187 +- .../maintenance.test.ts} | 1790 ++++++++++------- typescript/test/services/redemptions.test.ts | 839 ++++++++ 13 files changed, 2995 insertions(+), 3007 deletions(-) delete mode 100644 typescript/test/bitcoin-network.test.ts delete mode 100644 typescript/test/deposit-refund.test.ts delete mode 100644 typescript/test/deposit-sweep.test.ts delete mode 100644 typescript/test/electrum.test.ts delete mode 100644 typescript/test/hex.test.ts rename typescript/test/{ => lib}/bitcoin.test.ts (62%) create mode 100644 typescript/test/lib/electrum.test.ts rename typescript/test/{ => lib}/ethereum.test.ts (99%) create mode 100644 typescript/test/lib/utils.test.ts delete mode 100644 typescript/test/proof.test.ts rename typescript/test/{deposit.test.ts => services/deposits.test.ts} (79%) rename typescript/test/{redemption.test.ts => services/maintenance.test.ts} (59%) create mode 100644 typescript/test/services/redemptions.test.ts diff --git a/typescript/test/bitcoin-network.test.ts b/typescript/test/bitcoin-network.test.ts deleted file mode 100644 index b8457f52a..000000000 --- a/typescript/test/bitcoin-network.test.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { expect } from "chai" -import { BitcoinTxHash, BitcoinNetwork, toBitcoinJsLibNetwork } from "../src" -import { networks } from "bitcoinjs-lib" - -describe("BitcoinNetwork", () => { - const testData = [ - { - enumKey: BitcoinNetwork.Unknown, - enumValue: "unknown", - // any value that doesn't match other supported networks - genesisHash: BitcoinTxHash.from("0x00010203"), - expectedToBitcoinJsLibResult: new Error("network not supported"), - }, - { - enumKey: BitcoinNetwork.Testnet, - enumValue: "testnet", - genesisHash: BitcoinTxHash.from( - "0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" - ), - expectedToBitcoinJsLibResult: networks.testnet, - }, - { - enumKey: BitcoinNetwork.Mainnet, - enumValue: "mainnet", - genesisHash: BitcoinTxHash.from( - "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" - ), - expectedToBitcoinJsLibResult: networks.bitcoin, - }, - ] - - testData.forEach( - ({ enumKey, enumValue, genesisHash, expectedToBitcoinJsLibResult }) => { - context(enumKey, async () => { - describe(`toString`, async () => { - it(`should return correct value`, async () => { - expect(enumKey.toString()).to.be.equal(enumValue) - }) - }) - - describe(`fromGenesisHash`, async () => { - it(`should resolve correct enum key`, async () => { - expect(BitcoinNetwork.fromGenesisHash(genesisHash)).to.be.equal( - enumKey - ) - }) - }) - - describe(`toBitcoinJsLibNetwork`, async () => { - if (expectedToBitcoinJsLibResult instanceof Error) { - it(`should throw an error`, async () => { - expect(() => toBitcoinJsLibNetwork(enumKey)).to.throw( - expectedToBitcoinJsLibResult.message - ) - }) - } else { - it(`should return ${expectedToBitcoinJsLibResult}`, async () => { - expect(toBitcoinJsLibNetwork(enumKey)).to.be.equal( - expectedToBitcoinJsLibResult - ) - }) - } - }) - }) - } - ) -}) diff --git a/typescript/test/deposit-refund.test.ts b/typescript/test/deposit-refund.test.ts deleted file mode 100644 index 722d74566..000000000 --- a/typescript/test/deposit-refund.test.ts +++ /dev/null @@ -1,180 +0,0 @@ -import { BigNumber } from "ethers" -import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import * as chai from "chai" -import chaiAsPromised from "chai-as-promised" -chai.use(chaiAsPromised) -import { expect } from "chai" -import { BitcoinTxHash, BitcoinRawTx } from "./lib/bitcoin" -import { - refunderPrivateKey, - depositRefundOfWitnessDepositAndWitnessRefunderAddress, - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress, - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress, -} from "./data/deposit-refund" -import { DepositRefund } from "../src/services/deposits/refund" -import { DepositScript } from "../src/services/deposits" - -describe("Refund", () => { - const fee = BigNumber.from(1520) - - describe("DepositRefund", () => { - describe("submitTransaction", () => { - let bitcoinClient: MockBitcoinClient - - beforeEach(async () => { - bitcoinClient = new MockBitcoinClient() - }) - - context("when the refund transaction is requested to be witness", () => { - context("when the refunded deposit was witness", () => { - let transactionHash: BitcoinTxHash - - beforeEach(async () => { - const utxo = - depositRefundOfWitnessDepositAndWitnessRefunderAddress.deposit - .utxo - const deposit = - depositRefundOfWitnessDepositAndWitnessRefunderAddress.deposit - .data - const refunderAddress = - depositRefundOfWitnessDepositAndWitnessRefunderAddress.refunderAddress - const refunderPrivateKey = - "cTWhf1nXc7aW8BN2qLtWcPtcgcWYKfzRXkCJNsuQ86HR8uJBYfMc" - - const rawTransactions = new Map() - rawTransactions.set(utxo.transactionHash.toString(), { - transactionHex: utxo.transactionHex, - }) - bitcoinClient.rawTransactions = rawTransactions - - const depositRefund = DepositRefund.fromScript( - DepositScript.fromReceipt(deposit) - ) - - ;({ transactionHash } = await depositRefund.submitTransaction( - bitcoinClient, - fee, - utxo, - refunderAddress, - refunderPrivateKey - )) - }) - - it("should broadcast refund transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositRefundOfWitnessDepositAndWitnessRefunderAddress - .expectedRefund.transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositRefundOfWitnessDepositAndWitnessRefunderAddress - .expectedRefund.transactionHash - ) - }) - }) - - context("when the refunded deposit was non-witness", () => { - let transactionHash: BitcoinTxHash - - beforeEach(async () => { - const utxo = - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.deposit - .utxo - const deposit = - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.deposit - .data - const refunderAddress = - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.refunderAddress - - const rawTransactions = new Map() - rawTransactions.set(utxo.transactionHash.toString(), { - transactionHex: utxo.transactionHex, - }) - bitcoinClient.rawTransactions = rawTransactions - - const depositRefund = DepositRefund.fromScript( - DepositScript.fromReceipt(deposit) - ) - - ;({ transactionHash } = await depositRefund.submitTransaction( - bitcoinClient, - fee, - utxo, - refunderAddress, - refunderPrivateKey - )) - }) - - it("should broadcast refund transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress - .expectedRefund.transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositRefundOfNonWitnessDepositAndWitnessRefunderAddress - .expectedRefund.transactionHash - ) - }) - }) - }) - - context( - "when the refund transaction is requested to be non-witness", - () => { - let transactionHash: BitcoinTxHash - - beforeEach(async () => { - const utxo = - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.deposit - .utxo - const deposit = - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.deposit - .data - const refunderAddress = - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.refunderAddress - - const rawTransactions = new Map() - rawTransactions.set(utxo.transactionHash.toString(), { - transactionHex: utxo.transactionHex, - }) - - const depositRefund = DepositRefund.fromScript( - DepositScript.fromReceipt(deposit) - ) - - bitcoinClient.rawTransactions = rawTransactions - ;({ transactionHash } = await depositRefund.submitTransaction( - bitcoinClient, - fee, - utxo, - refunderAddress, - refunderPrivateKey - )) - }) - - it("should broadcast refund transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress - .expectedRefund.transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositRefundOfWitnessDepositAndNonWitnessRefunderAddress - .expectedRefund.transactionHash - ) - }) - } - ) - }) - }) -}) diff --git a/typescript/test/deposit-sweep.test.ts b/typescript/test/deposit-sweep.test.ts deleted file mode 100644 index 54965e208..000000000 --- a/typescript/test/deposit-sweep.test.ts +++ /dev/null @@ -1,1140 +0,0 @@ -import { BigNumber } from "ethers" -import { - BitcoinNetwork, - BitcoinRawTx, - BitcoinTxHash, - BitcoinUtxo, - BitcoinTx, - MaintenanceService, - WalletTx, -} from "../src" -import { testnetWalletAddress, testnetWalletPrivateKey } from "./data/deposit" -import { - depositSweepWithWitnessMainUtxoAndWitnessOutput, - depositSweepWithNoMainUtxoAndWitnessOutput, - depositSweepWithNoMainUtxoAndNonWitnessOutput, - depositSweepWithNonWitnessMainUtxoAndWitnessOutput, - depositSweepProof, - NO_MAIN_UTXO, -} from "./data/deposit-sweep" -import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import * as chai from "chai" -import chaiAsPromised from "chai-as-promised" -chai.use(chaiAsPromised) -import { expect } from "chai" -import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" -import { txToJSON } from "./utils/helpers" - -describe("Sweep", () => { - const fee = BigNumber.from(1600) - - describe("WalletTx", () => { - describe("DepositSweep", () => { - describe("submitTransaction", () => { - let tbtcContracts: MockTBTCContracts - let bitcoinClient: MockBitcoinClient - - beforeEach(async () => { - tbtcContracts = new MockTBTCContracts() - bitcoinClient = new MockBitcoinClient() - }) - - context("when the new main UTXO is requested to be witness", () => { - context( - "when there is no main UTXO from previous deposit sweep", - () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - - beforeEach(async () => { - // Map transaction hashes for UTXOs to transactions in hexadecimal and - // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() - for (const deposit of depositSweepWithNoMainUtxoAndWitnessOutput.deposits) { - rawTransactions.set(deposit.utxo.transactionHash.toString(), { - transactionHex: deposit.utxo.transactionHex, - }) - } - bitcoinClient.rawTransactions = rawTransactions - - const utxos: BitcoinUtxo[] = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( - (data) => { - return data.utxo - } - ) - - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) - const witness = - depositSweepWithNoMainUtxoAndWitnessOutput.witness - - const walletTx = new WalletTx( - tbtcContracts, - bitcoinClient, - witness - ) - - ;({ transactionHash, newMainUtxo } = - await walletTx.depositSweep.submitTransaction( - fee, - testnetWalletPrivateKey, - utxos, - deposit - )) - }) - - it("should broadcast sweep transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transactionHash, - outputIndex: 0, - value: BigNumber.from(35400), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - - context("when there is main UTXO from previous deposit sweep", () => { - context( - "when main UTXO from previous deposit sweep is witness", - () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - - beforeEach(async () => { - // Map transaction hashes for UTXOs to transactions in hexadecimal and - // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() - for (const deposit of depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits) { - rawTransactions.set( - deposit.utxo.transactionHash.toString(), - { - transactionHex: deposit.utxo.transactionHex, - } - ) - } - // The main UTXO resulting from another data set was used as input. - // Set raw data of that main UTXO as well. - rawTransactions.set( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString(), - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transaction - ) - bitcoinClient.rawTransactions = rawTransactions - - const utxos: BitcoinUtxo[] = - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.utxo - } - ) - - const deposit = - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) - - const witness = - depositSweepWithWitnessMainUtxoAndWitnessOutput.witness - - const mainUtxo = - depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo - - const walletTx = new WalletTx( - tbtcContracts, - bitcoinClient, - witness - ) - - ;({ transactionHash, newMainUtxo } = - await walletTx.depositSweep.submitTransaction( - fee, - testnetWalletPrivateKey, - utxos, - deposit, - mainUtxo - )) - }) - - it("should broadcast sweep transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositSweepWithWitnessMainUtxoAndWitnessOutput - .expectedSweep.transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash, - outputIndex: 0, - value: BigNumber.from(60800), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - - context( - "when main UTXO from previous deposit sweep is non-witness", - () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - - beforeEach(async () => { - // Map transaction hashes for UTXOs to transactions in hexadecimal and - // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() - for (const deposit of depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits) { - rawTransactions.set( - deposit.utxo.transactionHash.toString(), - { - transactionHex: deposit.utxo.transactionHex, - } - ) - } - rawTransactions.set( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString(), - { - transactionHex: - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .mainUtxo.transactionHex, - } - ) - bitcoinClient.rawTransactions = rawTransactions - - const utxos: BitcoinUtxo[] = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.utxo - } - ) - - const deposit = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) - - const witness = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.witness - - const mainUtxo = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo - - const walletTx = new WalletTx( - tbtcContracts, - bitcoinClient, - witness - ) - - ;({ transactionHash, newMainUtxo } = - await walletTx.depositSweep.submitTransaction( - fee, - testnetWalletPrivateKey, - utxos, - deposit, - mainUtxo - )) - }) - - it("should broadcast sweep transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .expectedSweep.transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash, - outputIndex: 0, - value: BigNumber.from(33800), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - }) - }) - - context("when the new main UTXO is requested to be non-witness", () => { - // The only difference between deposit sweep transactions with witness and - // non-witness output is the output type itself. - // Therefore only one test case was added for non-witness transactions. - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - - beforeEach(async () => { - // Map transaction hashes for UTXOs to transactions in hexadecimal and - // set the mapping in the mock Bitcoin client - const rawTransactions = new Map() - for (const deposit of depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits) { - rawTransactions.set(deposit.utxo.transactionHash.toString(), { - transactionHex: deposit.utxo.transactionHex, - }) - } - bitcoinClient.rawTransactions = rawTransactions - - const utxos = - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( - (data) => { - return data.utxo - } - ) - - const deposits = - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) - const witness = - depositSweepWithNoMainUtxoAndNonWitnessOutput.witness - - const walletTx = new WalletTx(tbtcContracts, bitcoinClient, witness) - - ;({ transactionHash, newMainUtxo } = - await walletTx.depositSweep.submitTransaction( - fee, - testnetWalletPrivateKey, - utxos, - deposits - )) - }) - - it("should broadcast sweep transaction with proper structure", async () => { - expect(bitcoinClient.broadcastLog.length).to.be.equal(1) - expect(bitcoinClient.broadcastLog[0]).to.be.eql( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transaction - ) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transactionHash, - outputIndex: 0, - value: BigNumber.from(13400), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - }) - }) - - describe("assembleTransaction", () => { - let tbtcContracts: MockTBTCContracts - let bitcoinClient: MockBitcoinClient - - beforeEach(async () => { - tbtcContracts = new MockTBTCContracts() - bitcoinClient = new MockBitcoinClient() - }) - - context("when the new main UTXO is requested to be witness", () => { - context( - "when there is no main UTXO from previous deposit sweep", - () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - let transaction: BitcoinRawTx - - const utxosWithRaw = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( - (data) => { - return data.utxo - } - ) - - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) - - const witness = depositSweepWithNoMainUtxoAndWitnessOutput.witness - - const walletTx = new WalletTx( - tbtcContracts, - bitcoinClient, - witness - ) - - beforeEach(async () => { - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await walletTx.depositSweep.assembleTransaction( - BitcoinNetwork.Testnet, - fee, - testnetWalletPrivateKey, - utxosWithRaw, - deposit - )) - }) - - it("should return sweep transaction with proper structure", () => { - // Compare HEXes. - expect(transaction).to.be.eql( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transaction - ) - - // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) - - expect(txJSON.hash).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) - - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(2) - - const p2shInput = txJSON.inputs[0] - expect(p2shInput.hash).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() - ) - expect(p2shInput.index).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo - .outputIndex - ) - // Transaction should be signed. As it's not SegWit input, the `witness` - // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.empty - expect(p2shInput.script.length).to.be.greaterThan(0) - - const p2wshInput = txJSON.inputs[1] - expect(p2wshInput.hash).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() - ) - expect(p2wshInput.index).to.be.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo - .outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wshInput.witness.length).to.be.greaterThan(0) - expect(p2wshInput.script.length).to.be.equal(0) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(1) - const sweepOutput = txJSON.outputs[0] - - // Should be OP_0 . Public key corresponds to the - // wallet BTC address. - expect(sweepOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - // The output's address should be the wallet's address - expect(sweepOutput.address).to.be.equal(testnetWalletAddress) - // The output's value should be equal to the sum of all input values - // minus fee (25000 + 12000 - 1600) - expect(sweepOutput.value).to.be.equal(35400) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep - .transactionHash, - outputIndex: 0, - value: BigNumber.from(35400), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - - context("when there is main UTXO from previous deposit sweep", () => { - context( - "when main UTXO prom previous deposit sweep is witness", - () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - let transaction: BitcoinRawTx - - const utxosWithRaw = - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.utxo - } - ) - - const deposit = - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) - - // P2WPKH - const mainUtxoWithRaw = - depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo - - const witness = - depositSweepWithWitnessMainUtxoAndWitnessOutput.witness - - const walletTx = new WalletTx( - tbtcContracts, - bitcoinClient, - witness - ) - - beforeEach(async () => { - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await walletTx.depositSweep.assembleTransaction( - BitcoinNetwork.Testnet, - fee, - testnetWalletPrivateKey, - utxosWithRaw, - deposit, - mainUtxoWithRaw - )) - }) - - it("should return sweep transaction with proper structure", () => { - // Compare HEXes. - expect(transaction).to.be.eql( - depositSweepWithWitnessMainUtxoAndWitnessOutput - .expectedSweep.transaction - ) - - // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) - - expect(txJSON.hash).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) - - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(3) - - const p2wkhInput = txJSON.inputs[0] - expect(p2wkhInput.hash).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() - ) - expect(p2wkhInput.index).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo - .outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wkhInput.witness.length).to.be.greaterThan(0) - expect(p2wkhInput.script.length).to.be.equal(0) - - const p2shInput = txJSON.inputs[1] - expect(p2shInput.hash).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() - ) - expect(p2shInput.index).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0] - .utxo.outputIndex - ) - // Transaction should be signed. As it's not SegWit input, the `witness` - // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.empty - expect(p2shInput.script.length).to.be.greaterThan(0) - - const p2wshInput = txJSON.inputs[2] - expect(p2wshInput.hash).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() - ) - expect(p2wshInput.index).to.be.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1] - .utxo.outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wshInput.witness.length).to.be.greaterThan(0) - expect(p2wshInput.script.length).to.be.equal(0) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(1) - - const sweepOutput = txJSON.outputs[0] - // Should be OP_0 . Public key corresponds to the - // wallet BTC address. - expect(sweepOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - // The output's address should be the wallet's address - expect(sweepOutput.address).to.be.equal(testnetWalletAddress) - // The output's value should be equal to the sum of all input values - // minus fee (17000 + 10000 + 35400 - 1600) - expect(sweepOutput.value).to.be.equal(60800) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash, - outputIndex: 0, - value: BigNumber.from(60800), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - - context( - "when main UTXO from previous deposit sweep is non-witness", - () => { - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - let transaction: BitcoinRawTx - - const utxosWithRaw = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.utxo - } - ) - - const deposit = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) - - // P2WPKH - const mainUtxoWithRaw = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo - - const witness = - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.witness - - const walletTx = new WalletTx( - tbtcContracts, - bitcoinClient, - witness - ) - - beforeEach(async () => { - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await walletTx.depositSweep.assembleTransaction( - BitcoinNetwork.Testnet, - fee, - testnetWalletPrivateKey, - utxosWithRaw, - deposit, - mainUtxoWithRaw - )) - }) - - it("should return sweep transaction with proper structure", () => { - // Compare HEXes. - expect(transaction).to.be.eql( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .expectedSweep.transaction - ) - - // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) - - expect(txJSON.hash).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) - - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(2) - - const p2pkhInput = txJSON.inputs[0] // main UTXO - expect(p2pkhInput.hash).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() - ) - expect(p2pkhInput.index).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo - .outputIndex - ) - // Transaction should be signed. As it's not SegWit input, the `witness` - // field should be empty, while the `script` field should be filled. - expect(p2pkhInput.witness).to.be.empty - expect(p2pkhInput.script.length).to.be.greaterThan(0) - - const p2wshInput = txJSON.inputs[1] - expect(p2wshInput.hash).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() - ) - expect(p2wshInput.index).to.be.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .deposits[0].utxo.outputIndex - ) - // Transaction should be signed. As it's a SegWit input, the `witness` - // field should be filled, while the `script` field should be empty. - expect(p2wshInput.witness.length).to.be.greaterThan(0) - expect(p2wshInput.script.length).to.be.equal(0) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(1) - - const sweepOutput = txJSON.outputs[0] - // Should be OP_0 . Public key corresponds to the - // wallet BTC address. - expect(sweepOutput.script).to.be.equal( - "00148db50eb52063ea9d98b3eac91489a90f738986f6" - ) - // The output's address should be the wallet's address - expect(sweepOutput.address).to.be.equal(testnetWalletAddress) - // The output's value should be equal to the sum of all input values - // minus fee (16400 + 19000 - 1600) - expect(sweepOutput.value).to.be.equal(33800) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNonWitnessMainUtxoAndWitnessOutput - .expectedSweep.transactionHash, - outputIndex: 0, - value: BigNumber.from(33800), - } - - expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) - }) - } - ) - }) - }) - - context("when the new main UTXO is requested to be non-witness", () => { - // The only difference between deposit sweep transactions with witness and - // non-witness output is the output type itself. - // Therefore only one test case was added for non-witness transactions. - let transactionHash: BitcoinTxHash - let newMainUtxo: BitcoinUtxo - let transaction: BitcoinRawTx - - const utxosWithRaw = - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( - (deposit) => { - return deposit.utxo - } - ) - - const deposit = - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( - (deposit) => { - return deposit.data - } - ) - - const witness = depositSweepWithNoMainUtxoAndNonWitnessOutput.witness - - const walletTx = new WalletTx(tbtcContracts, bitcoinClient, witness) - - beforeEach(async () => { - ;({ - transactionHash, - newMainUtxo, - rawTransaction: transaction, - } = await walletTx.depositSweep.assembleTransaction( - BitcoinNetwork.Testnet, - fee, - testnetWalletPrivateKey, - utxosWithRaw, - deposit - )) - }) - - it("should return sweep transaction with proper structure", () => { - // Compare HEXes. - expect(transaction).to.be.eql( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transaction - ) - - // Convert raw transaction to JSON to make detailed comparison. - const txJSON = txToJSON( - transaction.transactionHex, - BitcoinNetwork.Testnet - ) - - expect(txJSON.hash).to.be.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep.transactionHash.toString() - ) - expect(txJSON.version).to.be.equal(1) - - // Validate inputs. - expect(txJSON.inputs.length).to.be.equal(1) - - const p2shInput = txJSON.inputs[0] - expect(p2shInput.hash).to.be.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo.transactionHash.toString() - ) - expect(p2shInput.index).to.be.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo - .outputIndex - ) - // Transaction should be signed. As it's not SegWit input, the `witness` - // field should be empty, while the `script` field should be filled. - expect(p2shInput.witness).to.be.empty - expect(p2shInput.script.length).to.be.greaterThan(0) - - // Validate outputs. - expect(txJSON.outputs.length).to.be.equal(1) - - const sweepOutput = txJSON.outputs[0] - // OP_DUP OP_HASH160 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 - // OP_EQUALVERIFY OP_CHECKSIG - expect(sweepOutput.script).to.be.equal( - "76a9148db50eb52063ea9d98b3eac91489a90f738986f688ac" - ) - // The output's address should be the wallet's address - expect(sweepOutput.address).to.be.equal( - "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" - ) - // The output's value should be equal to the sum of all input values - // minus fee (15000- 1600) - expect(sweepOutput.value).to.be.equal(13400) - }) - - it("should return the proper transaction hash", async () => { - expect(transactionHash).to.be.deep.equal( - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transactionHash - ) - }) - - it("should return the proper new main UTXO", () => { - const expectedNewMainUtxo = { - transactionHash: - depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep - .transactionHash, - outputIndex: 0, - value: BigNumber.from(13400), - } - - expect(newMainUtxo).to.be.deep.equal(expectedNewMainUtxo) - }) - }) - - context("when there are no UTXOs", () => { - it("should revert", async () => { - const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - - await expect( - walletTx.depositSweep.assembleTransaction( - BitcoinNetwork.Testnet, - fee, - testnetWalletPrivateKey, - [], - [] - ) - ).to.be.rejectedWith( - "There must be at least one deposit UTXO to sweep" - ) - }) - }) - - context( - "when the numbers of UTXOs and deposit elements are not equal", - () => { - const utxosWithRaw = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( - (data) => { - return data.utxo - } - ) - - // Add only one element to the deposit - const deposit = [ - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data, - ] - - const witness = depositSweepWithNoMainUtxoAndWitnessOutput.witness - - it("should revert", async () => { - const walletTx = new WalletTx( - tbtcContracts, - bitcoinClient, - witness - ) - - await expect( - walletTx.depositSweep.assembleTransaction( - BitcoinNetwork.Testnet, - fee, - testnetWalletPrivateKey, - utxosWithRaw, - deposit - ) - ).to.be.rejectedWith( - "Number of UTXOs must equal the number of deposit elements" - ) - }) - } - ) - - context("when the main UTXO does not belong to the wallet", () => { - const utxoWithRaw = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data - - // The UTXO below does not belong to the wallet - const mainUtxoWithRaw = { - transactionHash: BitcoinTxHash.from( - "2f952bdc206bf51bb745b967cb7166149becada878d3191ffe341155ebcd4883" - ), - outputIndex: 1, - value: BigNumber.from(3933200), - transactionHex: - "0100000000010162cae24e74ad64f9f0493b09f3964908b3b3038f4924882d3d" + - "bd853b4c9bc7390100000000ffffffff02102700000000000017a914867120d5" + - "480a9cc0c11c1193fa59b3a92e852da78710043c00000000001600147ac2d937" + - "8a1c47e589dfb8095ca95ed2140d272602483045022100b70bd9b7f5d230444a" + - "542c7971bea79786b4ebde6703cee7b6ee8cd16e115ebf02204d50ea9d1ee08d" + - "e9741498c2cc64266e40d52c4adb9ef68e65aa2727cd4208b5012102ee067a02" + - "73f2e3ba88d23140a24fdb290f27bbcd0f94117a9c65be3911c5c04e00000000", - } - - it("should revert", async () => { - const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - - await expect( - walletTx.depositSweep.assembleTransaction( - BitcoinNetwork.Testnet, - fee, - testnetWalletPrivateKey, - [utxoWithRaw], - [deposit], - mainUtxoWithRaw - ) - ).to.be.rejectedWith("UTXO does not belong to the wallet") - }) - }) - - context( - "when the wallet private does not correspond to the wallet public key", - () => { - const utxoWithRaw = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data - const anotherPrivateKey = - "cRJvyxtoggjAm9A94cB86hZ7Y62z2ei5VNJHLksFi2xdnz1GJ6xt" - - it("should revert", async () => { - const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - - await expect( - walletTx.depositSweep.assembleTransaction( - BitcoinNetwork.Testnet, - fee, - anotherPrivateKey, - [utxoWithRaw], - [deposit] - ) - ).to.be.rejectedWith( - "Wallet public key does not correspond to wallet private key" - ) - }) - } - ) - - context("when the type of UTXO is unsupported", () => { - // Use coinbase transaction of some block - const utxoWithRaw = { - transactionHash: BitcoinTxHash.from( - "025de155e6f2ffbbf4851493e0d28dad54020db221a3f38bf63c1f65e3d3595b" - ), - outputIndex: 0, - value: BigNumber.from(5000000000), - transactionHex: - "010000000100000000000000000000000000000000000000000000000000000000" + - "00000000ffffffff0e04db07c34f0103062f503253482fffffffff0100f2052a01" + - "000000232102db6a0f2ef2e970eb1d2a84eabb5337f9cac0d85b49f209bffc4ec6" + - "805802e6a5ac00000000", - } - const deposit = - depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data - - it("should revert", async () => { - const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - - await expect( - walletTx.depositSweep.assembleTransaction( - BitcoinNetwork.Testnet, - fee, - testnetWalletPrivateKey, - [utxoWithRaw], - [deposit] - ) - ).to.be.rejectedWith("Unsupported UTXO script type") - }) - }) - }) - }) - }) - - describe("Spv", () => { - describe("submitDepositSweepProof", () => { - let bitcoinClient: MockBitcoinClient - let tbtcContracts: MockTBTCContracts - let maintenanceService: MaintenanceService - - beforeEach(async () => { - bitcoinClient = new MockBitcoinClient() - tbtcContracts = new MockTBTCContracts() - - maintenanceService = new MaintenanceService( - tbtcContracts, - bitcoinClient - ) - - const transactionHash = - depositSweepProof.bitcoinChainData.transaction.transactionHash - const transactions = new Map() - transactions.set( - transactionHash.toString(), - depositSweepProof.bitcoinChainData.transaction - ) - bitcoinClient.transactions = transactions - - const rawTransactions = new Map() - rawTransactions.set( - transactionHash.toString(), - depositSweepProof.bitcoinChainData.rawTransaction - ) - bitcoinClient.rawTransactions = rawTransactions - - bitcoinClient.latestHeight = - depositSweepProof.bitcoinChainData.latestBlockHeight - bitcoinClient.headersChain = - depositSweepProof.bitcoinChainData.headersChain - bitcoinClient.transactionMerkle = - depositSweepProof.bitcoinChainData.transactionMerkleBranch - const confirmations = new Map() - confirmations.set( - transactionHash.toString(), - depositSweepProof.bitcoinChainData.accumulatedTxConfirmations - ) - bitcoinClient.confirmations = confirmations - await maintenanceService.spv.submitDepositSweepProof( - transactionHash, - NO_MAIN_UTXO - ) - }) - - it("should submit deposit sweep proof with correct arguments", () => { - const bridgeLog = tbtcContracts.bridge.depositSweepProofLog - expect(bridgeLog.length).to.equal(1) - expect(bridgeLog[0].mainUtxo).to.equal(NO_MAIN_UTXO) - expect(bridgeLog[0].sweepTx).to.deep.equal( - depositSweepProof.expectedSweepProof.sweepTx - ) - expect(bridgeLog[0].sweepProof.txIndexInBlock).to.deep.equal( - depositSweepProof.expectedSweepProof.sweepProof.txIndexInBlock - ) - expect(bridgeLog[0].sweepProof.merkleProof).to.deep.equal( - depositSweepProof.expectedSweepProof.sweepProof.merkleProof - ) - expect(bridgeLog[0].sweepProof.bitcoinHeaders).to.deep.equal( - depositSweepProof.expectedSweepProof.sweepProof.bitcoinHeaders - ) - }) - }) - }) -}) diff --git a/typescript/test/electrum.test.ts b/typescript/test/electrum.test.ts deleted file mode 100644 index 6d8ff8730..000000000 --- a/typescript/test/electrum.test.ts +++ /dev/null @@ -1,290 +0,0 @@ -import { - BitcoinNetwork, - ElectrumCredentials, - ElectrumClient, - computeElectrumScriptHash, -} from "../src" -import { - testnetAddress, - testnetHeadersChain, - testnetRawTransaction, - testnetTransaction, - testnetTransactionMerkleBranch, - testnetUTXO, -} from "./data/electrum" -import { expect } from "chai" -import https from "https" - -const BLOCKSTREAM_TESTNET_API_URL = "https://blockstream.info/testnet/api" - -const testnetCredentials: ElectrumCredentials[] = [ - // FIXME: Enable all protocols test for test.tbtc.network servers once they are - // publicly exposed. - // // electrumx tcp - // { - // host: "electrumx-server.test.tbtc.network", - // port: 80, - // protocol: "tcp", - // }, - // electrumx ssl - // { - // host: "electrumx-server.test.tbtc.network", - // port: 443, - // protocol: "ssl", - // }, - // electrumx ws - // { - // host: "electrumx-server.test.tbtc.network", - // port: 8080, - // protocol: "ws", - // }, - // electrumx wss - { - host: "electrumx-server.test.tbtc.network", - port: 8443, - protocol: "wss", - }, - // electrs-esplora tcp - { - host: "electrum.blockstream.info", - port: 60001, - protocol: "tcp", - }, - // FIXME: https://github.com/keep-network/tbtc-v2/issues/502 - // // electrs-esplora ssl - // { - // host: "electrum.blockstream.info", - // port: 60002, - // protocol: "ssl", - // }, - // fulcrum tcp - { - host: "testnet.aranguren.org", - port: 51001, - protocol: "tcp", - }, - // FIXME: https://github.com/keep-network/tbtc-v2/issues/502 - // fulcrum ssl - // { - // host: "testnet.aranguren.org", - // port: 51002, - // protocol: "ssl", - // }, -] - -/** - * This test suite is meant to check the behavior of the Electrum-based - * Bitcoin client implementation. This suite requires an integration with a - * real testnet Electrum server. That requirement makes those tests - * time-consuming and vulnerable to external service health fluctuations. - * Because of that, they are skipped by default and should be run only - * on demand. Worth noting this test suite does not provide full coverage - * of all Electrum client functions. The `broadcast` function is not covered - * since it requires a proper Bitcoin transaction hex for each run which is - * out of scope of this suite. The `broadcast` function was tested manually - * though. - */ -describe.skip("Electrum", () => { - testnetCredentials.forEach((credentials) => { - describe(`${credentials.protocol}://${credentials.host}:${credentials.port}`, async () => { - let electrumClient: ElectrumClient - - before(async () => { - electrumClient = new ElectrumClient([credentials]) - }) - - describe("getNetwork", () => { - it("should return proper network", async () => { - const result = await electrumClient.getNetwork() - expect(result).to.be.eql(BitcoinNetwork.Testnet) - }) - }) - - describe("findAllUnspentTransactionOutputs", () => { - it("should return proper UTXOs for the given address", async () => { - const result = await electrumClient.findAllUnspentTransactionOutputs( - testnetAddress - ) - expect(result).to.be.eql([testnetUTXO]) - }) - }) - - describe("getTransactionHistory", () => { - it("should return proper transaction history for the given address", async () => { - // https://live.blockcypher.com/btc-testnet/address/tb1qumuaw3exkxdhtut0u85latkqfz4ylgwstkdzsx - const transactions = await electrumClient.getTransactionHistory( - "tb1qumuaw3exkxdhtut0u85latkqfz4ylgwstkdzsx", - 5 - ) - - const transactionsHashes = transactions.map((t) => - t.transactionHash.toString() - ) - - expect(transactionsHashes).to.be.eql([ - "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1", - "f65bc5029251f0042aedb37f90dbb2bfb63a2e81694beef9cae5ec62e954c22e", - "44863a79ce2b8fec9792403d5048506e50ffa7338191db0e6c30d3d3358ea2f6", - "4c6b33b7c0550e0e536a5d119ac7189d71e1296fcb0c258e0c115356895bc0e6", - "605edd75ae0b4fa7cfc7aae8f1399119e9d7ecc212e6253156b60d60f4925d44", - ]) - }) - }) - - describe("getTransaction", () => { - it("should return proper transaction for the given hash", async () => { - const result = await electrumClient.getTransaction( - testnetTransaction.transactionHash - ) - expect(result).to.be.eql(testnetTransaction) - }) - - // TODO: Add case when transaction doesn't exist. - }) - - describe("getRawTransaction", () => { - it("should return proper raw transaction for the given hash", async () => { - const result = await electrumClient.getRawTransaction( - testnetTransaction.transactionHash - ) - expect(result).to.be.eql(testnetRawTransaction) - }) - }) - - describe("getTransactionConfirmations", () => { - let result: number - - before(async () => { - result = await electrumClient.getTransactionConfirmations( - testnetTransaction.transactionHash - ) - }) - - it("should return value greater than 6", async () => { - // Strict comparison is not possible as the number of confirmations - // constantly grows. We just make sure it's 6+. - expect(result).to.be.greaterThan(6) - }) - - // This test depends on `latestBlockHeight` function. - it("should return proper confirmations number for the given hash", async () => { - const latestBlockHeight = await electrumClient.latestBlockHeight() - - const expectedResult = - latestBlockHeight - testnetTransactionMerkleBranch.blockHeight - - expect(result).to.be.closeTo(expectedResult, 3) - }) - }) - - describe("latestBlockHeight", () => { - let result: number - - before(async () => { - result = await electrumClient.latestBlockHeight() - }) - - it("should return value greater than 6", async () => { - // Strict comparison is not possible as the latest block height - // constantly grows. We just make sure it's bigger than 0. - expect(result).to.be.greaterThan(0) - }) - - // This test depends on fetching the expected latest block height from Blockstream API. - // It can fail if Blockstream API is down or if Blockstream API or if - // Electrum Server used in tests is out-of-sync with the Blockstream API. - it("should return proper latest block height", async () => { - const expectedResult = await getExpectedLatestBlockHeight() - - expect(result).to.be.closeTo(expectedResult, 3) - }) - }) - - describe("getHeadersChain", () => { - it("should return proper headers chain", async () => { - const result = await electrumClient.getHeadersChain( - testnetHeadersChain.blockHeight, - testnetHeadersChain.headersChainLength - ) - expect(result).to.be.eql(testnetHeadersChain.headersChain) - }) - }) - - describe("getTransactionMerkle", () => { - it("should return proper transaction merkle", async () => { - const result = await electrumClient.getTransactionMerkle( - testnetTransaction.transactionHash, - testnetTransactionMerkleBranch.blockHeight - ) - expect(result).to.be.eql(testnetTransactionMerkleBranch) - }) - }) - - describe("computeElectrumScriptHash", () => { - it("should convert Bitcoin script to an Electrum script hash correctly", () => { - const script = "00144b47c798d12edd17dfb4ea98e5447926f664731c" - const expectedScriptHash = - "cabdea0bfc10fb3521721dde503487dd1f0e41dd6609da228066757563f292ab" - - expect(computeElectrumScriptHash(script)).to.be.equal( - expectedScriptHash - ) - }) - }) - }) - }) - - describe("fallback connection", async () => { - let electrumClient: ElectrumClient - - before(async () => { - electrumClient = new ElectrumClient( - [ - // Invalid server - { - host: "non-existing-host.local", - port: 50001, - protocol: "tcp", - }, - // Valid server - testnetCredentials[0], - ], - undefined, - 2, - 1000, - 2000 - ) - }) - - it("should establish connection with a fallback server", async () => { - const result = await electrumClient.getNetwork() - expect(result).to.be.eql(BitcoinNetwork.Testnet) - }) - }) -}) - -/** - * Gets the height of the last block fetched from the Blockstream API. - * @returns Height of the last block. - */ -function getExpectedLatestBlockHeight(): Promise { - return new Promise((resolve, reject) => { - https - .get(`${BLOCKSTREAM_TESTNET_API_URL}/blocks/tip/height`, (resp) => { - let data = "" - - // A chunk of data has been received. - resp.on("data", (chunk) => { - data += chunk - }) - - // The whole response has been received. Print out the result. - resp.on("end", () => { - resolve(JSON.parse(data)) - }) - }) - .on("error", (err) => { - reject(err) - }) - }) -} diff --git a/typescript/test/hex.test.ts b/typescript/test/hex.test.ts deleted file mode 100644 index 252f1a93d..000000000 --- a/typescript/test/hex.test.ts +++ /dev/null @@ -1,179 +0,0 @@ -import { assert } from "chai" -import { Hex } from "../src" - -describe("Hex", () => { - const stringUnprefixed = - "6e30e6da7a7881a70de2a1cf67b77f2f643e58eb0d055b0f5ef85802a9167727" - const stringPrefixed = - "0x6e30e6da7a7881a70de2a1cf67b77f2f643e58eb0d055b0f5ef85802a9167727" - const stringReversed = - "277716a90258f85e0f5b050deb583e642f7fb767cfa1e20da781787adae6306e" - - const validInputTests = [ - { - name: "unprefixed string", - input: stringUnprefixed, - expectedString: stringUnprefixed, - expectedPrefixedString: stringPrefixed, - }, - { - name: "prefixed string", - input: stringPrefixed, - expectedString: stringUnprefixed, - expectedPrefixedString: stringPrefixed, - }, - { - name: "prefixed uppercase string", - input: stringPrefixed.toUpperCase(), - expectedString: stringUnprefixed, - expectedPrefixedString: stringPrefixed, - }, - { - name: "string with leading and trailing zeros", - input: "00000a12d073c00000", - expectedString: "00000a12d073c00000", - expectedPrefixedString: "0x00000a12d073c00000", - }, - { - name: "empty string", - input: "", - expectedString: "", - expectedPrefixedString: "", - }, - { - name: "unprefixed buffer", - input: Buffer.from(stringUnprefixed, "hex"), - expectedString: stringUnprefixed, - expectedPrefixedString: stringPrefixed, - }, - { - name: "unprefixed uppercase buffer", - input: Buffer.from(stringUnprefixed.toUpperCase(), "hex"), - expectedString: stringUnprefixed, - expectedPrefixedString: stringPrefixed, - }, - { - name: "empty buffer", - input: Buffer.from("", "hex"), - expectedString: "", - expectedPrefixedString: "", - }, - ] - - const invalidInputTests = [ - { - name: "string with a character out of 0-9,a-z,A-Z", - input: "3a9f5G", - expectedErrorMessage: "invalid format of hex string", - }, - { - name: "string of odd length", - input: "ab12345", - expectedErrorMessage: "invalid length of hex string: 7", - }, - ] - - validInputTests.forEach( - ({ name, input, expectedString, expectedPrefixedString }) => { - context(`with input as ${name}`, () => { - const hex = Hex.from(input) - - describe("`${hex}`", () => { - it("should output expected string", () => { - const actual = `${hex}` - assert.equal(actual, expectedString) - }) - }) - - describe("toString", () => { - it("should output expected string", () => { - const actual = hex.toString() - assert.equal(actual, expectedString) - }) - }) - - describe("toPrefixedString", () => { - it("should output expected string", () => { - const actual = hex.toPrefixedString() - assert.equal(actual, expectedPrefixedString) - }) - }) - }) - } - ) - - invalidInputTests.forEach(({ name, input, expectedErrorMessage }) => { - context(`with input as ${name}`, () => { - it(`should throw error with message: ${expectedErrorMessage}`, () => { - assert.throws( - () => { - Hex.from(input) - }, - Error, - expectedErrorMessage - ) - }) - }) - }) - - describe("reverse", () => { - const hex = Hex.from(stringPrefixed) - const hexReversed = hex.reverse() - - it("should not modify source hex", () => { - assert.equal(hex.toString(), stringUnprefixed) - }) - - it("should reverse target hex", () => { - assert.equal(hexReversed.toString(), stringReversed) - }) - }) - - describe("toBuffer", () => { - const hex = Hex.from(stringPrefixed) - const expectedBuffer = Buffer.from(stringUnprefixed, "hex") - - it("should output a buffer", () => { - assert.deepEqual(hex.toBuffer(), expectedBuffer) - }) - - it("should not modify source hex when target buffer is changed", () => { - const buffer = hex.toBuffer() - buffer.reverse() - - assert.equal(hex.toString(), stringUnprefixed) - }) - }) - - describe("equals", () => { - const hexLowerCased = Hex.from(stringPrefixed.toLowerCase()) - const hexUpperCased = Hex.from(stringPrefixed.toUpperCase()) - - context("for the same values with matching cases", () => { - it("should return true", () => { - assert.isTrue(hexUpperCased.equals(hexUpperCased)) - }) - }) - - context("for the same values but not matching cases", () => { - it("should return true", () => { - assert.isTrue(hexLowerCased.equals(hexUpperCased)) - }) - }) - - context("for the same value but prefixed and unprefixed", () => { - it("should return true", () => { - assert.isTrue( - Hex.from(stringPrefixed).equals(Hex.from(stringUnprefixed)) - ) - }) - }) - - context("for different values", () => { - it("should return false", () => { - const otherValue: Hex = Hex.from(stringPrefixed.slice(-2)) - assert.isFalse(hexLowerCased.equals(otherValue)) - }) - }) - }) -}) diff --git a/typescript/test/bitcoin.test.ts b/typescript/test/lib/bitcoin.test.ts similarity index 62% rename from typescript/test/bitcoin.test.ts rename to typescript/test/lib/bitcoin.test.ts index 6b5b2f206..8483732ba 100644 --- a/typescript/test/bitcoin.test.ts +++ b/typescript/test/lib/bitcoin.test.ts @@ -7,17 +7,98 @@ import { BitcoinHeaderSerializer, BitcoinLocktimeUtils, BitcoinNetwork, + toBitcoinJsLibNetwork, BitcoinPublicKeyUtils, BitcoinScriptUtils, BitcoinTargetConverter, extractBitcoinRawTxVectors, Hex, -} from "../src" + BitcoinTxHash, + BitcoinTx, + BitcoinSpvProof, + assembleBitcoinSpvProof, + validateBitcoinSpvProof, +} from "../../src" import { BigNumber } from "ethers" -import { btcAddresses, btcAddressFromPublicKey } from "./data/bitcoin" -import { depositSweepWithNoMainUtxoAndWitnessOutput } from "./data/deposit-sweep" +import { btcAddresses, btcAddressFromPublicKey } from "../data/bitcoin" +import { depositSweepWithNoMainUtxoAndWitnessOutput } from "../data/deposit-sweep" +import { networks } from "bitcoinjs-lib" +import { MockBitcoinClient } from "../utils/mock-bitcoin-client" +import { + multipleInputsProofTestData, + ProofTestData, + singleInputProofTestData, + testnetTransactionData, + transactionConfirmationsInOneEpochData, + transactionConfirmationsInTwoEpochsData, + TransactionProofData, +} from "../data/proof" describe("Bitcoin", () => { + describe("BitcoinNetwork", () => { + const testData = [ + { + enumKey: BitcoinNetwork.Unknown, + enumValue: "unknown", + // any value that doesn't match other supported networks + genesisHash: BitcoinTxHash.from("0x00010203"), + expectedToBitcoinJsLibResult: new Error("network not supported"), + }, + { + enumKey: BitcoinNetwork.Testnet, + enumValue: "testnet", + genesisHash: BitcoinTxHash.from( + "0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943" + ), + expectedToBitcoinJsLibResult: networks.testnet, + }, + { + enumKey: BitcoinNetwork.Mainnet, + enumValue: "mainnet", + genesisHash: BitcoinTxHash.from( + "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" + ), + expectedToBitcoinJsLibResult: networks.bitcoin, + }, + ] + + testData.forEach( + ({ enumKey, enumValue, genesisHash, expectedToBitcoinJsLibResult }) => { + context(enumKey, async () => { + describe(`toString`, async () => { + it(`should return correct value`, async () => { + expect(enumKey.toString()).to.be.equal(enumValue) + }) + }) + + describe(`fromGenesisHash`, async () => { + it(`should resolve correct enum key`, async () => { + expect(BitcoinNetwork.fromGenesisHash(genesisHash)).to.be.equal( + enumKey + ) + }) + }) + + describe(`toBitcoinJsLibNetwork`, async () => { + if (expectedToBitcoinJsLibResult instanceof Error) { + it(`should throw an error`, async () => { + expect(() => toBitcoinJsLibNetwork(enumKey)).to.throw( + expectedToBitcoinJsLibResult.message + ) + }) + } else { + it(`should return ${expectedToBitcoinJsLibResult}`, async () => { + expect(toBitcoinJsLibNetwork(enumKey)).to.be.equal( + expectedToBitcoinJsLibResult + ) + }) + } + }) + }) + } + ) + }) + describe("BitcoinPublicKeyUtils", () => { const { compressPublicKey } = BitcoinPublicKeyUtils @@ -803,4 +884,373 @@ describe("Bitcoin", () => { expect(decomposedTransaction.locktime).to.be.equal("00000000") }) }) + + describe("assembleTransactionProof", () => { + let bitcoinClient: MockBitcoinClient + + beforeEach(async () => { + bitcoinClient = new MockBitcoinClient() + }) + + context("when the transaction has one input", () => { + let proof: BitcoinTx & BitcoinSpvProof + + beforeEach(async () => { + proof = await runProofScenario(singleInputProofTestData) + }) + + it("should return the correct value of the proof", async () => { + const expectedProof = singleInputProofTestData.expectedProof + expect(proof.transactionHash).to.be.deep.equal( + expectedProof.transactionHash + ) + expect(proof.inputs).to.deep.equal(expectedProof.inputs) + expect(proof.outputs).to.deep.equal(expectedProof.outputs) + expect(proof.merkleProof).to.equal(expectedProof.merkleProof) + expect(proof.txIndexInBlock).to.equal(expectedProof.txIndexInBlock) + expect(proof.bitcoinHeaders).to.equal(expectedProof.bitcoinHeaders) + }) + }) + + context("when the transaction has multiple inputs", () => { + let proof: BitcoinTx & BitcoinSpvProof + + beforeEach(async () => { + proof = await runProofScenario(multipleInputsProofTestData) + }) + + it("should return the correct value of the proof", async () => { + const expectedProof = multipleInputsProofTestData.expectedProof + expect(proof.transactionHash).to.deep.equal( + expectedProof.transactionHash + ) + expect(proof.inputs).to.deep.equal(expectedProof.inputs) + expect(proof.outputs).to.deep.equal(expectedProof.outputs) + expect(proof.merkleProof).to.equal(expectedProof.merkleProof) + expect(proof.txIndexInBlock).to.equal(expectedProof.txIndexInBlock) + expect(proof.bitcoinHeaders).to.equal(expectedProof.bitcoinHeaders) + }) + }) + + context("when the transaction does not have enough confirmations", () => { + let notEnoughConfirmationsSweepProofTestData: ProofTestData + + beforeEach(async () => { + notEnoughConfirmationsSweepProofTestData = singleInputProofTestData + notEnoughConfirmationsSweepProofTestData.bitcoinChainData.accumulatedTxConfirmations = 5 + }) + + it("should revert", async () => { + await expect( + runProofScenario(notEnoughConfirmationsSweepProofTestData) + ).to.be.rejectedWith( + "Transaction confirmations number[5] is not enough, required [6]" + ) + }) + }) + + async function runProofScenario( + data: ProofTestData + ): Promise { + const transactions = new Map() + const transactionHash = data.bitcoinChainData.transaction.transactionHash + transactions.set( + transactionHash.toString(), + data.bitcoinChainData.transaction + ) + bitcoinClient.transactions = transactions + bitcoinClient.latestHeight = data.bitcoinChainData.latestBlockHeight + bitcoinClient.headersChain = data.bitcoinChainData.headersChain + bitcoinClient.transactionMerkle = + data.bitcoinChainData.transactionMerkleBranch + const confirmations = new Map() + confirmations.set( + transactionHash.toString(), + data.bitcoinChainData.accumulatedTxConfirmations + ) + bitcoinClient.confirmations = confirmations + + const proof = await assembleBitcoinSpvProof( + transactionHash, + data.requiredConfirmations, + bitcoinClient + ) + + return proof + } + }) + + describe("validateTransactionProof", () => { + let bitcoinClient: MockBitcoinClient + + beforeEach(async () => { + bitcoinClient = new MockBitcoinClient() + }) + + context("when the transaction proof is correct", () => { + context("when the transaction is from Bitcoin Mainnet", () => { + context( + "when the transaction confirmations span only one epoch", + () => { + it("should not throw", async () => { + await expect( + runProofValidationScenario( + transactionConfirmationsInOneEpochData + ) + ).not.to.be.rejected + }) + } + ) + + context("when the transaction confirmations span two epochs", () => { + it("should not throw", async () => { + await expect( + runProofValidationScenario( + transactionConfirmationsInTwoEpochsData + ) + ).not.to.be.rejected + }) + }) + }) + + context("when the transaction is from Bitcoin Testnet", () => { + it("should not throw", async () => { + await expect(runProofValidationScenario(testnetTransactionData)).not + .to.be.rejected + }) + }) + }) + + context("when the transaction proof is incorrect", () => { + context("when the length of headers chain is incorrect", () => { + it("should throw", async () => { + // Corrupt data by adding additional byte to the headers chain. + const corruptedProofData: TransactionProofData = { + ...transactionConfirmationsInOneEpochData, + bitcoinChainData: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData, + headersChain: + transactionConfirmationsInOneEpochData.bitcoinChainData + .headersChain + "ff", + }, + } + await expect( + runProofValidationScenario(corruptedProofData) + ).to.be.rejectedWith("Incorrect length of Bitcoin headers") + }) + }) + + context( + "when the headers chain contains an incorrect number of headers", + () => { + // Corrupt the data by adding additional 80 bytes to the headers chain. + it("should throw", async () => { + const corruptedProofData: TransactionProofData = { + ...transactionConfirmationsInOneEpochData, + bitcoinChainData: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData, + headersChain: + transactionConfirmationsInOneEpochData.bitcoinChainData + .headersChain + "f".repeat(160), + }, + } + await expect( + runProofValidationScenario(corruptedProofData) + ).to.be.rejectedWith("Wrong number of confirmations") + }) + } + ) + + context("when the merkle proof is of incorrect length", () => { + it("should throw", async () => { + // Corrupt the data by adding a byte to the Merkle proof. + const merkle = [ + ...transactionConfirmationsInOneEpochData.bitcoinChainData + .transactionMerkleBranch.merkle, + ] + merkle[merkle.length - 1] += "ff" + + const corruptedProofData: TransactionProofData = { + ...transactionConfirmationsInOneEpochData, + bitcoinChainData: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData, + transactionMerkleBranch: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData + .transactionMerkleBranch, + merkle: merkle, + }, + }, + } + + await expect( + runProofValidationScenario(corruptedProofData) + ).to.be.rejectedWith("Incorrect length of Merkle proof") + }) + }) + + context("when the merkle proof is empty", () => { + it("should throw", async () => { + // Corrupt the data by making the Merkle proof empty. + const corruptedProofData: TransactionProofData = { + ...transactionConfirmationsInOneEpochData, + bitcoinChainData: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData, + transactionMerkleBranch: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData + .transactionMerkleBranch, + merkle: [], + }, + }, + } + + await expect( + runProofValidationScenario(corruptedProofData) + ).to.be.rejectedWith("Invalid merkle tree") + }) + }) + + context("when the merkle proof contains incorrect hash", () => { + it("should throw", async () => { + // Corrupt the data by changing a byte of one of the hashes in the + // Merkle proof. + const merkle = [ + ...transactionConfirmationsInOneEpochData.bitcoinChainData + .transactionMerkleBranch.merkle, + ] + + merkle[3] = "ff" + merkle[3].slice(2) + + const corruptedProofData: TransactionProofData = { + ...transactionConfirmationsInOneEpochData, + bitcoinChainData: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData, + transactionMerkleBranch: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData + .transactionMerkleBranch, + merkle: merkle, + }, + }, + } + + await expect( + runProofValidationScenario(corruptedProofData) + ).to.be.rejectedWith( + "Transaction Merkle proof is not valid for provided header and transaction hash" + ) + }) + }) + + context("when the block headers do not form a chain", () => { + it("should throw", async () => { + // Corrupt data by modifying previous block header hash of one of the + // headers. + const headers: BitcoinHeader[] = + BitcoinHeaderSerializer.deserializeHeadersChain( + transactionConfirmationsInOneEpochData.bitcoinChainData + .headersChain + ) + headers[headers.length - 1].previousBlockHeaderHash = Hex.from( + "ff".repeat(32) + ) + const corruptedHeadersChain: string = headers + .map(BitcoinHeaderSerializer.serializeHeader) + .join("") + + const corruptedProofData: TransactionProofData = { + ...transactionConfirmationsInOneEpochData, + bitcoinChainData: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData, + headersChain: corruptedHeadersChain, + }, + } + + await expect( + runProofValidationScenario(corruptedProofData) + ).to.be.rejectedWith("Invalid headers chain") + }) + }) + + context("when one of the block headers has insufficient work", () => { + it("should throw", async () => { + // Corrupt data by modifying the nonce of one of the headers, so that + // the resulting hash will be above the required difficulty target. + const headers: BitcoinHeader[] = + BitcoinHeaderSerializer.deserializeHeadersChain( + transactionConfirmationsInOneEpochData.bitcoinChainData + .headersChain + ) + headers[headers.length - 1].nonce++ + const corruptedHeadersChain: string = headers + .map(BitcoinHeaderSerializer.serializeHeader) + .join("") + + const corruptedProofData: TransactionProofData = { + ...transactionConfirmationsInOneEpochData, + bitcoinChainData: { + ...transactionConfirmationsInOneEpochData.bitcoinChainData, + headersChain: corruptedHeadersChain, + }, + } + + await expect( + runProofValidationScenario(corruptedProofData) + ).to.be.rejectedWith("Insufficient work in the header") + }) + }) + + context( + "when some of the block headers are not at current or previous difficulty", + () => { + it("should throw", async () => { + // Corrupt data by setting current difficulty to a different value + // than stored in block headers. + const corruptedProofData: TransactionProofData = { + ...transactionConfirmationsInTwoEpochsData, + bitcoinChainData: { + ...transactionConfirmationsInTwoEpochsData.bitcoinChainData, + currentDifficulty: + transactionConfirmationsInTwoEpochsData.bitcoinChainData.currentDifficulty.add( + 1 + ), + }, + } + + await expect( + runProofValidationScenario(corruptedProofData) + ).to.be.rejectedWith( + "Header difficulty not at current or previous Bitcoin difficulty" + ) + }) + } + ) + }) + + async function runProofValidationScenario(data: TransactionProofData) { + const transactions = new Map() + const transactionHash = data.bitcoinChainData.transaction.transactionHash + transactions.set( + transactionHash.toString(), + data.bitcoinChainData.transaction + ) + bitcoinClient.transactions = transactions + bitcoinClient.latestHeight = data.bitcoinChainData.latestBlockHeight + bitcoinClient.headersChain = data.bitcoinChainData.headersChain + bitcoinClient.transactionMerkle = + data.bitcoinChainData.transactionMerkleBranch + const confirmations = new Map() + confirmations.set( + transactionHash.toString(), + data.bitcoinChainData.accumulatedTxConfirmations + ) + bitcoinClient.confirmations = confirmations + + await validateBitcoinSpvProof( + data.bitcoinChainData.transaction.transactionHash, + data.requiredConfirmations, + data.bitcoinChainData.previousDifficulty, + data.bitcoinChainData.currentDifficulty, + bitcoinClient + ) + } + }) }) diff --git a/typescript/test/lib/electrum.test.ts b/typescript/test/lib/electrum.test.ts new file mode 100644 index 000000000..76f521fc0 --- /dev/null +++ b/typescript/test/lib/electrum.test.ts @@ -0,0 +1,293 @@ +import { + BitcoinNetwork, + ElectrumCredentials, + ElectrumClient, + computeElectrumScriptHash, +} from "../../src" +import { + testnetAddress, + testnetHeadersChain, + testnetRawTransaction, + testnetTransaction, + testnetTransactionMerkleBranch, + testnetUTXO, +} from "../data/electrum" +import { expect } from "chai" +import https from "https" + +const BLOCKSTREAM_TESTNET_API_URL = "https://blockstream.info/testnet/api" + +const testnetCredentials: ElectrumCredentials[] = [ + // FIXME: Enable all protocols test for test.tbtc.network servers once they are + // publicly exposed. + // // electrumx tcp + // { + // host: "electrumx-server.test.tbtc.network", + // port: 80, + // protocol: "tcp", + // }, + // electrumx ssl + // { + // host: "electrumx-server.test.tbtc.network", + // port: 443, + // protocol: "ssl", + // }, + // electrumx ws + // { + // host: "electrumx-server.test.tbtc.network", + // port: 8080, + // protocol: "ws", + // }, + // electrumx wss + { + host: "electrumx-server.test.tbtc.network", + port: 8443, + protocol: "wss", + }, + // electrs-esplora tcp + { + host: "electrum.blockstream.info", + port: 60001, + protocol: "tcp", + }, + // FIXME: https://github.com/keep-network/tbtc-v2/issues/502 + // // electrs-esplora ssl + // { + // host: "electrum.blockstream.info", + // port: 60002, + // protocol: "ssl", + // }, + // fulcrum tcp + { + host: "testnet.aranguren.org", + port: 51001, + protocol: "tcp", + }, + // FIXME: https://github.com/keep-network/tbtc-v2/issues/502 + // fulcrum ssl + // { + // host: "testnet.aranguren.org", + // port: 51002, + // protocol: "ssl", + // }, +] + +describe("Electrum", () => { + /** + * This test suite is meant to check the behavior of the Electrum-based + * Bitcoin client implementation. This suite requires an integration with a + * real testnet Electrum server. That requirement makes those tests + * time-consuming and vulnerable to external service health fluctuations. + * Because of that, they are skipped by default and should be run only + * on demand. Worth noting this test suite does not provide full coverage + * of all Electrum client functions. The `broadcast` function is not covered + * since it requires a proper Bitcoin transaction hex for each run which is + * out of scope of this suite. The `broadcast` function was tested manually + * though. + */ + describe.skip("ElectrumClient", () => { + testnetCredentials.forEach((credentials) => { + describe(`${credentials.protocol}://${credentials.host}:${credentials.port}`, async () => { + let electrumClient: ElectrumClient + + before(async () => { + electrumClient = new ElectrumClient([credentials]) + }) + + describe("getNetwork", () => { + it("should return proper network", async () => { + const result = await electrumClient.getNetwork() + expect(result).to.be.eql(BitcoinNetwork.Testnet) + }) + }) + + describe("findAllUnspentTransactionOutputs", () => { + it("should return proper UTXOs for the given address", async () => { + const result = + await electrumClient.findAllUnspentTransactionOutputs( + testnetAddress + ) + expect(result).to.be.eql([testnetUTXO]) + }) + }) + + describe("getTransactionHistory", () => { + it("should return proper transaction history for the given address", async () => { + // https://live.blockcypher.com/btc-testnet/address/tb1qumuaw3exkxdhtut0u85latkqfz4ylgwstkdzsx + const transactions = await electrumClient.getTransactionHistory( + "tb1qumuaw3exkxdhtut0u85latkqfz4ylgwstkdzsx", + 5 + ) + + const transactionsHashes = transactions.map((t) => + t.transactionHash.toString() + ) + + expect(transactionsHashes).to.be.eql([ + "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1", + "f65bc5029251f0042aedb37f90dbb2bfb63a2e81694beef9cae5ec62e954c22e", + "44863a79ce2b8fec9792403d5048506e50ffa7338191db0e6c30d3d3358ea2f6", + "4c6b33b7c0550e0e536a5d119ac7189d71e1296fcb0c258e0c115356895bc0e6", + "605edd75ae0b4fa7cfc7aae8f1399119e9d7ecc212e6253156b60d60f4925d44", + ]) + }) + }) + + describe("getTransaction", () => { + it("should return proper transaction for the given hash", async () => { + const result = await electrumClient.getTransaction( + testnetTransaction.transactionHash + ) + expect(result).to.be.eql(testnetTransaction) + }) + + // TODO: Add case when transaction doesn't exist. + }) + + describe("getRawTransaction", () => { + it("should return proper raw transaction for the given hash", async () => { + const result = await electrumClient.getRawTransaction( + testnetTransaction.transactionHash + ) + expect(result).to.be.eql(testnetRawTransaction) + }) + }) + + describe("getTransactionConfirmations", () => { + let result: number + + before(async () => { + result = await electrumClient.getTransactionConfirmations( + testnetTransaction.transactionHash + ) + }) + + it("should return value greater than 6", async () => { + // Strict comparison is not possible as the number of confirmations + // constantly grows. We just make sure it's 6+. + expect(result).to.be.greaterThan(6) + }) + + // This test depends on `latestBlockHeight` function. + it("should return proper confirmations number for the given hash", async () => { + const latestBlockHeight = await electrumClient.latestBlockHeight() + + const expectedResult = + latestBlockHeight - testnetTransactionMerkleBranch.blockHeight + + expect(result).to.be.closeTo(expectedResult, 3) + }) + }) + + describe("latestBlockHeight", () => { + let result: number + + before(async () => { + result = await electrumClient.latestBlockHeight() + }) + + it("should return value greater than 6", async () => { + // Strict comparison is not possible as the latest block height + // constantly grows. We just make sure it's bigger than 0. + expect(result).to.be.greaterThan(0) + }) + + // This test depends on fetching the expected latest block height from Blockstream API. + // It can fail if Blockstream API is down or if Blockstream API or if + // Electrum Server used in tests is out-of-sync with the Blockstream API. + it("should return proper latest block height", async () => { + const expectedResult = await getExpectedLatestBlockHeight() + + expect(result).to.be.closeTo(expectedResult, 3) + }) + }) + + describe("getHeadersChain", () => { + it("should return proper headers chain", async () => { + const result = await electrumClient.getHeadersChain( + testnetHeadersChain.blockHeight, + testnetHeadersChain.headersChainLength + ) + expect(result).to.be.eql(testnetHeadersChain.headersChain) + }) + }) + + describe("getTransactionMerkle", () => { + it("should return proper transaction merkle", async () => { + const result = await electrumClient.getTransactionMerkle( + testnetTransaction.transactionHash, + testnetTransactionMerkleBranch.blockHeight + ) + expect(result).to.be.eql(testnetTransactionMerkleBranch) + }) + }) + + describe("computeElectrumScriptHash", () => { + it("should convert Bitcoin script to an Electrum script hash correctly", () => { + const script = "00144b47c798d12edd17dfb4ea98e5447926f664731c" + const expectedScriptHash = + "cabdea0bfc10fb3521721dde503487dd1f0e41dd6609da228066757563f292ab" + + expect(computeElectrumScriptHash(script)).to.be.equal( + expectedScriptHash + ) + }) + }) + }) + }) + + describe("fallback connection", async () => { + let electrumClient: ElectrumClient + + before(async () => { + electrumClient = new ElectrumClient( + [ + // Invalid server + { + host: "non-existing-host.local", + port: 50001, + protocol: "tcp", + }, + // Valid server + testnetCredentials[0], + ], + undefined, + 2, + 1000, + 2000 + ) + }) + + it("should establish connection with a fallback server", async () => { + const result = await electrumClient.getNetwork() + expect(result).to.be.eql(BitcoinNetwork.Testnet) + }) + }) + }) +}) + +/** + * Gets the height of the last block fetched from the Blockstream API. + * @returns Height of the last block. + */ +function getExpectedLatestBlockHeight(): Promise { + return new Promise((resolve, reject) => { + https + .get(`${BLOCKSTREAM_TESTNET_API_URL}/blocks/tip/height`, (resp) => { + let data = "" + + // A chunk of data has been received. + resp.on("data", (chunk) => { + data += chunk + }) + + // The whole response has been received. Print out the result. + resp.on("end", () => { + resolve(JSON.parse(data)) + }) + }) + .on("error", (err) => { + reject(err) + }) + }) +} diff --git a/typescript/test/ethereum.test.ts b/typescript/test/lib/ethereum.test.ts similarity index 99% rename from typescript/test/ethereum.test.ts rename to typescript/test/lib/ethereum.test.ts index 45e248a0f..727c273b3 100644 --- a/typescript/test/ethereum.test.ts +++ b/typescript/test/lib/ethereum.test.ts @@ -5,7 +5,7 @@ import { EthereumBridge, EthereumTBTCToken, Hex, -} from "../src" +} from "../../src" import { deployMockContract, MockContract, @@ -21,7 +21,7 @@ import { waffleChai } from "@ethereum-waffle/chai" chai.use(waffleChai) describe("Ethereum", () => { - describe("Bridge", () => { + describe("EthereumBridge", () => { let walletRegistry: MockContract let bridgeContract: MockContract let bridgeHandle: EthereumBridge @@ -490,7 +490,7 @@ describe("Ethereum", () => { ) } - describe("TBTCToken", () => { + describe("EthereumTBTCToken", () => { let tbtcToken: MockContract let tokenHandle: EthereumTBTCToken const signer: Wallet = new MockProvider().getWallets()[0] diff --git a/typescript/test/lib/utils.test.ts b/typescript/test/lib/utils.test.ts new file mode 100644 index 000000000..563fbbfda --- /dev/null +++ b/typescript/test/lib/utils.test.ts @@ -0,0 +1,181 @@ +import { assert } from "chai" +import { Hex } from "../../src" + +describe("Utils", () => { + describe("Hex", () => { + const stringUnprefixed = + "6e30e6da7a7881a70de2a1cf67b77f2f643e58eb0d055b0f5ef85802a9167727" + const stringPrefixed = + "0x6e30e6da7a7881a70de2a1cf67b77f2f643e58eb0d055b0f5ef85802a9167727" + const stringReversed = + "277716a90258f85e0f5b050deb583e642f7fb767cfa1e20da781787adae6306e" + + const validInputTests = [ + { + name: "unprefixed string", + input: stringUnprefixed, + expectedString: stringUnprefixed, + expectedPrefixedString: stringPrefixed, + }, + { + name: "prefixed string", + input: stringPrefixed, + expectedString: stringUnprefixed, + expectedPrefixedString: stringPrefixed, + }, + { + name: "prefixed uppercase string", + input: stringPrefixed.toUpperCase(), + expectedString: stringUnprefixed, + expectedPrefixedString: stringPrefixed, + }, + { + name: "string with leading and trailing zeros", + input: "00000a12d073c00000", + expectedString: "00000a12d073c00000", + expectedPrefixedString: "0x00000a12d073c00000", + }, + { + name: "empty string", + input: "", + expectedString: "", + expectedPrefixedString: "", + }, + { + name: "unprefixed buffer", + input: Buffer.from(stringUnprefixed, "hex"), + expectedString: stringUnprefixed, + expectedPrefixedString: stringPrefixed, + }, + { + name: "unprefixed uppercase buffer", + input: Buffer.from(stringUnprefixed.toUpperCase(), "hex"), + expectedString: stringUnprefixed, + expectedPrefixedString: stringPrefixed, + }, + { + name: "empty buffer", + input: Buffer.from("", "hex"), + expectedString: "", + expectedPrefixedString: "", + }, + ] + + const invalidInputTests = [ + { + name: "string with a character out of 0-9,a-z,A-Z", + input: "3a9f5G", + expectedErrorMessage: "invalid format of hex string", + }, + { + name: "string of odd length", + input: "ab12345", + expectedErrorMessage: "invalid length of hex string: 7", + }, + ] + + validInputTests.forEach( + ({ name, input, expectedString, expectedPrefixedString }) => { + context(`with input as ${name}`, () => { + const hex = Hex.from(input) + + describe("`${hex}`", () => { + it("should output expected string", () => { + const actual = `${hex}` + assert.equal(actual, expectedString) + }) + }) + + describe("toString", () => { + it("should output expected string", () => { + const actual = hex.toString() + assert.equal(actual, expectedString) + }) + }) + + describe("toPrefixedString", () => { + it("should output expected string", () => { + const actual = hex.toPrefixedString() + assert.equal(actual, expectedPrefixedString) + }) + }) + }) + } + ) + + invalidInputTests.forEach(({ name, input, expectedErrorMessage }) => { + context(`with input as ${name}`, () => { + it(`should throw error with message: ${expectedErrorMessage}`, () => { + assert.throws( + () => { + Hex.from(input) + }, + Error, + expectedErrorMessage + ) + }) + }) + }) + + describe("reverse", () => { + const hex = Hex.from(stringPrefixed) + const hexReversed = hex.reverse() + + it("should not modify source hex", () => { + assert.equal(hex.toString(), stringUnprefixed) + }) + + it("should reverse target hex", () => { + assert.equal(hexReversed.toString(), stringReversed) + }) + }) + + describe("toBuffer", () => { + const hex = Hex.from(stringPrefixed) + const expectedBuffer = Buffer.from(stringUnprefixed, "hex") + + it("should output a buffer", () => { + assert.deepEqual(hex.toBuffer(), expectedBuffer) + }) + + it("should not modify source hex when target buffer is changed", () => { + const buffer = hex.toBuffer() + buffer.reverse() + + assert.equal(hex.toString(), stringUnprefixed) + }) + }) + + describe("equals", () => { + const hexLowerCased = Hex.from(stringPrefixed.toLowerCase()) + const hexUpperCased = Hex.from(stringPrefixed.toUpperCase()) + + context("for the same values with matching cases", () => { + it("should return true", () => { + assert.isTrue(hexUpperCased.equals(hexUpperCased)) + }) + }) + + context("for the same values but not matching cases", () => { + it("should return true", () => { + assert.isTrue(hexLowerCased.equals(hexUpperCased)) + }) + }) + + context("for the same value but prefixed and unprefixed", () => { + it("should return true", () => { + assert.isTrue( + Hex.from(stringPrefixed).equals(Hex.from(stringUnprefixed)) + ) + }) + }) + + context("for different values", () => { + it("should return false", () => { + const otherValue: Hex = Hex.from(stringPrefixed.slice(-2)) + assert.isFalse(hexLowerCased.equals(otherValue)) + }) + }) + }) + }) +}) diff --git a/typescript/test/proof.test.ts b/typescript/test/proof.test.ts deleted file mode 100644 index fc52d7bc2..000000000 --- a/typescript/test/proof.test.ts +++ /dev/null @@ -1,394 +0,0 @@ -import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import { - BitcoinHeaderSerializer, - BitcoinTx, - BitcoinHeader, - BitcoinSpvProof, - assembleBitcoinSpvProof, - validateBitcoinSpvProof, - Hex, -} from "../src" -import { - singleInputProofTestData, - multipleInputsProofTestData, - transactionConfirmationsInOneEpochData, - transactionConfirmationsInTwoEpochsData, - testnetTransactionData, - ProofTestData, - TransactionProofData, -} from "./data/proof" -import { expect } from "chai" -import * as chai from "chai" -import chaiAsPromised from "chai-as-promised" -chai.use(chaiAsPromised) - -describe("Proof", () => { - describe("assembleTransactionProof", () => { - let bitcoinClient: MockBitcoinClient - - beforeEach(async () => { - bitcoinClient = new MockBitcoinClient() - }) - - context("when the transaction has one input", () => { - let proof: BitcoinTx & BitcoinSpvProof - - beforeEach(async () => { - proof = await runProofScenario(singleInputProofTestData) - }) - - it("should return the correct value of the proof", async () => { - const expectedProof = singleInputProofTestData.expectedProof - expect(proof.transactionHash).to.be.deep.equal( - expectedProof.transactionHash - ) - expect(proof.inputs).to.deep.equal(expectedProof.inputs) - expect(proof.outputs).to.deep.equal(expectedProof.outputs) - expect(proof.merkleProof).to.equal(expectedProof.merkleProof) - expect(proof.txIndexInBlock).to.equal(expectedProof.txIndexInBlock) - expect(proof.bitcoinHeaders).to.equal(expectedProof.bitcoinHeaders) - }) - }) - - context("when the transaction has multiple inputs", () => { - let proof: BitcoinTx & BitcoinSpvProof - - beforeEach(async () => { - proof = await runProofScenario(multipleInputsProofTestData) - }) - - it("should return the correct value of the proof", async () => { - const expectedProof = multipleInputsProofTestData.expectedProof - expect(proof.transactionHash).to.deep.equal( - expectedProof.transactionHash - ) - expect(proof.inputs).to.deep.equal(expectedProof.inputs) - expect(proof.outputs).to.deep.equal(expectedProof.outputs) - expect(proof.merkleProof).to.equal(expectedProof.merkleProof) - expect(proof.txIndexInBlock).to.equal(expectedProof.txIndexInBlock) - expect(proof.bitcoinHeaders).to.equal(expectedProof.bitcoinHeaders) - }) - }) - - context("when the transaction does not have enough confirmations", () => { - let notEnoughConfirmationsSweepProofTestData: ProofTestData - - beforeEach(async () => { - notEnoughConfirmationsSweepProofTestData = singleInputProofTestData - notEnoughConfirmationsSweepProofTestData.bitcoinChainData.accumulatedTxConfirmations = 5 - }) - - it("should revert", async () => { - await expect( - runProofScenario(notEnoughConfirmationsSweepProofTestData) - ).to.be.rejectedWith( - "Transaction confirmations number[5] is not enough, required [6]" - ) - }) - }) - - async function runProofScenario( - data: ProofTestData - ): Promise { - const transactions = new Map() - const transactionHash = data.bitcoinChainData.transaction.transactionHash - transactions.set( - transactionHash.toString(), - data.bitcoinChainData.transaction - ) - bitcoinClient.transactions = transactions - bitcoinClient.latestHeight = data.bitcoinChainData.latestBlockHeight - bitcoinClient.headersChain = data.bitcoinChainData.headersChain - bitcoinClient.transactionMerkle = - data.bitcoinChainData.transactionMerkleBranch - const confirmations = new Map() - confirmations.set( - transactionHash.toString(), - data.bitcoinChainData.accumulatedTxConfirmations - ) - bitcoinClient.confirmations = confirmations - - const proof = await assembleBitcoinSpvProof( - transactionHash, - data.requiredConfirmations, - bitcoinClient - ) - - return proof - } - }) - - describe("validateTransactionProof", () => { - let bitcoinClient: MockBitcoinClient - - beforeEach(async () => { - bitcoinClient = new MockBitcoinClient() - }) - - context("when the transaction proof is correct", () => { - context("when the transaction is from Bitcoin Mainnet", () => { - context( - "when the transaction confirmations span only one epoch", - () => { - it("should not throw", async () => { - await expect( - runProofValidationScenario( - transactionConfirmationsInOneEpochData - ) - ).not.to.be.rejected - }) - } - ) - - context("when the transaction confirmations span two epochs", () => { - it("should not throw", async () => { - await expect( - runProofValidationScenario( - transactionConfirmationsInTwoEpochsData - ) - ).not.to.be.rejected - }) - }) - }) - - context("when the transaction is from Bitcoin Testnet", () => { - it("should not throw", async () => { - await expect(runProofValidationScenario(testnetTransactionData)).not - .to.be.rejected - }) - }) - }) - - context("when the transaction proof is incorrect", () => { - context("when the length of headers chain is incorrect", () => { - it("should throw", async () => { - // Corrupt data by adding additional byte to the headers chain. - const corruptedProofData: TransactionProofData = { - ...transactionConfirmationsInOneEpochData, - bitcoinChainData: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData, - headersChain: - transactionConfirmationsInOneEpochData.bitcoinChainData - .headersChain + "ff", - }, - } - await expect( - runProofValidationScenario(corruptedProofData) - ).to.be.rejectedWith("Incorrect length of Bitcoin headers") - }) - }) - - context( - "when the headers chain contains an incorrect number of headers", - () => { - // Corrupt the data by adding additional 80 bytes to the headers chain. - it("should throw", async () => { - const corruptedProofData: TransactionProofData = { - ...transactionConfirmationsInOneEpochData, - bitcoinChainData: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData, - headersChain: - transactionConfirmationsInOneEpochData.bitcoinChainData - .headersChain + "f".repeat(160), - }, - } - await expect( - runProofValidationScenario(corruptedProofData) - ).to.be.rejectedWith("Wrong number of confirmations") - }) - } - ) - - context("when the merkle proof is of incorrect length", () => { - it("should throw", async () => { - // Corrupt the data by adding a byte to the Merkle proof. - const merkle = [ - ...transactionConfirmationsInOneEpochData.bitcoinChainData - .transactionMerkleBranch.merkle, - ] - merkle[merkle.length - 1] += "ff" - - const corruptedProofData: TransactionProofData = { - ...transactionConfirmationsInOneEpochData, - bitcoinChainData: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData, - transactionMerkleBranch: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData - .transactionMerkleBranch, - merkle: merkle, - }, - }, - } - - await expect( - runProofValidationScenario(corruptedProofData) - ).to.be.rejectedWith("Incorrect length of Merkle proof") - }) - }) - - context("when the merkle proof is empty", () => { - it("should throw", async () => { - // Corrupt the data by making the Merkle proof empty. - const corruptedProofData: TransactionProofData = { - ...transactionConfirmationsInOneEpochData, - bitcoinChainData: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData, - transactionMerkleBranch: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData - .transactionMerkleBranch, - merkle: [], - }, - }, - } - - await expect( - runProofValidationScenario(corruptedProofData) - ).to.be.rejectedWith("Invalid merkle tree") - }) - }) - - context("when the merkle proof contains incorrect hash", () => { - it("should throw", async () => { - // Corrupt the data by changing a byte of one of the hashes in the - // Merkle proof. - const merkle = [ - ...transactionConfirmationsInOneEpochData.bitcoinChainData - .transactionMerkleBranch.merkle, - ] - - merkle[3] = "ff" + merkle[3].slice(2) - - const corruptedProofData: TransactionProofData = { - ...transactionConfirmationsInOneEpochData, - bitcoinChainData: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData, - transactionMerkleBranch: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData - .transactionMerkleBranch, - merkle: merkle, - }, - }, - } - - await expect( - runProofValidationScenario(corruptedProofData) - ).to.be.rejectedWith( - "Transaction Merkle proof is not valid for provided header and transaction hash" - ) - }) - }) - - context("when the block headers do not form a chain", () => { - it("should throw", async () => { - // Corrupt data by modifying previous block header hash of one of the - // headers. - const headers: BitcoinHeader[] = - BitcoinHeaderSerializer.deserializeHeadersChain( - transactionConfirmationsInOneEpochData.bitcoinChainData - .headersChain - ) - headers[headers.length - 1].previousBlockHeaderHash = Hex.from( - "ff".repeat(32) - ) - const corruptedHeadersChain: string = headers - .map(BitcoinHeaderSerializer.serializeHeader) - .join("") - - const corruptedProofData: TransactionProofData = { - ...transactionConfirmationsInOneEpochData, - bitcoinChainData: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData, - headersChain: corruptedHeadersChain, - }, - } - - await expect( - runProofValidationScenario(corruptedProofData) - ).to.be.rejectedWith("Invalid headers chain") - }) - }) - - context("when one of the block headers has insufficient work", () => { - it("should throw", async () => { - // Corrupt data by modifying the nonce of one of the headers, so that - // the resulting hash will be above the required difficulty target. - const headers: BitcoinHeader[] = - BitcoinHeaderSerializer.deserializeHeadersChain( - transactionConfirmationsInOneEpochData.bitcoinChainData - .headersChain - ) - headers[headers.length - 1].nonce++ - const corruptedHeadersChain: string = headers - .map(BitcoinHeaderSerializer.serializeHeader) - .join("") - - const corruptedProofData: TransactionProofData = { - ...transactionConfirmationsInOneEpochData, - bitcoinChainData: { - ...transactionConfirmationsInOneEpochData.bitcoinChainData, - headersChain: corruptedHeadersChain, - }, - } - - await expect( - runProofValidationScenario(corruptedProofData) - ).to.be.rejectedWith("Insufficient work in the header") - }) - }) - - context( - "when some of the block headers are not at current or previous difficulty", - () => { - it("should throw", async () => { - // Corrupt data by setting current difficulty to a different value - // than stored in block headers. - const corruptedProofData: TransactionProofData = { - ...transactionConfirmationsInTwoEpochsData, - bitcoinChainData: { - ...transactionConfirmationsInTwoEpochsData.bitcoinChainData, - currentDifficulty: - transactionConfirmationsInTwoEpochsData.bitcoinChainData.currentDifficulty.add( - 1 - ), - }, - } - - await expect( - runProofValidationScenario(corruptedProofData) - ).to.be.rejectedWith( - "Header difficulty not at current or previous Bitcoin difficulty" - ) - }) - } - ) - }) - - async function runProofValidationScenario(data: TransactionProofData) { - const transactions = new Map() - const transactionHash = data.bitcoinChainData.transaction.transactionHash - transactions.set( - transactionHash.toString(), - data.bitcoinChainData.transaction - ) - bitcoinClient.transactions = transactions - bitcoinClient.latestHeight = data.bitcoinChainData.latestBlockHeight - bitcoinClient.headersChain = data.bitcoinChainData.headersChain - bitcoinClient.transactionMerkle = - data.bitcoinChainData.transactionMerkleBranch - const confirmations = new Map() - confirmations.set( - transactionHash.toString(), - data.bitcoinChainData.accumulatedTxConfirmations - ) - bitcoinClient.confirmations = confirmations - - await validateBitcoinSpvProof( - data.bitcoinChainData.transaction.transactionHash, - data.requiredConfirmations, - data.bitcoinChainData.previousDifficulty, - data.bitcoinChainData.currentDifficulty, - bitcoinClient - ) - } - }) -}) diff --git a/typescript/test/deposit.test.ts b/typescript/test/services/deposits.test.ts similarity index 79% rename from typescript/test/deposit.test.ts rename to typescript/test/services/deposits.test.ts index 73f33e320..821228f8c 100644 --- a/typescript/test/deposit.test.ts +++ b/typescript/test/services/deposits.test.ts @@ -6,7 +6,7 @@ import { testnetTransaction, testnetTransactionHash, testnetUTXO, -} from "./data/deposit" +} from "../data/deposit" import { BitcoinLocktimeUtils, BitcoinNetwork, @@ -16,15 +16,22 @@ import { Deposit, DepositFunding, DepositReceipt, + DepositRefund, DepositScript, EthereumAddress, extractBitcoinRawTxVectors, -} from "../src" -import { MockBitcoinClient } from "./utils/mock-bitcoin-client" -import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" -import { txToJSON } from "./utils/helpers" +} from "../../src" +import { MockBitcoinClient } from "../utils/mock-bitcoin-client" +import { MockTBTCContracts } from "../utils/mock-tbtc-contracts" +import { txToJSON } from "../utils/helpers" +import { + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress, + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress, + depositRefundOfWitnessDepositAndWitnessRefunderAddress, + refunderPrivateKey, +} from "../data/deposit-refund" -describe("Deposit", () => { +describe("Deposits", () => { const depositCreatedAt: number = 1640181600 const depositRefundLocktimeDuration: number = 2592000 @@ -723,4 +730,172 @@ describe("Deposit", () => { describe("DepositsService", () => { // TODO: Implement unit tests. }) + + describe("DepositRefund", () => { + const fee = BigNumber.from(1520) + + describe("DepositRefund", () => { + describe("submitTransaction", () => { + let bitcoinClient: MockBitcoinClient + + beforeEach(async () => { + bitcoinClient = new MockBitcoinClient() + }) + + context( + "when the refund transaction is requested to be witness", + () => { + context("when the refunded deposit was witness", () => { + let transactionHash: BitcoinTxHash + + beforeEach(async () => { + const utxo = + depositRefundOfWitnessDepositAndWitnessRefunderAddress.deposit + .utxo + const deposit = + depositRefundOfWitnessDepositAndWitnessRefunderAddress.deposit + .data + const refunderAddress = + depositRefundOfWitnessDepositAndWitnessRefunderAddress.refunderAddress + const refunderPrivateKey = + "cTWhf1nXc7aW8BN2qLtWcPtcgcWYKfzRXkCJNsuQ86HR8uJBYfMc" + + const rawTransactions = new Map() + rawTransactions.set(utxo.transactionHash.toString(), { + transactionHex: utxo.transactionHex, + }) + bitcoinClient.rawTransactions = rawTransactions + + const depositRefund = DepositRefund.fromScript( + DepositScript.fromReceipt(deposit) + ) + + ;({ transactionHash } = await depositRefund.submitTransaction( + bitcoinClient, + fee, + utxo, + refunderAddress, + refunderPrivateKey + )) + }) + + it("should broadcast refund transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositRefundOfWitnessDepositAndWitnessRefunderAddress + .expectedRefund.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositRefundOfWitnessDepositAndWitnessRefunderAddress + .expectedRefund.transactionHash + ) + }) + }) + + context("when the refunded deposit was non-witness", () => { + let transactionHash: BitcoinTxHash + + beforeEach(async () => { + const utxo = + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress + .deposit.utxo + const deposit = + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress + .deposit.data + const refunderAddress = + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress.refunderAddress + + const rawTransactions = new Map() + rawTransactions.set(utxo.transactionHash.toString(), { + transactionHex: utxo.transactionHex, + }) + bitcoinClient.rawTransactions = rawTransactions + + const depositRefund = DepositRefund.fromScript( + DepositScript.fromReceipt(deposit) + ) + + ;({ transactionHash } = await depositRefund.submitTransaction( + bitcoinClient, + fee, + utxo, + refunderAddress, + refunderPrivateKey + )) + }) + + it("should broadcast refund transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress + .expectedRefund.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositRefundOfNonWitnessDepositAndWitnessRefunderAddress + .expectedRefund.transactionHash + ) + }) + }) + } + ) + + context( + "when the refund transaction is requested to be non-witness", + () => { + let transactionHash: BitcoinTxHash + + beforeEach(async () => { + const utxo = + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress + .deposit.utxo + const deposit = + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress + .deposit.data + const refunderAddress = + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress.refunderAddress + + const rawTransactions = new Map() + rawTransactions.set(utxo.transactionHash.toString(), { + transactionHex: utxo.transactionHex, + }) + + const depositRefund = DepositRefund.fromScript( + DepositScript.fromReceipt(deposit) + ) + + bitcoinClient.rawTransactions = rawTransactions + ;({ transactionHash } = await depositRefund.submitTransaction( + bitcoinClient, + fee, + utxo, + refunderAddress, + refunderPrivateKey + )) + }) + + it("should broadcast refund transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress + .expectedRefund.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositRefundOfWitnessDepositAndNonWitnessRefunderAddress + .expectedRefund.transactionHash + ) + }) + } + ) + }) + }) + }) }) diff --git a/typescript/test/redemption.test.ts b/typescript/test/services/maintenance.test.ts similarity index 59% rename from typescript/test/redemption.test.ts rename to typescript/test/services/maintenance.test.ts index 4fbd9f5fe..cbca52a78 100644 --- a/typescript/test/redemption.test.ts +++ b/typescript/test/services/maintenance.test.ts @@ -1,23 +1,28 @@ +import { BigNumber, BigNumberish } from "ethers" +import { MockTBTCContracts } from "../utils/mock-tbtc-contracts" +import { MockBitcoinClient } from "../utils/mock-bitcoin-client" import { - BitcoinAddressConverter, - BitcoinHashUtils, BitcoinNetwork, BitcoinRawTx, BitcoinTx, BitcoinTxHash, BitcoinUtxo, - Hex, MaintenanceService, - NewWalletRegisteredEvent, RedemptionRequest, - RedemptionsService, - Wallet, - WalletState, WalletTx, -} from "../src" -import { MockBitcoinClient } from "./utils/mock-bitcoin-client" +} from "../../src" +import { + depositSweepProof, + depositSweepWithNoMainUtxoAndNonWitnessOutput, + depositSweepWithNoMainUtxoAndWitnessOutput, + depositSweepWithNonWitnessMainUtxoAndWitnessOutput, + depositSweepWithWitnessMainUtxoAndWitnessOutput, + NO_MAIN_UTXO, +} from "../data/deposit-sweep" +import { testnetWalletAddress, testnetWalletPrivateKey } from "../data/deposit" +import { expect } from "chai" +import { txToJSON } from "../utils/helpers" import { - findWalletForRedemptionData, multipleRedemptionsWithoutChange, multipleRedemptionsWithWitnessChange, p2pkhWalletAddress, @@ -31,787 +36,1052 @@ import { singleP2WSHRedemptionWithWitnessChange, walletPrivateKey, walletPublicKey, -} from "./data/redemption" -import { MockBridge } from "./utils/mock-bridge" -import * as chai from "chai" -import { expect } from "chai" -import chaiAsPromised from "chai-as-promised" -import { BigNumber, BigNumberish } from "ethers" -import { MockTBTCContracts } from "./utils/mock-tbtc-contracts" -import { txToJSON } from "./utils/helpers" - -chai.use(chaiAsPromised) - -describe("Redemption", () => { - describe("RedemptionsService", () => { - describe("requestRedemption", () => { - const data: RedemptionTestData = singleP2PKHRedemptionWithWitnessChange - const { transactionHash, value } = data.mainUtxo - const mainUtxo: BitcoinUtxo = { - transactionHash, - outputIndex: 0, - value, - } - const redeemerOutputScript = - data.pendingRedemptions[0].pendingRedemption.redeemerOutputScript - const amount = - data.pendingRedemptions[0].pendingRedemption.requestedAmount +} from "../data/redemption" +import { runRedemptionScenario } from "./redemptions.test" - let tbtcContracts: MockTBTCContracts - let bitcoinClient: MockBitcoinClient +describe("Maintenance", () => { + describe("WalletTx", () => { + describe("DepositSweep", () => { + const fee = BigNumber.from(1600) - beforeEach(async () => { - tbtcContracts = new MockTBTCContracts() - bitcoinClient = new MockBitcoinClient() + describe("submitTransaction", () => { + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient - const walletPublicKeyHash = Hex.from( - BitcoinHashUtils.computeHash160(walletPublicKey) - ) + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + }) - // Prepare NewWalletRegisteredEvent history. Set only relevant fields. - tbtcContracts.bridge.newWalletRegisteredEvents = [ - { - walletPublicKeyHash: walletPublicKeyHash, - } as NewWalletRegisteredEvent, - ] - - // Prepare wallet data in the Bridge. Set only relevant fields. - tbtcContracts.bridge.setWallet(walletPublicKeyHash.toPrefixedString(), { - state: WalletState.Live, - walletPublicKey: Hex.from(walletPublicKey), - pendingRedemptionsValue: BigNumber.from(0), - mainUtxoHash: tbtcContracts.bridge.buildUtxoHash(mainUtxo), - } as Wallet) - - const walletAddress = BitcoinAddressConverter.publicKeyHashToAddress( - walletPublicKeyHash.toString(), - true, - BitcoinNetwork.Testnet - ) + context("when the new main UTXO is requested to be witness", () => { + context( + "when there is no main UTXO from previous deposit sweep", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo - // Prepare wallet transaction history for main UTXO lookup. - // Set only relevant fields. - const transactionHistory = new Map() - transactionHistory.set(walletAddress, [ - { - transactionHash: mainUtxo.transactionHash, - outputs: [ - { - outputIndex: mainUtxo.outputIndex, - value: mainUtxo.value, - scriptPubKey: BitcoinAddressConverter.addressToOutputScript( - walletAddress, - BitcoinNetwork.Testnet - ), - }, - ], - } as BitcoinTx, - ]) - bitcoinClient.transactionHistory = transactionHistory - - const redemptionsService = new RedemptionsService( - tbtcContracts, - bitcoinClient - ) + beforeEach(async () => { + // Map transaction hashes for UTXOs to transactions in hexadecimal and + // set the mapping in the mock Bitcoin client + const rawTransactions = new Map() + for (const deposit of depositSweepWithNoMainUtxoAndWitnessOutput.deposits) { + rawTransactions.set(deposit.utxo.transactionHash.toString(), { + transactionHex: deposit.utxo.transactionHex, + }) + } + bitcoinClient.rawTransactions = rawTransactions - await redemptionsService.requestRedemption( - BitcoinAddressConverter.outputScriptToAddress( - Hex.from(redeemerOutputScript), - BitcoinNetwork.Testnet - ), - amount - ) - }) + const utxos: BitcoinUtxo[] = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( + (data) => { + return data.utxo + } + ) - it("should submit redemption request with correct arguments", () => { - const tokenLog = tbtcContracts.tbtcToken.requestRedemptionLog + const deposit = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + const witness = + depositSweepWithNoMainUtxoAndWitnessOutput.witness - expect(tokenLog.length).to.equal(1) - expect(tokenLog[0]).to.deep.equal({ - walletPublicKey, - mainUtxo, - redeemerOutputScript, - amount, + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) + + ;({ transactionHash, newMainUtxo } = + await walletTx.depositSweep.submitTransaction( + fee, + testnetWalletPrivateKey, + utxos, + deposit + )) + }) + + it("should broadcast sweep transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transactionHash, + outputIndex: 0, + value: BigNumber.from(35400), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + + context("when there is main UTXO from previous deposit sweep", () => { + context( + "when main UTXO from previous deposit sweep is witness", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + + beforeEach(async () => { + // Map transaction hashes for UTXOs to transactions in hexadecimal and + // set the mapping in the mock Bitcoin client + const rawTransactions = new Map() + for (const deposit of depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits) { + rawTransactions.set( + deposit.utxo.transactionHash.toString(), + { + transactionHex: deposit.utxo.transactionHex, + } + ) + } + // The main UTXO resulting from another data set was used as input. + // Set raw data of that main UTXO as well. + rawTransactions.set( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString(), + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transaction + ) + bitcoinClient.rawTransactions = rawTransactions + + const utxos: BitcoinUtxo[] = + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.utxo + } + ) + + const deposit = + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + + const witness = + depositSweepWithWitnessMainUtxoAndWitnessOutput.witness + + const mainUtxo = + depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) + + ;({ transactionHash, newMainUtxo } = + await walletTx.depositSweep.submitTransaction( + fee, + testnetWalletPrivateKey, + utxos, + deposit, + mainUtxo + )) + }) + + it("should broadcast sweep transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash, + outputIndex: 0, + value: BigNumber.from(60800), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + + context( + "when main UTXO from previous deposit sweep is non-witness", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + + beforeEach(async () => { + // Map transaction hashes for UTXOs to transactions in hexadecimal and + // set the mapping in the mock Bitcoin client + const rawTransactions = new Map() + for (const deposit of depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits) { + rawTransactions.set( + deposit.utxo.transactionHash.toString(), + { + transactionHex: deposit.utxo.transactionHex, + } + ) + } + rawTransactions.set( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString(), + { + transactionHex: + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .mainUtxo.transactionHex, + } + ) + bitcoinClient.rawTransactions = rawTransactions + + const utxos: BitcoinUtxo[] = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.utxo + } + ) + + const deposit = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + + const witness = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.witness + + const mainUtxo = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) + + ;({ transactionHash, newMainUtxo } = + await walletTx.depositSweep.submitTransaction( + fee, + testnetWalletPrivateKey, + utxos, + deposit, + mainUtxo + )) + }) + + it("should broadcast sweep transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash, + outputIndex: 0, + value: BigNumber.from(33800), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + }) }) - }) - }) - describe("getRedemptionRequest", () => { - context("when asked for a pending request", () => { - const { redemptionKey, pendingRedemption: redemptionRequest } = - multipleRedemptionsWithWitnessChange.pendingRedemptions[0] + context("when the new main UTXO is requested to be non-witness", () => { + // The only difference between deposit sweep transactions with witness and + // non-witness output is the output type itself. + // Therefore only one test case was added for non-witness transactions. + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + + beforeEach(async () => { + // Map transaction hashes for UTXOs to transactions in hexadecimal and + // set the mapping in the mock Bitcoin client + const rawTransactions = new Map() + for (const deposit of depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits) { + rawTransactions.set(deposit.utxo.transactionHash.toString(), { + transactionHex: deposit.utxo.transactionHex, + }) + } + bitcoinClient.rawTransactions = rawTransactions + + const utxos = + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( + (data) => { + return data.utxo + } + ) + + const deposits = + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + const witness = + depositSweepWithNoMainUtxoAndNonWitnessOutput.witness + + const walletTx = new WalletTx(tbtcContracts, bitcoinClient, witness) + + ;({ transactionHash, newMainUtxo } = + await walletTx.depositSweep.submitTransaction( + fee, + testnetWalletPrivateKey, + utxos, + deposits + )) + }) + + it("should broadcast sweep transaction with proper structure", async () => { + expect(bitcoinClient.broadcastLog.length).to.be.equal(1) + expect(bitcoinClient.broadcastLog[0]).to.be.eql( + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep + .transaction + ) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep + .transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep + .transactionHash, + outputIndex: 0, + value: BigNumber.from(13400), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + }) + }) + describe("assembleTransaction", () => { let tbtcContracts: MockTBTCContracts let bitcoinClient: MockBitcoinClient - let redemptionsService: RedemptionsService - beforeEach(async () => { - tbtcContracts = new MockTBTCContracts() - bitcoinClient = new MockBitcoinClient() + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + }) + + context("when the new main UTXO is requested to be witness", () => { + context( + "when there is no main UTXO from previous deposit sweep", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx + + const utxosWithRaw = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( + (data) => { + return data.utxo + } + ) + + const deposit = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + + const witness = depositSweepWithNoMainUtxoAndWitnessOutput.witness + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) + + beforeEach(async () => { + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, + fee, + testnetWalletPrivateKey, + utxosWithRaw, + deposit + )) + }) + + it("should return sweep transaction with proper structure", () => { + // Compare HEXes. + expect(transaction).to.be.eql( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transaction + ) + + // Convert raw transaction to JSON to make detailed comparison. + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) + + expect(txJSON.hash).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) + + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(2) + + const p2shInput = txJSON.inputs[0] + expect(p2shInput.hash).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() + ) + expect(p2shInput.index).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo + .outputIndex + ) + // Transaction should be signed. As it's not SegWit input, the `witness` + // field should be empty, while the `script` field should be filled. + expect(p2shInput.witness).to.be.empty + expect(p2shInput.script.length).to.be.greaterThan(0) + + const p2wshInput = txJSON.inputs[1] + expect(p2wshInput.hash).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() + ) + expect(p2wshInput.index).to.be.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[1].utxo + .outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wshInput.witness.length).to.be.greaterThan(0) + expect(p2wshInput.script.length).to.be.equal(0) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(1) + const sweepOutput = txJSON.outputs[0] + + // Should be OP_0 . Public key corresponds to the + // wallet BTC address. + expect(sweepOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The output's address should be the wallet's address + expect(sweepOutput.address).to.be.equal(testnetWalletAddress) + // The output's value should be equal to the sum of all input values + // minus fee (25000 + 12000 - 1600) + expect(sweepOutput.value).to.be.equal(35400) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNoMainUtxoAndWitnessOutput.expectedSweep + .transactionHash, + outputIndex: 0, + value: BigNumber.from(35400), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + + context("when there is main UTXO from previous deposit sweep", () => { + context( + "when main UTXO prom previous deposit sweep is witness", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx + + const utxosWithRaw = + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.utxo + } + ) + + const deposit = + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + + // P2WPKH + const mainUtxoWithRaw = + depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo + + const witness = + depositSweepWithWitnessMainUtxoAndWitnessOutput.witness + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) + + beforeEach(async () => { + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, + fee, + testnetWalletPrivateKey, + utxosWithRaw, + deposit, + mainUtxoWithRaw + )) + }) + + it("should return sweep transaction with proper structure", () => { + // Compare HEXes. + expect(transaction).to.be.eql( + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transaction + ) + + // Convert raw transaction to JSON to make detailed comparison. + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) + + expect(txJSON.hash).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) + + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(3) + + const p2wkhInput = txJSON.inputs[0] + expect(p2wkhInput.hash).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() + ) + expect(p2wkhInput.index).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.mainUtxo + .outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wkhInput.witness.length).to.be.greaterThan(0) + expect(p2wkhInput.script.length).to.be.equal(0) + + const p2shInput = txJSON.inputs[1] + expect(p2shInput.hash).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() + ) + expect(p2shInput.index).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[0] + .utxo.outputIndex + ) + // Transaction should be signed. As it's not SegWit input, the `witness` + // field should be empty, while the `script` field should be filled. + expect(p2shInput.witness).to.be.empty + expect(p2shInput.script.length).to.be.greaterThan(0) + + const p2wshInput = txJSON.inputs[2] + expect(p2wshInput.hash).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1].utxo.transactionHash.toString() + ) + expect(p2wshInput.index).to.be.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput.deposits[1] + .utxo.outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wshInput.witness.length).to.be.greaterThan(0) + expect(p2wshInput.script.length).to.be.equal(0) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(1) + + const sweepOutput = txJSON.outputs[0] + // Should be OP_0 . Public key corresponds to the + // wallet BTC address. + expect(sweepOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The output's address should be the wallet's address + expect(sweepOutput.address).to.be.equal(testnetWalletAddress) + // The output's value should be equal to the sum of all input values + // minus fee (17000 + 10000 + 35400 - 1600) + expect(sweepOutput.value).to.be.equal(60800) + }) + + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash + ) + }) + + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash, + outputIndex: 0, + value: BigNumber.from(60800), + } + + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } + ) + + context( + "when main UTXO from previous deposit sweep is non-witness", + () => { + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx + + const utxosWithRaw = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.utxo + } + ) + + const deposit = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) + + // P2WPKH + const mainUtxoWithRaw = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo + + const witness = + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.witness + + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) + + beforeEach(async () => { + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, + fee, + testnetWalletPrivateKey, + utxosWithRaw, + deposit, + mainUtxoWithRaw + )) + }) + + it("should return sweep transaction with proper structure", () => { + // Compare HEXes. + expect(transaction).to.be.eql( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transaction + ) + + // Convert raw transaction to JSON to make detailed comparison. + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet + ) + + expect(txJSON.hash).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.expectedSweep.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) + + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(2) + + const p2pkhInput = txJSON.inputs[0] // main UTXO + expect(p2pkhInput.hash).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo.transactionHash.toString() + ) + expect(p2pkhInput.index).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.mainUtxo + .outputIndex + ) + // Transaction should be signed. As it's not SegWit input, the `witness` + // field should be empty, while the `script` field should be filled. + expect(p2pkhInput.witness).to.be.empty + expect(p2pkhInput.script.length).to.be.greaterThan(0) + + const p2wshInput = txJSON.inputs[1] + expect(p2wshInput.hash).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput.deposits[0].utxo.transactionHash.toString() + ) + expect(p2wshInput.index).to.be.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .deposits[0].utxo.outputIndex + ) + // Transaction should be signed. As it's a SegWit input, the `witness` + // field should be filled, while the `script` field should be empty. + expect(p2wshInput.witness.length).to.be.greaterThan(0) + expect(p2wshInput.script.length).to.be.equal(0) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(1) - const pendingRedemptions = new Map() - pendingRedemptions.set(redemptionKey, redemptionRequest) + const sweepOutput = txJSON.outputs[0] + // Should be OP_0 . Public key corresponds to the + // wallet BTC address. + expect(sweepOutput.script).to.be.equal( + "00148db50eb52063ea9d98b3eac91489a90f738986f6" + ) + // The output's address should be the wallet's address + expect(sweepOutput.address).to.be.equal(testnetWalletAddress) + // The output's value should be equal to the sum of all input values + // minus fee (16400 + 19000 - 1600) + expect(sweepOutput.value).to.be.equal(33800) + }) - tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash + ) + }) - redemptionsService = new RedemptionsService( - tbtcContracts, - bitcoinClient - ) - }) + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNonWitnessMainUtxoAndWitnessOutput + .expectedSweep.transactionHash, + outputIndex: 0, + value: BigNumber.from(33800), + } - it("should return the expected redemption request", async () => { - const actualRedemptionRequest = - await redemptionsService.getRedemptionRequests( - BitcoinAddressConverter.outputScriptToAddress( - Hex.from(redemptionRequest.redeemerOutputScript), - BitcoinNetwork.Testnet - ), - walletPublicKey, - "pending" + expect(newMainUtxo).to.be.eql(expectedNewMainUtxo) + }) + } ) - - expect(actualRedemptionRequest).to.be.eql(redemptionRequest) + }) }) - }) - context("when asked for a timed-out request", () => { - const { redemptionKey, pendingRedemption: redemptionRequest } = - multipleRedemptionsWithWitnessChange.pendingRedemptions[0] + context("when the new main UTXO is requested to be non-witness", () => { + // The only difference between deposit sweep transactions with witness and + // non-witness output is the output type itself. + // Therefore only one test case was added for non-witness transactions. + let transactionHash: BitcoinTxHash + let newMainUtxo: BitcoinUtxo + let transaction: BitcoinRawTx + + const utxosWithRaw = + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( + (deposit) => { + return deposit.utxo + } + ) - let tbtcContracts: MockTBTCContracts - let bitcoinClient: MockBitcoinClient - let redemptionsService: RedemptionsService + const deposit = + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits.map( + (deposit) => { + return deposit.data + } + ) - beforeEach(async () => { - tbtcContracts = new MockTBTCContracts() - bitcoinClient = new MockBitcoinClient() + const witness = depositSweepWithNoMainUtxoAndNonWitnessOutput.witness - const timedOutRedemptions = new Map() - timedOutRedemptions.set(redemptionKey, redemptionRequest) + const walletTx = new WalletTx(tbtcContracts, bitcoinClient, witness) - tbtcContracts.bridge.setTimedOutRedemptions(timedOutRedemptions) + beforeEach(async () => { + ;({ + transactionHash, + newMainUtxo, + rawTransaction: transaction, + } = await walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, + fee, + testnetWalletPrivateKey, + utxosWithRaw, + deposit + )) + }) - redemptionsService = new RedemptionsService( - tbtcContracts, - bitcoinClient - ) - }) + it("should return sweep transaction with proper structure", () => { + // Compare HEXes. + expect(transaction).to.be.eql( + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep + .transaction + ) - it("should return the expected redemption request", async () => { - const actualRedemptionRequest = - await redemptionsService.getRedemptionRequests( - BitcoinAddressConverter.outputScriptToAddress( - Hex.from(redemptionRequest.redeemerOutputScript), - BitcoinNetwork.Testnet - ), - walletPublicKey, - "timedOut" + // Convert raw transaction to JSON to make detailed comparison. + const txJSON = txToJSON( + transaction.transactionHex, + BitcoinNetwork.Testnet ) - expect(actualRedemptionRequest).to.be.eql(redemptionRequest) - }) - }) - }) + expect(txJSON.hash).to.be.equal( + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep.transactionHash.toString() + ) + expect(txJSON.version).to.be.equal(1) - describe("findWalletForRedemption", () => { - class TestRedemptionsService extends RedemptionsService { - public async findWalletForRedemption( - redeemerOutputScript: string, - amount: BigNumber - ): Promise<{ - walletPublicKey: string - mainUtxo: BitcoinUtxo - }> { - return super.findWalletForRedemption(redeemerOutputScript, amount) - } - } + // Validate inputs. + expect(txJSON.inputs.length).to.be.equal(1) - let tbtcContracts: MockTBTCContracts - let bitcoinClient: MockBitcoinClient - let redemptionsService: TestRedemptionsService - // script for testnet P2WSH address - // tb1qau95mxzh2249aa3y8exx76ltc2sq0e7kw8hj04936rdcmnynhswqqz02vv - const redeemerOutputScript = - "0x220020ef0b4d985752aa5ef6243e4c6f6bebc2a007e7d671ef27d4b1d0db8dcc93bc1c" - - context( - "when there are no wallets in the network that can handle redemption", - () => { - const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC - beforeEach(() => { - bitcoinClient = new MockBitcoinClient() - tbtcContracts = new MockTBTCContracts() - tbtcContracts.bridge.newWalletRegisteredEvents = [] - redemptionsService = new TestRedemptionsService( - tbtcContracts, - bitcoinClient + const p2shInput = txJSON.inputs[0] + expect(p2shInput.hash).to.be.equal( + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo.transactionHash.toString() + ) + expect(p2shInput.index).to.be.equal( + depositSweepWithNoMainUtxoAndNonWitnessOutput.deposits[0].utxo + .outputIndex ) + // Transaction should be signed. As it's not SegWit input, the `witness` + // field should be empty, while the `script` field should be filled. + expect(p2shInput.witness).to.be.empty + expect(p2shInput.script.length).to.be.greaterThan(0) + + // Validate outputs. + expect(txJSON.outputs.length).to.be.equal(1) + + const sweepOutput = txJSON.outputs[0] + // OP_DUP OP_HASH160 0x14 0x8db50eb52063ea9d98b3eac91489a90f738986f6 + // OP_EQUALVERIFY OP_CHECKSIG + expect(sweepOutput.script).to.be.equal( + "76a9148db50eb52063ea9d98b3eac91489a90f738986f688ac" + ) + // The output's address should be the wallet's address + expect(sweepOutput.address).to.be.equal( + "mtSEUCE7G8om9zJttG9twtjoiSsUz7QnY9" + ) + // The output's value should be equal to the sum of all input values + // minus fee (15000- 1600) + expect(sweepOutput.value).to.be.equal(13400) }) - it("should throw an error", async () => { - await expect( - redemptionsService.findWalletForRedemption( - redeemerOutputScript, - amount - ) - ).to.be.rejectedWith( - "Currently, there are no live wallets in the network." + it("should return the proper transaction hash", async () => { + expect(transactionHash).to.be.deep.equal( + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep + .transactionHash ) }) - } - ) - - context("when there are registered wallets in the network", () => { - let result: Awaited | never> - const walletsOrder = [ - findWalletForRedemptionData.nonLiveWallet, - findWalletForRedemptionData.walletWithoutUtxo, - findWalletForRedemptionData.walletWithPendingRedemption, - findWalletForRedemptionData.liveWallet, - ] - - beforeEach(async () => { - bitcoinClient = new MockBitcoinClient() - tbtcContracts = new MockTBTCContracts() - tbtcContracts.bridge.newWalletRegisteredEvents = walletsOrder.map( - (wallet) => wallet.event - ) + it("should return the proper new main UTXO", () => { + const expectedNewMainUtxo = { + transactionHash: + depositSweepWithNoMainUtxoAndNonWitnessOutput.expectedSweep + .transactionHash, + outputIndex: 0, + value: BigNumber.from(13400), + } - const walletsTransactionHistory = new Map() - - walletsOrder.forEach((wallet) => { - const { - state, - mainUtxoHash, - walletPublicKey, - btcAddress, - transactions, - pendingRedemptionsValue, - } = wallet.data - - walletsTransactionHistory.set(btcAddress, transactions) - tbtcContracts.bridge.setWallet( - wallet.event.walletPublicKeyHash.toPrefixedString(), - { - state, - mainUtxoHash, - walletPublicKey, - pendingRedemptionsValue, - } as Wallet - ) + expect(newMainUtxo).to.be.deep.equal(expectedNewMainUtxo) }) + }) - bitcoinClient.transactionHistory = walletsTransactionHistory + context("when there are no UTXOs", () => { + it("should revert", async () => { + const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - redemptionsService = new TestRedemptionsService( - tbtcContracts, - bitcoinClient - ) + await expect( + walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, + fee, + testnetWalletPrivateKey, + [], + [] + ) + ).to.be.rejectedWith( + "There must be at least one deposit UTXO to sweep" + ) + }) }) context( - "when there is a wallet that can handle the redemption request", + "when the numbers of UTXOs and deposit elements are not equal", () => { - const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC - beforeEach(async () => { - result = await redemptionsService.findWalletForRedemption( - redeemerOutputScript, - amount + const utxosWithRaw = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits.map( + (data) => { + return data.utxo + } ) - }) - - it("should get all registered wallets", () => { - const bridgeQueryEventsLog = - tbtcContracts.bridge.newWalletRegisteredEventsLog - expect(bridgeQueryEventsLog.length).to.equal(1) - expect(bridgeQueryEventsLog[0]).to.deep.equal({ - options: undefined, - filterArgs: [], - }) - }) + // Add only one element to the deposit + const deposit = [ + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data, + ] - it("should return the wallet data that can handle redemption request", () => { - const expectedWalletData = - findWalletForRedemptionData.walletWithPendingRedemption.data + const witness = depositSweepWithNoMainUtxoAndWitnessOutput.witness - expect(result).to.deep.eq({ - walletPublicKey: expectedWalletData.walletPublicKey.toString(), - mainUtxo: expectedWalletData.mainUtxo, - }) - }) - } - ) + it("should revert", async () => { + const walletTx = new WalletTx( + tbtcContracts, + bitcoinClient, + witness + ) - context( - "when the redemption request amount is too large and no wallet can handle the request", - () => { - const amount = BigNumber.from("10000000000") // 1 000 BTC - const expectedMaxAmount = walletsOrder - .map((wallet) => wallet.data) - .map((wallet) => wallet.mainUtxo) - .map((utxo) => utxo.value) - .sort((a, b) => (b.gt(a) ? 0 : -1))[0] - - it("should throw an error", async () => { await expect( - redemptionsService.findWalletForRedemption( - redeemerOutputScript, - amount + walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, + fee, + testnetWalletPrivateKey, + utxosWithRaw, + deposit ) ).to.be.rejectedWith( - `Could not find a wallet with enough funds. Maximum redemption amount is ${expectedMaxAmount.toString()} Satoshi.` + "Number of UTXOs must equal the number of deposit elements" ) }) } ) - context( - "when there is pending redemption request from a given wallet to the same address", - () => { - beforeEach(async () => { - const redeemerOutputScript = - findWalletForRedemptionData.pendingRedemption - .redeemerOutputScript - const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC - - const walletPublicKeyHash = - findWalletForRedemptionData.walletWithPendingRedemption.event - .walletPublicKeyHash - - const pendingRedemptions = new Map< - BigNumberish, - RedemptionRequest - >() - - const key = MockBridge.buildRedemptionKey( - walletPublicKeyHash.toString(), - redeemerOutputScript - ) - - pendingRedemptions.set( - key, - findWalletForRedemptionData.pendingRedemption - ) - tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) - - result = await redemptionsService.findWalletForRedemption( - redeemerOutputScript, - amount - ) - }) - - it("should get all registered wallets", () => { - const bridgeQueryEventsLog = - tbtcContracts.bridge.newWalletRegisteredEventsLog - - expect(bridgeQueryEventsLog.length).to.equal(1) - expect(bridgeQueryEventsLog[0]).to.deep.equal({ - options: undefined, - filterArgs: [], - }) - }) - - it("should skip the wallet for which there is a pending redemption request to the same redeemer output script and return the wallet data that can handle redemption request", () => { - const expectedWalletData = - findWalletForRedemptionData.liveWallet.data - - expect(result).to.deep.eq({ - walletPublicKey: expectedWalletData.walletPublicKey.toString(), - mainUtxo: expectedWalletData.mainUtxo, - }) - }) + context("when the main UTXO does not belong to the wallet", () => { + const utxoWithRaw = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo + const deposit = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data + + // The UTXO below does not belong to the wallet + const mainUtxoWithRaw = { + transactionHash: BitcoinTxHash.from( + "2f952bdc206bf51bb745b967cb7166149becada878d3191ffe341155ebcd4883" + ), + outputIndex: 1, + value: BigNumber.from(3933200), + transactionHex: + "0100000000010162cae24e74ad64f9f0493b09f3964908b3b3038f4924882d3d" + + "bd853b4c9bc7390100000000ffffffff02102700000000000017a914867120d5" + + "480a9cc0c11c1193fa59b3a92e852da78710043c00000000001600147ac2d937" + + "8a1c47e589dfb8095ca95ed2140d272602483045022100b70bd9b7f5d230444a" + + "542c7971bea79786b4ebde6703cee7b6ee8cd16e115ebf02204d50ea9d1ee08d" + + "e9741498c2cc64266e40d52c4adb9ef68e65aa2727cd4208b5012102ee067a02" + + "73f2e3ba88d23140a24fdb290f27bbcd0f94117a9c65be3911c5c04e00000000", } - ) - - context( - "when wallet has pending redemptions and the requested amount is greater than possible", - () => { - beforeEach(async () => { - const wallet = - findWalletForRedemptionData.walletWithPendingRedemption - const walletBTCBalance = wallet.data.mainUtxo.value - const amount: BigNumber = walletBTCBalance - .sub(wallet.data.pendingRedemptionsValue) - .add(BigNumber.from(500000)) // 0.005 BTC - - console.log("amount", amount.toString()) + it("should revert", async () => { + const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - result = await redemptionsService.findWalletForRedemption( - redeemerOutputScript, - amount + await expect( + walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, + fee, + testnetWalletPrivateKey, + [utxoWithRaw], + [deposit], + mainUtxoWithRaw ) - }) - - it("should skip the wallet wallet with pending redemptions and return the wallet data that can handle redemption request ", () => { - const expectedWalletData = - findWalletForRedemptionData.liveWallet.data - - expect(result).to.deep.eq({ - walletPublicKey: expectedWalletData.walletPublicKey.toString(), - mainUtxo: expectedWalletData.mainUtxo, - }) - }) - } - ) + ).to.be.rejectedWith("UTXO does not belong to the wallet") + }) + }) context( - "when all active wallets has pending redemption for a given Bitcoin address", + "when the wallet private does not correspond to the wallet public key", () => { - const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC - const redeemerOutputScript = - findWalletForRedemptionData.pendingRedemption.redeemerOutputScript - - beforeEach(async () => { - const walletPublicKeyHash = - findWalletForRedemptionData.walletWithPendingRedemption.event - .walletPublicKeyHash - - const pendingRedemptions = new Map< - BigNumberish, - RedemptionRequest - >() - - const pendingRedemption1 = MockBridge.buildRedemptionKey( - walletPublicKeyHash.toString(), - redeemerOutputScript - ) - - const pendingRedemption2 = MockBridge.buildRedemptionKey( - findWalletForRedemptionData.liveWallet.event.walletPublicKeyHash.toString(), - redeemerOutputScript - ) + const utxoWithRaw = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].utxo + const deposit = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data + const anotherPrivateKey = + "cRJvyxtoggjAm9A94cB86hZ7Y62z2ei5VNJHLksFi2xdnz1GJ6xt" - pendingRedemptions.set( - pendingRedemption1, - findWalletForRedemptionData.pendingRedemption - ) - - pendingRedemptions.set( - pendingRedemption2, - findWalletForRedemptionData.pendingRedemption - ) - tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) - }) + it("should revert", async () => { + const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - it("should throw an error", async () => { await expect( - redemptionsService.findWalletForRedemption( - redeemerOutputScript, - amount + walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, + fee, + anotherPrivateKey, + [utxoWithRaw], + [deposit] ) ).to.be.rejectedWith( - "All live wallets in the network have the pending redemption for a given Bitcoin address. Please use another Bitcoin address." + "Wallet public key does not correspond to wallet private key" ) }) } ) - }) - }) - - describe("determineWalletMainUtxo", () => { - class TestRedemptionsService extends RedemptionsService { - public async determineWalletMainUtxo( - walletPublicKeyHash: Hex, - bitcoinNetwork: BitcoinNetwork - ): Promise { - return super.determineWalletMainUtxo( - walletPublicKeyHash, - bitcoinNetwork - ) - } - } - - // Just an arbitrary 20-byte wallet public key hash. - const walletPublicKeyHash = Hex.from( - "e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0" - ) - - // Helper function facilitating creation of mock transactions. - const mockTransaction = ( - hash: string, - outputs: Record // key: locking script, value: amount of locked satoshis - ): BitcoinTx => { - return { - transactionHash: Hex.from(hash), - inputs: [], // not relevant in this test scenario - outputs: Object.entries(outputs).map( - ([scriptPubKey, value], index) => ({ - outputIndex: index, - value: BigNumber.from(value), - scriptPubKey: Hex.from(scriptPubKey), - }) - ), - } - } - // Create a fake wallet witness transaction history that consists of 6 transactions. - const walletWitnessTransactionHistory: BitcoinTx[] = [ - mockTransaction( - "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1", - { - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "4c6b33b7c0550e0e536a5d119ac7189d71e1296fcb0c258e0c115356895bc0e6", - { - "00140000000000000000000000000000000000000001": 100000, - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 200000, // wallet witness output - } - ), - mockTransaction( - "44863a79ce2b8fec9792403d5048506e50ffa7338191db0e6c30d3d3358ea2f6", - { - "00140000000000000000000000000000000000000001": 100000, - "00140000000000000000000000000000000000000002": 200000, - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 300000, // wallet witness output - } - ), - mockTransaction( - "f65bc5029251f0042aedb37f90dbb2bfb63a2e81694beef9cae5ec62e954c22e", - { - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "2724545276df61f43f1e92c4b9f1dd3c9109595c022dbd9dc003efbad8ded38b", - { - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214", - { - "00140000000000000000000000000000000000000001": 100000, - "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 200000, // wallet witness output - } - ), - ] - - // Create a fake wallet legacy transaction history that consists of 6 transactions. - const walletLegacyTransactionHistory: BitcoinTx[] = [ - mockTransaction( - "230a19d8867ff3f5b409e924d9dd6413188e215f9bb52f1c47de6154dac42267", - { - "00140000000000000000000000000000000000000001": 100000, - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 200000, // wallet legacy output - } - ), - mockTransaction( - "b11bfc481b95769b8488bd661d5f61a35f7c3c757160494d63f6e04e532dfcb9", - { - "00140000000000000000000000000000000000000001": 100000, - "00140000000000000000000000000000000000000002": 200000, - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 300000, // wallet legacy output - } - ), - mockTransaction( - "7e91580d989f8541489a37431381ff9babd596111232f1bc7a1a1ba503c27dee", - { - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "5404e339ba82e6e52fcc24cb40029bed8425baa4c7f869626ef9de956186f910", - { - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94", - { - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output - "00140000000000000000000000000000000000000001": 200000, - } - ), - mockTransaction( - "00cc0cd13fc4de7a15cb41ab6d58f8b31c75b6b9b4194958c381441a67d09b08", - { - "00140000000000000000000000000000000000000001": 100000, - "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 200000, // wallet legacy output + context("when the type of UTXO is unsupported", () => { + // Use coinbase transaction of some block + const utxoWithRaw = { + transactionHash: BitcoinTxHash.from( + "025de155e6f2ffbbf4851493e0d28dad54020db221a3f38bf63c1f65e3d3595b" + ), + outputIndex: 0, + value: BigNumber.from(5000000000), + transactionHex: + "010000000100000000000000000000000000000000000000000000000000000000" + + "00000000ffffffff0e04db07c34f0103062f503253482fffffffff0100f2052a01" + + "000000232102db6a0f2ef2e970eb1d2a84eabb5337f9cac0d85b49f209bffc4ec6" + + "805802e6a5ac00000000", } - ), - ] - - let tbtcContracts: MockTBTCContracts - let bitcoinClient: MockBitcoinClient - let bitcoinNetwork: BitcoinNetwork - let redemptionsService: TestRedemptionsService - - beforeEach(async () => { - tbtcContracts = new MockTBTCContracts() - bitcoinClient = new MockBitcoinClient() - redemptionsService = new TestRedemptionsService( - tbtcContracts, - bitcoinClient - ) - }) - - context("when wallet main UTXO is not set in the Bridge", () => { - beforeEach(async () => { - tbtcContracts.bridge.setWallet( - walletPublicKeyHash.toPrefixedString(), - { - mainUtxoHash: Hex.from( - "0x0000000000000000000000000000000000000000000000000000000000000000" - ), - } as Wallet - ) - }) - - it("should return undefined", async () => { - const mainUtxo = await redemptionsService.determineWalletMainUtxo( - walletPublicKeyHash, - bitcoinNetwork - ) - - expect(mainUtxo).to.be.undefined - }) - }) - - context("when wallet main UTXO is set in the Bridge", () => { - const tests = [ - { - testName: "recent witness transaction", - // Set the main UTXO hash based on the latest transaction from walletWitnessTransactionHistory. - actualMainUtxo: { - transactionHash: Hex.from( - "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214" - ), - outputIndex: 1, - value: BigNumber.from(200000), - }, - expectedMainUtxo: { - transactionHash: Hex.from( - "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214" - ), - outputIndex: 1, - value: BigNumber.from(200000), - }, - }, - { - testName: "recent legacy transaction", - // Set the main UTXO hash based on the second last transaction from walletLegacyTransactionHistory. - actualMainUtxo: { - transactionHash: Hex.from( - "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94" - ), - outputIndex: 0, - value: BigNumber.from(100000), - }, - expectedMainUtxo: { - transactionHash: Hex.from( - "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94" - ), - outputIndex: 0, - value: BigNumber.from(100000), - }, - }, - { - testName: "old witness transaction", - // Set the main UTXO hash based on the oldest transaction from walletWitnessTransactionHistory. - actualMainUtxo: { - transactionHash: Hex.from( - "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1" - ), - outputIndex: 0, - value: BigNumber.from(100000), - }, - expectedMainUtxo: undefined, - }, - { - testName: "old legacy transaction", - // Set the main UTXO hash based on the oldest transaction from walletLegacyTransactionHistory. - actualMainUtxo: { - transactionHash: Hex.from( - "230a19d8867ff3f5b409e924d9dd6413188e215f9bb52f1c47de6154dac42267" - ), - outputIndex: 1, - value: BigNumber.from(200000), - }, - expectedMainUtxo: undefined, - }, - ] - - tests.forEach(({ testName, actualMainUtxo, expectedMainUtxo }) => { - context(`with main UTXO coming from ${testName}`, () => { - const networkTests = [ - { - networkTestName: "bitcoin testnet", - network: BitcoinNetwork.Testnet, - }, - { - networkTestName: "bitcoin mainnet", - network: BitcoinNetwork.Mainnet, - }, - ] - - networkTests.forEach(({ networkTestName, network }) => { - context(`with ${networkTestName} network`, () => { - beforeEach(async () => { - bitcoinNetwork = network - - const walletWitnessAddress = - BitcoinAddressConverter.publicKeyHashToAddress( - walletPublicKeyHash.toString(), - true, - bitcoinNetwork - ) - const walletLegacyAddress = - BitcoinAddressConverter.publicKeyHashToAddress( - walletPublicKeyHash.toString(), - false, - bitcoinNetwork - ) - - // Record the fake transaction history for both address types. - const transactionHistory = new Map() - transactionHistory.set( - walletWitnessAddress, - walletWitnessTransactionHistory - ) - transactionHistory.set( - walletLegacyAddress, - walletLegacyTransactionHistory - ) - bitcoinClient.transactionHistory = transactionHistory - - tbtcContracts.bridge.setWallet( - walletPublicKeyHash.toPrefixedString(), - { - mainUtxoHash: - tbtcContracts.bridge.buildUtxoHash(actualMainUtxo), - } as Wallet - ) - }) + const deposit = + depositSweepWithNoMainUtxoAndWitnessOutput.deposits[0].data - it("should return the expected main UTXO", async () => { - const mainUtxo = - await redemptionsService.determineWalletMainUtxo( - walletPublicKeyHash, - bitcoinNetwork - ) + it("should revert", async () => { + const walletTx = new WalletTx(tbtcContracts, bitcoinClient) - expect(mainUtxo).to.be.eql(expectedMainUtxo) - }) - }) - }) + await expect( + walletTx.depositSweep.assembleTransaction( + BitcoinNetwork.Testnet, + fee, + testnetWalletPrivateKey, + [utxoWithRaw], + [deposit] + ) + ).to.be.rejectedWith("Unsupported UTXO script type") }) }) }) }) - }) - describe("WalletTx", () => { describe("Redemption", () => { describe("submitTransaction", () => { let tbtcContracts: MockTBTCContracts @@ -2141,6 +2411,73 @@ describe("Redemption", () => { }) describe("Spv", () => { + describe("submitDepositSweepProof", () => { + let bitcoinClient: MockBitcoinClient + let tbtcContracts: MockTBTCContracts + let maintenanceService: MaintenanceService + + beforeEach(async () => { + bitcoinClient = new MockBitcoinClient() + tbtcContracts = new MockTBTCContracts() + + maintenanceService = new MaintenanceService( + tbtcContracts, + bitcoinClient + ) + + const transactionHash = + depositSweepProof.bitcoinChainData.transaction.transactionHash + const transactions = new Map() + transactions.set( + transactionHash.toString(), + depositSweepProof.bitcoinChainData.transaction + ) + bitcoinClient.transactions = transactions + + const rawTransactions = new Map() + rawTransactions.set( + transactionHash.toString(), + depositSweepProof.bitcoinChainData.rawTransaction + ) + bitcoinClient.rawTransactions = rawTransactions + + bitcoinClient.latestHeight = + depositSweepProof.bitcoinChainData.latestBlockHeight + bitcoinClient.headersChain = + depositSweepProof.bitcoinChainData.headersChain + bitcoinClient.transactionMerkle = + depositSweepProof.bitcoinChainData.transactionMerkleBranch + const confirmations = new Map() + confirmations.set( + transactionHash.toString(), + depositSweepProof.bitcoinChainData.accumulatedTxConfirmations + ) + bitcoinClient.confirmations = confirmations + await maintenanceService.spv.submitDepositSweepProof( + transactionHash, + NO_MAIN_UTXO + ) + }) + + it("should submit deposit sweep proof with correct arguments", () => { + const bridgeLog = tbtcContracts.bridge.depositSweepProofLog + expect(bridgeLog.length).to.equal(1) + expect(bridgeLog[0].mainUtxo).to.equal(NO_MAIN_UTXO) + expect(bridgeLog[0].sweepTx).to.deep.equal( + depositSweepProof.expectedSweepProof.sweepTx + ) + expect(bridgeLog[0].sweepProof.txIndexInBlock).to.deep.equal( + depositSweepProof.expectedSweepProof.sweepProof.txIndexInBlock + ) + expect(bridgeLog[0].sweepProof.merkleProof).to.deep.equal( + depositSweepProof.expectedSweepProof.sweepProof.merkleProof + ) + expect(bridgeLog[0].sweepProof.bitcoinHeaders).to.deep.equal( + depositSweepProof.expectedSweepProof.sweepProof.bitcoinHeaders + ) + }) + }) + describe("submitRedemptionProof", () => { const mainUtxo = { transactionHash: BitcoinTxHash.from( @@ -2223,40 +2560,3 @@ describe("Redemption", () => { }) }) }) - -async function runRedemptionScenario( - walletPrivKey: string, - bitcoinClient: MockBitcoinClient, - tbtcContracts: MockTBTCContracts, - data: RedemptionTestData -): Promise<{ - transactionHash: BitcoinTxHash - newMainUtxo?: BitcoinUtxo -}> { - const rawTransactions = new Map() - rawTransactions.set(data.mainUtxo.transactionHash.toString(), { - transactionHex: data.mainUtxo.transactionHex, - }) - bitcoinClient.rawTransactions = rawTransactions - - tbtcContracts.bridge.setPendingRedemptions( - new Map( - data.pendingRedemptions.map((redemption) => [ - redemption.redemptionKey, - redemption.pendingRedemption, - ]) - ) - ) - - const redeemerOutputScripts = data.pendingRedemptions.map( - (redemption) => redemption.pendingRedemption.redeemerOutputScript - ) - - const walletTx = new WalletTx(tbtcContracts, bitcoinClient, data.witness) - - return walletTx.redemption.submitTransaction( - walletPrivKey, - data.mainUtxo, - redeemerOutputScripts - ) -} diff --git a/typescript/test/services/redemptions.test.ts b/typescript/test/services/redemptions.test.ts new file mode 100644 index 000000000..1b9a82e24 --- /dev/null +++ b/typescript/test/services/redemptions.test.ts @@ -0,0 +1,839 @@ +import { + BitcoinAddressConverter, + BitcoinHashUtils, + BitcoinNetwork, + BitcoinRawTx, + BitcoinTx, + BitcoinTxHash, + BitcoinUtxo, + Hex, + NewWalletRegisteredEvent, + RedemptionRequest, + RedemptionsService, + Wallet, + WalletState, + WalletTx, +} from "../../src" +import { MockBitcoinClient } from "../utils/mock-bitcoin-client" +import { + findWalletForRedemptionData, + multipleRedemptionsWithWitnessChange, + RedemptionTestData, + singleP2PKHRedemptionWithWitnessChange, + walletPublicKey, +} from "../data/redemption" +import { MockBridge } from "../utils/mock-bridge" +import * as chai from "chai" +import { expect } from "chai" +import chaiAsPromised from "chai-as-promised" +import { BigNumber, BigNumberish } from "ethers" +import { MockTBTCContracts } from "../utils/mock-tbtc-contracts" + +chai.use(chaiAsPromised) + +describe("Redemptions", () => { + describe("RedemptionsService", () => { + describe("requestRedemption", () => { + const data: RedemptionTestData = singleP2PKHRedemptionWithWitnessChange + const { transactionHash, value } = data.mainUtxo + const mainUtxo: BitcoinUtxo = { + transactionHash, + outputIndex: 0, + value, + } + const redeemerOutputScript = + data.pendingRedemptions[0].pendingRedemption.redeemerOutputScript + const amount = + data.pendingRedemptions[0].pendingRedemption.requestedAmount + + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + + const walletPublicKeyHash = Hex.from( + BitcoinHashUtils.computeHash160(walletPublicKey) + ) + + // Prepare NewWalletRegisteredEvent history. Set only relevant fields. + tbtcContracts.bridge.newWalletRegisteredEvents = [ + { + walletPublicKeyHash: walletPublicKeyHash, + } as NewWalletRegisteredEvent, + ] + + // Prepare wallet data in the Bridge. Set only relevant fields. + tbtcContracts.bridge.setWallet(walletPublicKeyHash.toPrefixedString(), { + state: WalletState.Live, + walletPublicKey: Hex.from(walletPublicKey), + pendingRedemptionsValue: BigNumber.from(0), + mainUtxoHash: tbtcContracts.bridge.buildUtxoHash(mainUtxo), + } as Wallet) + + const walletAddress = BitcoinAddressConverter.publicKeyHashToAddress( + walletPublicKeyHash.toString(), + true, + BitcoinNetwork.Testnet + ) + + // Prepare wallet transaction history for main UTXO lookup. + // Set only relevant fields. + const transactionHistory = new Map() + transactionHistory.set(walletAddress, [ + { + transactionHash: mainUtxo.transactionHash, + outputs: [ + { + outputIndex: mainUtxo.outputIndex, + value: mainUtxo.value, + scriptPubKey: BitcoinAddressConverter.addressToOutputScript( + walletAddress, + BitcoinNetwork.Testnet + ), + }, + ], + } as BitcoinTx, + ]) + bitcoinClient.transactionHistory = transactionHistory + + const redemptionsService = new RedemptionsService( + tbtcContracts, + bitcoinClient + ) + + await redemptionsService.requestRedemption( + BitcoinAddressConverter.outputScriptToAddress( + Hex.from(redeemerOutputScript), + BitcoinNetwork.Testnet + ), + amount + ) + }) + + it("should submit redemption request with correct arguments", () => { + const tokenLog = tbtcContracts.tbtcToken.requestRedemptionLog + + expect(tokenLog.length).to.equal(1) + expect(tokenLog[0]).to.deep.equal({ + walletPublicKey, + mainUtxo, + redeemerOutputScript, + amount, + }) + }) + }) + + describe("getRedemptionRequest", () => { + context("when asked for a pending request", () => { + const { redemptionKey, pendingRedemption: redemptionRequest } = + multipleRedemptionsWithWitnessChange.pendingRedemptions[0] + + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + let redemptionsService: RedemptionsService + + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + + const pendingRedemptions = new Map() + pendingRedemptions.set(redemptionKey, redemptionRequest) + + tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) + + redemptionsService = new RedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + it("should return the expected redemption request", async () => { + const actualRedemptionRequest = + await redemptionsService.getRedemptionRequests( + BitcoinAddressConverter.outputScriptToAddress( + Hex.from(redemptionRequest.redeemerOutputScript), + BitcoinNetwork.Testnet + ), + walletPublicKey, + "pending" + ) + + expect(actualRedemptionRequest).to.be.eql(redemptionRequest) + }) + }) + + context("when asked for a timed-out request", () => { + const { redemptionKey, pendingRedemption: redemptionRequest } = + multipleRedemptionsWithWitnessChange.pendingRedemptions[0] + + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + let redemptionsService: RedemptionsService + + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + + const timedOutRedemptions = new Map() + timedOutRedemptions.set(redemptionKey, redemptionRequest) + + tbtcContracts.bridge.setTimedOutRedemptions(timedOutRedemptions) + + redemptionsService = new RedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + it("should return the expected redemption request", async () => { + const actualRedemptionRequest = + await redemptionsService.getRedemptionRequests( + BitcoinAddressConverter.outputScriptToAddress( + Hex.from(redemptionRequest.redeemerOutputScript), + BitcoinNetwork.Testnet + ), + walletPublicKey, + "timedOut" + ) + + expect(actualRedemptionRequest).to.be.eql(redemptionRequest) + }) + }) + }) + + describe("findWalletForRedemption", () => { + class TestRedemptionsService extends RedemptionsService { + public async findWalletForRedemption( + redeemerOutputScript: string, + amount: BigNumber + ): Promise<{ + walletPublicKey: string + mainUtxo: BitcoinUtxo + }> { + return super.findWalletForRedemption(redeemerOutputScript, amount) + } + } + + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + let redemptionsService: TestRedemptionsService + // script for testnet P2WSH address + // tb1qau95mxzh2249aa3y8exx76ltc2sq0e7kw8hj04936rdcmnynhswqqz02vv + const redeemerOutputScript = + "0x220020ef0b4d985752aa5ef6243e4c6f6bebc2a007e7d671ef27d4b1d0db8dcc93bc1c" + + context( + "when there are no wallets in the network that can handle redemption", + () => { + const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC + beforeEach(() => { + bitcoinClient = new MockBitcoinClient() + tbtcContracts = new MockTBTCContracts() + tbtcContracts.bridge.newWalletRegisteredEvents = [] + redemptionsService = new TestRedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + it("should throw an error", async () => { + await expect( + redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + ).to.be.rejectedWith( + "Currently, there are no live wallets in the network." + ) + }) + } + ) + + context("when there are registered wallets in the network", () => { + let result: Awaited | never> + const walletsOrder = [ + findWalletForRedemptionData.nonLiveWallet, + findWalletForRedemptionData.walletWithoutUtxo, + findWalletForRedemptionData.walletWithPendingRedemption, + findWalletForRedemptionData.liveWallet, + ] + + beforeEach(async () => { + bitcoinClient = new MockBitcoinClient() + tbtcContracts = new MockTBTCContracts() + + tbtcContracts.bridge.newWalletRegisteredEvents = walletsOrder.map( + (wallet) => wallet.event + ) + + const walletsTransactionHistory = new Map() + + walletsOrder.forEach((wallet) => { + const { + state, + mainUtxoHash, + walletPublicKey, + btcAddress, + transactions, + pendingRedemptionsValue, + } = wallet.data + + walletsTransactionHistory.set(btcAddress, transactions) + tbtcContracts.bridge.setWallet( + wallet.event.walletPublicKeyHash.toPrefixedString(), + { + state, + mainUtxoHash, + walletPublicKey, + pendingRedemptionsValue, + } as Wallet + ) + }) + + bitcoinClient.transactionHistory = walletsTransactionHistory + + redemptionsService = new TestRedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + context( + "when there is a wallet that can handle the redemption request", + () => { + const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC + beforeEach(async () => { + result = await redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + }) + + it("should get all registered wallets", () => { + const bridgeQueryEventsLog = + tbtcContracts.bridge.newWalletRegisteredEventsLog + + expect(bridgeQueryEventsLog.length).to.equal(1) + expect(bridgeQueryEventsLog[0]).to.deep.equal({ + options: undefined, + filterArgs: [], + }) + }) + + it("should return the wallet data that can handle redemption request", () => { + const expectedWalletData = + findWalletForRedemptionData.walletWithPendingRedemption.data + + expect(result).to.deep.eq({ + walletPublicKey: expectedWalletData.walletPublicKey.toString(), + mainUtxo: expectedWalletData.mainUtxo, + }) + }) + } + ) + + context( + "when the redemption request amount is too large and no wallet can handle the request", + () => { + const amount = BigNumber.from("10000000000") // 1 000 BTC + const expectedMaxAmount = walletsOrder + .map((wallet) => wallet.data) + .map((wallet) => wallet.mainUtxo) + .map((utxo) => utxo.value) + .sort((a, b) => (b.gt(a) ? 0 : -1))[0] + + it("should throw an error", async () => { + await expect( + redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + ).to.be.rejectedWith( + `Could not find a wallet with enough funds. Maximum redemption amount is ${expectedMaxAmount.toString()} Satoshi.` + ) + }) + } + ) + + context( + "when there is pending redemption request from a given wallet to the same address", + () => { + beforeEach(async () => { + const redeemerOutputScript = + findWalletForRedemptionData.pendingRedemption + .redeemerOutputScript + const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC + + const walletPublicKeyHash = + findWalletForRedemptionData.walletWithPendingRedemption.event + .walletPublicKeyHash + + const pendingRedemptions = new Map< + BigNumberish, + RedemptionRequest + >() + + const key = MockBridge.buildRedemptionKey( + walletPublicKeyHash.toString(), + redeemerOutputScript + ) + + pendingRedemptions.set( + key, + findWalletForRedemptionData.pendingRedemption + ) + tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) + + result = await redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + }) + + it("should get all registered wallets", () => { + const bridgeQueryEventsLog = + tbtcContracts.bridge.newWalletRegisteredEventsLog + + expect(bridgeQueryEventsLog.length).to.equal(1) + expect(bridgeQueryEventsLog[0]).to.deep.equal({ + options: undefined, + filterArgs: [], + }) + }) + + it("should skip the wallet for which there is a pending redemption request to the same redeemer output script and return the wallet data that can handle redemption request", () => { + const expectedWalletData = + findWalletForRedemptionData.liveWallet.data + + expect(result).to.deep.eq({ + walletPublicKey: expectedWalletData.walletPublicKey.toString(), + mainUtxo: expectedWalletData.mainUtxo, + }) + }) + } + ) + + context( + "when wallet has pending redemptions and the requested amount is greater than possible", + () => { + beforeEach(async () => { + const wallet = + findWalletForRedemptionData.walletWithPendingRedemption + const walletBTCBalance = wallet.data.mainUtxo.value + + const amount: BigNumber = walletBTCBalance + .sub(wallet.data.pendingRedemptionsValue) + .add(BigNumber.from(500000)) // 0.005 BTC + + console.log("amount", amount.toString()) + + result = await redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + }) + + it("should skip the wallet wallet with pending redemptions and return the wallet data that can handle redemption request ", () => { + const expectedWalletData = + findWalletForRedemptionData.liveWallet.data + + expect(result).to.deep.eq({ + walletPublicKey: expectedWalletData.walletPublicKey.toString(), + mainUtxo: expectedWalletData.mainUtxo, + }) + }) + } + ) + + context( + "when all active wallets has pending redemption for a given Bitcoin address", + () => { + const amount: BigNumber = BigNumber.from("1000000") // 0.01 BTC + const redeemerOutputScript = + findWalletForRedemptionData.pendingRedemption.redeemerOutputScript + + beforeEach(async () => { + const walletPublicKeyHash = + findWalletForRedemptionData.walletWithPendingRedemption.event + .walletPublicKeyHash + + const pendingRedemptions = new Map< + BigNumberish, + RedemptionRequest + >() + + const pendingRedemption1 = MockBridge.buildRedemptionKey( + walletPublicKeyHash.toString(), + redeemerOutputScript + ) + + const pendingRedemption2 = MockBridge.buildRedemptionKey( + findWalletForRedemptionData.liveWallet.event.walletPublicKeyHash.toString(), + redeemerOutputScript + ) + + pendingRedemptions.set( + pendingRedemption1, + findWalletForRedemptionData.pendingRedemption + ) + + pendingRedemptions.set( + pendingRedemption2, + findWalletForRedemptionData.pendingRedemption + ) + tbtcContracts.bridge.setPendingRedemptions(pendingRedemptions) + }) + + it("should throw an error", async () => { + await expect( + redemptionsService.findWalletForRedemption( + redeemerOutputScript, + amount + ) + ).to.be.rejectedWith( + "All live wallets in the network have the pending redemption for a given Bitcoin address. Please use another Bitcoin address." + ) + }) + } + ) + }) + }) + + describe("determineWalletMainUtxo", () => { + class TestRedemptionsService extends RedemptionsService { + public async determineWalletMainUtxo( + walletPublicKeyHash: Hex, + bitcoinNetwork: BitcoinNetwork + ): Promise { + return super.determineWalletMainUtxo( + walletPublicKeyHash, + bitcoinNetwork + ) + } + } + + // Just an arbitrary 20-byte wallet public key hash. + const walletPublicKeyHash = Hex.from( + "e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0" + ) + + // Helper function facilitating creation of mock transactions. + const mockTransaction = ( + hash: string, + outputs: Record // key: locking script, value: amount of locked satoshis + ): BitcoinTx => { + return { + transactionHash: Hex.from(hash), + inputs: [], // not relevant in this test scenario + outputs: Object.entries(outputs).map( + ([scriptPubKey, value], index) => ({ + outputIndex: index, + value: BigNumber.from(value), + scriptPubKey: Hex.from(scriptPubKey), + }) + ), + } + } + + // Create a fake wallet witness transaction history that consists of 6 transactions. + const walletWitnessTransactionHistory: BitcoinTx[] = [ + mockTransaction( + "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1", + { + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "4c6b33b7c0550e0e536a5d119ac7189d71e1296fcb0c258e0c115356895bc0e6", + { + "00140000000000000000000000000000000000000001": 100000, + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 200000, // wallet witness output + } + ), + mockTransaction( + "44863a79ce2b8fec9792403d5048506e50ffa7338191db0e6c30d3d3358ea2f6", + { + "00140000000000000000000000000000000000000001": 100000, + "00140000000000000000000000000000000000000002": 200000, + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 300000, // wallet witness output + } + ), + mockTransaction( + "f65bc5029251f0042aedb37f90dbb2bfb63a2e81694beef9cae5ec62e954c22e", + { + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "2724545276df61f43f1e92c4b9f1dd3c9109595c022dbd9dc003efbad8ded38b", + { + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 100000, // wallet witness output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214", + { + "00140000000000000000000000000000000000000001": 100000, + "0014e6f9d74726b19b75f16fe1e9feaec048aa4fa1d0": 200000, // wallet witness output + } + ), + ] + + // Create a fake wallet legacy transaction history that consists of 6 transactions. + const walletLegacyTransactionHistory: BitcoinTx[] = [ + mockTransaction( + "230a19d8867ff3f5b409e924d9dd6413188e215f9bb52f1c47de6154dac42267", + { + "00140000000000000000000000000000000000000001": 100000, + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 200000, // wallet legacy output + } + ), + mockTransaction( + "b11bfc481b95769b8488bd661d5f61a35f7c3c757160494d63f6e04e532dfcb9", + { + "00140000000000000000000000000000000000000001": 100000, + "00140000000000000000000000000000000000000002": 200000, + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 300000, // wallet legacy output + } + ), + mockTransaction( + "7e91580d989f8541489a37431381ff9babd596111232f1bc7a1a1ba503c27dee", + { + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "5404e339ba82e6e52fcc24cb40029bed8425baa4c7f869626ef9de956186f910", + { + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94", + { + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 100000, // wallet legacy output + "00140000000000000000000000000000000000000001": 200000, + } + ), + mockTransaction( + "00cc0cd13fc4de7a15cb41ab6d58f8b31c75b6b9b4194958c381441a67d09b08", + { + "00140000000000000000000000000000000000000001": 100000, + "76a914e6f9d74726b19b75f16fe1e9feaec048aa4fa1d088ac": 200000, // wallet legacy output + } + ), + ] + + let tbtcContracts: MockTBTCContracts + let bitcoinClient: MockBitcoinClient + let bitcoinNetwork: BitcoinNetwork + let redemptionsService: TestRedemptionsService + + beforeEach(async () => { + tbtcContracts = new MockTBTCContracts() + bitcoinClient = new MockBitcoinClient() + redemptionsService = new TestRedemptionsService( + tbtcContracts, + bitcoinClient + ) + }) + + context("when wallet main UTXO is not set in the Bridge", () => { + beforeEach(async () => { + tbtcContracts.bridge.setWallet( + walletPublicKeyHash.toPrefixedString(), + { + mainUtxoHash: Hex.from( + "0x0000000000000000000000000000000000000000000000000000000000000000" + ), + } as Wallet + ) + }) + + it("should return undefined", async () => { + const mainUtxo = await redemptionsService.determineWalletMainUtxo( + walletPublicKeyHash, + bitcoinNetwork + ) + + expect(mainUtxo).to.be.undefined + }) + }) + + context("when wallet main UTXO is set in the Bridge", () => { + const tests = [ + { + testName: "recent witness transaction", + // Set the main UTXO hash based on the latest transaction from walletWitnessTransactionHistory. + actualMainUtxo: { + transactionHash: Hex.from( + "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214" + ), + outputIndex: 1, + value: BigNumber.from(200000), + }, + expectedMainUtxo: { + transactionHash: Hex.from( + "ea374ab6842723c647c3fc0ab281ca0641eaa768576cf9df695ca5b827140214" + ), + outputIndex: 1, + value: BigNumber.from(200000), + }, + }, + { + testName: "recent legacy transaction", + // Set the main UTXO hash based on the second last transaction from walletLegacyTransactionHistory. + actualMainUtxo: { + transactionHash: Hex.from( + "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94" + ), + outputIndex: 0, + value: BigNumber.from(100000), + }, + expectedMainUtxo: { + transactionHash: Hex.from( + "05dabb0291c0a6aa522de5ded5cb6d14ee2159e7ff109d3ef0f21de128b56b94" + ), + outputIndex: 0, + value: BigNumber.from(100000), + }, + }, + { + testName: "old witness transaction", + // Set the main UTXO hash based on the oldest transaction from walletWitnessTransactionHistory. + actualMainUtxo: { + transactionHash: Hex.from( + "3ca4ae3f8ee3b48949192bc7a146c8d9862267816258c85e02a44678364551e1" + ), + outputIndex: 0, + value: BigNumber.from(100000), + }, + expectedMainUtxo: undefined, + }, + { + testName: "old legacy transaction", + // Set the main UTXO hash based on the oldest transaction from walletLegacyTransactionHistory. + actualMainUtxo: { + transactionHash: Hex.from( + "230a19d8867ff3f5b409e924d9dd6413188e215f9bb52f1c47de6154dac42267" + ), + outputIndex: 1, + value: BigNumber.from(200000), + }, + expectedMainUtxo: undefined, + }, + ] + + tests.forEach(({ testName, actualMainUtxo, expectedMainUtxo }) => { + context(`with main UTXO coming from ${testName}`, () => { + const networkTests = [ + { + networkTestName: "bitcoin testnet", + network: BitcoinNetwork.Testnet, + }, + { + networkTestName: "bitcoin mainnet", + network: BitcoinNetwork.Mainnet, + }, + ] + + networkTests.forEach(({ networkTestName, network }) => { + context(`with ${networkTestName} network`, () => { + beforeEach(async () => { + bitcoinNetwork = network + + const walletWitnessAddress = + BitcoinAddressConverter.publicKeyHashToAddress( + walletPublicKeyHash.toString(), + true, + bitcoinNetwork + ) + const walletLegacyAddress = + BitcoinAddressConverter.publicKeyHashToAddress( + walletPublicKeyHash.toString(), + false, + bitcoinNetwork + ) + + // Record the fake transaction history for both address types. + const transactionHistory = new Map() + transactionHistory.set( + walletWitnessAddress, + walletWitnessTransactionHistory + ) + transactionHistory.set( + walletLegacyAddress, + walletLegacyTransactionHistory + ) + bitcoinClient.transactionHistory = transactionHistory + + tbtcContracts.bridge.setWallet( + walletPublicKeyHash.toPrefixedString(), + { + mainUtxoHash: + tbtcContracts.bridge.buildUtxoHash(actualMainUtxo), + } as Wallet + ) + }) + + it("should return the expected main UTXO", async () => { + const mainUtxo = + await redemptionsService.determineWalletMainUtxo( + walletPublicKeyHash, + bitcoinNetwork + ) + + expect(mainUtxo).to.be.eql(expectedMainUtxo) + }) + }) + }) + }) + }) + }) + }) + }) +}) + +export async function runRedemptionScenario( + walletPrivKey: string, + bitcoinClient: MockBitcoinClient, + tbtcContracts: MockTBTCContracts, + data: RedemptionTestData +): Promise<{ + transactionHash: BitcoinTxHash + newMainUtxo?: BitcoinUtxo +}> { + const rawTransactions = new Map() + rawTransactions.set(data.mainUtxo.transactionHash.toString(), { + transactionHex: data.mainUtxo.transactionHex, + }) + bitcoinClient.rawTransactions = rawTransactions + + tbtcContracts.bridge.setPendingRedemptions( + new Map( + data.pendingRedemptions.map((redemption) => [ + redemption.redemptionKey, + redemption.pendingRedemption, + ]) + ) + ) + + const redeemerOutputScripts = data.pendingRedemptions.map( + (redemption) => redemption.pendingRedemption.redeemerOutputScript + ) + + const walletTx = new WalletTx(tbtcContracts, bitcoinClient, data.witness) + + return walletTx.redemption.submitTransaction( + walletPrivKey, + data.mainUtxo, + redeemerOutputScripts + ) +} From 3d0e38b6ef4e3b79db89a10d875c315abc91b82a Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 11 Oct 2023 11:26:02 +0200 Subject: [PATCH 190/205] Adjust refund.ts script --- typescript/scripts/refund.ts | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/typescript/scripts/refund.ts b/typescript/scripts/refund.ts index 1eb56ab36..11931b978 100644 --- a/typescript/scripts/refund.ts +++ b/typescript/scripts/refund.ts @@ -1,10 +1,15 @@ import { BigNumber } from "ethers" -import { Deposit } from "../src/deposit" -import { submitDepositRefundTransaction } from "../src/deposit-refund" -import { TransactionHash, UnspentTransactionOutput } from "../src/bitcoin" -import { Client as ElectrumClient } from "../src/electrum" import { program } from "commander" -import fs from "fs" +import * as fs from "fs" +import { + BitcoinTxHash, + BitcoinUtxo, + DepositReceipt, + DepositRefund, + DepositScript, + ElectrumClient, + ElectrumCredentials, +} from "../src" program .version("0.0.1") @@ -49,13 +54,12 @@ const electrumCredentials = { host: options.host, port: options.port, protocol: options.protocol, -} +} as ElectrumCredentials const depositJson = JSON.parse(fs.readFileSync(depositJsonPath, "utf-8")) -const deposit: Deposit = { +const deposit: DepositReceipt = { depositor: depositJson.depositor, - amount: BigNumber.from(refundAmount), walletPublicKeyHash: depositJson.walletPublicKeyHash, refundPublicKeyHash: depositJson.refundPublicKeyHash, blindingFactor: depositJson.blindingFactor, @@ -73,19 +77,21 @@ console.log("electrum credentials:", electrumCredentials) console.log("=====================================") async function run(): Promise { - const client = new ElectrumClient(electrumCredentials) + const client = new ElectrumClient([electrumCredentials]) - const depositUtxo: UnspentTransactionOutput = { - transactionHash: TransactionHash.from(transactionId), + const depositUtxo: BitcoinUtxo = { + transactionHash: BitcoinTxHash.from(transactionId), outputIndex: Number(transactionIndex), value: BigNumber.from(refundAmount), } - const refundTxHash = await submitDepositRefundTransaction( + const depositScript = DepositScript.fromReceipt(deposit) + const depositRefund = DepositRefund.fromScript(depositScript) + + const refundTxHash = await depositRefund.submitTransaction( client, BigNumber.from(fee), depositUtxo, - deposit, recoveryAddress, refunderPrivateKey ) From 407be177c40b168964fa6d21c082239d9621047c Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 09:50:47 +0200 Subject: [PATCH 191/205] Fix the `npm-compile-publish` job The typescript library has been migrated from Node 14 to Node LTS (18) recently. We need to reflect that change in all CI jobs. --- .github/workflows/npm-typescript.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-typescript.yml b/.github/workflows/npm-typescript.yml index e1e97e733..c950491a1 100644 --- a/.github/workflows/npm-typescript.yml +++ b/.github/workflows/npm-typescript.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: "14.x" + node-version: "18.x" registry-url: "https://registry.npmjs.org" cache: "yarn" cache-dependency-path: typescript/yarn.lock From 475cd5710e1ea5772097915307d3797409530f12 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 11:03:23 +0200 Subject: [PATCH 192/205] TypeScript: Start version 2.0.0-dev We released version 1.4.0, so need to start a next one for development. --- typescript/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/package.json b/typescript/package.json index 0f803bdc4..b7cc037e9 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@keep-network/tbtc-v2.ts", - "version": "1.4.0-dev", + "version": "2.0.0-dev", "license": "MIT", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", From 4d4f45cf2da4f9cde2e349cd62f5298c7cbedbff Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 14:50:43 +0200 Subject: [PATCH 193/205] Make `BitcoinCompactSizeUint.read` throw on empty varlen data --- typescript/src/lib/bitcoin/csuint.ts | 6 +++++- typescript/test/lib/bitcoin.test.ts | 14 +++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/typescript/src/lib/bitcoin/csuint.ts b/typescript/src/lib/bitcoin/csuint.ts index e0576e176..163bc30c1 100644 --- a/typescript/src/lib/bitcoin/csuint.ts +++ b/typescript/src/lib/bitcoin/csuint.ts @@ -14,6 +14,10 @@ function read(varLenData: Hex): { value: number byteLength: number } { + if (varLenData.toString().length == 0) { + throw new Error("Empty variable length data argument") + } + // The varLenData is prefixed with the compact size uint. According to the docs // (https://developer.bitcoin.org/reference/transactions.html#compactsize-unsigned-integers) // a compact size uint can be 1, 3, 5 or 9 bytes. To determine the exact length, @@ -26,7 +30,7 @@ function read(varLenData: Hex): { case "fe": case "fd": { throw new Error( - "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + "Support for 3, 5 and 9 bytes compact size uints is not implemented yet" ) } default: { diff --git a/typescript/test/lib/bitcoin.test.ts b/typescript/test/lib/bitcoin.test.ts index 8483732ba..8fdd766a1 100644 --- a/typescript/test/lib/bitcoin.test.ts +++ b/typescript/test/lib/bitcoin.test.ts @@ -765,6 +765,14 @@ describe("Bitcoin", () => { const { read } = BitcoinCompactSizeUint describe("read", () => { + context("when the compact size uint is empty", () => { + it("should throw", () => { + expect(() => { + return read(Hex.from("")) + }).to.throw("Empty variable length data argument") + }) + }) + context("when the compact size uint is 1-byte", () => { it("should return the the uint value and byte length", () => { expect(read(Hex.from("bb"))).to.be.eql({ @@ -777,7 +785,7 @@ describe("Bitcoin", () => { context("when the compact size uint is 3-byte", () => { it("should throw", () => { expect(() => read(Hex.from("fd0302"))).to.throw( - "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + "Support for 3, 5 and 9 bytes compact size uints is not implemented yet" ) }) }) @@ -785,7 +793,7 @@ describe("Bitcoin", () => { context("when the compact size uint is 5-byte", () => { it("should throw", () => { expect(() => read(Hex.from("fe703a0f00"))).to.throw( - "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + "Support for 3, 5 and 9 bytes compact size uints is not implemented yet" ) }) }) @@ -795,7 +803,7 @@ describe("Bitcoin", () => { expect(() => { return read(Hex.from("ff57284e56dab40000")) }).to.throw( - "support for 3, 5 and 9 bytes compact size uints is not implemented yet" + "Support for 3, 5 and 9 bytes compact size uints is not implemented yet" ) }) }) From 2343c83854a38e7c12a3e627935e8ef718600d07 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 14:52:38 +0200 Subject: [PATCH 194/205] Fix some typos around SDK functions --- typescript/src/lib/bitcoin/csuint.ts | 2 +- typescript/src/lib/bitcoin/ecdsa-key.ts | 4 ++-- typescript/test/lib/bitcoin.test.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/typescript/src/lib/bitcoin/csuint.ts b/typescript/src/lib/bitcoin/csuint.ts index 163bc30c1..e32dc8932 100644 --- a/typescript/src/lib/bitcoin/csuint.ts +++ b/typescript/src/lib/bitcoin/csuint.ts @@ -35,7 +35,7 @@ function read(varLenData: Hex): { } default: { // The discriminant tells the compact size uint is 1 byte. That means - // the discriminant represent the value itself. + // the discriminant represents the value itself. return { value: parseInt(discriminant, 16), byteLength: 1, diff --git a/typescript/src/lib/bitcoin/ecdsa-key.ts b/typescript/src/lib/bitcoin/ecdsa-key.ts index f7b845840..4c7b38b77 100644 --- a/typescript/src/lib/bitcoin/ecdsa-key.ts +++ b/typescript/src/lib/bitcoin/ecdsa-key.ts @@ -52,7 +52,7 @@ function compressPublicKey(publicKey: string | Hex): string { } /** - * Utility functions allowing to perform Bitcoin ECDSA public keys. + * Utility functions allowing to perform operations on Bitcoin ECDSA public keys. */ export const BitcoinPublicKeyUtils = { isCompressedPublicKey, @@ -77,7 +77,7 @@ function createKeyPair( } /** - * Utility functions allowing to perform Bitcoin ECDSA public keys. + * Utility functions allowing to perform operations on Bitcoin ECDSA private keys. */ export const BitcoinPrivateKeyUtils = { createKeyPair, diff --git a/typescript/test/lib/bitcoin.test.ts b/typescript/test/lib/bitcoin.test.ts index 8fdd766a1..80e1212c3 100644 --- a/typescript/test/lib/bitcoin.test.ts +++ b/typescript/test/lib/bitcoin.test.ts @@ -774,7 +774,7 @@ describe("Bitcoin", () => { }) context("when the compact size uint is 1-byte", () => { - it("should return the the uint value and byte length", () => { + it("should return the uint value and byte length", () => { expect(read(Hex.from("bb"))).to.be.eql({ value: 187, byteLength: 1, From c359fef9218dfc2913c60e6466176011608fe104 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 14:55:40 +0200 Subject: [PATCH 195/205] Use ternary operator in `BitcoinPublicKeyUtils.compressPublicKey` function --- typescript/src/lib/bitcoin/ecdsa-key.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/typescript/src/lib/bitcoin/ecdsa-key.ts b/typescript/src/lib/bitcoin/ecdsa-key.ts index 4c7b38b77..214e59bf4 100644 --- a/typescript/src/lib/bitcoin/ecdsa-key.ts +++ b/typescript/src/lib/bitcoin/ecdsa-key.ts @@ -41,12 +41,7 @@ function compressPublicKey(publicKey: string | Hex): string { // The Y coordinate is the next 32 bytes. const publicKeyY = publicKey.substring(64) - let prefix: string - if (BigNumber.from(`0x${publicKeyY}`).mod(2).eq(0)) { - prefix = "02" - } else { - prefix = "03" - } + const prefix = BigNumber.from(`0x${publicKeyY}`).mod(2).eq(0) ? "02" : "03" return `${prefix}${publicKeyX}` } From ad51b2ed85092a42e99b1e4e4276038d2f376555 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 15:03:33 +0200 Subject: [PATCH 196/205] Improvements around SDK functions docstrings --- typescript/src/lib/bitcoin/address.ts | 6 +++--- typescript/src/lib/bitcoin/ecdsa-key.ts | 1 + typescript/src/lib/bitcoin/hash.ts | 10 +++++----- typescript/src/lib/bitcoin/tx.ts | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/typescript/src/lib/bitcoin/address.ts b/typescript/src/lib/bitcoin/address.ts index 3d5dd2594..08231f769 100644 --- a/typescript/src/lib/bitcoin/address.ts +++ b/typescript/src/lib/bitcoin/address.ts @@ -5,9 +5,9 @@ import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./network" /** * Creates the Bitcoin address from the public key. Supports SegWit (P2WPKH) and * Legacy (P2PKH) formats. - * @param publicKey - Public key used to derive the Bitcoin address. - * @param bitcoinNetwork - Target Bitcoin network. - * @param witness - Flag to determine address format: true for SegWit (P2WPKH) + * @param publicKey Compressed public key used to derive the Bitcoin address. + * @param bitcoinNetwork Target Bitcoin network. + * @param witness Flag to determine address format: true for SegWit (P2WPKH) * and false for Legacy (P2PKH). Default is true. * @returns The derived Bitcoin address. */ diff --git a/typescript/src/lib/bitcoin/ecdsa-key.ts b/typescript/src/lib/bitcoin/ecdsa-key.ts index 214e59bf4..f622490be 100644 --- a/typescript/src/lib/bitcoin/ecdsa-key.ts +++ b/typescript/src/lib/bitcoin/ecdsa-key.ts @@ -57,6 +57,7 @@ export const BitcoinPublicKeyUtils = { /** * Creates a Bitcoin key pair based on the given private key. * @param privateKey Private key that should be used to create the key pair. + * Should be passed in the WIF format. * @param bitcoinNetwork Bitcoin network the given key pair is relevant for. * @returns Bitcoin key ring. */ diff --git a/typescript/src/lib/bitcoin/hash.ts b/typescript/src/lib/bitcoin/hash.ts index 018771f19..876e69888 100644 --- a/typescript/src/lib/bitcoin/hash.ts +++ b/typescript/src/lib/bitcoin/hash.ts @@ -2,8 +2,8 @@ import { BigNumber, utils } from "ethers" import { Hex } from "../utils" /** - * Computes the HASH160 for the given text. - * @param text - Text the HASH160 is computed for. + * Computes the HASH160 (i.e. RIPEMD160(SHA256(text))) for the given text. + * @param text Text the HASH160 is computed for. * @returns Hash as a 20-byte un-prefixed hex string. */ function computeHash160(text: string): string { @@ -17,7 +17,7 @@ function computeHash160(text: string): string { /** * Computes the double SHA256 for the given text. - * @param text - Text the double SHA256 is computed for. + * @param text Text the double SHA256 is computed for. * @returns Hash as a 32-byte un-prefixed hex string. * @dev Do not confuse it with computeSha256 which computes single SHA256. */ @@ -30,7 +30,7 @@ function computeHash256(text: Hex): Hex { /** * Converts a hash in hex string in little endian to a BigNumber. - * @param hash - Hash in hex-string format. + * @param hash Hash in hex-string format. * @returns BigNumber representation of the hash. */ function hashLEToBigNumber(hash: Hex): BigNumber { @@ -39,7 +39,7 @@ function hashLEToBigNumber(hash: Hex): BigNumber { /** * Computes the single SHA256 for the given text. - * @param text - Text the single SHA256 is computed for. + * @param text Text the single SHA256 is computed for. * @returns Hash as a 32-byte un-prefixed hex string. * @dev Do not confuse it with computeHash256 which computes double SHA256. */ diff --git a/typescript/src/lib/bitcoin/tx.ts b/typescript/src/lib/bitcoin/tx.ts index f068500b1..3593ddfe6 100644 --- a/typescript/src/lib/bitcoin/tx.ts +++ b/typescript/src/lib/bitcoin/tx.ts @@ -185,7 +185,7 @@ export function extractBitcoinRawTxVectors( /** * Converts Bitcoin specific locktime value to a number. The number represents - * either a block height or an Unix timestamp depending on the value. + * either a block height or a Unix timestamp, depending on the value. * * If the number is less than 500 000 000 it is a block height. * If the number is greater or equal 500 000 000 it is a Unix timestamp. From cb80637751541aa710bc2bf69fcce316453a0c44 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 15:07:20 +0200 Subject: [PATCH 197/205] Include `src` and `typechain` in the resulting npm package This is needed to make the source maps work correctly. --- typescript/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/typescript/package.json b/typescript/package.json index c241f46bb..b7cc037e9 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -16,7 +16,9 @@ "dev": "tsc --project tsconfig.build.json --watch" }, "files": [ - "dist" + "dist/", + "src/", + "typechain/" ], "config": { "contracts": "./node_modules/@keep-network/ecdsa/artifacts/WalletRegistry.json ./node_modules/@keep-network/tbtc-v2/artifacts/{Bridge,TBTCVault,TBTC}.json" From e063022e2840cfaf71c672dd5c4bc8c108622404 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 15:09:26 +0200 Subject: [PATCH 198/205] Do not export `publicKeyToAddress` directly --- typescript/src/lib/bitcoin/address.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/src/lib/bitcoin/address.ts b/typescript/src/lib/bitcoin/address.ts index 08231f769..36f660ba2 100644 --- a/typescript/src/lib/bitcoin/address.ts +++ b/typescript/src/lib/bitcoin/address.ts @@ -11,7 +11,7 @@ import { BitcoinNetwork, toBitcoinJsLibNetwork } from "./network" * and false for Legacy (P2PKH). Default is true. * @returns The derived Bitcoin address. */ -export function publicKeyToAddress( +function publicKeyToAddress( publicKey: Hex, bitcoinNetwork: BitcoinNetwork, witness: boolean = true From 62ac6082ec3cecb85ce0c3724c6241a20bdafa36 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 15:13:45 +0200 Subject: [PATCH 199/205] Add header index to error message thrown by `validateBitcoinHeadersChain` --- typescript/src/lib/bitcoin/header.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/typescript/src/lib/bitcoin/header.ts b/typescript/src/lib/bitcoin/header.ts index 06531d933..99faa237a 100644 --- a/typescript/src/lib/bitcoin/header.ts +++ b/typescript/src/lib/bitcoin/header.ts @@ -147,7 +147,9 @@ export function validateBitcoinHeadersChain( if ( !previousBlockHeaderHash.equals(currentHeader.previousBlockHeaderHash) ) { - throw new Error("Invalid headers chain") + throw new Error( + `Invalid headers chain; problem with header index: ${index}` + ) } } From 4bdc2a14dc49330610fb1a412e1cf8823f9044ca Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 16 Oct 2023 15:15:47 +0200 Subject: [PATCH 200/205] Update supported Node.js and Yarn versions in READMEs --- typescript/README.adoc | 4 ++-- typescript/scripts/README.adoc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/typescript/README.adoc b/typescript/README.adoc index 36fadc0c0..9d518ab76 100644 --- a/typescript/README.adoc +++ b/typescript/README.adoc @@ -14,8 +14,8 @@ toc::[] Please make sure you have the following prerequisites installed on your machine: -- https://nodejs.org[Node.js] >14.17.4 -- https://yarnpkg.com[Yarn] >1.22.10 +- https://nodejs.org[Node.js] >=16 +- https://yarnpkg.com[Yarn] >=1.22.19 === Install dependencies diff --git a/typescript/scripts/README.adoc b/typescript/scripts/README.adoc index b057d463a..da1ad4bdb 100644 --- a/typescript/scripts/README.adoc +++ b/typescript/scripts/README.adoc @@ -12,8 +12,8 @@ toc::[] Please make sure you have the following prerequisites installed on your machine: -- https://nodejs.org[Node.js] >14.18.0 -- https://yarnpkg.com[Yarn] >1.22.19 +- https://nodejs.org[Node.js] >=16 +- https://yarnpkg.com[Yarn] >=1.22.19 tBTCv2 system prerequisite is that you can refund your BTC only if it was not used for minting tBTC and after `refundLocktime` has passed. From 8307463eb2240548d30a7c09cb065bc27ef71f94 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Wed, 18 Oct 2023 13:11:12 +0200 Subject: [PATCH 201/205] TypeScript: Start version 2.1.0-dev We released version 2.0.0, so need to start a next one for development. --- typescript/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/package.json b/typescript/package.json index b7cc037e9..31c54ba3e 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@keep-network/tbtc-v2.ts", - "version": "2.0.0-dev", + "version": "2.1.0-dev", "license": "MIT", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", From fc5f15eaa0e86ba27f42f1e3e57be3f604ccd56e Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 23 Oct 2023 10:53:30 +0200 Subject: [PATCH 202/205] New `ArbitrumWormholeGateway` artifact The `ArbitrumWormholeGateway` implementation was upgraded recently. Here we add the appropriate artifact that reflects that. --- .../arbitrum/.openzeppelin/unknown-42161.json | 164 ++++++++++++++++++ .../arbitrumOne/ArbitrumWormholeGateway.json | 17 +- 2 files changed, 166 insertions(+), 15 deletions(-) diff --git a/cross-chain/arbitrum/.openzeppelin/unknown-42161.json b/cross-chain/arbitrum/.openzeppelin/unknown-42161.json index 01f43f51a..96b7914cf 100644 --- a/cross-chain/arbitrum/.openzeppelin/unknown-42161.json +++ b/cross-chain/arbitrum/.openzeppelin/unknown-42161.json @@ -617,6 +617,170 @@ } } } + }, + "4eab818d90a79d503842492e9ce92e35a3b96c1835245a0d54c5b023197ec36a": { + "address": "0xaaC423eDC4E3ee9ef81517e8093d52737165b71F", + "txHash": "0x86dee88c640d1cd36f7e5b6c9535062bc323be6b3f94f72989d713bf373cf9e7", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_status", + "offset": 0, + "slot": "101", + "type": "t_uint256", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:80" + }, + { + "label": "bridge", + "offset": 0, + "slot": "151", + "type": "t_contract(IWormholeTokenBridge)518", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:122" + }, + { + "label": "bridgeToken", + "offset": 0, + "slot": "152", + "type": "t_contract(IERC20Upgradeable)2208", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:123" + }, + { + "label": "tbtc", + "offset": 0, + "slot": "153", + "type": "t_contract(L2TBTC)443", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:124" + }, + { + "label": "gateways", + "offset": 0, + "slot": "154", + "type": "t_mapping(t_uint16,t_bytes32)", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:136" + }, + { + "label": "mintingLimit", + "offset": 0, + "slot": "155", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:147" + }, + { + "label": "mintedAmount", + "offset": 0, + "slot": "156", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:151" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IERC20Upgradeable)2208": { + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IWormholeTokenBridge)518": { + "label": "contract IWormholeTokenBridge", + "numberOfBytes": "20" + }, + "t_contract(L2TBTC)443": { + "label": "contract L2TBTC", + "numberOfBytes": "20" + }, + "t_mapping(t_uint16,t_bytes32)": { + "label": "mapping(uint16 => bytes32)", + "numberOfBytes": "32" + }, + "t_uint16": { + "label": "uint16", + "numberOfBytes": "2" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } } } } diff --git a/cross-chain/arbitrum/deployments/arbitrumOne/ArbitrumWormholeGateway.json b/cross-chain/arbitrum/deployments/arbitrumOne/ArbitrumWormholeGateway.json index fdcfde559..cefc99fd8 100644 --- a/cross-chain/arbitrum/deployments/arbitrumOne/ArbitrumWormholeGateway.json +++ b/cross-chain/arbitrum/deployments/arbitrumOne/ArbitrumWormholeGateway.json @@ -172,19 +172,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "depositWormholeTbtc", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -451,7 +438,7 @@ "status": 1, "byzantium": true }, - "numDeployments": 2, - "implementation": "0xa10aD2570ea7b93d19fDae6Bd7189fF4929Bc747", + "numDeployments": 3, + "implementation": "0xaaC423eDC4E3ee9ef81517e8093d52737165b71F", "devdoc": "Contract deployed as upgradable proxy" } \ No newline at end of file From 1781e599445b742f523c31f03de658855248e0f8 Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 23 Oct 2023 10:53:50 +0200 Subject: [PATCH 203/205] New `BaseWormholeGateway` artifact The `BaseWormholeGateway` implementation was upgraded recently. Here we add the appropriate artifact that reflects that. --- .../base/.openzeppelin/unknown-8453.json | 164 ++++++++++++++++++ .../deployments/base/BaseWormholeGateway.json | 17 +- 2 files changed, 166 insertions(+), 15 deletions(-) diff --git a/cross-chain/base/.openzeppelin/unknown-8453.json b/cross-chain/base/.openzeppelin/unknown-8453.json index 41fc6dfe4..cd384ad5a 100644 --- a/cross-chain/base/.openzeppelin/unknown-8453.json +++ b/cross-chain/base/.openzeppelin/unknown-8453.json @@ -453,6 +453,170 @@ } } } + }, + "4eab818d90a79d503842492e9ce92e35a3b96c1835245a0d54c5b023197ec36a": { + "address": "0x00A5504eFB14373FAF38cB6AB4fc03fDb7762ebE", + "txHash": "0x8be13304406c358de242e2c81348338aede32e2ec5ba70c8c05d9da680df07e1", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_status", + "offset": 0, + "slot": "101", + "type": "t_uint256", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:80" + }, + { + "label": "bridge", + "offset": 0, + "slot": "151", + "type": "t_contract(IWormholeTokenBridge)518", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:122" + }, + { + "label": "bridgeToken", + "offset": 0, + "slot": "152", + "type": "t_contract(IERC20Upgradeable)2208", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:123" + }, + { + "label": "tbtc", + "offset": 0, + "slot": "153", + "type": "t_contract(L2TBTC)443", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:124" + }, + { + "label": "gateways", + "offset": 0, + "slot": "154", + "type": "t_mapping(t_uint16,t_bytes32)", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:136" + }, + { + "label": "mintingLimit", + "offset": 0, + "slot": "155", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:147" + }, + { + "label": "mintedAmount", + "offset": 0, + "slot": "156", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:151" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IERC20Upgradeable)2208": { + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IWormholeTokenBridge)518": { + "label": "contract IWormholeTokenBridge", + "numberOfBytes": "20" + }, + "t_contract(L2TBTC)443": { + "label": "contract L2TBTC", + "numberOfBytes": "20" + }, + "t_mapping(t_uint16,t_bytes32)": { + "label": "mapping(uint16 => bytes32)", + "numberOfBytes": "32" + }, + "t_uint16": { + "label": "uint16", + "numberOfBytes": "2" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } } } } diff --git a/cross-chain/base/deployments/base/BaseWormholeGateway.json b/cross-chain/base/deployments/base/BaseWormholeGateway.json index 9b10333fa..13a3a45a8 100644 --- a/cross-chain/base/deployments/base/BaseWormholeGateway.json +++ b/cross-chain/base/deployments/base/BaseWormholeGateway.json @@ -172,19 +172,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "depositWormholeTbtc", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -489,7 +476,7 @@ "status": 1, "byzantium": true }, - "numDeployments": 1, - "implementation": "0x292C9fdf2e2475599cBe350cc473c221Bd67AE28", + "numDeployments": 2, + "implementation": "0x00A5504eFB14373FAF38cB6AB4fc03fDb7762ebE", "devdoc": "Contract deployed as upgradable proxy" } \ No newline at end of file From bfaa50be90d92fd4fa8567080e74ddc77499a75e Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 23 Oct 2023 10:54:11 +0200 Subject: [PATCH 204/205] New `OptimismWormholeGateway` artifact The `OptimismWormholeGateway` implementation was upgraded recently. Here we add the appropriate artifact that reflects that. --- .../optimism/.openzeppelin/optimism.json | 164 ++++++++++++++++++ .../optimism/OptimismWormholeGateway.json | 17 +- 2 files changed, 166 insertions(+), 15 deletions(-) diff --git a/cross-chain/optimism/.openzeppelin/optimism.json b/cross-chain/optimism/.openzeppelin/optimism.json index 94ff55b5d..bf5123805 100644 --- a/cross-chain/optimism/.openzeppelin/optimism.json +++ b/cross-chain/optimism/.openzeppelin/optimism.json @@ -617,6 +617,170 @@ } } } + }, + "4eab818d90a79d503842492e9ce92e35a3b96c1835245a0d54c5b023197ec36a": { + "address": "0xC08dcC93130Ab30987dD7fe64e011402BbE5FdA6", + "txHash": "0x0668c5ce526563d6ef603b1ea0df1717271a9cac97895817e8893e2fb164be96", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_status", + "offset": 0, + "slot": "101", + "type": "t_uint256", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:80" + }, + { + "label": "bridge", + "offset": 0, + "slot": "151", + "type": "t_contract(IWormholeTokenBridge)518", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:122" + }, + { + "label": "bridgeToken", + "offset": 0, + "slot": "152", + "type": "t_contract(IERC20Upgradeable)2208", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:123" + }, + { + "label": "tbtc", + "offset": 0, + "slot": "153", + "type": "t_contract(L2TBTC)443", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:124" + }, + { + "label": "gateways", + "offset": 0, + "slot": "154", + "type": "t_mapping(t_uint16,t_bytes32)", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:136" + }, + { + "label": "mintingLimit", + "offset": 0, + "slot": "155", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:147" + }, + { + "label": "mintedAmount", + "offset": 0, + "slot": "156", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:151" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IERC20Upgradeable)2208": { + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IWormholeTokenBridge)518": { + "label": "contract IWormholeTokenBridge", + "numberOfBytes": "20" + }, + "t_contract(L2TBTC)443": { + "label": "contract L2TBTC", + "numberOfBytes": "20" + }, + "t_mapping(t_uint16,t_bytes32)": { + "label": "mapping(uint16 => bytes32)", + "numberOfBytes": "32" + }, + "t_uint16": { + "label": "uint16", + "numberOfBytes": "2" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } } } } diff --git a/cross-chain/optimism/deployments/optimism/OptimismWormholeGateway.json b/cross-chain/optimism/deployments/optimism/OptimismWormholeGateway.json index 509239987..7d5280b58 100644 --- a/cross-chain/optimism/deployments/optimism/OptimismWormholeGateway.json +++ b/cross-chain/optimism/deployments/optimism/OptimismWormholeGateway.json @@ -172,19 +172,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "depositWormholeTbtc", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -451,7 +438,7 @@ "status": 1, "byzantium": true }, - "numDeployments": 2, - "implementation": "0xF94D0d0471Ae14B6310d94fA4F95e5fc9f3ffC17", + "numDeployments": 3, + "implementation": "0xC08dcC93130Ab30987dD7fe64e011402BbE5FdA6", "devdoc": "Contract deployed as upgradable proxy" } \ No newline at end of file From 2fc28ebc4891e357b19f14ac201cf7fd4c1b9d2d Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Mon, 23 Oct 2023 10:54:35 +0200 Subject: [PATCH 205/205] New `PolygonWormholeGateway` artifact The `PolygonWormholeGateway` implementation was upgraded recently. Here we add the appropriate artifact that reflects that. --- .../polygon/.openzeppelin/polygon.json | 164 ++++++++++++++++++ .../polygon/PolygonWormholeGateway.json | 17 +- 2 files changed, 166 insertions(+), 15 deletions(-) diff --git a/cross-chain/polygon/.openzeppelin/polygon.json b/cross-chain/polygon/.openzeppelin/polygon.json index 73a98be6d..d5ddad936 100644 --- a/cross-chain/polygon/.openzeppelin/polygon.json +++ b/cross-chain/polygon/.openzeppelin/polygon.json @@ -617,6 +617,170 @@ } } } + }, + "4eab818d90a79d503842492e9ce92e35a3b96c1835245a0d54c5b023197ec36a": { + "address": "0x04671C72Aab5AC02A03c1098314b1BB6B560c197", + "txHash": "0xbdc3017d335d0209565f182c4b7d29bd52babf6d67ea94c2f49a0087df7e3e45", + "layout": { + "solcVersion": "0.8.17", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "_status", + "offset": 0, + "slot": "101", + "type": "t_uint256", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:38" + }, + { + "label": "__gap", + "offset": 0, + "slot": "102", + "type": "t_array(t_uint256)49_storage", + "contract": "ReentrancyGuardUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol:80" + }, + { + "label": "bridge", + "offset": 0, + "slot": "151", + "type": "t_contract(IWormholeTokenBridge)518", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:122" + }, + { + "label": "bridgeToken", + "offset": 0, + "slot": "152", + "type": "t_contract(IERC20Upgradeable)2208", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:123" + }, + { + "label": "tbtc", + "offset": 0, + "slot": "153", + "type": "t_contract(L2TBTC)443", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:124" + }, + { + "label": "gateways", + "offset": 0, + "slot": "154", + "type": "t_mapping(t_uint16,t_bytes32)", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:136" + }, + { + "label": "mintingLimit", + "offset": 0, + "slot": "155", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:147" + }, + { + "label": "mintedAmount", + "offset": 0, + "slot": "156", + "type": "t_uint256", + "contract": "L2WormholeGateway", + "src": "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol:151" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_bytes32": { + "label": "bytes32", + "numberOfBytes": "32" + }, + "t_contract(IERC20Upgradeable)2208": { + "label": "contract IERC20Upgradeable", + "numberOfBytes": "20" + }, + "t_contract(IWormholeTokenBridge)518": { + "label": "contract IWormholeTokenBridge", + "numberOfBytes": "20" + }, + "t_contract(L2TBTC)443": { + "label": "contract L2TBTC", + "numberOfBytes": "20" + }, + "t_mapping(t_uint16,t_bytes32)": { + "label": "mapping(uint16 => bytes32)", + "numberOfBytes": "32" + }, + "t_uint16": { + "label": "uint16", + "numberOfBytes": "2" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + } + } } } } diff --git a/cross-chain/polygon/deployments/polygon/PolygonWormholeGateway.json b/cross-chain/polygon/deployments/polygon/PolygonWormholeGateway.json index 59ad2c417..2352666e5 100644 --- a/cross-chain/polygon/deployments/polygon/PolygonWormholeGateway.json +++ b/cross-chain/polygon/deployments/polygon/PolygonWormholeGateway.json @@ -172,19 +172,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "depositWormholeTbtc", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, { "inputs": [ { @@ -466,7 +453,7 @@ "status": 1, "byzantium": true }, - "numDeployments": 2, - "implementation": "0xdF708431162Ba247dDaE362D2c919e0fbAfcf9DE", + "numDeployments": 3, + "implementation": "0x04671C72Aab5AC02A03c1098314b1BB6B560c197", "devdoc": "Contract deployed as upgradable proxy" } \ No newline at end of file