From 51190b5583b867674c17471f548cb8925f7f1366 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 11 Jun 2024 14:56:33 -0700 Subject: [PATCH 1/2] examples/p-chain/export.ts: P-chain export do not depends on the target address Unfortunately, as currently written, the two following expression: bech32ToBytes(X_CHAIN_ADDRESS) and bech32ToBytes(P_CHAIN_ADDRESS) intra-account results in the same output. The generated UTxO will include a pseudo-CorETH address which will prevent import on the C-chain and return the following error: Error: import tx transfer failed verification: wrong signature: expected signature from JTWYVMiL9CmJvWBVbhZzMtyV8wW4C1Ztt but got from auLWN59QX8b9hFwt1e5oLaCRWMM1j4HU --- examples/p-chain/export.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/p-chain/export.ts b/examples/p-chain/export.ts index 5f1f13c60..f5ece8eef 100644 --- a/examples/p-chain/export.ts +++ b/examples/p-chain/export.ts @@ -7,11 +7,10 @@ import { pvmapi } from '../chain_apis'; import { getChainIdFromContext } from '../utils/getChainIdFromContext'; const P_CHAIN_ADDRESS = process.env.P_CHAIN_ADDRESS; -const X_CHAIN_ADDRESS = process.env.X_CHAIN_ADDRESS; const PRIVATE_KEY = process.env.PRIVATE_KEY; const main = async () => { - if (!P_CHAIN_ADDRESS || !X_CHAIN_ADDRESS || !PRIVATE_KEY) { + if (!P_CHAIN_ADDRESS || !PRIVATE_KEY) { throw new Error('Missing environment variable(s).'); } @@ -28,7 +27,7 @@ const main = async () => { utxos, [ TransferableOutput.fromNative(context.avaxAssetID, BigInt(0.1 * 1e9), [ - bech32ToBytes(X_CHAIN_ADDRESS), + bech32ToBytes(P_CHAIN_ADDRESS), ]), ], ); From e07d2dfd1078045d968741ab290c532df867cdb9 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 11 Jun 2024 14:56:53 -0700 Subject: [PATCH 2/2] examples/p-chain/export.ts: add boilerplate to export to the C-chain --- examples/p-chain/export.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/p-chain/export.ts b/examples/p-chain/export.ts index f5ece8eef..ecd108650 100644 --- a/examples/p-chain/export.ts +++ b/examples/p-chain/export.ts @@ -9,7 +9,7 @@ import { getChainIdFromContext } from '../utils/getChainIdFromContext'; const P_CHAIN_ADDRESS = process.env.P_CHAIN_ADDRESS; const PRIVATE_KEY = process.env.PRIVATE_KEY; -const main = async () => { +const main = async (destinationChain: 'C' | 'X') => { if (!P_CHAIN_ADDRESS || !PRIVATE_KEY) { throw new Error('Missing environment variable(s).'); } @@ -22,7 +22,7 @@ const main = async () => { const tx = newExportTx( context, - getChainIdFromContext('X', context), + getChainIdFromContext(destinationChain, context), [bech32ToBytes(P_CHAIN_ADDRESS)], utxos, [ @@ -40,4 +40,4 @@ const main = async () => { return pvmapi.issueSignedTx(tx.getSignedTx()); }; -main().then(console.log); +main('C').then(console.log);