Преглед изворни кода

Remove now unnused parsePriceAttestation function

Tom Pointon пре 3 година
родитељ
комит
4861c1822b
2 измењених фајлова са 0 додато и 89 уклоњено
  1. 0 56
      ethereum/contracts/pyth/Pyth.sol
  2. 0 33
      ethereum/test/pyth.js

+ 0 - 56
ethereum/contracts/pyth/Pyth.sol

@@ -151,60 +151,4 @@ contract Pyth is PythGovernance {
             index += 8;
         }
     }
-
-    function parsePriceAttestation(bytes memory encodedPriceAttestation) public pure returns (PythStructs.PriceAttestation memory pa) {
-        uint index = 0;
-
-        pa.header.magic = encodedPriceAttestation.toUint32(index);
-        index += 4;
-        require(pa.header.magic == 0x50325748, "invalid protocol");
-
-        pa.header.version = encodedPriceAttestation.toUint16(index);
-        index += 2;
-        require(pa.header.version == 1, "invalid protocol");
-
-        pa.header.payloadId = encodedPriceAttestation.toUint8(index);
-        index += 1;
-        require(pa.header.payloadId == 1, "invalid PriceAttestation");
-
-        pa.productId = encodedPriceAttestation.toBytes32(index);
-        index += 32;
-        pa.priceId = encodedPriceAttestation.toBytes32(index);
-        index += 32;
-
-        pa.priceType = encodedPriceAttestation.toUint8(index);
-        index += 1;
-
-        pa.price = int64(encodedPriceAttestation.toUint64(index));
-        index += 8;
-        pa.exponent = int32(encodedPriceAttestation.toUint32(index));
-        index += 4;
-
-        pa.emaPrice.value = int64(encodedPriceAttestation.toUint64(index));
-        index += 8;
-        pa.emaPrice.numerator = int64(encodedPriceAttestation.toUint64(index));
-        index += 8;
-        pa.emaPrice.denominator = int64(encodedPriceAttestation.toUint64(index));
-        index += 8;
-
-        pa.emaConf.value = int64(encodedPriceAttestation.toUint64(index));
-        index += 8;
-        pa.emaConf.numerator = int64(encodedPriceAttestation.toUint64(index));
-        index += 8;
-        pa.emaConf.denominator = int64(encodedPriceAttestation.toUint64(index));
-        index += 8;
-
-        pa.confidenceInterval = encodedPriceAttestation.toUint64(index);
-        index += 8;
-
-        pa.status = encodedPriceAttestation.toUint8(index);
-        index += 1;
-        pa.corpAct = encodedPriceAttestation.toUint8(index);
-        index += 1;
-
-        pa.timestamp = encodedPriceAttestation.toUint64(index);
-        index += 8;
-
-        require(encodedPriceAttestation.length == index, "invalid PriceAttestation");
-    }
 }

+ 0 - 33
ethereum/test/pyth.js

@@ -92,39 +92,6 @@ contract("Pyth", function () {
         assert.ok(isUpgraded);
     })
 
-    let testUpdate = "0x"+
-        "503257480001011515151515151515151515151515151515151515151515151515151515151515DEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDEDE01DEADBEEFDEADBABEFFFFFFFDFFFFFFFFFFFFFFD6000000000000000F0000000000000025000000000000002A000000000000045700000000000008AE0000000000000065010000000000075BCD15";
-
-    it("should parse price update correctly", async function() {
-        const initialized = new web3.eth.Contract(P2WImplementationFullABI, PythDataBridge.address);
-
-        let parsed = await initialized.methods.parsePriceAttestation(testUpdate).call();
-
-        assert.equal(parsed.header.magic, 1345476424);
-        assert.equal(parsed.header.version, 1);
-        assert.equal(parsed.header.payloadId, 1);
-        assert.equal(parsed.productId, "0x1515151515151515151515151515151515151515151515151515151515151515");
-        assert.equal(parsed.priceId, "0xdededededededededededededededededededededededededededededededede");
-        assert.equal(parsed.priceType, 1);
-        assert.equal(parsed.price, -2401053088876217666);
-        assert.equal(parsed.exponent, -3);
-
-        assert.equal(parsed.emaPrice.value, -42);
-        assert.equal(parsed.emaPrice.numerator, 15);
-        assert.equal(parsed.emaPrice.denominator, 37);
-
-        assert.equal(parsed.emaConf.value, 42);
-        assert.equal(parsed.emaConf.numerator, 1111);
-        assert.equal(parsed.emaConf.denominator, 2222);
-
-        assert.equal(parsed.confidenceInterval, 101);
-
-        assert.equal(parsed.status, 1);
-        assert.equal(parsed.corpAct, 0);
-
-        assert.equal(parsed.timestamp, 123456789);
-    })
-
     const rawBatchPriceAttestation = "0x"+"503257480002020004009650325748000201c0e11df4c58a4e53f2bc059ba57a7c8f30ddada70b5bdc3753f90b824b64dd73c1902e05cdf03bc089a943d921f87ccd0e3e1b774b5660d037b9f428c0d3305e01000000000000071dfffffffb00000000000005f70000000132959bbd00000000c8bfed5f00000000000000030000000041c7b65b00000000c8bfed5f0000000000000003010000000000622f65f4503257480002017090c4ecf0309718d04c5a162c08aa4b78f533f688fa2f3ccd7be74c2a253a54fd4caca566fc44a9d6585420959d13897877c606477b3f0e7f247295b7275620010000000000000440fffffffb00000000000005fb000000015cfe8c9d00000000e3dbaa7f00000000000000020000000041c7c5bb00000000e3dbaa7f0000000000000007010000000000622f65f4503257480002012f064374f55cb2efbbef29329de3b652013a76261876c55a1caf3a489c721ccd8c5dd422900917e8e26316fe598e8f062058d390644e0e36d42c187298420ccd010000000000000609fffffffb00000000000005cd00000001492c19bd00000000dd92071f00000000000000020000000041c7d3fb00000000dd92071f0000000000000001010000000000622f65f45032574800020171ddabd1a2c1fb6d6c4707b245b7c0ab6af0ae7b96b2ff866954a0b71124aee517fbe895e5416ddb4d5af9d83c599ee2c4f94cb25e8597f9e5978bd63a7cdcb70100000000000007bcfffffffb00000000000005e2000000014db2995d00000000dd8f775f00000000000000020000000041c7df9b00000000dd8f775f0000000000000003010000000000622f65f4";
 
     it("should parse batch price attestation correctly", async function() {