Reisen 2 лет назад
Родитель
Сommit
ef02cfefe4

+ 24 - 0
target_chains/near/README.md

@@ -0,0 +1,24 @@
+# Pyth NEAR
+
+This directory contains the Pyth contract for NEAR, examples, and utilities to deploy. Within the `example/`
+directory you will find an example skeleton NEAR contract that updates and uses a price. You can find
+updates to test with from the Hermes API. Additionally see the `scripts/update.sh` script for an example
+of how to manually submit a price update from the CLI.
+
+## Deployment
+
+Deploying the NEAR contract has three steps:
+
+1. Create a NEAR key with `near generate-key`
+2. Fetch NEAR tokens from an available faucet, at last deploy around 100~ NEAR were needed.
+3. See the example deploy script in `scripts/deploy.sh` to deploy the contract. You can find a codehash by:
+   - `sha256sum pyth.wasm` after building the contract.
+   - `list(bytes.fromhex(hash))` in Python to get a byte array.
+   - Replace the `codehash` field in deploy.sh for the initial codehash.
+
+## Further Documentation
+
+You can find more in-depth documentation on the [Pyth Website][pyth website] for a more in-depth guide to
+working with Pyth concepts in general in the context of NEAR.
+
+[pyth website]: https://docs.pyth.network/documentation/pythnet-price-feeds/near

+ 0 - 27
target_chains/near/receiver/deploy.sh

@@ -1,27 +0,0 @@
-#!/usr/bin/env bash
-
-INIT_ARGS=$(cat <<-EOF
-{
-    "wormhole": "wormhole.wormhole.testnet",
-    "codehash": [164, 14, 107, 15, 190, 232, 208, 235, 112, 211, 222, 28, 219, 44, 65, 197, 14, 136, 98, 3, 140, 61, 207, 211, 221, 184, 237, 78, 167, 115, 95, 234],
-    "initial_source": {
-        "emitter": [225, 1, 250, 237, 172, 88, 81, 227, 43, 155, 35, 181, 249, 65, 26, 140, 43, 172, 74, 174, 62, 212, 221, 123, 129, 29, 209, 167, 46, 164, 170, 113],
-        "chain": 26
-    },
-    "gov_source": {
-        "emitter": [86, 53, 151, 154, 34, 28, 52, 147, 30, 50, 98, 11, 146, 147, 164, 99, 6, 85, 85, 234, 113, 254, 151, 205, 98, 55, 173, 232, 117, 177, 46, 158],
-        "chain": 1
-    },
-    "update_fee": "1",
-    "stale_threshold": 60
-}
-EOF
-)
-
-INIT_JSON=$(echo "$INIT_ARGS" | jq -c '.' -M)
-
-near deploy \
-    --accountId "780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7" \
-    --wasmFile pyth.wasm \
-    --initFunction new \
-    --initArgs "$INIT_JSON"

+ 0 - 12
target_chains/near/receiver/transfers.sh

@@ -1,12 +0,0 @@
-# near send 8c77a9896504848e06092618aa166aea4470153c16d38af3902c2ac688eb3a12 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send 245e9ccf5f51a6eb08d80095db8623809f0a9a3fc2811c2b316d3b3305c6a4bc 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send f2f8df27296c9d01da063a6cc724dcbadb844ab1490e0b4f0e56995ed2a10239 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send c1aae1fb5b504865ee2748257a6ec4b86b4b0c215c1ecfc0da66f389f5d5c510 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send 6c1233da7e91a72f0e298c16d04eb729d8e924a2806d5a339cdb4159aa2e2514 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send 192b010686fe6cfca168b2cc21e455b5d10c61037f5ade85b6c791dc81284260 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send 597c2ec824154507ecd72997bb041a60d357a103fab163891a7b55e64f62e9ca 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send 985fb94522458ec08a400ea8848d6d6ad4a75eb2a7a394ef1d1752050d49460a 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send ce94a02bf130fa5a68daa09fead47d2b6f0768ff16b9ca1311a88ce8c9f4e9ea 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send 63c97554b0995d67ebe264730782f7366494207a635b3684270c3523865a501a 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-# near send 879ad801aedfaeaf1924ce3e31e8111ee04548703c922b25a3eae67ea2887776 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 9.9
-near send 83f84e22f92089bef6a2ae443626c92e894f10a46b426ffd575e9ea14da2a3f2 780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 200

+ 33 - 0
target_chains/near/scripts/deploy.sh

@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+# This is an example payload for deploying the NEAR receiver contract. Note that the codehash can be obtained
+# by `sha256sum` on the compiled contract. The initial and governance sources are the PythNet emitters for
+# governance payloads.
+INIT_ARGS=$(
+	cat <<-EOF
+		{
+		    "wormhole": "wormhole.wormhole.testnet",
+		    "codehash": [113, 49, 20, 252, 226, 220, 48, 15, 139, 92, 255, 117, 94, 178, 130, 162, 252, 5, 252, 188, 87, 122, 50, 175, 109, 12, 26, 189, 9, 107, 214, 116],
+		    "initial_source": {
+		        "emitter": [225, 1, 250, 237, 172, 88, 81, 227, 43, 155, 35, 181, 249, 65, 26, 140, 43, 172, 74, 174, 62, 212, 221, 123, 129, 29, 209, 167, 46, 164, 170, 113],
+		        "chain": 26
+		    },
+		    "gov_source": {
+		        "emitter": [86, 53, 151, 154, 34, 28, 52, 147, 30, 50, 98, 11, 146, 147, 164, 99, 6, 85, 85, 234, 113, 254, 151, 205, 98, 55, 173, 232, 117, 177, 46, 158],
+		        "chain": 1
+		    },
+		    "update_fee": "1",
+		    "stale_threshold": 60
+		}
+	EOF
+)
+
+# Feed through jq to get compressed JSON to avoid CLI weirdness.
+INIT_JSON=$(echo "$INIT_ARGS" | jq -c '.' -M)
+
+# Deploy..
+near deploy \
+	--accountId "pyth.testnet" \
+	--wasmFile pyth.wasm \
+	--initFunction new \
+	--initArgs "$INIT_JSON"

+ 6 - 3
target_chains/near/receiver/update.sh → target_chains/near/scripts/update.sh

@@ -1,5 +1,6 @@
 #!/usr/bin/env bash
 
+# This is an example payload for subitting a price update from Hermes to a NEAR contract.
 UPDATE_ARGS=$(
 	cat <<-EOF
 		{
@@ -8,12 +9,14 @@ UPDATE_ARGS=$(
 	EOF
 )
 
+# Feed through jq to get compressed JSON to avoid CLI weirdness.
 UPDATE_JSON=$(echo "$UPDATE_ARGS" | jq -c '.' -M)
 
+# Submit.
 near call \
-	--accountId "780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7" \
+    --accountId "780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7" \
     780e82bd52465f8a4f5ed8cf5a30666eb41208849956bf87a377da9d8174e2b7 \
-	update_price_feed \
+    update_price_feed \
     --gas 300000000000000 \
     --deposit 1 \
-	--args "$UPDATE_JSON"
+    --args "$UPDATE_JSON"