@@ -3,13 +3,13 @@ import { hideBin } from "yargs/helpers";
33import {
44 DefaultStore ,
55 getDefaultDeploymentConfig ,
6- SuiChain ,
7- SuiPriceFeedContract ,
6+ IotaChain ,
7+ IotaPriceFeedContract ,
88} from "@pythnetwork/contract-manager" ;
99import { PriceServiceConnection } from "@pythnetwork/price-service-client" ;
1010import { execSync } from "child_process" ;
1111import { initPyth , publishPackage } from "./pyth_deploy" ;
12- import { Ed25519Keypair } from "@mysten/sui /keypairs/ed25519" ;
12+ import { Ed25519Keypair } from "@iota/iota-sdk /keypairs/ed25519" ;
1313import { resolve } from "path" ;
1414import {
1515 buildForBytecodeAndDigest ,
@@ -26,15 +26,16 @@ const OPTIONS = {
2626 contract : {
2727 type : "string" ,
2828 demandOption : true ,
29- desc : "Contract to use for the command (e.g sui_testnet_0xe8c2ddcd5b10e8ed98e53b12fcf8f0f6fd9315f810ae61fa4001858851f21c88 )" ,
29+ desc : "Contract to use for the command (e.g FIXME )" ,
3030 } ,
3131 path : {
3232 type : "string" ,
3333 default : "../../contracts" ,
34- desc : "Path to the sui contracts, will use ../../contracts by default" ,
34+ desc : "Path to the iota contracts, will use ../../contracts by default" ,
3535 } ,
3636 endpoint : {
3737 type : "string" ,
38+ default : "https://hermes.pyth.network" ,
3839 desc : "Price service endpoint to use, defaults to https://hermes.pyth.network for mainnet and https://hermes-beta.pyth.network for testnet" ,
3940 } ,
4041 "feed-id" : {
@@ -44,24 +45,14 @@ const OPTIONS = {
4445 } ,
4546} as const ;
4647
47- function getContract ( contractId : string ) : SuiPriceFeedContract {
48- const contract = DefaultStore . contracts [ contractId ] as SuiPriceFeedContract ;
48+ function getContract ( contractId : string ) : IotaPriceFeedContract {
49+ const contract = DefaultStore . contracts [ contractId ] as IotaPriceFeedContract ;
4950 if ( ! contract ) {
5051 throw new Error ( `Contract ${ contractId } not found` ) ;
5152 }
5253 return contract ;
5354}
5455
55- function getPriceService (
56- contract : SuiPriceFeedContract ,
57- endpointOverride : string | undefined
58- ) : PriceServiceConnection {
59- const defaultEndpoint = contract . getChain ( ) . isMainnet ( )
60- ? "https://hermes.pyth.network"
61- : "https://hermes-beta.pyth.network" ;
62- return new PriceServiceConnection ( endpointOverride || defaultEndpoint ) ;
63- }
64-
6556yargs ( hideBin ( process . argv ) )
6657 . command (
6758 "create" ,
@@ -80,7 +71,7 @@ yargs(hideBin(process.argv))
8071 } ,
8172 async ( argv ) => {
8273 const contract = getContract ( argv . contract ) ;
83- const priceService = getPriceService ( contract , argv . endpoint ) ;
74+ const priceService = new PriceServiceConnection ( argv . endpoint ) ;
8475 const feedIds = argv [ "feed-id" ] as string [ ] ;
8576 const vaas = await priceService . getLatestVaas ( feedIds ) ;
8677 const digest = await contract . executeCreatePriceFeed (
@@ -106,7 +97,7 @@ yargs(hideBin(process.argv))
10697 } ,
10798 async ( argv ) => {
10899 const contract = getContract ( argv . contract ) ;
109- const priceService = getPriceService ( contract , argv . endpoint ) ;
100+ const priceService = new PriceServiceConnection ( argv . endpoint ) ;
110101 const feedIds = await priceService . getPriceFeedIds ( ) ;
111102 const BATCH_SIZE = 10 ;
112103 for ( let i = 0 ; i < feedIds . length ; i += BATCH_SIZE ) {
@@ -138,7 +129,7 @@ yargs(hideBin(process.argv))
138129 digest : number [ ] ;
139130 } = JSON . parse (
140131 execSync (
141- `sui move build --dump-bytecode-as-base64 --path ${ __dirname } /${ argv . path } 2> /dev/null` ,
132+ `iota move build --dump-bytecode-as-base64 --path ${ __dirname } /${ argv . path } 2> /dev/null` ,
142133 {
143134 encoding : "utf-8" ,
144135 }
@@ -158,26 +149,26 @@ yargs(hideBin(process.argv))
158149 chain : {
159150 type : "string" ,
160151 demandOption : true ,
161- desc : "Chain to deploy the code to. Can be sui_mainnet or sui_testnet " ,
152+ desc : "Chain to deploy the code to. Can be iota_mainnet or iota_testnet " ,
162153 } ,
163154 path : OPTIONS . path ,
164155 } )
165156 . usage (
166- "$0 deploy --private-key <private-key> --chain [sui_mainnet|sui_testnet ] --path <path-to-contracts>"
157+ "$0 deploy --private-key <private-key> --chain [iota_mainnet|iota_testnet ] --path <path-to-contracts>"
167158 ) ;
168159 } ,
169160 async ( argv ) => {
170161 const walletPrivateKey = argv [ "private-key" ] ;
171- const chain = DefaultStore . chains [ argv . chain ] as SuiChain ;
162+ const chain = DefaultStore . chains [ argv . chain ] as IotaChain ;
172163 const keypair = Ed25519Keypair . fromSecretKey (
173- Buffer . from ( walletPrivateKey , "hex" )
164+ new Uint8Array ( Buffer . from ( walletPrivateKey , "hex" ) )
174165 ) ;
175166 const result = await publishPackage (
176167 keypair ,
177168 chain . getProvider ( ) ,
178169 argv . path
179170 ) ;
180- const deploymentType = chain . isMainnet ( ) ? "stable" : "beta ";
171+ const deploymentType = "stable" ;
181172 const config = getDefaultDeploymentConfig ( deploymentType ) ;
182173 await initPyth (
183174 keypair ,
@@ -206,7 +197,7 @@ yargs(hideBin(process.argv))
206197 } ,
207198 async ( argv ) => {
208199 const contract = getContract ( argv . contract ) ;
209- const priceService = getPriceService ( contract , argv . endpoint ) ;
200+ const priceService = new PriceServiceConnection ( argv . endpoint ) ;
210201 const feedIds = argv [ "feed-id" ] as string [ ] ;
211202 const vaas = await priceService . getLatestVaas ( feedIds ) ;
212203 const digest = await contract . executeUpdatePriceFeedWithFeeds (
@@ -239,7 +230,7 @@ yargs(hideBin(process.argv))
239230 async ( argv ) => {
240231 const contract = getContract ( argv . contract ) ;
241232 const keypair = Ed25519Keypair . fromSecretKey (
242- Buffer . from ( argv [ "private-key" ] , "hex" )
233+ new Uint8Array ( Buffer . from ( argv [ "private-key" ] , "hex" ) )
243234 ) ;
244235
245236 const pythContractsPath = resolve ( `${ __dirname } /${ argv . path } ` ) ;
0 commit comments