From a531aadfc9c8f3c4eb3693d2f8fcabaf2e1fd51e Mon Sep 17 00:00:00 2001 From: lbqds Date: Tue, 13 Aug 2024 21:34:02 +0800 Subject: [PATCH] Update the DIA oracle interface --- call-oracle/.project.json | 12 ++++++------ call-oracle/artifacts/PriceFetcher.ral.json | 4 ++-- call-oracle/artifacts/structs.ral.json | 6 +++--- call-oracle/artifacts/ts/PriceFetcher.ts | 2 +- call-oracle/artifacts/ts/scripts.ts | 2 +- call-oracle/artifacts/ts/types.ts | 2 +- call-oracle/contracts/price_fetcher.ral | 12 ++++++------ call-oracle/docker/docker-compose.yaml | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/call-oracle/.project.json b/call-oracle/.project.json index 844cc2b..0681d2f 100644 --- a/call-oracle/.project.json +++ b/call-oracle/.project.json @@ -1,5 +1,5 @@ { - "fullNodeVersion": "v3.3.1", + "fullNodeVersion": "v3.5.0", "compilerOptionsUsed": { "ignoreUnusedConstantsWarnings": false, "ignoreUnusedVariablesWarnings": false, @@ -9,23 +9,23 @@ "ignoreCheckExternalCallerWarnings": false }, "infos": { - "IOracle": { + "DIAOracleValue": { "sourceFile": "price_fetcher.ral", - "sourceCodeHash": "2d69637edba7d73038d6c408b7a2be3f72554193c6d915f532c1822c1e00cea2", + "sourceCodeHash": "0b4cfa86cb15cee0dbfb5d7f31800b82025f6b44aea7439558d6912f2bb84bc3", "bytecodeDebugPatch": "", "codeHashDebug": "", "warnings": [] }, - "OracleValue": { + "IDIAOracle": { "sourceFile": "price_fetcher.ral", - "sourceCodeHash": "2d69637edba7d73038d6c408b7a2be3f72554193c6d915f532c1822c1e00cea2", + "sourceCodeHash": "0b4cfa86cb15cee0dbfb5d7f31800b82025f6b44aea7439558d6912f2bb84bc3", "bytecodeDebugPatch": "", "codeHashDebug": "", "warnings": [] }, "PriceFetcher": { "sourceFile": "price_fetcher.ral", - "sourceCodeHash": "2d69637edba7d73038d6c408b7a2be3f72554193c6d915f532c1822c1e00cea2", + "sourceCodeHash": "0b4cfa86cb15cee0dbfb5d7f31800b82025f6b44aea7439558d6912f2bb84bc3", "bytecodeDebugPatch": "", "codeHashDebug": "234c356f92e0e441323a14f31234857df46285aba20dc9423bccba90b0f3714e", "warnings": [] diff --git a/call-oracle/artifacts/PriceFetcher.ral.json b/call-oracle/artifacts/PriceFetcher.ral.json index 24d814c..83d185a 100644 --- a/call-oracle/artifacts/PriceFetcher.ral.json +++ b/call-oracle/artifacts/PriceFetcher.ral.json @@ -1,5 +1,5 @@ { - "version": "v3.3.1", + "version": "v3.3.0", "name": "PriceFetcher", "bytecode": "060140910100000a00402ed3948fae9514074254432f5553440d0ece00d4a0e6c231170117001600a10014074554482f5553440d0ece00d4a0e6c231170317021602a1011408555344432f5553440d0ece00d4a0e6c231170517041604a1021408414c50482f5553440d0ece00d4a0e6c231170717061606a10314084159494e2f5553440d0ece00d4a0e6c231170917081608a104", "codeHash": "234c356f92e0e441323a14f31234857df46285aba20dc9423bccba90b0f3714e", @@ -13,7 +13,7 @@ "ayinPrice" ], "types": [ - "IOracle", + "IDIAOracle", "U256", "U256", "U256", diff --git a/call-oracle/artifacts/structs.ral.json b/call-oracle/artifacts/structs.ral.json index 8afb17e..d6ecd13 100644 --- a/call-oracle/artifacts/structs.ral.json +++ b/call-oracle/artifacts/structs.ral.json @@ -1,6 +1,6 @@ [ { - "name": "OracleValue", + "name": "DIAOracleValue", "fieldNames": [ "value", "timestamp" @@ -10,8 +10,8 @@ "U256" ], "isMutable": [ - false, - false + true, + true ] } ] \ No newline at end of file diff --git a/call-oracle/artifacts/ts/PriceFetcher.ts b/call-oracle/artifacts/ts/PriceFetcher.ts index 1f6688b..e64c165 100644 --- a/call-oracle/artifacts/ts/PriceFetcher.ts +++ b/call-oracle/artifacts/ts/PriceFetcher.ts @@ -33,7 +33,7 @@ import { } from "@alephium/web3"; import { default as PriceFetcherContractJson } from "../PriceFetcher.ral.json"; import { getContractByCodeHash } from "./contracts"; -import { OracleValue, AllStructs } from "./types"; +import { DIAOracleValue, AllStructs } from "./types"; // Custom types for the contract export namespace PriceFetcherTypes { diff --git a/call-oracle/artifacts/ts/scripts.ts b/call-oracle/artifacts/ts/scripts.ts index 91488eb..b30c915 100644 --- a/call-oracle/artifacts/ts/scripts.ts +++ b/call-oracle/artifacts/ts/scripts.ts @@ -13,4 +13,4 @@ import { } from "@alephium/web3"; import { getContractByCodeHash } from "./contracts"; -import { OracleValue, AllStructs } from "./types"; +import { DIAOracleValue, AllStructs } from "./types"; diff --git a/call-oracle/artifacts/ts/types.ts b/call-oracle/artifacts/ts/types.ts index b28b727..762924c 100644 --- a/call-oracle/artifacts/ts/types.ts +++ b/call-oracle/artifacts/ts/types.ts @@ -5,7 +5,7 @@ import { Address, HexString, Val, Struct } from "@alephium/web3"; import { default as allStructsJson } from "../structs.ral.json"; export const AllStructs = allStructsJson.map((json) => Struct.fromJson(json)); -export interface OracleValue extends Record { +export interface DIAOracleValue extends Record { value: bigint; timestamp: bigint; } diff --git a/call-oracle/contracts/price_fetcher.ral b/call-oracle/contracts/price_fetcher.ral index 3909e4f..e5700b3 100644 --- a/call-oracle/contracts/price_fetcher.ral +++ b/call-oracle/contracts/price_fetcher.ral @@ -1,14 +1,14 @@ -struct OracleValue { - value: U256, - timestamp: U256 +struct DIAOracleValue { + mut value: U256, + mut timestamp: U256 } -Interface IOracle { - pub fn getValue(key: ByteVec) -> OracleValue +Interface IDIAOracle { + pub fn getValue(key: ByteVec) -> DIAOracleValue } Contract PriceFetcher( - oracle: IOracle, + oracle: IDIAOracle, mut btcPrice: U256, mut ethPrice: U256, mut usdcPrice: U256, diff --git a/call-oracle/docker/docker-compose.yaml b/call-oracle/docker/docker-compose.yaml index b16daf9..20b63b7 100644 --- a/call-oracle/docker/docker-compose.yaml +++ b/call-oracle/docker/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3.3" services: alephium: - image: alephium/alephium:v3.3.0 + image: alephium/alephium:v3.5.0 restart: "no" ports: - 19973:19973/tcp