File tree Expand file tree Collapse file tree 4 files changed +75
-5
lines changed
Expand file tree Collapse file tree 4 files changed +75
-5
lines changed Original file line number Diff line number Diff line change 44 "scripts" : {
55 "p-chain-import" : " ts-node ./src/test-p-chain-import.ts" ,
66 "p-chain-export" : " ts-node ./src/test-p-chain-export.ts" ,
7+ "p-chain-transfer" : " ts-node ./src/test-p-chain-transfer.ts" ,
78 "x-chain-import" : " ts-node ./src/test-x-chain-import.ts" ,
89 "x-chain-export" : " ts-node ./src/test-x-chain-export.ts" ,
910 "add-validator" : " ts-node ./src/test-add-validator.ts" ,
10- "add-delegator" : " ts-node ./src/test-add-delegator.ts"
11+ "add-delegator" : " ts-node ./src/test-add-delegator.ts" ,
12+ "etna-p-chain-import" : " ts-node ./src/etna/test-p-chain-import.ts" ,
13+ "etna-p-chain-export" : " ts-node ./src/etna/test-p-chain-export.ts" ,
14+ "etna-p-chain-transfer" : " ts-node ./src/etna/test-p-chain-transfer.ts" ,
15+ "etna-x-chain-import" : " ts-node ./src/etna/test-x-chain-import.ts" ,
16+ "etna-x-chain-export" : " ts-node ./src/etna/test-x-chain-export.ts" ,
17+ "etna-add-validator" : " ts-node ./src/etna/test-add-validator.ts" ,
18+ "etna-add-delegator" : " ts-node ./src/etna/test-add-delegator.ts"
1119 },
1220 "keywords" : [],
1321 "author" : " Flare Foundation" ,
Original file line number Diff line number Diff line change 1+ import { pvm , utils , TransferableOutput } from "@flarenetwork/flarejs" ;
2+ import { issuePChainTx , localFlareContext } from "../utils" ;
3+ import { runTest } from "../runner" ;
4+
5+ async function PChainTransfer ( amountFLR : number , toAddress : string ) {
6+ const ctx = await localFlareContext ( ) ;
7+
8+ // Create and issue a P chain transfer transaction (BaseTx)
9+ console . log ( `Creating P chain transfer transaction for ${ amountFLR } FLR to address ${ toAddress } ...` ) ;
10+
11+ const feeState = await ctx . pvmapi . getFeeState ( ) ;
12+ const { utxos } = await ctx . pvmapi . getUTXOs ( {
13+ addresses : [ ctx . addressP ] ,
14+ } ) ;
15+ const exportTx = pvm . e . newBaseTx (
16+ {
17+ feeState,
18+ fromAddressesBytes : [ utils . bech32ToBytes ( ctx . addressP ) ] ,
19+ outputs : [
20+ TransferableOutput . fromNative (
21+ ctx . context . avaxAssetID ,
22+ BigInt ( amountFLR * 1e9 ) ,
23+ [ utils . bech32ToBytes ( toAddress ) ] ,
24+ ) ,
25+ ] ,
26+ utxos,
27+ } ,
28+ ctx . context ,
29+ ) ;
30+ await issuePChainTx ( ctx . pvmapi , exportTx , ctx . privateKey ) ;
31+ }
32+
33+ runTest ( ( ) => PChainTransfer ( 100 , "P-localflare1zjaa3yjnzn5cjx9r56x59raam2jgwnmztlg995" ) ) ;
Original file line number Diff line number Diff line change 1+ import { pvm , utils , TransferableOutput } from '@flarenetwork/flarejs' ;
2+ import { issuePChainTx , localFlareContext } from './utils' ;
3+ import { runTest } from './runner' ;
4+
5+ async function PtoCExport ( amountFLR : number , toAddress : string ) {
6+ const ctx = await localFlareContext ( ) ;
7+
8+ // Create and issue a P chain transfer transaction (BaseTx)
9+ console . log ( `Creating P chain transfer transaction for ${ amountFLR } FLR to address ${ toAddress } ...` ) ;
10+
11+ const { utxos : utxosp } = await ctx . pvmapi . getUTXOs ( {
12+ addresses : [ ctx . addressP ]
13+ } ) ;
14+ const exportTx = pvm . newBaseTx (
15+ ctx . context ,
16+ [ utils . bech32ToBytes ( ctx . addressP ) ] ,
17+ utxosp ,
18+ [
19+ TransferableOutput . fromNative ( ctx . context . avaxAssetID , BigInt ( amountFLR * 1e9 ) , [
20+ utils . bech32ToBytes ( toAddress )
21+ ] )
22+ ]
23+ ) ;
24+ await issuePChainTx ( ctx . pvmapi , exportTx , ctx . privateKey ) ;
25+ }
26+
27+
28+ runTest ( ( ) => PtoCExport ( 100 , "P-localflare1zjaa3yjnzn5cjx9r56x59raam2jgwnmztlg995" ) )
29+
Original file line number Diff line number Diff line change 1212 resolved "https://registry.yarnpkg.com/@ethereumjs/rlp/-/rlp-5.0.0.tgz#dd81b32b2237bc32fb1b54534f8ff246a6c89d9b"
1313 integrity sha512-WuS1l7GJmB0n0HsXLozCoEFc9IwYgf3l0gCkKVYgR67puVF1O4OpEaN0hWmm1c+iHUHFCKt1hJrvy5toLg+6ag==
1414
15- " @flarenetwork/flarejs@^4.0.5 " :
16- version "4.0.5 "
17- resolved "https://registry.yarnpkg.com/@flarenetwork/flarejs/-/flarejs-4.0.5 .tgz#deaebb65bf9ca4d2917aee4966ee804345a67d63 "
18- integrity sha512-H9Mh3SKH4aN7kZOEdHG2dh+eSsB+cIS7288FTAo+GHrbwuMoL39t0IwGXY3Ra8NB8/e06cn33C6FX7DvITtKJw ==
15+ " @flarenetwork/flarejs@^4.1.1 " :
16+ version "4.1.1-rc0 "
17+ resolved "https://registry.yarnpkg.com/@flarenetwork/flarejs/-/flarejs-4.1.1-rc0 .tgz#49abad5c65c5ddd97888d4c2bc4adbb971b18ba6 "
18+ integrity sha512-QSN4siKddoWPu6vUNNElN0PMSxrUDHq4k39kspBTg2CIoLyt0g3XU+o4luvZ8zTnIv9VTM2BWlDe5xhDK4z/rQ ==
1919 dependencies :
2020 " @noble/curves" " 1.3.0"
2121 " @noble/hashes" " 1.3.3"
You can’t perform that action at this time.
0 commit comments