-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove etna builder minPrice usage and update examples (#881)
- Loading branch information
1 parent
47f216e
commit 5b7868a
Showing
12 changed files
with
83 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { secp256k1, utils } from '../src'; | ||
import { Address } from 'micro-eth-signer'; | ||
|
||
/** | ||
* Generate a new private/public key pair and console log out the needed environment variables | ||
* needed to run the examples. Please these values in a `.env` file. | ||
*/ | ||
const main = async () => { | ||
const privateKey = secp256k1.randomPrivateKey(); | ||
const publicKey = secp256k1.getPublicKey(privateKey); | ||
|
||
const hrp = 'custom'; | ||
const address = utils.formatBech32( | ||
hrp, | ||
secp256k1.publicKeyBytesToAddress(publicKey), | ||
); | ||
|
||
console.log('Copy the below values to your `.env` file:'); | ||
console.log('------------------------------------------\n'); | ||
|
||
console.log('## PUBLIC_KEY=', `"${utils.bufferToHex(publicKey)}"`); | ||
|
||
console.log('PRIVATE_KEY=', `"${utils.bufferToHex(privateKey)}"`); | ||
|
||
console.log('P_CHAIN_ADDRESS=', `"P-${address}"`); | ||
console.log('X_CHAIN_ADDRESS=', `"X-${address}"`); | ||
console.log('C_CHAIN_ADDRESS=', `"${Address.fromPublicKey(publicKey)}"`); | ||
console.log('CORETH_ADDRESS=', `"C-${address}"`); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Context, Info, pvm } from '../../../../src'; | ||
import type { FeeState } from '../../../../src/vms/pvm'; | ||
|
||
export const setupEtnaExample = async ( | ||
uri: string, | ||
): Promise<{ | ||
context: Context.Context; | ||
feeState: FeeState; | ||
pvmApi: pvm.PVMApi; | ||
}> => { | ||
const context = await Context.getContextFromURI(uri); | ||
const pvmApi = new pvm.PVMApi(uri); | ||
const feeState = await pvmApi.getFeeState(); | ||
|
||
const info = new Info(uri); | ||
|
||
const { etnaTime } = await info.getUpgradesInfo(); | ||
|
||
const etnaDateTime = new Date(etnaTime); | ||
const now = new Date(); | ||
|
||
if (etnaDateTime >= now) { | ||
throw new Error( | ||
`Etna upgrade is not enabled. Upgrade time: ${etnaDateTime}`, | ||
); | ||
} | ||
|
||
return { | ||
context, | ||
feeState, | ||
pvmApi, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters